diff --git a/composer.json b/composer.json index 15978c6..e8cd4e6 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php": "^8.1", "ext-json": "*", "guzzlehttp/guzzle": "^7.5.0", - "psr/log": "^3.0.0", + "psr/log": "^1.0|^2.0|^3.0.0", "webmozart/assert": "^1.11.0" }, "require-dev": { diff --git a/src/Api/BrandsApi.php b/src/Api/BrandsApi.php index 122564a..7fdb084 100644 --- a/src/Api/BrandsApi.php +++ b/src/Api/BrandsApi.php @@ -46,6 +46,16 @@ public function list( return BrandCollection::fromArray($response->json()); } + public function export( + string $customer, + array $parameters = [] + ): array { + $query = $parameters; + $query['export'] = 'true'; + $response = $this->client->get("/v2/customers/{$customer}/brands", $query); + return $response->json()['entities']; + } + /** * @see https://dm.realtimeregister.com/docs/api/brands/create * diff --git a/src/Api/CustomersApi.php b/src/Api/CustomersApi.php index 5fb877e..6b0a4db 100644 --- a/src/Api/CustomersApi.php +++ b/src/Api/CustomersApi.php @@ -18,6 +18,6 @@ public function priceList(string $customer): PriceCollection public function credits(string $customer): AccountCollection { $response = $this->client->get("v2/customers/{$customer}/credit"); - return AccountCollection::fromArray($response->json()); + return AccountCollection::fromArray($response->json()['accounts']); } } diff --git a/src/Api/DnsZonesApi.php b/src/Api/DnsZonesApi.php index 9eaf530..3c98e9e 100644 --- a/src/Api/DnsZonesApi.php +++ b/src/Api/DnsZonesApi.php @@ -101,28 +101,28 @@ public function create( if ($master !== null) { $payload['master'] = $master; } - if($ns !== null) { + if ($ns !== null) { $payload['ns'] = $ns; } - if($dnssec !== null) { + if ($dnssec !== null) { $payload['dnssec'] = $dnssec; } - if($hostMaster !== null) { + if ($hostMaster !== null) { $payload['hostMaster'] = $hostMaster; } - if($refresh !== null) { + if ($refresh !== null) { $payload['refresh'] = $refresh; } - if($retry !== null) { + if ($retry !== null) { $payload['retry'] = $retry; } - if($expire !== null) { + if ($expire !== null) { $payload['expire'] = $expire; } - if($ttl !== null) { + if ($ttl !== null) { $payload['ttl'] = $ttl; } - if($records !== null) { + if ($records !== null) { $payload['records'] = $records->toArray(); } @@ -167,28 +167,28 @@ public function update( if ($master !== null) { $payload['master'] = $master; } - if($ns !== null) { + if ($ns !== null) { $payload['ns'] = $ns; } - if($dnssec !== null) { + if ($dnssec !== null) { $payload['dnssec'] = $dnssec; } - if($hostMaster !== null) { + if ($hostMaster !== null) { $payload['hostMaster'] = $hostMaster; } - if($refresh !== null) { + if ($refresh !== null) { $payload['refresh'] = $refresh; } - if($retry !== null) { + if ($retry !== null) { $payload['retry'] = $retry; } - if($expire !== null) { + if ($expire !== null) { $payload['expire'] = $expire; } - if($ttl !== null) { + if ($ttl !== null) { $payload['ttl'] = $ttl; } - if($records !== null) { + if ($records !== null) { $payload['records'] = $records->toArray(); } diff --git a/src/Api/DomainsApi.php b/src/Api/DomainsApi.php index 48c8873..c698c4e 100644 --- a/src/Api/DomainsApi.php +++ b/src/Api/DomainsApi.php @@ -54,6 +54,14 @@ public function list( return DomainDetailsCollection::fromArray($response->json()); } + public function export(array $parameters = []): array + { + $query = $parameters; + $query['export'] = 'true'; + $response = $this->client->get('v2/domains', $query); + return $response->json()['entities']; + } + /* @see https://dm.realtimeregister.com/docs/api/domains/check */ public function check(string $domainName, ?string $languageCode = null): DomainAvailability { @@ -151,7 +159,7 @@ public function register( } $response = $this->client->post("v2/domains/{$domainName}", $payload, [ - 'quote' => $isQuote, + 'quote' => $isQuote ? 'true' : 'false', ]); if ($isQuote) { diff --git a/src/Api/ProvidersApi.php b/src/Api/ProvidersApi.php index faec13f..b034386 100644 --- a/src/Api/ProvidersApi.php +++ b/src/Api/ProvidersApi.php @@ -41,6 +41,14 @@ public function list( return ProviderCollection::fromArray($response->json()); } + public function export(array $parameters = []): array + { + $query = $parameters; + $query['export'] = 'true'; + $response = $this->client->get('v2/providers', $query); + return $response->json()['entities']; + } + /* @see https://dm.realtimeregister.com/docs/api/providers/downtime/get */ public function getDowntime(int $id): Downtime { diff --git a/tests/Clients/CustomersApiCreditsTest.php b/tests/Clients/CustomersApiCreditsTest.php index 43d8df6..70c2d3d 100644 --- a/tests/Clients/CustomersApiCreditsTest.php +++ b/tests/Clients/CustomersApiCreditsTest.php @@ -3,6 +3,7 @@ namespace SandwaveIo\RealtimeRegister\Tests\Clients; use PHPUnit\Framework\TestCase; +use SandwaveIo\RealtimeRegister\Domain\Account; use SandwaveIo\RealtimeRegister\Domain\AccountCollection; use SandwaveIo\RealtimeRegister\Tests\Helpers\MockedClientFactory; @@ -10,24 +11,28 @@ class CustomersApiCreditsTest extends TestCase { public function test_credits(): void { + $primary = include __DIR__ . '/../Domain/data/account_valid.php'; + $primary['primary'] = true; + + $secondary = include __DIR__ . '/../Domain/data/account_valid.php'; + $secondary['primary'] = false; $sdk = MockedClientFactory::makeSdk( 200, - json_encode([ - 'entities' => [ - include __DIR__ . '/../Domain/data/account_valid.php', - include __DIR__ . '/../Domain/data/account_valid.php', - include __DIR__ . '/../Domain/data/account_valid.php', - ], - 'pagination' => [ - 'total' => 3, - 'offset' => 0, - 'limit' => 10, - ], - ]), + json_encode( + [ + 'accounts' => [ + $primary, + $secondary, + $secondary, + ], + ] + ), MockedClientFactory::assertRoute('GET', 'v2/customers/johndoe/credit', $this) ); $response = $sdk->customers->credits('johndoe'); $this->assertInstanceOf(AccountCollection::class, $response); + $this->assertInstanceOf(Account::class, $response->entities[0]); + $this->assertCount(3, $response->entities); } } diff --git a/tests/Domain/data/exchangerates_valid.php b/tests/Domain/data/exchangerates_valid.php index a2a58db..a00b76e 100644 --- a/tests/Domain/data/exchangerates_valid.php +++ b/tests/Domain/data/exchangerates_valid.php @@ -1,6 +1,6 @@ 'EUR', 'exchangerates' => [ 'USD' => 1000000, diff --git a/tests/Domain/data/process_invalid_status.php b/tests/Domain/data/process_invalid_status.php index c1e11f6..7afa898 100644 --- a/tests/Domain/data/process_invalid_status.php +++ b/tests/Domain/data/process_invalid_status.php @@ -1,6 +1,6 @@ 46069000, 'user' => 'johndoe/died', 'customer' => 'johndoe', diff --git a/tests/Domain/data/process_valid.php b/tests/Domain/data/process_valid.php index 8444ca2..5ee64c6 100644 --- a/tests/Domain/data/process_valid.php +++ b/tests/Domain/data/process_valid.php @@ -1,6 +1,6 @@ 46069000, 'user' => 'johndoe/died', 'customer' => 'johndoe', diff --git a/tests/Domain/data/process_valid_only_required.php b/tests/Domain/data/process_valid_only_required.php index 6f012b7..0cd9179 100644 --- a/tests/Domain/data/process_valid_only_required.php +++ b/tests/Domain/data/process_valid_only_required.php @@ -1,6 +1,6 @@ 46069000, 'user' => 'johndoe/died', 'customer' => 'johndoe', diff --git a/tests/Domain/data/transaction_valid.php b/tests/Domain/data/transaction_valid.php index 78dfe67..35d943a 100644 --- a/tests/Domain/data/transaction_valid.php +++ b/tests/Domain/data/transaction_valid.php @@ -1,6 +1,6 @@ 654563, 'customer' => 'johndoe', 'date' => '2021-08-11T06:17:15Z',