diff --git a/composer.json b/composer.json index 4a5b854..6b3c057 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "PHP binding for v4 of the Cloudflare Client API.", "type": "library", "require": { - "guzzlehttp/guzzle": "~6.0", + "guzzlehttp/guzzle": "^7.0.1", "php": ">=7.2.5", "psr/http-message": "~1.0", "ext-json": "*" diff --git a/src/Endpoints/AccountMembers.php b/src/Endpoints/AccountMembers.php new file mode 100644 index 0000000..ec9e90a --- /dev/null +++ b/src/Endpoints/AccountMembers.php @@ -0,0 +1,50 @@ +adapter = $adapter; + } + + public function addAccountMember(string $accountId, string $email, array $roles): \stdClass + { + $options = [ + 'email' => $email, + 'roles' => $roles, + ]; + + $account = $this->adapter->post('accounts/' . $accountId . '/members', $options); + $this->body = json_decode($account->getBody()); + + 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, + ]; + } +} diff --git a/src/Endpoints/AccountRoles.php b/src/Endpoints/AccountRoles.php new file mode 100644 index 0000000..aca7615 --- /dev/null +++ b/src/Endpoints/AccountRoles.php @@ -0,0 +1,33 @@ +adapter = $adapter; + } + + public function listAccountRoles(string $accountId): stdClass + { + $roles = $this->adapter->get('accounts/' . $accountId . '/roles'); + $this->body = json_decode($roles->getBody()); + + return (object)[ + 'result' => $this->body->result, + 'result_info' => $this->body->result_info, + ]; + } +} diff --git a/src/Endpoints/Accounts.php b/src/Endpoints/Accounts.php index 4d4d80a..838afb9 100644 --- a/src/Endpoints/Accounts.php +++ b/src/Endpoints/Accounts.php @@ -21,6 +21,19 @@ class Accounts implements API $this->adapter = $adapter; } + public function addAccount(string $name, string $type = 'standard'): \stdClass + { + $options = [ + 'name' => $name, + 'type' => $type, + ]; + + $account = $this->adapter->post('accounts', $options); + $this->body = json_decode($account->getBody()); + + return $this->body->result; + } + public function listAccounts( int $page = 1, int $perPage = 20, diff --git a/src/Endpoints/ZoneSubscriptions.php b/src/Endpoints/ZoneSubscriptions.php new file mode 100644 index 0000000..6149dd9 --- /dev/null +++ b/src/Endpoints/ZoneSubscriptions.php @@ -0,0 +1,51 @@ +adapter = $adapter; + } + + public function listZoneSubscriptions(string $zoneId): \stdClass + { + $user = $this->adapter->get('zones/' . $zoneId . '/subscriptions'); + $this->body = json_decode($user->getBody()); + + return (object)[ + 'result' => $this->body->result, + ]; + } + + public function addZoneSubscription(string $zoneId, string $ratePlanId = ''): stdClass + { + $options = []; + + if (empty($ratePlanId) === false) { + $options['rate_plan'] = [ + 'id' => $ratePlanId, + ]; + } + + $existingSubscription = $this->listZoneSubscriptions($zoneId); + $method = empty($existingSubscription->result) ? 'post' : 'put'; + + $subscription = $this->adapter->{$method}('zones/' . $zoneId . '/subscription', $options); + $this->body = json_decode($subscription->getBody()); + + return $this->body->result; + } +} diff --git a/src/Endpoints/Zones.php b/src/Endpoints/Zones.php index 2335b1c..fd9e18b 100644 --- a/src/Endpoints/Zones.php +++ b/src/Endpoints/Zones.php @@ -27,18 +27,20 @@ class Zones implements API * * @param string $name * @param bool $jumpStart - * @param string $organizationID + * @param string $accountId * @return \stdClass */ - public function addZone(string $name, bool $jumpStart = false, string $organizationID = ''): \stdClass + public function addZone(string $name, bool $jumpStart = false, string $accountId = ''): \stdClass { $options = [ 'name' => $name, 'jump_start' => $jumpStart ]; - if (!empty($organizationID)) { - $options['organization'] = ['id' => $organizationID]; + if (!empty($accountId)) { + $options['account'] = [ + 'id' => $accountId, + ]; } $user = $this->adapter->post('zones', $options); diff --git a/tests/Endpoints/AccountMembersTest.php b/tests/Endpoints/AccountMembersTest.php new file mode 100644 index 0000000..431e263 --- /dev/null +++ b/tests/Endpoints/AccountMembersTest.php @@ -0,0 +1,59 @@ +getPsr7JsonResponseForFixture('Endpoints/createAccountMember.json'); + + $mock = $this->getMockBuilder(Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/members'), + $this->equalTo([ + 'email' => 'user@example.com', + 'roles' => [ + '3536bcfad5faccb999b47003c79917fb', + ], + ]) + ); + + $accountMembers = new AccountMembers($mock); + $accountMembers->addAccountMember('01a7362d577a6c3019a474fd6f485823', 'user@example.com', ['3536bcfad5faccb999b47003c79917fb']); + + $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); + } +} diff --git a/tests/Endpoints/AccountRolesTest.php b/tests/Endpoints/AccountRolesTest.php new file mode 100644 index 0000000..acb16be --- /dev/null +++ b/tests/Endpoints/AccountRolesTest.php @@ -0,0 +1,32 @@ +getPsr7JsonResponseForFixture('Endpoints/listAccountRoles.json'); + + $adapter = $this->getMockBuilder(Adapter::class)->getMock(); + $adapter->method('get')->willReturn($response); + + $adapter->expects($this->once()) + ->method('get') + ->with($this->equalTo('accounts/023e105f4ecef8ad9ca31a8372d0c353/roles')); + + $roles = new AccountRoles($adapter); + $result = $roles->listAccountRoles('023e105f4ecef8ad9ca31a8372d0c353'); + + $this->assertObjectHasAttribute('result', $result); + $this->assertObjectHasAttribute('result_info', $result); + + $this->assertEquals('3536bcfad5faccb999b47003c79917fb', $result->result[0]->id); + $this->assertEquals(1, $result->result_info->page); + $this->assertEquals('3536bcfad5faccb999b47003c79917fb', $roles->getBody()->result[0]->id); + } +} diff --git a/tests/Endpoints/AccountsTest.php b/tests/Endpoints/AccountsTest.php index db2b1be..24f1f3c 100644 --- a/tests/Endpoints/AccountsTest.php +++ b/tests/Endpoints/AccountsTest.php @@ -1,4 +1,7 @@ listAccounts(1, 20, 'desc'); $this->assertObjectHasAttribute('result', $result); @@ -34,4 +37,50 @@ class AccountsTest extends TestCase $this->assertEquals(1, $result->result_info->page); $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $accounts->getBody()->result[0]->id); } + + public function testAddAccountWithDefaultType() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/createStandardAccount.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('accounts'), + $this->equalTo([ + 'name' => 'Foo Bar', + 'type' => 'standard', + ]) + ); + + $accounts = new Accounts($mock); + + $accounts->addAccount('Foo Bar'); + $this->assertEquals('2bab6ace8c72ed3f09b9eca6db1396bb', $accounts->getBody()->result->id); + } + + public function testAddAccountWithCustomType() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/createEnterpriseAccount.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('accounts'), + $this->equalTo([ + 'name' => 'Foo Bar', + 'type' => 'enterprise', + ]) + ); + + $accounts = new Accounts($mock); + + $accounts->addAccount('Foo Bar', 'enterprise'); + $this->assertEquals('2bab6ace8c72ed3f09b9eca6db1396bb', $accounts->getBody()->result->id); + } } diff --git a/tests/Endpoints/ZoneCacheTest.php b/tests/Endpoints/ZoneCacheTest.php new file mode 100644 index 0000000..bdefeec --- /dev/null +++ b/tests/Endpoints/ZoneCacheTest.php @@ -0,0 +1,78 @@ +getPsr7JsonResponseForFixture('Endpoints/cachePurgeEverything.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), + $this->equalTo(['purge_everything' => true]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->cachePurgeEverything('c2547eb745079dac9320b638f5e225cf483cc5cfdda41'); + + $this->assertTrue($result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); + } + + public function testCachePurgeHost() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeHost.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), + $this->equalTo( + [ + 'files' => [], + 'tags' => [], + 'hosts' => ['dash.cloudflare.com'] + ] + ) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [], [], ['dash.cloudflare.com']); + + $this->assertTrue($result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); + } + + public function testCachePurge() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurge.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), + $this->equalTo(['files' => [ + 'https://example.com/file.jpg', + ] + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [ + 'https://example.com/file.jpg', + ]); + + $this->assertTrue($result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); + } +} diff --git a/tests/Endpoints/ZoneSubscriptionsTest.php b/tests/Endpoints/ZoneSubscriptionsTest.php new file mode 100644 index 0000000..bd4b7c4 --- /dev/null +++ b/tests/Endpoints/ZoneSubscriptionsTest.php @@ -0,0 +1,81 @@ +getPsr7JsonResponseForFixture('Endpoints/listZoneSubscriptions.json'); + + $mock = $this->getMockBuilder(Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/subscriptions') + ); + + $zoneSubscriptions = new ZoneSubscriptions($mock); + $zoneSubscriptions->listZoneSubscriptions('023e105f4ecef8ad9ca31a8372d0c353'); + + $this->assertEquals('506e3185e9c882d175a2d0cb0093d9f2', $zoneSubscriptions->getBody()->result[0]->id); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zoneSubscriptions->getBody()->result[0]->zone->id); + } + + public function testAddZoneSubscriptionIfMissing() + { + $postResponse = $this->getPsr7JsonResponseForFixture('Endpoints/createZoneSubscription.json'); + $getResponse = $this->getPsr7JsonResponseForFixture('Endpoints/listEmptyZoneSubscriptions.json'); + + $mock = $this->getMockBuilder(Adapter::class)->getMock(); + $mock->method('post')->willReturn($postResponse); + $mock->method('get')->willReturn($getResponse); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/subscription'), + $this->equalTo([ + 'rate_plan' => [ + 'id' => 'PARTNER_PRO', + ], + ]) + ); + + $zoneSubscriptions = new ZoneSubscriptions($mock); + $zoneSubscriptions->addZoneSubscription('023e105f4ecef8ad9ca31a8372d0c353', 'PARTNER_PRO'); + + $this->assertEquals('506e3185e9c882d175a2d0cb0093d9f2', $zoneSubscriptions->getBody()->result->id); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zoneSubscriptions->getBody()->result->zone->id); + } + + public function testAddZoneSubscriptionIfExisting() + { + $postResponse = $this->getPsr7JsonResponseForFixture('Endpoints/createZoneSubscription.json'); + $getResponse = $this->getPsr7JsonResponseForFixture('Endpoints/listZoneSubscriptions.json'); + + $mock = $this->getMockBuilder(Adapter::class)->getMock(); + $mock->method('put')->willReturn($postResponse); + $mock->method('get')->willReturn($getResponse); + + $mock->expects($this->once()) + ->method('put') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/subscription'), + $this->equalTo([ + 'rate_plan' => [ + 'id' => 'PARTNER_PRO', + ], + ]) + ); + + $zoneSubscriptions = new ZoneSubscriptions($mock); + $zoneSubscriptions->addZoneSubscription('023e105f4ecef8ad9ca31a8372d0c353', 'PARTNER_PRO'); + + $this->assertEquals('506e3185e9c882d175a2d0cb0093d9f2', $zoneSubscriptions->getBody()->result->id); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zoneSubscriptions->getBody()->result->zone->id); + } +} diff --git a/tests/Endpoints/ZonesTest.php b/tests/Endpoints/ZonesTest.php index 02addeb..b4412f7 100644 --- a/tests/Endpoints/ZonesTest.php +++ b/tests/Endpoints/ZonesTest.php @@ -40,7 +40,9 @@ class ZonesTest extends TestCase $this->equalTo([ 'name' => 'example.com', 'jump_start' => true, - 'organization' => ['id' => '01a7362d577a6c3019a474fd6f485823'] + 'account' => [ + 'id' => '01a7362d577a6c3019a474fd6f485823', + ], ]) ); @@ -49,6 +51,33 @@ class ZonesTest extends TestCase $this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $zones->getBody()->result->id); } + public function testAddZoneWithAccountId() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/addZone.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('zones'), + $this->equalTo([ + 'name' => 'example.com', + 'jump_start' => false, + 'account' => [ + 'id' => '023e105f4ecef8ad9ca31a8372d0c353', + ], + ]) + ); + + $zones = new \Cloudflare\API\Endpoints\Zones($mock); + $result = $zones->addZone('example.com', false, '023e105f4ecef8ad9ca31a8372d0c353'); + + $this->assertObjectHasAttribute('id', $result); + $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $result->account->id); + } + public function testActivationTest() { $response = $this->getPsr7JsonResponseForFixture('Endpoints/activationTest.json'); @@ -188,78 +217,4 @@ class ZonesTest extends TestCase $this->assertTrue($result); $this->assertEquals('development_mode', $zones->getBody()->result->id); } - - public function testCachePurgeEverything() - { - $response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeEverything.json'); - - $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); - $mock->method('post')->willReturn($response); - - $mock->expects($this->once()) - ->method('post') - ->with( - $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), - $this->equalTo(['purge_everything' => true]) - ); - - $zones = new \Cloudflare\API\Endpoints\Zones($mock); - $result = $zones->cachePurgeEverything('c2547eb745079dac9320b638f5e225cf483cc5cfdda41'); - - $this->assertTrue($result); - $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); - } - - public function testCachePurgeHost() - { - $response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeHost.json'); - - $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); - $mock->method('post')->willReturn($response); - - $mock->expects($this->once()) - ->method('post') - ->with( - $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), - $this->equalTo( - [ - 'files' => [], - 'tags' => [], - 'hosts' => ['dash.cloudflare.com'] - ] - ) - ); - - $zones = new \Cloudflare\API\Endpoints\Zones($mock); - $result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [], [], ['dash.cloudflare.com']); - - $this->assertTrue($result); - $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); - } - - public function testCachePurge() - { - $response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurge.json'); - - $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); - $mock->method('post')->willReturn($response); - - $mock->expects($this->once()) - ->method('post') - ->with( - $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'), - $this->equalTo(['files' => [ - 'https://example.com/file.jpg', - ] - ]) - ); - - $zones = new \Cloudflare\API\Endpoints\Zones($mock); - $result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [ - 'https://example.com/file.jpg', - ]); - - $this->assertTrue($result); - $this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id); - } } diff --git a/tests/Fixtures/Endpoints/addZone.json b/tests/Fixtures/Endpoints/addZone.json index d3903c1..685e8cd 100644 --- a/tests/Fixtures/Endpoints/addZone.json +++ b/tests/Fixtures/Endpoints/addZone.json @@ -23,6 +23,10 @@ "email": "user@example.com", "owner_type": "user" }, + "account": { + "id": "023e105f4ecef8ad9ca31a8372d0c353", + "name": "Demo Account" + }, "permissions": [ "#zone:read", "#zone:edit" diff --git a/tests/Fixtures/Endpoints/createAccountMember.json b/tests/Fixtures/Endpoints/createAccountMember.json new file mode 100644 index 0000000..c7e310f --- /dev/null +++ b/tests/Fixtures/Endpoints/createAccountMember.json @@ -0,0 +1,74 @@ +{ + "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 + } + } + } + ] + } +} diff --git a/tests/Fixtures/Endpoints/createEnterpriseAccount.json b/tests/Fixtures/Endpoints/createEnterpriseAccount.json new file mode 100644 index 0000000..8f41a7a --- /dev/null +++ b/tests/Fixtures/Endpoints/createEnterpriseAccount.json @@ -0,0 +1,13 @@ +{ + "result": { + "id": "2bab6ace8c72ed3f09b9eca6db1396bb", + "name": "Foo Bar", + "type": "enterprise", + "settings": { + "enforce_twofactor": false + } + }, + "success": true, + "errors": [], + "messages": [] +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/createStandardAccount.json b/tests/Fixtures/Endpoints/createStandardAccount.json new file mode 100644 index 0000000..e970a50 --- /dev/null +++ b/tests/Fixtures/Endpoints/createStandardAccount.json @@ -0,0 +1,13 @@ +{ + "result": { + "id": "2bab6ace8c72ed3f09b9eca6db1396bb", + "name": "Foo Bar", + "type": "standard", + "settings": { + "enforce_twofactor": false + } + }, + "success": true, + "errors": [], + "messages": [] +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/createZoneSubscription.json b/tests/Fixtures/Endpoints/createZoneSubscription.json new file mode 100644 index 0000000..b16f022 --- /dev/null +++ b/tests/Fixtures/Endpoints/createZoneSubscription.json @@ -0,0 +1,40 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "app": { + "install_id": null + }, + "id": "506e3185e9c882d175a2d0cb0093d9f2", + "state": "Paid", + "price": 20, + "currency": "USD", + "component_values": [ + { + "name": "page_rules", + "value": 20, + "default": 5, + "price": 5 + } + ], + "zone": { + "id": "023e105f4ecef8ad9ca31a8372d0c353", + "name": "example.com" + }, + "frequency": "monthly", + "rate_plan": { + "id": "free", + "public_name": "Business Plan", + "currency": "USD", + "scope": "zone", + "sets": [ + {} + ], + "is_contract": false, + "externally_managed": false + }, + "current_period_end": "2014-03-31T12:20:00Z", + "current_period_start": "2014-05-11T12:20:00Z" + } +} diff --git a/tests/Fixtures/Endpoints/listAccountMembers.json b/tests/Fixtures/Endpoints/listAccountMembers.json new file mode 100644 index 0000000..5096fa0 --- /dev/null +++ b/tests/Fixtures/Endpoints/listAccountMembers.json @@ -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 + } +} diff --git a/tests/Fixtures/Endpoints/listAccountRoles.json b/tests/Fixtures/Endpoints/listAccountRoles.json new file mode 100644 index 0000000..b4f7224 --- /dev/null +++ b/tests/Fixtures/Endpoints/listAccountRoles.json @@ -0,0 +1,69 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": [ + { + "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": 1, + "total_pages": 1, + "count": 1, + "total_count": 1 + } +} diff --git a/tests/Fixtures/Endpoints/listEmptyZoneSubscriptions.json b/tests/Fixtures/Endpoints/listEmptyZoneSubscriptions.json new file mode 100644 index 0000000..8e0c15e --- /dev/null +++ b/tests/Fixtures/Endpoints/listEmptyZoneSubscriptions.json @@ -0,0 +1,6 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": [] +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/listZoneSubscriptions.json b/tests/Fixtures/Endpoints/listZoneSubscriptions.json new file mode 100644 index 0000000..080f4d7 --- /dev/null +++ b/tests/Fixtures/Endpoints/listZoneSubscriptions.json @@ -0,0 +1,42 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": [ + { + "app": { + "install_id": null + }, + "id": "506e3185e9c882d175a2d0cb0093d9f2", + "state": "Paid", + "price": 20, + "currency": "USD", + "component_values": [ + { + "name": "page_rules", + "value": 20, + "default": 5, + "price": 5 + } + ], + "zone": { + "id": "023e105f4ecef8ad9ca31a8372d0c353", + "name": "example.com" + }, + "frequency": "monthly", + "rate_plan": { + "id": "free", + "public_name": "Business Plan", + "currency": "USD", + "scope": "zone", + "sets": [ + {} + ], + "is_contract": false, + "externally_managed": false + }, + "current_period_end": "2014-03-31T12:20:00Z", + "current_period_start": "2014-05-11T12:20:00Z" + } + ] +} \ No newline at end of file