Add Account Member Listing (#194)
This commit is contained in:
@@ -31,4 +31,20 @@ class AccountMembers implements API
|
|||||||
|
|
||||||
return $this->body->result;
|
return $this->body->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function listAccountMembers(string $accountId, int $page = 1, int $perPage = 20): \stdClass
|
||||||
|
{
|
||||||
|
$query = [
|
||||||
|
'page' => $page,
|
||||||
|
'per_page' => $perPage,
|
||||||
|
];
|
||||||
|
|
||||||
|
$zone = $this->adapter->get('accounts/' . $accountId . '/members', $query);
|
||||||
|
$this->body = json_decode($zone->getBody());
|
||||||
|
|
||||||
|
return (object)[
|
||||||
|
'result' => $this->body->result,
|
||||||
|
'result_info' => $this->body->result_info,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,31 @@ class AccountMembersTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals('4536bcfad5faccb111b47003c79917fa', $accountMembers->getBody()->result->id);
|
$this->assertEquals('4536bcfad5faccb111b47003c79917fa', $accountMembers->getBody()->result->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testListAccountMembers()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listAccountMembers.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('accounts/023e105f4ecef8ad9ca31a8372d0c353/members'),
|
||||||
|
$this->equalTo([
|
||||||
|
'page' => 1,
|
||||||
|
'per_page' => 20,
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
$accountMembers = new AccountMembers($mock);
|
||||||
|
$result = $accountMembers->listAccountMembers('023e105f4ecef8ad9ca31a8372d0c353', 1, 20);
|
||||||
|
|
||||||
|
$this->assertObjectHasAttribute('result', $result);
|
||||||
|
|
||||||
|
$this->assertEquals('4536bcfad5faccb111b47003c79917fa', $result->result[0]->id);
|
||||||
|
$this->assertEquals(1, $result->result_info->count);
|
||||||
|
$this->assertEquals('4536bcfad5faccb111b47003c79917fa', $accountMembers->getBody()->result[0]->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
82
tests/Fixtures/Endpoints/listAccountMembers.json
Normal file
82
tests/Fixtures/Endpoints/listAccountMembers.json
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "4536bcfad5faccb111b47003c79917fa",
|
||||||
|
"code": "05dd05cce12bbed97c0d87cd78e89bc2fd41a6cee72f27f6fc84af2e45c0fac0",
|
||||||
|
"user": {
|
||||||
|
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||||
|
"first_name": "John",
|
||||||
|
"last_name": "Appleseed",
|
||||||
|
"email": "user@example.com",
|
||||||
|
"two_factor_authentication_enabled": false
|
||||||
|
},
|
||||||
|
"status": "accepted",
|
||||||
|
"roles": [
|
||||||
|
{
|
||||||
|
"id": "3536bcfad5faccb999b47003c79917fb",
|
||||||
|
"name": "Account Administrator",
|
||||||
|
"description": "Administrative access to the entire Account",
|
||||||
|
"permissions": {
|
||||||
|
"analytics": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"billing": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"cache_purge": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"dns": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"dns_records": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"lb": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"logs": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"organization": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"ssl": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"waf": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"zones": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
},
|
||||||
|
"zone_settings": {
|
||||||
|
"read": true,
|
||||||
|
"write": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 200
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user