diff --git a/src/Endpoints/Organizations.php b/src/Endpoints/Organizations.php index dd30a193..bec946aa 100644 --- a/src/Endpoints/Organizations.php +++ b/src/Endpoints/Organizations.php @@ -54,6 +54,19 @@ public function getMembers($organizationUuid) ); } + /** + * Show all admins of an organisation. + * + * @param string $organizationUuid + * @return MembersResponse + */ + public function getAdmins($organizationUuid) + { + return new MembersResponse( + $this->client->request('get', "/organizations/${organizationUuid}/admins") + ); + } + /** * Show all members invited to an organisation. * @@ -113,7 +126,7 @@ public function inviteAdmin($organizationUuid, $email) ]; return new OperationResponse( - $this->client->request('post', "/teams/${organizationUuid}/invites", $options) + $this->client->request('post', "/organizations/${organizationUuid}/admin-invites", $options) ); } } diff --git a/tests/Endpoints/MembersTest.php b/tests/Endpoints/MembersTest.php index 26c34e24..813d4640 100644 --- a/tests/Endpoints/MembersTest.php +++ b/tests/Endpoints/MembersTest.php @@ -40,6 +40,27 @@ public function testGetOrganizationMembers() } } + public function testGetOrganizationAdmins() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/getAdmins.json'); + $client = $this->getMockClient($response); + + /** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ + $organization = new Organizations($client); + $result = $organization->getAdmins('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); + + $this->assertInstanceOf('\ArrayObject', $result); + $this->assertInstanceOf('\AcquiaCloudApi\Response\MembersResponse', $result); + + foreach ($result as $record) { + $this->assertInstanceOf('\AcquiaCloudApi\Response\MemberResponse', $record); + + foreach ($this->properties as $property) { + $this->assertObjectHasAttribute($property, $record); + } + } + } + public function testMemberDelete() { $response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/deleteMember.json'); diff --git a/tests/Fixtures/Endpoints/Organizations/getAdmins.json b/tests/Fixtures/Endpoints/Organizations/getAdmins.json new file mode 100644 index 00000000..4cc47475 --- /dev/null +++ b/tests/Fixtures/Endpoints/Organizations/getAdmins.json @@ -0,0 +1,66 @@ +{ + "total": 3, + "_links": { + "self": { + "href": "https://cloud.acquia.com/api/organizations/3c9ea553-3216-11e3-9170-12313920a23a/admins" + }, + "parent": { + "href": "https://cloud.acquia.com/api/organizations/3c9ea553-3216-11e3-9170-12313920a23a" + } + }, + "_embedded": { + "items": [ + { + "uuid": "5aa902c5-f1c1-6c94-edfa-86bc58d0dce3", + "first_name": "James", + "last_name": "Kirk", + "last_login_at": "2017-03-28T13:07:54-0500", + "mail": "james.kirk@example.com", + "picture_url": "https://accounts.acquia.com/images/users/5aa902c5-f1c1-6c94-edfa-86bc58d0dce3/style/avatar", + "username": "james.kirk", + "flags": { + "owner": true + }, + "_links": { + "self": { + "href": "https://cloud.acquia.com/api/organizations/3c9ea553-3216-11e3-9170-12313920a23a/admins/5aa902c5-f1c1-6c94-edfa-86bc58d0dce3" + } + } + }, + { + "uuid": "30dacb5e-4122-11e1-9eb5-12313928d3c2", + "first_name": "Christopher", + "last_name": "Pike", + "last_login_at": "2016-03-28T13:07:54-0500", + "mail": "chris.pike@example.com", + "picture_url": "https://accounts.acquia.com/images/users/30dacb5e-4122-11e1-9eb5-12313928d3c2/style/avatar", + "username": "chris.pike", + "flags": { + "owner": false + }, + "_links": { + "self": { + "href": "https://cloud.acquia.com/api/organizations/3c9ea553-3216-11e3-9170-12313920a23a/admins/30dacb5e-4122-11e1-9eb5-12313928d3c2" + } + } + }, + { + "uuid": "3bcddc3a-52ba-4cce-aaa3-9adf721c1b52", + "first_name": "Jonathan", + "last_name": "Archer", + "last_login_at": null, + "mail": "jonathan.archer@example.com", + "picture_url": "https://accounts.acquia.com/images/users/3bcddc3a-52ba-4cce-aaa3-9adf721c1b52/style/avatar", + "username": "jonathan.archer", + "flags": { + "owner": false + }, + "_links": { + "self": { + "href": "https://cloud.acquia.com/api/organizations/3c9ea553-3216-11e3-9170-12313920a23a/admins/3bcddc3a-52ba-4cce-aaa3-9adf721c1b52" + } + } + } + ] + } + } \ No newline at end of file