Skip to content

Commit

Permalink
Added export functionality where needed
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
zbrag committed Jan 8, 2025
1 parent 1c431c8 commit 293b2a4
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 104 deletions.
18 changes: 9 additions & 9 deletions src/Api/BrandsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class BrandsApi extends AbstractApi
/* @see https://dm.realtimeregister.com/docs/api/brands/get */
public function get(string $customer, string $handle): Brand
{
$response = $this->client->get("/v2/customers/{$customer}/brands/{$handle}");
$response = $this->client->get(sprintf('/v2/customers/%s/brands/%s', urlencode($customer), urlencode($handle)));
return Brand::fromArray($response->json());
}

Expand All @@ -30,7 +30,7 @@ public function list(
): BrandCollection {
$query = $this->processListQuery($limit, $offset, $search, $parameters);

$response = $this->client->get("/v2/customers/{$customer}/brands", $query);
$response = $this->client->get(sprintf('/v2/customers/%s/brands', urlencode($customer)), $query);
return BrandCollection::fromArray($response->json());
}

Expand All @@ -40,7 +40,7 @@ public function export(
): array {
$query = $parameters;
$query['export'] = 'true';
$response = $this->client->get("/v2/customers/{$customer}/brands", $query);
$response = $this->client->get(sprintf('/v2/customers/%s/brands', urlencode($customer)), $query);
return $response->json()['entities'];
}

Expand Down Expand Up @@ -99,7 +99,7 @@ public function create(
$payload['updatedDate'] = $updatedDate;
}

$this->client->post("/v2/customers/{$customer}/brands/{$handle}", $payload);
$this->client->post(sprintf('/v2/customers/%s/brands/%s', urlencode($customer), urlencode($handle)), $payload);
}

/**
Expand Down Expand Up @@ -188,7 +188,7 @@ public function update(
$payload['updatedDate'] = $updatedDate;
}

$this->client->post("/v2/customers/{$customer}/brands/{$handle}/update", $payload);
$this->client->post(sprintf('/v2/customers/%s/brands/%s/update', urlencode($customer), urlencode($handle)), $payload);
}

/* @see https://dm.realtimeregister.com/docs/api/brands/delete */
Expand All @@ -202,7 +202,7 @@ public function getTemplate(string $customer, string $brand, string $name): Temp
{
TemplateNameEnum::validate($name);

return Template::fromArray($this->client->get("/v2/customers/{$customer}/brands/{$brand}/templates/{$name}")->json());
return Template::fromArray($this->client->get(sprintf('/v2/customers/%s/brands/%s/templates/%s', urlencode($customer), urlencode($brand), urlencode($name)))->json());
}

/* @see https://dm.realtimeregister.com/docs/api/brands/templates/list */
Expand All @@ -216,7 +216,7 @@ public function listTemplates(
): TemplateCollection {
$query = $this->processListQuery($limit, $offset, $search, $parameters);

$response = $this->client->get("/v2/customers/{$customer}/brands/{$brand}/templates", $query);
$response = $this->client->get(sprintf('/v2/customers/%s/brands/%s/templates', urlencode($customer), urlencode($brand)), $query);
return TemplateCollection::fromArray($response->json());
}

Expand All @@ -241,7 +241,7 @@ public function updateTemplate(
$payload['html'] = $html;
}

$this->client->post("/v2/customers/{$customer}/brands/{$brand}/templates/{$name}/update", $payload);
$this->client->post(sprintf('/v2/customers/%s/brands/%s/templates/%s/update', urlencode($customer), urlencode($brand), urlencode($name)), $payload);
}

