1- <?php namespace App \Http \Controllers ;
1+ <?php
2+ namespace App \Http \Controllers ;
23/**
34 * Copyright 2016 OpenStack Foundation
45 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,16 +48,38 @@ final class OAuth2MembersApiController extends OAuth2ProtectedController
4748 */
4849 public function __construct
4950 (
50- IMemberRepository $ member_repository ,
51- IMemberService $ member_service ,
51+ IMemberRepository $ member_repository ,
52+ IMemberService $ member_service ,
5253 IResourceServerContext $ resource_server_context
53- )
54- {
54+ ) {
5555 parent ::__construct ($ resource_server_context );
5656 $ this ->repository = $ member_repository ;
5757 $ this ->member_service = $ member_service ;
5858 }
5959
60+ #[OA \Get(
61+ path: '/api/public/v1/members ' ,
62+ summary: 'Get all members ' ,
63+ description: 'Returns a paginated list of members with optional filtering, sorting and search capabilities ' ,
64+ security: [['bearer ' => []]],
65+ tags: ['Members (Public) ' ],
66+ parameters: [
67+ new OA \Parameter (name: 'page ' , in: 'query ' , required: false , description: 'Page number ' , schema: new OA \Schema (type: 'integer ' , default: 1 )),
68+ new OA \Parameter (name: 'per_page ' , in: 'query ' , required: false , description: 'Items per page ' , schema: new OA \Schema (type: 'integer ' , default: 10 , maximum: 100 )),
69+ new OA \Parameter (name: 'filter ' , in: 'query ' , required: false , description: 'Filter by irc, twitter, first_name, last_name, email, group_slug, group_id, email_verified, active, github_user, full_name, created, last_edited, membership_type ' , schema: new OA \Schema (type: 'string ' )),
70+ new OA \Parameter (name: 'order ' , in: 'query ' , required: false , description: 'Order by first_name, last_name, id, created, last_edited, membership_type ' , schema: new OA \Schema (type: 'string ' )),
71+ new OA \Parameter (name: 'expand ' , in: 'query ' , required: false , description: 'Expand relationships ' , schema: new OA \Schema (type: 'string ' )),
72+ ],
73+ responses: [
74+ new OA \Response (
75+ response: Response::HTTP_OK ,
76+ description: 'Successful operation ' ,
77+ content: new OA \JsonContent (ref: '#/components/schemas/PaginatedMembersResponse ' )
78+ ),
79+ new OA \Response (response: Response::HTTP_BAD_REQUEST , description: 'Bad request ' ),
80+ new OA \Response (response: Response::HTTP_UNAUTHORIZED , description: 'Unauthorized ' ),
81+ ]
82+ )]
6083 #[OA \Get(
6184 path: '/api/v1/members ' ,
6285 summary: 'Get all members ' ,
@@ -100,8 +123,8 @@ function () {
100123 'active ' => ['== ' ],
101124 'github_user ' => ['=@ ' , '== ' , '@@ ' ],
102125 'full_name ' => ['=@ ' , '== ' , '@@ ' ],
103- 'created ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' ,'[] ' ],
104- 'last_edited ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' ,'[] ' ],
126+ 'created ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' , '[] ' ],
127+ 'last_edited ' => ['> ' , '< ' , '<= ' , '>= ' , '== ' , '[] ' ],
105128 'membership_type ' => ['== ' , '=@ ' , '@@ ' ],
106129 ];
107130 },
@@ -169,7 +192,8 @@ function () use ($current_member, $application_type) {
169192 new OA \Response (response: Response::HTTP_UNAUTHORIZED , description: 'Unauthorized ' ),
170193 ]
171194 )]
172- public function getAllCompanies (){
195+ public function getAllCompanies ()
196+ {
173197 return $ this ->_getAll (
174198 function () {
175199 return [
@@ -179,7 +203,7 @@ function () {
179203 function () {
180204 return [
181205 'company ' => 'sometimes|string ' ,
182- ];
206+ ];
183207 },
184208 function () {
185209 return [
@@ -276,7 +300,8 @@ public function updateMyMember()
276300
277301 $ member = $ this ->resource_server_context ->getCurrentUser ();
278302
279- if (is_null ($ member )) return $ this ->error404 ();
303+ if (is_null ($ member ))
304+ return $ this ->error404 ();
280305
281306 $ payload = $ this ->getJsonPayload ([
282307 'projects ' => 'sometimes|string_array ' ,
@@ -401,7 +426,8 @@ public function getMemberAffiliations($member_id)
401426 $ this ->resource_server_context ->getCurrentUser () :
402427 $ this ->repository ->getById ($ member_id );
403428
404- if (is_null ($ member )) return $ this ->error404 ();
429+ if (is_null ($ member ))
430+ return $ this ->error404 ();
405431 $ affiliations = $ member ->getAffiliations ()->toArray ();
406432
407433 $ response = new PagingResponse
@@ -480,7 +506,8 @@ public function addAffiliation($member_id)
480506 $ this ->resource_server_context ->getCurrentUser () :
481507 $ this ->repository ->getById ($ member_id );
482508
483- if (is_null ($ member )) return $ this ->error404 ();
509+ if (is_null ($ member ))
510+ return $ this ->error404 ();
484511
485512 $ payload = $ this ->getJsonPayload ([
486513 'is_current ' => 'required|boolean ' ,
@@ -564,7 +591,8 @@ public function updateAffiliation($member_id, $affiliation_id)
564591 $ this ->resource_server_context ->getCurrentUser () :
565592 $ this ->repository ->getById ($ member_id );
566593
567- if (is_null ($ member )) return $ this ->error404 ();
594+ if (is_null ($ member ))
595+ return $ this ->error404 ();
568596
569597 $ payload = $ this ->getJsonPayload ([
570598 'is_current ' => 'sometimes|boolean ' ,
@@ -630,7 +658,8 @@ public function deleteAffiliation($member_id, $affiliation_id)
630658 $ this ->resource_server_context ->getCurrentUser () :
631659 $ this ->repository ->getById ($ member_id );
632660
633- if (is_null ($ member )) return $ this ->error404 ();
661+ if (is_null ($ member ))
662+ return $ this ->error404 ();
634663
635664 $ this ->member_service ->deleteAffiliation ($ member , $ affiliation_id );
636665
@@ -659,7 +688,8 @@ public function deleteRSVP($member_id, $rsvp_id)
659688 return $ this ->processRequest (function () use ($ member_id , $ rsvp_id ) {
660689
661690 $ member = $ this ->repository ->getById (intval ($ member_id ));
662- if (is_null ($ member )) return $ this ->error404 ();
691+ if (is_null ($ member ))
692+ return $ this ->error404 ();
663693
664694 $ this ->member_service ->deleteRSVP ($ member , intval ($ rsvp_id ));
665695
@@ -689,7 +719,8 @@ public function signFoundationMembership()
689719
690720 $ member = $ this ->resource_server_context ->getCurrentUser ();
691721
692- if (is_null ($ member )) return $ this ->error404 ();
722+ if (is_null ($ member ))
723+ return $ this ->error404 ();
693724
694725 $ member = $ this ->member_service ->signFoundationMembership ($ member );
695726
@@ -698,10 +729,10 @@ public function signFoundationMembership()
698729 $ member ,
699730 SerializerRegistry::SerializerType_Private
700731 )->serialize (
701- SerializerUtils::getExpand (),
702- SerializerUtils::getFields (),
703- SerializerUtils::getRelations ()
704- ));
732+ SerializerUtils::getExpand (),
733+ SerializerUtils::getFields (),
734+ SerializerUtils::getRelations ()
735+ ));
705736 });
706737 }
707738
@@ -727,7 +758,8 @@ public function signCommunityMembership()
727758
728759 $ member = $ this ->resource_server_context ->getCurrentUser ();
729760
730- if (is_null ($ member )) return $ this ->error404 ();
761+ if (is_null ($ member ))
762+ return $ this ->error404 ();
731763
732764 $ member = $ this ->member_service ->signCommunityMembership ($ member );
733765
@@ -736,10 +768,10 @@ public function signCommunityMembership()
736768 $ member ,
737769 SerializerRegistry::SerializerType_Private
738770 )->serialize (
739- SerializerUtils::getExpand (),
740- SerializerUtils::getFields (),
741- SerializerUtils::getRelations ()
742- ));
771+ SerializerUtils::getExpand (),
772+ SerializerUtils::getFields (),
773+ SerializerUtils::getRelations ()
774+ ));
743775 });
744776 }
745777
@@ -760,7 +792,8 @@ public function resignMembership()
760792 return $ this ->processRequest (function () {
761793 $ member = $ this ->resource_server_context ->getCurrentUser ();
762794
763- if (is_null ($ member )) return $ this ->error404 ();
795+ if (is_null ($ member ))
796+ return $ this ->error404 ();
764797
765798 $ this ->member_service ->resignMembership ($ member );
766799
@@ -790,7 +823,8 @@ public function signIndividualMembership()
790823
791824 $ member = $ this ->resource_server_context ->getCurrentUser ();
792825
793- if (is_null ($ member )) return $ this ->error404 ();
826+ if (is_null ($ member ))
827+ return $ this ->error404 ();
794828
795829 $ member = $ this ->member_service ->signIndividualMembership ($ member );
796830
@@ -799,11 +833,11 @@ public function signIndividualMembership()
799833 $ member ,
800834 SerializerRegistry::SerializerType_Private
801835 )->serialize (
802- SerializerUtils::getExpand (),
803- SerializerUtils::getFields (),
804- SerializerUtils::getRelations ()
805- ));
836+ SerializerUtils::getExpand (),
837+ SerializerUtils::getFields (),
838+ SerializerUtils::getRelations ()
839+ ));
806840 });
807841 }
808842
809- }
843+ }
0 commit comments