Skip to content

Commit

Permalink
Adds getAdmin method to find organisation admins.
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Jan 21, 2020
1 parent 2afdfb3 commit 9c0954b
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Endpoints/Organizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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)
);
}
}
21 changes: 21 additions & 0 deletions tests/Endpoints/MembersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
66 changes: 66 additions & 0 deletions tests/Fixtures/Endpoints/Organizations/getAdmins.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
]
}
}

0 comments on commit 9c0954b

Please sign in to comment.