/**
Expand Down Expand Up @@ -271,7 +271,7 @@ public function previewTemplate(string $customer, string $brand, string $name, ?
}

return TemplatePreview::fromArray(
$this->client->get("/v2/customers/{$customer}/brands/{$brand}/templates/{$name}/preview", $payload)->json()
$this->client->get(sprintf('/v2/customers/%s/brands/%s/templates/%s/preview', urlencode($customer), urlencode($brand), urlencode($name)), $payload)->json()
);
}
}
32 changes: 20 additions & 12 deletions src/Api/CertificatesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class CertificatesApi extends AbstractApi
/* @see https://dm.realtimeregister.com/docs/api/ssl/get */
public function getCertificate(int $certificateId): Certificate
{
$response = $this->client->get('/v2/ssl/certificates/' . $certificateId);
$response = $this->client->get(sprintf('/v2/ssl/certificates/%s', $certificateId));

return Certificate::fromArray($response->json());
}
Expand All @@ -40,7 +40,7 @@ public function downloadCertificate(int $certificateId, string $format = 'CRT'):
{
DownloadFormatEnum::validate($format);

$response = $this->client->get('/v2/ssl/certificates/' . $certificateId . '/download', ['format' => $format]);
$response = $this->client->get(sprintf('/v2/ssl/certificates/%s/download', $certificateId), ['format' => $format]);

return $response->text();
}
Expand All @@ -49,15 +49,15 @@ public function downloadCertificate(int $certificateId, string $format = 'CRT'):
public function listDcvEmailAddresses(string $domainName, string $product = null): array
{

$response = $this->client->get('/v2/ssl/dcvemailaddresslist/' . $domainName . ($product ? '?product=' . $product : ''));
$response = $this->client->get(sprintf('/v2/ssl/dcvemailaddresslist/%s', urlencode($domainName)) . ($product ? sprintf('?product=%s', urlencode($product)) : ''));

return $response->json();
}

/* @see https://dm.realtimeregister.com/docs/api/ssl/products/get */
public function getProduct(string $product): Product
{
$response = $this->client->get('/v2/ssl/products/' . $product);
$response = $this->client->get(sprintf('/v2/ssl/products/%s', urlencode($product)));

return Product::fromArray($response->json());
}
Expand All @@ -76,6 +76,14 @@ public function listProducts(
return ProductCollection::fromArray($response->json());
}

public function export(array $parameters = []): array
{
$query = $parameters;
$query['export'] = 'true';
$response = $this->client->get('/v2/ssl/products', $query);
return $response->json()['entities'];
}

/* @see https://dm.realtimeregister.com/docs/api/ssl/request */
public function requestCertificate(
string $customer,
Expand Down Expand Up @@ -261,7 +269,7 @@ public function renewCertificate(
$payload['product'] = $product;
}

$response = $this->client->post('/v2/ssl/certificates/' . $certificateId . '/renew', $payload);
$response = $this->client->post(sprintf('/v2/ssl/certificates/%s/renew', $certificateId), $payload);

return CertificateInfoProcess::fromArray(array_merge($response->json(), ['headers' => $response->headers()]));
}
Expand Down Expand Up @@ -345,7 +353,7 @@ public function reissueCertificate(
$payload['state'] = $state;
}

$response = $this->client->post('/v2/ssl/certificates/' . $certificateId . '/reissue', $payload);
$response = $this->client->post(sprintf('/v2/ssl/certificates/%s/reissue', $certificateId), $payload);

return CertificateInfoProcess::fromArray(array_merge($response->json(), ['headers' => $response->headers()]));
}
Expand All @@ -359,7 +367,7 @@ public function revokeCertificate(int $certificateId, ?string $reason = null): v
$payload['reason'] = $reason;
}

$this->client->delete('/v2/ssl/certificates/' . $certificateId, $payload);
$this->client->delete(sprintf('/v2/ssl/certificates/%s', $certificateId), $payload);
}

public function sendSubscriberAgreement(int $processId, string $email, ?string $language): void
Expand All @@ -372,7 +380,7 @@ public function sendSubscriberAgreement(int $processId, string $email, ?string $
$payload['language'] = $language;
}

$this->client->post('/v2/processes/' . $processId . '/send-subscriber-agreement', $payload);
$this->client->post(sprintf('/v2/processes/%s/send-subscriber-agreement', $processId), $payload);
}

/** @see https://dm.realtimeregister.com/docs/api/ssl/add-note */
Expand All @@ -382,7 +390,7 @@ public function addNote(int $processId, string $message): void
'message' => $message,
];

$this->client->post('/v2/processes/' . $processId . '/add-note', $payload);
$this->client->post(sprintf('/v2/processes/%s/add-note', $processId), $payload);
}

/** @see https://dm.realtimeregister.com/docs/api/ssl/schedule-validation-call */
Expand All @@ -392,13 +400,13 @@ public function scheduleValidationCall(int $processId, DateTimeImmutable $date):
'date' => $date,
];

$this->client->post('/v2/processes/' . $processId . '/schedule-validation-call', $payload);
$this->client->post(sprintf('/v2/processes/%s/schedule-validation-call', $processId), $payload);
}

