Skip to content

Commit

Permalink
update SDK from api-definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
rebilly-machine-user authored Oct 30, 2023
1 parent 64b4ba5 commit 6651fa1
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 73 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-ties-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Make Plan.id readOnly Rebilly/api-definitions#1651
5 changes: 5 additions & 0 deletions .changeset/great-waves-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Make cashier request fields nullable Rebilly/api-definitions#1654
5 changes: 3 additions & 2 deletions src/Api/CashierRequestsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use GuzzleHttp\Utils;
use Rebilly\Sdk\Collection;
use Rebilly\Sdk\Model\CashierRequest;
use Rebilly\Sdk\Model\CashierRequest2;
use Rebilly\Sdk\Paginator;

class CashierRequestsApi
Expand All @@ -30,11 +31,11 @@ public function __construct(protected ?ClientInterface $client)
* @return CashierRequest
*/
public function create(
CashierRequest $cashierRequest,
CashierRequest2 $cashierRequest2,
): CashierRequest {
$uri = '/cashier-requests';

$request = new Request('POST', $uri, body: Utils::jsonEncode($cashierRequest));
$request = new Request('POST', $uri, body: Utils::jsonEncode($cashierRequest2));
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

Expand Down
36 changes: 0 additions & 36 deletions src/Model/CashierRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ public function __construct(array $data = [])
if (array_key_exists('customerId', $data)) {
$this->setCustomerId($data['customerId']);
}
if (array_key_exists('strategyId', $data)) {
$this->setStrategyId($data['strategyId']);
}
if (array_key_exists('transactionId', $data)) {
$this->setTransactionId($data['transactionId']);
}
Expand All @@ -64,9 +61,6 @@ public function __construct(array $data = [])
if (array_key_exists('expirationTime', $data)) {
$this->setExpirationTime($data['expirationTime']);
}
if (array_key_exists('customPropertySetId', $data)) {
$this->setCustomPropertySetId($data['customPropertySetId']);
}
if (array_key_exists('propertiesSchema', $data)) {
$this->setPropertiesSchema($data['propertiesSchema']);
}
Expand Down Expand Up @@ -121,18 +115,6 @@ public function setCustomerId(string $customerId): static
return $this;
}

public function getStrategyId(): ?string
{
return $this->fields['strategyId'] ?? null;
}

public function setStrategyId(null|string $strategyId): static
{
$this->fields['strategyId'] = $strategyId;

return $this;
}

public function getTransactionId(): ?string
{
return $this->fields['transactionId'] ?? null;
Expand Down Expand Up @@ -222,18 +204,6 @@ public function setExpirationTime(null|DateTimeImmutable|string $expirationTime)
return $this;
}

public function getCustomPropertySetId(): ?string
{
return $this->fields['customPropertySetId'] ?? null;
}

public function setCustomPropertySetId(null|string $customPropertySetId): static
{
$this->fields['customPropertySetId'] = $customPropertySetId;

return $this;
}

