Skip to content

Commit

Permalink
Adds getMember and getAdmin calls to get single user records.
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Jan 22, 2020
1 parent 9c0954b commit 9dabdf3
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Endpoints/Organizations.php
Expand Up @@ -6,6 +6,7 @@
use AcquiaCloudApi\Response\ApplicationsResponse;
use AcquiaCloudApi\Response\InvitationsResponse;
use AcquiaCloudApi\Response\MembersResponse;
use AcquiaCloudApi\Response\MemberResponse;
use AcquiaCloudApi\Response\OrganizationsResponse;
use AcquiaCloudApi\Response\TeamsResponse;
use AcquiaCloudApi\Response\OperationResponse;
Expand Down Expand Up @@ -54,6 +55,20 @@ public function getMembers($organizationUuid)
);
}

/**
* Returns the user profile of this organization member.
*
* @param string $organizationUuid
* @param string $memberUuid
* @return MemberResponse
*/
public function getMember($organizationUuid, $memberUuid)
{
return new MemberResponse(
$this->client->request('get', "/organizations/${organizationUuid}/members/${memberUuid}")
);
}

/**
* Show all admins of an organisation.
*
Expand All @@ -67,6 +82,20 @@ public function getAdmins($organizationUuid)
);
}

/**
* Returns the user profile of this organization administrator.
*
* @param string $organizationUuid
* @param string $memberUuid
* @return MemberResponse
*/
public function getAdmin($organizationUuid, $memberUuid)
{
return new MemberResponse(
$this->client->request('get', "/organizations/${organizationUuid}/admins/${memberUuid}")
);
}

/**
* Show all members invited to an organisation.
*
Expand Down
40 changes: 40 additions & 0 deletions tests/Endpoints/MembersTest.php
Expand Up @@ -40,6 +40,26 @@ public function testGetOrganizationMembers()
}
}

public function testGetOrganizationMember()
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/getMember.json');
$client = $this->getMockClient($response);

/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */
$organization = new Organizations($client);
$result = $organization->getMember(
'14-0c7e79ab-1c4a-424e-8446-76ae8be7e851',
'f2daa9cc-e5a0-4036-a5c8-f96e336c62b5'
);

$this->assertNotInstanceOf('\AcquiaCloudApi\Response\MembersResponse', $result);
$this->assertInstanceOf('\AcquiaCloudApi\Response\MemberResponse', $result);

foreach ($this->properties as $property) {
$this->assertObjectHasAttribute($property, $result);
}
}

public function testGetOrganizationAdmins()
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/getAdmins.json');
Expand All @@ -61,6 +81,26 @@ public function testGetOrganizationAdmins()
}
}

public function testGetOrganizationAdmin()
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/getAdmin.json');
$client = $this->getMockClient($response);

/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */
$organization = new Organizations($client);
$result = $organization->getAdmin(
'14-0c7e79ab-1c4a-424e-8446-76ae8be7e851',
'f2daa9cc-e5a0-4036-a5c8-f96e336c62b5'
);

$this->assertNotInstanceOf('\AcquiaCloudApi\Response\MembersResponse', $result);
$this->assertInstanceOf('\AcquiaCloudApi\Response\MemberResponse', $result);

foreach ($this->properties as $property) {
$this->assertObjectHasAttribute($property, $result);
}
}

public function testMemberDelete()
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/deleteMember.json');
Expand Down
20 changes: 20 additions & 0 deletions tests/Fixtures/Endpoints/Organizations/getAdmin.json
@@ -0,0 +1,20 @@
{
"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/2375e327-3fff-11e3-9170-12313920a02c/admins/5aa902c5-f1c1-6c94-edfa-86bc58d0dce3"
},
"parent": {
"href": "https://cloud.acquia.com/api/organizations/2375e327-3fff-11e3-9170-12313920a02c/admins"
}
}
}
42 changes: 42 additions & 0 deletions tests/Fixtures/Endpoints/Organizations/getMember.json
@@ -0,0 +1,42 @@
{
"uuid": "3bcddc3a-52ba-4cce-aaa3-9adf721c1b52",
"first_name": "Jonathan",
"last_name": "Archer",
"last_login_at": "2017-03-28T13:07:54-0500",
"mail": "jonathan.archer@example.com",
"picture_url": "https://accounts.acquia.com/images/users/3bcddc3a-52ba-4cce-aaa3-9adf721c1b52/style/avatar",
"username": "jonathan.archer",
"teams": [
{
"name": "Team Name 1",
"uuid": "7325ba1a-5bfd-4341-9b23-55ffada3c131",
"roles": [
{
"uuid": "312c0121-906b-4498-8402-7b479172768c",
"name": "Team Lead"
}
]
},
{
"name": "Team Name 2",
"uuid": "bca134fb-55d4-41ec-9558-d14531fa9899",
"roles": [
{
"uuid": "d33cd9ff-281d-4bcf-9f89-b10b249caa35",
"name": "Developer"
}
]
}
],
"_links": {
"self": {
"href": "https://cloud.acquia.com/api/organizations/2375e327-3fff-11e3-9170-12313920a02c/members/3bcddc3a-52ba-4cce-aaa3-9adf721c1b52"
},
"parent": {
"href": "https://cloud.acquia.com/api/organizations/2375e327-3fff-11e3-9170-12313920a02c/members"
},
"applications": {
"href": "https://cloud.acquia.com/api/organizations/2375e327-3fff-11e3-9170-12313920a02c/members/3bcddc3a-52ba-4cce-aaa3-9adf721c1b52/applications"
}
}
}

0 comments on commit 9dabdf3

Please sign in to comment.