/** @see https://dm.realtimeregister.com/docs/api/processes/info */
public function info(int $processId): CertificateInfoProcess
{
$response = $this->client->get('/v2/processes/' . $processId . '/info');
$response = $this->client->get(sprintf('/v2/processes/%s/info', $processId));

return CertificateInfoProcess::fromArray(array_merge($response->json(), ['headers' => $response->headers()]));

Expand Down Expand Up @@ -447,7 +455,7 @@ public function generateAuthKey(string $product, string $csr): array
/** @see https://dm.yoursrs-ote.com/docs/api/ssl/resenddcv */
public function resendDcv(int $processId, ResendDcvCollection $resendDcvCollection): ?array
{
$response = $this->client->post('/v2/processes/' . $processId . '/resend', $resendDcvCollection->toArray());
$response = $this->client->post(sprintf('/v2/processes/%s/resend', $processId), $resendDcvCollection->toArray());

if (
is_array($response->headers()) && array_key_exists('content-type', $response->headers())
Expand Down
22 changes: 11 additions & 11 deletions src/Api/ContactsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ public function list(
): ContactCollection {
$query = $this->processListQuery($limit, $offset, $search, $parameters);

$response = $this->client->get("v2/customers/{$customer}/contacts", $query);
$response = $this->client->get(sprintf('v2/customers/%s/contacts', urlencode($customer)), $query);
return ContactCollection::fromArray($response->json());
}

public function export(string $customer, array $parameters = []): array
{
$query = $parameters;
$query['export'] = 'true';
$response = $this->client->get("v2/customers/{$customer}/contacts", $query);
$response = $this->client->get(sprintf('v2/customers/%s/contacts', urlencode($customer)), $query);
return $response->json()['entities'];
}

/* @see https://dm.realtimeregister.com/docs/api/contacts/get */
public function get(string $customer, string $handle): Contact
{
$response = $this->client->get("v2/customers/{$customer}/contacts/{$handle}");
$response = $this->client->get(sprintf('v2/customers/%s/contacts/%s', urlencode($customer), urlencode($handle)));
return Contact::fromArray($response->json());
}

Expand Down Expand Up @@ -83,7 +83,7 @@ public function create(
$payload['fax'] = $fax;
}

$this->client->post("v2/customers/{$customer}/contacts/$handle", $payload);
$this->client->post(sprintf('v2/customers/%s/contacts/%s', urlencode($customer), urlencode($handle)), $payload);
}

/**
Expand Down Expand Up @@ -145,7 +145,7 @@ public function update(
$payload['fax'] = $fax;
}

$this->client->post("v2/customers/{$customer}/contacts/{$handle}/update", $payload);
$this->client->post(sprintf('v2/customers/%s/contacts/%s/update', urlencode($customer), urlencode($handle)), $payload);
}

/**
Expand All @@ -164,7 +164,7 @@ public function validate(string $customer, string $handle, array $categories): v
}
}

$this->client->post("v2/customers/{$customer}/contacts/{$handle}/validate", [
$this->client->post(sprintf('v2/customers/%s/contacts/%s/validate', urlencode($customer), urlencode($handle)), [
'categories' => $categories,
]);
}
Expand All @@ -182,15 +182,15 @@ public function split(string $customer, string $handle, string $newHandle, ?arra
$payload['registries'] = $registries;
}

$this->client->post("v2/customers/{$customer}/contacts/{$handle}/split", $payload);
$this->client->post(sprintf('v2/customers/%s/contacts/%s/split', urlencode($customer), urlencode($handle)), $payload);
}

/**
* @see https://dm.realtimeregister.com/docs/api/contacts/delete
*/
public function delete(string $customer, string $handle): void
{
$this->client->delete("v2/customers/{$customer}/contacts/{$handle}");
$this->client->delete(sprintf('v2/customers/%s/contacts/%s', urlencode($customer), urlencode($handle)));
}

/**
Expand All @@ -212,7 +212,7 @@ public function addProperties(string $customer, string $handle, string $registry

$payload['intendedUsage'] = $intendedUsage;
}
$this->client->post("v2/customers/{$customer}/contacts/{$handle}/{$registry}", $payload);
$this->client->post(sprintf('v2/customers/%s/contacts/%s/%s', urlencode($customer), urlencode($handle), urlencode($registry)), $payload);
}

/**
Expand All @@ -222,15 +222,15 @@ public function addProperties(string $customer, string $handle, string $registry
*/
public function updateProperties(string $customer, string $handle, string $registry, array $properties): void
{
$this->client->post("v2/customers/{$customer}/contacts/{$handle}/{$registry}/update", [
$this->client->post(sprintf('v2/customers/%s/contacts/%s/%s/update', urlencode($customer), urlencode($handle), urlencode($registry)), [
'properties' => $properties,
]);
}

/* @see https://dm.realtimeregister.com/docs/api/countries/get */
public function getCountry(string $country): Country
{
return Country::fromArray($this->client->get("v2/countries/{$country}")->json());
return Country::fromArray($this->client->get(sprintf('v2/countries/%s', urlencode($country)))->json());
}

/* @see https://dm.realtimeregister.com/docs/api/contacts/list */
Expand Down
6 changes: 3 additions & 3 deletions src/Api/CustomersApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ final class CustomersApi extends AbstractApi
/* @see https://dm.realtimeregister.com/docs/api/customers/pricelist */
public function priceList(string $customer): PriceCollection
{
$response = $this->client->get("v2/customers/{$customer}/pricelist");
$response = $this->client->get(sprintf('v2/customers/%s/pricelist', urlencode($customer)));
return PriceCollection::fromArray($response->json()['prices']);
}

/* @see https://dm.realtimeregister.com/docs/api/customers/pricelist#promos */
public function promoList(string $customer): PromoCollection
{
$response = $this->client->get("v2/customers/{$customer}/pricelist");
$response = $this->client->get(sprintf('v2/customers/%s/pricelist', urlencode($customer)));
return PromoCollection::fromArray($response->json()['promos']);
}

/* @see https://dm.realtimeregister.com/docs/api/customers/credits */
public function credits(string $customer): AccountCollection
{
$response = $this->client->get("v2/customers/{$customer}/credit");
$response = $this->client->get(sprintf('v2/customers/%s/credit', urlencode($customer)));
return AccountCollection::fromArray($response->json()['accounts']);
}
}
10 changes: 10 additions & 0 deletions src/Api/DnsTemplatesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public function list(
return DnsTemplateCollection::fromArray($response->json());
}

public function export(
string $customer,
array $parameters = []
): array {
$query = $parameters;
$query['export'] = 'true';
$response = $this->client->get(sprintf('v2/customers/%s/dnstemplates', urlencode($customer)), $query);
return $response->json()['entities'];
}

/**
* @see https://dm.realtimeregister.com/docs/api/templates/get
*
Expand Down
16 changes: 12 additions & 4 deletions src/Api/DnsZonesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public function list(
return DnsZoneCollection::fromArray($response->json());
}

public function export(array $parameters = []): array
{
$query = $parameters;
$query['export'] = 'true';
$response = $this->client->get('v2/dns/zones', $query);
return $response->json()['entities'];
}

/**
* @see https://dm.realtimeregister.com/docs/api/dns/zones/get
*
Expand Down Expand Up @@ -208,27 +216,27 @@ public function delete(int $id): void
/** @see https://dm.realtimeregister.com/docs/api/dns/zones/stats */
public function statistics(int $zoneId): DomainZoneStatistics
{
$result = $this->client->get("v2/dns/zones/{$zoneId}/stats");
$result = $this->client->get(sprintf('v2/dns/zones/%s/stats', $zoneId));

return DomainZoneStatistics::fromArray($result->json());
}

/** @see https://dm.realtimeregister.com/docs/api/dns/zones/retrieve */
public function retrieve(int $zoneId): void
{
$this->client->post("v2/dns/zones/{$zoneId}/retrieve");
$this->client->post(sprintf('v2/dns/zones/%s/retrieve', $zoneId));
}

/** @see https://dm.realtimeregister.com/docs/api/dns/zones/key-rollover */
public function keyRollover(int $zoneId): void
{
$this->client->post("v2/dns/zones/{$zoneId}/key-rollover");
$this->client->post(sprintf('v2/dns/zones/%s/key-rollover', $zoneId));
}

/** @see https://dm.realtimeregister.com/docs/api/dns/ack-ds-update */
public function ackDSUpdate(int $processId): void
{
$this->client->post("v2/processes/{$processId}/ack-ds-update");
$this->client->post(sprintf('v2/processes/%s/ack-ds-update', $processId));
}

/**
Expand Down
Loading

0 comments on commit 293b2a4

Please sign in to comment.