public function getPropertiesSchema(): ?object
{
return $this->fields['propertiesSchema'] ?? null;
Expand Down Expand Up @@ -293,9 +263,6 @@ public function jsonSerialize(): array
if (array_key_exists('customerId', $this->fields)) {
$data['customerId'] = $this->fields['customerId'];
}
if (array_key_exists('strategyId', $this->fields)) {
$data['strategyId'] = $this->fields['strategyId'];
}
if (array_key_exists('transactionId', $this->fields)) {
$data['transactionId'] = $this->fields['transactionId'];
}
Expand All @@ -317,9 +284,6 @@ public function jsonSerialize(): array
if (array_key_exists('expirationTime', $this->fields)) {
$data['expirationTime'] = $this->fields['expirationTime']?->format(DateTimeInterface::RFC3339);
}
if (array_key_exists('customPropertySetId', $this->fields)) {
$data['customPropertySetId'] = $this->fields['customPropertySetId'];
}
if (array_key_exists('propertiesSchema', $this->fields)) {
$data['propertiesSchema'] = $this->fields['propertiesSchema'];
}
Expand Down
220 changes: 220 additions & 0 deletions src/Model/CashierRequest2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

declare(strict_types=1);

namespace Rebilly\Sdk\Model;

use DateTimeImmutable;
use DateTimeInterface;
use JsonSerializable;

class CashierRequest2 implements JsonSerializable
{
private array $fields = [];

public function __construct(array $data = [])
{
if (array_key_exists('websiteId', $data)) {
$this->setWebsiteId($data['websiteId']);
}
if (array_key_exists('customerId', $data)) {
$this->setCustomerId($data['customerId']);
}
if (array_key_exists('strategyId', $data)) {
$this->setStrategyId($data['strategyId']);
}
if (array_key_exists('currency', $data)) {
$this->setCurrency($data['currency']);
}
if (array_key_exists('amounts', $data)) {
$this->setAmounts($data['amounts']);
}
if (array_key_exists('customAmount', $data)) {
$this->setCustomAmount($data['customAmount']);
}
if (array_key_exists('redirectUrl', $data)) {
$this->setRedirectUrl($data['redirectUrl']);
}
if (array_key_exists('expirationTime', $data)) {
$this->setExpirationTime($data['expirationTime']);
}
if (array_key_exists('customPropertySetId', $data)) {
$this->setCustomPropertySetId($data['customPropertySetId']);
}
}

public static function from(array $data = []): self
{
return new self($data);
}

public function getWebsiteId(): string
{
return $this->fields['websiteId'];
}

public function setWebsiteId(string $websiteId): static
{
$this->fields['websiteId'] = $websiteId;

return $this;
}

public function getCustomerId(): string
{
return $this->fields['customerId'];
}

public function setCustomerId(string $customerId): static
{
$this->fields['customerId'] = $customerId;

return $this;
}

public function getStrategyId(): ?string
{
return $this->fields['strategyId'] ?? null;
}

public function setStrategyId(null|string $strategyId): static
{
$this->fields['strategyId'] = $strategyId;

return $this;
}

public function getCurrency(): string
{
return $this->fields['currency'];
}

public function setCurrency(string $currency): static
{
$this->fields['currency'] = $currency;

return $this;
}

/**
* @return null|float[]
*/
public function getAmounts(): ?array
{
return $this->fields['amounts'] ?? null;
}

/**
* @param null|float[] $amounts
*/
public function setAmounts(null|array $amounts): static
{
$amounts = $amounts !== null ? array_map(
fn ($value) => $value,
$amounts,
) : null;

$this->fields['amounts'] = $amounts;

return $this;
}

public function getCustomAmount(): ?CashierRequestCustomAmount
{
return $this->fields['customAmount'] ?? null;
}

public function setCustomAmount(null|CashierRequestCustomAmount|array $customAmount): static
{
if ($customAmount !== null && !($customAmount instanceof CashierRequestCustomAmount)) {
$customAmount = CashierRequestCustomAmount::from($customAmount);
}

$this->fields['customAmount'] = $customAmount;

return $this;
}

public function getRedirectUrl(): ?string
{
return $this->fields['redirectUrl'] ?? null;
}

public function setRedirectUrl(null|string $redirectUrl): static
{
$this->fields['redirectUrl'] = $redirectUrl;

return $this;
}

public function getExpirationTime(): ?DateTimeImmutable
{
return $this->fields['expirationTime'] ?? null;
}

public function setExpirationTime(null|DateTimeImmutable|string $expirationTime): static
{
if ($expirationTime !== null && !($expirationTime instanceof DateTimeImmutable)) {
$expirationTime = new DateTimeImmutable($expirationTime);
}

$this->fields['expirationTime'] = $expirationTime;

return $this;
}

public function getCustomPropertySetId(): ?string
{
return $this->fields['customPropertySetId'] ?? null;
}

public function setCustomPropertySetId(null|string $customPropertySetId): static
{
$this->fields['customPropertySetId'] = $customPropertySetId;

return $this;
}

public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('websiteId', $this->fields)) {
$data['websiteId'] = $this->fields['websiteId'];
}
if (array_key_exists('customerId', $this->fields)) {
$data['customerId'] = $this->fields['customerId'];
}
if (array_key_exists('strategyId', $this->fields)) {
$data['strategyId'] = $this->fields['strategyId'];
}
if (array_key_exists('currency', $this->fields)) {
$data['currency'] = $this->fields['currency'];
}
if (array_key_exists('amounts', $this->fields)) {
$data['amounts'] = $this->fields['amounts'];
}
if (array_key_exists('customAmount', $this->fields)) {
$data['customAmount'] = $this->fields['customAmount']?->jsonSerialize();
}
if (array_key_exists('redirectUrl', $this->fields)) {
$data['redirectUrl'] = $this->fields['redirectUrl'];
}
if (array_key_exists('expirationTime', $this->fields)) {
$data['expirationTime'] = $this->fields['expirationTime']?->format(DateTimeInterface::RFC3339);
}
if (array_key_exists('customPropertySetId', $this->fields)) {
$data['customPropertySetId'] = $this->fields['customPropertySetId'];
}

return $data;
}
}
18 changes: 9 additions & 9 deletions src/Model/FlexiblePlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,14 @@ public function setLinks(null|array $links): static
return $this;
}

public function getRecurringInterval(): ?SubscriptionOrderPlanRecurringInterval
public function getRecurringInterval(): SubscriptionOrderPlanRecurringInterval
{
return $this->fields['recurringInterval'] ?? null;
return $this->fields['recurringInterval'];
}

public function setRecurringInterval(null|SubscriptionOrderPlanRecurringInterval|array $recurringInterval): static
public function setRecurringInterval(SubscriptionOrderPlanRecurringInterval|array $recurringInterval): static
{
if ($recurringInterval !== null && !($recurringInterval instanceof SubscriptionOrderPlanRecurringInterval)) {
if (!($recurringInterval instanceof SubscriptionOrderPlanRecurringInterval)) {
$recurringInterval = SubscriptionOrderPlanRecurringInterval::from($recurringInterval);
}

Expand All @@ -303,15 +303,15 @@ public function setRecurringInterval(null|SubscriptionOrderPlanRecurringInterval
return $this;
}

public function getTrial(): ?PlanTrial
public function getTrial(): TrialOnlyPlanTrial
{
return $this->fields['trial'] ?? null;
return $this->fields['trial'];
}

public function setTrial(null|PlanTrial|array $trial): static
public function setTrial(TrialOnlyPlanTrial|array $trial): static
{
if ($trial !== null && !($trial instanceof PlanTrial)) {
$trial = PlanTrial::from($trial);
if (!($trial instanceof TrialOnlyPlanTrial)) {
$trial = TrialOnlyPlanTrial::from($trial);
}

$this->fields['trial'] = $trial;
Expand Down
Loading

0 comments on commit 6651fa1

Please sign in to comment.