From fe3d930299fea5ea157bb24fb357b0709512bd8a Mon Sep 17 00:00:00 2001 From: Rebilly Machine User Date: Wed, 27 Mar 2024 19:12:40 +0200 Subject: [PATCH] chore: update SDK from api-definitions (#677) Co-authored-by: rebilly-machine-user --- .changeset/brave-needles-drive.md | 5 + .changeset/brave-pandas-protect.md | 5 + .changeset/breezy-rats-sniff.md | 5 + .changeset/cold-cows-build.md | 5 + .changeset/curvy-ligers-serve.md | 5 + .changeset/dirty-jeans-judge.md | 5 + .changeset/friendly-gifts-sin.md | 5 + .changeset/happy-bananas-mix.md | 5 + .changeset/khaki-news-do.md | 5 + .changeset/odd-singers-eat.md | 5 + .changeset/popular-trains-think.md | 5 + .changeset/purple-plums-lick.md | 5 + .changeset/quiet-carpets-try.md | 5 + .changeset/rich-badgers-pay.md | 5 + .changeset/rotten-feet-hear.md | 5 + .changeset/ten-avocados-pull.md | 5 + .changeset/tidy-poets-watch.md | 5 + src/Api/EventsApi.php | 44 +- src/Api/GatewayAccountsApi.php | 6 +- src/Api/ServiceCredentialsApi.php | 5 +- src/Model/Dispute.php | 2 + src/Model/FlexiblePlan.php | 16 +- src/Model/OneTimeSale.php | 62 +- src/Model/PatchPaymentInstrumentRequest.php | 4 - src/Model/PayoutRequestAllocations.php | 18 + src/Model/Plan.php | 16 +- ...OneTimeSalePlanSetup.php => PlanSetup.php} | 2 +- .../{TrialOnlyPlanTrial.php => PlanTrial.php} | 10 +- ...lanTrialPeriod.php => PlanTrialPeriod.php} | 2 +- src/Model/PostServiceCredentialRequest.php | 714 ------------------ src/Model/QuoteChangeOrder.php | 18 + src/Model/QuoteCreateOrder.php | 18 + src/Model/QuoteReactivateOrder.php | 18 + src/Model/QuoteTrialConversionOrder.php | 18 + src/Model/ServiceCredential.php | 2 + src/Model/Subscription.php | 38 +- src/Model/SubscriptionChangeItems.php | 6 +- .../SubscriptionOrOneTimeSaleItemPlan.php | 16 +- 38 files changed, 325 insertions(+), 795 deletions(-) create mode 100644 .changeset/brave-needles-drive.md create mode 100644 .changeset/brave-pandas-protect.md create mode 100644 .changeset/breezy-rats-sniff.md create mode 100644 .changeset/cold-cows-build.md create mode 100644 .changeset/curvy-ligers-serve.md create mode 100644 .changeset/dirty-jeans-judge.md create mode 100644 .changeset/friendly-gifts-sin.md create mode 100644 .changeset/happy-bananas-mix.md create mode 100644 .changeset/khaki-news-do.md create mode 100644 .changeset/odd-singers-eat.md create mode 100644 .changeset/popular-trains-think.md create mode 100644 .changeset/purple-plums-lick.md create mode 100644 .changeset/quiet-carpets-try.md create mode 100644 .changeset/rich-badgers-pay.md create mode 100644 .changeset/rotten-feet-hear.md create mode 100644 .changeset/ten-avocados-pull.md create mode 100644 .changeset/tidy-poets-watch.md rename src/Model/{OneTimeSalePlanSetup.php => PlanSetup.php} (95%) rename src/Model/{TrialOnlyPlanTrial.php => PlanTrial.php} (81%) rename src/Model/{SubscriptionPlanTrialPeriod.php => PlanTrialPeriod.php} (96%) delete mode 100644 src/Model/PostServiceCredentialRequest.php diff --git a/.changeset/brave-needles-drive.md b/.changeset/brave-needles-drive.md new file mode 100644 index 000000000..01e09a0bd --- /dev/null +++ b/.changeset/brave-needles-drive.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Fix GatewayAccount PUT SDK operation name Rebilly/api-definitions#1845 diff --git a/.changeset/brave-pandas-protect.md b/.changeset/brave-pandas-protect.md new file mode 100644 index 000000000..cea971e8c --- /dev/null +++ b/.changeset/brave-pandas-protect.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add subscription billingPortalToken Rebilly/api-definitions#1834 diff --git a/.changeset/breezy-rats-sniff.md b/.changeset/breezy-rats-sniff.md new file mode 100644 index 000000000..cc1802a93 --- /dev/null +++ b/.changeset/breezy-rats-sniff.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add paypal-claim dispute type Rebilly/api-definitions#1825 diff --git a/.changeset/cold-cows-build.md b/.changeset/cold-cows-build.md new file mode 100644 index 000000000..a3b893c10 --- /dev/null +++ b/.changeset/cold-cows-build.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add interimOnly for ChangeQuote Rebilly/api-definitions#1819 diff --git a/.changeset/curvy-ligers-serve.md b/.changeset/curvy-ligers-serve.md new file mode 100644 index 000000000..378e90cdd --- /dev/null +++ b/.changeset/curvy-ligers-serve.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Bump @redocly/cli from 1.10.5 to 1.10.6 Rebilly/api-definitions#1847 diff --git a/.changeset/dirty-jeans-judge.md b/.changeset/dirty-jeans-judge.md new file mode 100644 index 000000000..5a3b56e2f --- /dev/null +++ b/.changeset/dirty-jeans-judge.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add StorefrontPostSubscriptionReactivation Rebilly/api-definitions#1830 diff --git a/.changeset/friendly-gifts-sin.md b/.changeset/friendly-gifts-sin.md new file mode 100644 index 000000000..bbbfce74b --- /dev/null +++ b/.changeset/friendly-gifts-sin.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Make WebhookCredential type readonly Rebilly/api-definitions#1832 diff --git a/.changeset/happy-bananas-mix.md b/.changeset/happy-bananas-mix.md new file mode 100644 index 000000000..1083b1351 --- /dev/null +++ b/.changeset/happy-bananas-mix.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add KYC links to Storefront transaction Rebilly/api-definitions#1850 diff --git a/.changeset/khaki-news-do.md b/.changeset/khaki-news-do.md new file mode 100644 index 000000000..22e2234d2 --- /dev/null +++ b/.changeset/khaki-news-do.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Adjust SubscriptionChange items-quantity Rebilly/api-definitions#1829 diff --git a/.changeset/odd-singers-eat.md b/.changeset/odd-singers-eat.md new file mode 100644 index 000000000..c4b66d329 --- /dev/null +++ b/.changeset/odd-singers-eat.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Flatten plan related schemas Rebilly/api-definitions#1838 diff --git a/.changeset/popular-trains-think.md b/.changeset/popular-trains-think.md new file mode 100644 index 000000000..49305a66e --- /dev/null +++ b/.changeset/popular-trains-think.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Simplify service credential Rebilly/api-definitions#1831 diff --git a/.changeset/purple-plums-lick.md b/.changeset/purple-plums-lick.md new file mode 100644 index 000000000..41e104113 --- /dev/null +++ b/.changeset/purple-plums-lick.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add method to payout request allocation Rebilly/api-definitions#1833 diff --git a/.changeset/quiet-carpets-try.md b/.changeset/quiet-carpets-try.md new file mode 100644 index 000000000..6f919f845 --- /dev/null +++ b/.changeset/quiet-carpets-try.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +add parameters to GetEventCollection Rebilly/api-definitions#1835 diff --git a/.changeset/rich-badgers-pay.md b/.changeset/rich-badgers-pay.md new file mode 100644 index 000000000..b7bd68327 --- /dev/null +++ b/.changeset/rich-badgers-pay.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add query collection parameter to GetEventCollection Rebilly/api-definitions#1837 diff --git a/.changeset/rotten-feet-hear.md b/.changeset/rotten-feet-hear.md new file mode 100644 index 000000000..c812e59f7 --- /dev/null +++ b/.changeset/rotten-feet-hear.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +bump deps and remove extra deps Rebilly/api-definitions#1842 diff --git a/.changeset/ten-avocados-pull.md b/.changeset/ten-avocados-pull.md new file mode 100644 index 000000000..9080cebcc --- /dev/null +++ b/.changeset/ten-avocados-pull.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Rename Subscription endTime to churnTime Rebilly/api-definitions#1836 diff --git a/.changeset/tidy-poets-watch.md b/.changeset/tidy-poets-watch.md new file mode 100644 index 000000000..d4c271b6a --- /dev/null +++ b/.changeset/tidy-poets-watch.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +feat: Allow clearing sticky gateway from payment instrument by sending value Rebilly/api-definitions#1786 diff --git a/src/Api/EventsApi.php b/src/Api/EventsApi.php index 6f8157b26..7204fb3db 100644 --- a/src/Api/EventsApi.php +++ b/src/Api/EventsApi.php @@ -141,17 +141,51 @@ public function get( } /** - * @return SystemEvent[] + * @return Collection */ - public function getAll(): array - { - $uri = '/events'; + public function getAll( + ?int $limit = null, + ?int $offset = null, + ?string $filter = null, + ?string $q = null, + ): Collection { + $queryParams = [ + 'limit' => $limit, + 'offset' => $offset, + 'filter' => $filter, + 'q' => $q, + ]; + $uri = '/events?' . http_build_query($queryParams); $request = new Request('GET', $uri); $response = $this->client->send($request); $data = Utils::jsonDecode((string) $response->getBody(), true); - return array_map(fn (array $item): SystemEvent => SystemEvent::from($item), $data); + return new Collection( + array_map(fn (array $item): SystemEvent => SystemEvent::from($item), $data), + (int) $response->getHeaderLine(Collection::HEADER_LIMIT), + (int) $response->getHeaderLine(Collection::HEADER_OFFSET), + (int) $response->getHeaderLine(Collection::HEADER_TOTAL), + ); + } + + public function getAllPaginator( + ?int $limit = null, + ?int $offset = null, + ?string $filter = null, + ?string $q = null, + ): Paginator { + $closure = fn (?int $limit, ?int $offset): Collection => $this->getAll( + limit: $limit, + offset: $offset, + filter: $filter, + q: $q, + ); + + return new Paginator( + $limit !== null || $offset !== null ? $closure(limit: $limit, offset: $offset) : null, + $closure, + ); } /** diff --git a/src/Api/GatewayAccountsApi.php b/src/Api/GatewayAccountsApi.php index 89c2f6155..4137dad2b 100644 --- a/src/Api/GatewayAccountsApi.php +++ b/src/Api/GatewayAccountsApi.php @@ -536,7 +536,7 @@ public function update( $uri = str_replace(array_keys($pathParams), array_values($pathParams), '/gateway-accounts/{id}'); - $request = new Request('PUT', $uri, body: Utils::jsonEncode($gatewayAccount)); + $request = new Request('PATCH', $uri, body: Utils::jsonEncode($gatewayAccount)); $response = $this->client->send($request); $data = Utils::jsonDecode((string) $response->getBody(), true); @@ -590,7 +590,7 @@ public function updateVolumeLimit( /** * @return GatewayAccount */ - public function update_0( + public function upsert( string $id, GatewayAccount $gatewayAccount, ): GatewayAccount { @@ -600,7 +600,7 @@ public function update_0( $uri = str_replace(array_keys($pathParams), array_values($pathParams), '/gateway-accounts/{id}'); - $request = new Request('PATCH', $uri, body: Utils::jsonEncode($gatewayAccount)); + $request = new Request('PUT', $uri, body: Utils::jsonEncode($gatewayAccount)); $response = $this->client->send($request); $data = Utils::jsonDecode((string) $response->getBody(), true); diff --git a/src/Api/ServiceCredentialsApi.php b/src/Api/ServiceCredentialsApi.php index fa3b19721..7554c8b41 100644 --- a/src/Api/ServiceCredentialsApi.php +++ b/src/Api/ServiceCredentialsApi.php @@ -19,7 +19,6 @@ use Rebilly\Sdk\Collection; use Rebilly\Sdk\Model\GoogleSpreadsheet; use Rebilly\Sdk\Model\PatchServiceCredentialRequest; -use Rebilly\Sdk\Model\PostServiceCredentialRequest; use Rebilly\Sdk\Model\ServiceCredential; use Rebilly\Sdk\Model\ServiceCredentialFactory; use Rebilly\Sdk\Paginator; @@ -35,7 +34,7 @@ public function __construct(protected ?ClientInterface $client) */ public function create( string $type, - PostServiceCredentialRequest $postServiceCredentialRequest, + ServiceCredential $serviceCredential, ): ServiceCredential { $pathParams = [ '{type}' => $type, @@ -43,7 +42,7 @@ public function create( $uri = str_replace(array_keys($pathParams), array_values($pathParams), '/service-credentials/{type}'); - $request = new Request('POST', $uri, body: Utils::jsonEncode($postServiceCredentialRequest)); + $request = new Request('POST', $uri, body: Utils::jsonEncode($serviceCredential)); $response = $this->client->send($request); $data = Utils::jsonDecode((string) $response->getBody(), true); diff --git a/src/Model/Dispute.php b/src/Model/Dispute.php index deee33906..dac70b603 100644 --- a/src/Model/Dispute.php +++ b/src/Model/Dispute.php @@ -47,6 +47,8 @@ class Dispute implements JsonSerializable public const TYPE_BANK_RETURN = 'bank-return'; + public const TYPE_PAYPAL_CLAIM = 'paypal-claim'; + public const STATUS_RESPONSE_NEEDED = 'response-needed'; public const STATUS_UNDER_REVIEW = 'under-review'; diff --git a/src/Model/FlexiblePlan.php b/src/Model/FlexiblePlan.php index a7c563519..84d1ba5b0 100644 --- a/src/Model/FlexiblePlan.php +++ b/src/Model/FlexiblePlan.php @@ -204,15 +204,15 @@ public function setPricing(PlanPriceFormula|array $pricing): static return $this; } - public function getSetup(): ?OneTimeSalePlanSetup + public function getSetup(): ?PlanSetup { return $this->fields['setup'] ?? null; } - public function setSetup(null|OneTimeSalePlanSetup|array $setup): static + public function setSetup(null|PlanSetup|array $setup): static { - if ($setup !== null && !($setup instanceof OneTimeSalePlanSetup)) { - $setup = OneTimeSalePlanSetup::from($setup); + if ($setup !== null && !($setup instanceof PlanSetup)) { + $setup = PlanSetup::from($setup); } $this->fields['setup'] = $setup; @@ -288,15 +288,15 @@ public function setRecurringInterval(SubscriptionPlanRecurringInterval|array $re return $this; } - public function getTrial(): TrialOnlyPlanTrial + public function getTrial(): PlanTrial { return $this->fields['trial']; } - public function setTrial(TrialOnlyPlanTrial|array $trial): static + public function setTrial(PlanTrial|array $trial): static { - if (!($trial instanceof TrialOnlyPlanTrial)) { - $trial = TrialOnlyPlanTrial::from($trial); + if (!($trial instanceof PlanTrial)) { + $trial = PlanTrial::from($trial); } $this->fields['trial'] = $trial; diff --git a/src/Model/OneTimeSale.php b/src/Model/OneTimeSale.php index 24b0d8e1f..f8e276fac 100644 --- a/src/Model/OneTimeSale.php +++ b/src/Model/OneTimeSale.php @@ -184,6 +184,9 @@ public function __construct(array $data = []) if (array_key_exists('trialReminderNumber', $data)) { $this->setTrialReminderNumber($data['trialReminderNumber']); } + if (array_key_exists('churnTime', $data)) { + $this->setChurnTime($data['churnTime']); + } if (array_key_exists('lineItemSubtotal', $data)) { $this->setLineItemSubtotal($data['lineItemSubtotal']); } @@ -223,15 +226,15 @@ public function __construct(array $data = []) if (array_key_exists('renewalReminderNumber', $data)) { $this->setRenewalReminderNumber($data['renewalReminderNumber']); } + if (array_key_exists('billingPortalToken', $data)) { + $this->setBillingPortalToken($data['billingPortalToken']); + } if (array_key_exists('abandonReminderTime', $data)) { $this->setAbandonReminderTime($data['abandonReminderTime']); } if (array_key_exists('isTrialConverted', $data)) { $this->setIsTrialConverted($data['isTrialConverted']); } - if (array_key_exists('endTime', $data)) { - $this->setEndTime($data['endTime']); - } if (array_key_exists('cancelCategory', $data)) { $this->setCancelCategory($data['cancelCategory']); } @@ -589,6 +592,11 @@ public function getTrialReminderNumber(): ?int return $this->fields['trialReminderNumber'] ?? null; } + public function getChurnTime(): ?DateTimeImmutable + { + return $this->fields['churnTime'] ?? null; + } + public function getLineItemSubtotal(): ?SubscriptionLineItemSubtotal { return $this->fields['lineItemSubtotal'] ?? null; @@ -723,6 +731,11 @@ public function getRenewalReminderNumber(): ?int return $this->fields['renewalReminderNumber'] ?? null; } + public function getBillingPortalToken(): ?string + { + return $this->fields['billingPortalToken'] ?? null; + } + public function getAbandonReminderTime(): ?DateTimeImmutable { return $this->fields['abandonReminderTime'] ?? null; @@ -733,11 +746,6 @@ public function getIsTrialConverted(): ?bool return $this->fields['isTrialConverted'] ?? null; } - public function getEndTime(): ?DateTimeImmutable - { - return $this->fields['endTime'] ?? null; - } - public function getCancelCategory(): ?string { return $this->fields['cancelCategory'] ?? null; @@ -847,6 +855,9 @@ public function jsonSerialize(): array if (array_key_exists('trialReminderNumber', $this->fields)) { $data['trialReminderNumber'] = $this->fields['trialReminderNumber']; } + if (array_key_exists('churnTime', $this->fields)) { + $data['churnTime'] = $this->fields['churnTime']?->format(DateTimeInterface::RFC3339); + } if (array_key_exists('lineItemSubtotal', $this->fields)) { $data['lineItemSubtotal'] = $this->fields['lineItemSubtotal']?->jsonSerialize(); } @@ -886,15 +897,15 @@ public function jsonSerialize(): array if (array_key_exists('renewalReminderNumber', $this->fields)) { $data['renewalReminderNumber'] = $this->fields['renewalReminderNumber']; } + if (array_key_exists('billingPortalToken', $this->fields)) { + $data['billingPortalToken'] = $this->fields['billingPortalToken']; + } if (array_key_exists('abandonReminderTime', $this->fields)) { $data['abandonReminderTime'] = $this->fields['abandonReminderTime']?->format(DateTimeInterface::RFC3339); } if (array_key_exists('isTrialConverted', $this->fields)) { $data['isTrialConverted'] = $this->fields['isTrialConverted']; } - if (array_key_exists('endTime', $this->fields)) { - $data['endTime'] = $this->fields['endTime']?->format(DateTimeInterface::RFC3339); - } if (array_key_exists('cancelCategory', $this->fields)) { $data['cancelCategory'] = $this->fields['cancelCategory']; } @@ -1039,6 +1050,17 @@ private function setTrialReminderNumber(null|int $trialReminderNumber): static return $this; } + private function setChurnTime(null|DateTimeImmutable|string $churnTime): static + { + if ($churnTime !== null && !($churnTime instanceof DateTimeImmutable)) { + $churnTime = new DateTimeImmutable($churnTime); + } + + $this->fields['churnTime'] = $churnTime; + + return $this; + } + private function setTrialReminderTime(null|DateTimeImmutable|string $trialReminderTime): static { if ($trialReminderTime !== null && !($trialReminderTime instanceof DateTimeImmutable)) { @@ -1089,6 +1111,13 @@ private function setRenewalReminderNumber(null|int $renewalReminderNumber): stat return $this; } + private function setBillingPortalToken(null|string $billingPortalToken): static + { + $this->fields['billingPortalToken'] = $billingPortalToken; + + return $this; + } + private function setAbandonReminderTime(null|DateTimeImmutable|string $abandonReminderTime): static { if ($abandonReminderTime !== null && !($abandonReminderTime instanceof DateTimeImmutable)) { @@ -1107,17 +1136,6 @@ private function setIsTrialConverted(null|bool $isTrialConverted): static return $this; } - private function setEndTime(null|DateTimeImmutable|string $endTime): static - { - if ($endTime !== null && !($endTime instanceof DateTimeImmutable)) { - $endTime = new DateTimeImmutable($endTime); - } - - $this->fields['endTime'] = $endTime; - - return $this; - } - private function setCancelCategory(null|string $cancelCategory): static { $this->fields['cancelCategory'] = $cancelCategory; diff --git a/src/Model/PatchPaymentInstrumentRequest.php b/src/Model/PatchPaymentInstrumentRequest.php index f21d920a6..54423dc22 100644 --- a/src/Model/PatchPaymentInstrumentRequest.php +++ b/src/Model/PatchPaymentInstrumentRequest.php @@ -19,10 +19,6 @@ public function getBillingAddress(): ?ContactObject; public function setBillingAddress(null|ContactObject|array $billingAddress): static; - public function getStickyGatewayAccountId(): ?string; - - public function setStickyGatewayAccountId(null|string $stickyGatewayAccountId): static; - public function getCustomFields(): ?array; public function setCustomFields(null|array $customFields): static; diff --git a/src/Model/PayoutRequestAllocations.php b/src/Model/PayoutRequestAllocations.php index f74d6d73a..cdbbb69ba 100644 --- a/src/Model/PayoutRequestAllocations.php +++ b/src/Model/PayoutRequestAllocations.php @@ -39,6 +39,9 @@ public function __construct(array $data = []) if (array_key_exists('transactionResult', $data)) { $this->setTransactionResult($data['transactionResult']); } + if (array_key_exists('method', $data)) { + $this->setMethod($data['method']); + } if (array_key_exists('gatewayName', $data)) { $this->setGatewayName($data['gatewayName']); } @@ -78,6 +81,18 @@ public function getTransactionResult(): ?string return $this->fields['transactionResult'] ?? null; } + public function getMethod(): ?string + { + return $this->fields['method'] ?? null; + } + + public function setMethod(null|string $method): static + { + $this->fields['method'] = $method; + + return $this; + } + public function getGatewayName(): ?string { return $this->fields['gatewayName'] ?? null; @@ -137,6 +152,9 @@ public function jsonSerialize(): array if (array_key_exists('transactionResult', $this->fields)) { $data['transactionResult'] = $this->fields['transactionResult']; } + if (array_key_exists('method', $this->fields)) { + $data['method'] = $this->fields['method']; + } if (array_key_exists('gatewayName', $this->fields)) { $data['gatewayName'] = $this->fields['gatewayName']; } diff --git a/src/Model/Plan.php b/src/Model/Plan.php index 00df5a4ab..a0e30fd54 100644 --- a/src/Model/Plan.php +++ b/src/Model/Plan.php @@ -197,15 +197,15 @@ public function setPricing(PlanPriceFormula|array $pricing): static return $this; } - public function getSetup(): ?OneTimeSalePlanSetup + public function getSetup(): ?PlanSetup { return $this->fields['setup'] ?? null; } - public function setSetup(null|OneTimeSalePlanSetup|array $setup): static + public function setSetup(null|PlanSetup|array $setup): static { - if ($setup !== null && !($setup instanceof OneTimeSalePlanSetup)) { - $setup = OneTimeSalePlanSetup::from($setup); + if ($setup !== null && !($setup instanceof PlanSetup)) { + $setup = PlanSetup::from($setup); } $this->fields['setup'] = $setup; @@ -281,15 +281,15 @@ public function setRecurringInterval(SubscriptionPlanRecurringInterval|array $re return $this; } - public function getTrial(): TrialOnlyPlanTrial + public function getTrial(): PlanTrial { return $this->fields['trial']; } - public function setTrial(TrialOnlyPlanTrial|array $trial): static + public function setTrial(PlanTrial|array $trial): static { - if (!($trial instanceof TrialOnlyPlanTrial)) { - $trial = TrialOnlyPlanTrial::from($trial); + if (!($trial instanceof PlanTrial)) { + $trial = PlanTrial::from($trial); } $this->fields['trial'] = $trial; diff --git a/src/Model/OneTimeSalePlanSetup.php b/src/Model/PlanSetup.php similarity index 95% rename from src/Model/OneTimeSalePlanSetup.php rename to src/Model/PlanSetup.php index 81dc4af49..ea5fefa51 100644 --- a/src/Model/OneTimeSalePlanSetup.php +++ b/src/Model/PlanSetup.php @@ -15,7 +15,7 @@ use JsonSerializable; -class OneTimeSalePlanSetup implements JsonSerializable +class PlanSetup implements JsonSerializable { private array $fields = []; diff --git a/src/Model/TrialOnlyPlanTrial.php b/src/Model/PlanTrial.php similarity index 81% rename from src/Model/TrialOnlyPlanTrial.php rename to src/Model/PlanTrial.php index 2ca5ea794..b2befb018 100644 --- a/src/Model/TrialOnlyPlanTrial.php +++ b/src/Model/PlanTrial.php @@ -15,7 +15,7 @@ use JsonSerializable; -class TrialOnlyPlanTrial implements JsonSerializable +class PlanTrial implements JsonSerializable { private array $fields = []; @@ -50,15 +50,15 @@ public function setPrice(float|string $price): static return $this; } - public function getPeriod(): SubscriptionPlanTrialPeriod + public function getPeriod(): PlanTrialPeriod { return $this->fields['period']; } - public function setPeriod(SubscriptionPlanTrialPeriod|array $period): static + public function setPeriod(PlanTrialPeriod|array $period): static { - if (!($period instanceof SubscriptionPlanTrialPeriod)) { - $period = SubscriptionPlanTrialPeriod::from($period); + if (!($period instanceof PlanTrialPeriod)) { + $period = PlanTrialPeriod::from($period); } $this->fields['period'] = $period; diff --git a/src/Model/SubscriptionPlanTrialPeriod.php b/src/Model/PlanTrialPeriod.php similarity index 96% rename from src/Model/SubscriptionPlanTrialPeriod.php rename to src/Model/PlanTrialPeriod.php index c3b8fca14..fbe012759 100644 --- a/src/Model/SubscriptionPlanTrialPeriod.php +++ b/src/Model/PlanTrialPeriod.php @@ -15,7 +15,7 @@ use JsonSerializable; -class SubscriptionPlanTrialPeriod implements JsonSerializable +class PlanTrialPeriod implements JsonSerializable { public const UNIT_DAY = 'day'; diff --git a/src/Model/PostServiceCredentialRequest.php b/src/Model/PostServiceCredentialRequest.php deleted file mode 100644 index 66b7c7440..000000000 --- a/src/Model/PostServiceCredentialRequest.php +++ /dev/null @@ -1,714 +0,0 @@ -setId($data['id']); - } - if (array_key_exists('hash', $data)) { - $this->setHash($data['hash']); - } - if (array_key_exists('status', $data)) { - $this->setStatus($data['status']); - } - if (array_key_exists('deactivationTime', $data)) { - $this->setDeactivationTime($data['deactivationTime']); - } - if (array_key_exists('type', $data)) { - $this->setType($data['type']); - } - if (array_key_exists('host', $data)) { - $this->setHost($data['host']); - } - if (array_key_exists('port', $data)) { - $this->setPort($data['port']); - } - if (array_key_exists('encryption', $data)) { - $this->setEncryption($data['encryption']); - } - if (array_key_exists('auth', $data)) { - $this->setAuth($data['auth']); - } - if (array_key_exists('_links', $data)) { - $this->setLinks($data['_links']); - } - if (array_key_exists('username', $data)) { - $this->setUsername($data['username']); - } - if (array_key_exists('password', $data)) { - $this->setPassword($data['password']); - } - if (array_key_exists('hmacKey', $data)) { - $this->setHmacKey($data['hmacKey']); - } - if (array_key_exists('publicKey', $data)) { - $this->setPublicKey($data['publicKey']); - } - if (array_key_exists('emailFrom', $data)) { - $this->setEmailFrom($data['emailFrom']); - } - if (array_key_exists('apiKey', $data)) { - $this->setApiKey($data['apiKey']); - } - if (array_key_exists('domain', $data)) { - $this->setDomain($data['domain']); - } - if (array_key_exists('service', $data)) { - $this->setService($data['service']); - } - if (array_key_exists('code', $data)) { - $this->setCode($data['code']); - } - if (array_key_exists('accessToken', $data)) { - $this->setAccessToken($data['accessToken']); - } - if (array_key_exists('refreshToken', $data)) { - $this->setRefreshToken($data['refreshToken']); - } - if (array_key_exists('scopes', $data)) { - $this->setScopes($data['scopes']); - } - if (array_key_exists('serverApiToken', $data)) { - $this->setServerApiToken($data['serverApiToken']); - } - if (array_key_exists('key', $data)) { - $this->setKey($data['key']); - } - if (array_key_exists('secret', $data)) { - $this->setSecret($data['secret']); - } - if (array_key_exists('region', $data)) { - $this->setRegion($data['region']); - } - if (array_key_exists('configurationSetName', $data)) { - $this->setConfigurationSetName($data['configurationSetName']); - } - if (array_key_exists('apiToken', $data)) { - $this->setApiToken($data['apiToken']); - } - if (array_key_exists('omitFromAddress', $data)) { - $this->setOmitFromAddress($data['omitFromAddress']); - } - if (array_key_exists('licenseKey', $data)) { - $this->setLicenseKey($data['licenseKey']); - } - if (array_key_exists('accountId', $data)) { - $this->setAccountId($data['accountId']); - } - if (array_key_exists('websiteId', $data)) { - $this->setWebsiteId($data['websiteId']); - } - if (array_key_exists('clientId', $data)) { - $this->setClientId($data['clientId']); - } - if (array_key_exists('secretToken', $data)) { - $this->setSecretToken($data['secretToken']); - } - if (array_key_exists('useStripe', $data)) { - $this->setUseStripe($data['useStripe']); - } - } - - public static function from(array $data = []): self - { - return new self($data); - } - - public function getId(): ?string - { - return $this->fields['id'] ?? null; - } - - public function getHash(): ?string - { - return $this->fields['hash'] ?? null; - } - - public function getStatus(): ?string - { - return $this->fields['status'] ?? null; - } - - public function setStatus(null|string $status): static - { - $this->fields['status'] = $status; - - return $this; - } - - public function getDeactivationTime(): ?DateTimeImmutable - { - return $this->fields['deactivationTime'] ?? null; - } - - public function getType(): string - { - return $this->fields['type']; - } - - public function getHost(): string - { - return $this->fields['host']; - } - - public function setHost(string $host): static - { - $this->fields['host'] = $host; - - return $this; - } - - public function getPort(): ?int - { - return $this->fields['port'] ?? null; - } - - public function setPort(null|int $port): static - { - $this->fields['port'] = $port; - - return $this; - } - - public function getEncryption(): ?string - { - return $this->fields['encryption'] ?? null; - } - - public function setEncryption(null|string $encryption): static - { - $this->fields['encryption'] = $encryption; - - return $this; - } - - public function getAuth(): ?WebhookAuthorization - { - return $this->fields['auth'] ?? null; - } - - public function setAuth(null|WebhookAuthorization|array $auth): static - { - if ($auth !== null && !($auth instanceof WebhookAuthorization)) { - $auth = WebhookAuthorizationFactory::from($auth); - } - - $this->fields['auth'] = $auth; - - return $this; - } - - /** - * @return null|ResourceLink[] - */ - public function getLinks(): ?array - { - return $this->fields['_links'] ?? null; - } - - public function getUsername(): string - { - return $this->fields['username']; - } - - public function setUsername(string $username): static - { - $this->fields['username'] = $username; - - return $this; - } - - public function getPassword(): string - { - return $this->fields['password']; - } - - public function setPassword(string $password): static - { - $this->fields['password'] = $password; - - return $this; - } - - public function getHmacKey(): string - { - return $this->fields['hmacKey']; - } - - public function setHmacKey(string $hmacKey): static - { - $this->fields['hmacKey'] = $hmacKey; - - return $this; - } - - public function getPublicKey(): string - { - return $this->fields['publicKey']; - } - - public function setPublicKey(string $publicKey): static - { - $this->fields['publicKey'] = $publicKey; - - return $this; - } - - public function getEmailFrom(): string - { - return $this->fields['emailFrom']; - } - - public function setEmailFrom(string $emailFrom): static - { - $this->fields['emailFrom'] = $emailFrom; - - return $this; - } - - public function getApiKey(): string - { - return $this->fields['apiKey']; - } - - public function setApiKey(string $apiKey): static - { - $this->fields['apiKey'] = $apiKey; - - return $this; - } - - public function getDomain(): string - { - return $this->fields['domain']; - } - - public function setDomain(string $domain): static - { - $this->fields['domain'] = $domain; - - return $this; - } - - public function getService(): string - { - return $this->fields['service']; - } - - public function setService(string $service): static - { - $this->fields['service'] = $service; - - return $this; - } - - public function getCode(): string - { - return $this->fields['code']; - } - - public function setCode(string $code): static - { - $this->fields['code'] = $code; - - return $this; - } - - public function getAccessToken(): ?string - { - return $this->fields['accessToken'] ?? null; - } - - public function getRefreshToken(): ?string - { - return $this->fields['refreshToken'] ?? null; - } - - /** - * @return string[] - */ - public function getScopes(): array - { - return $this->fields['scopes']; - } - - /** - * @param string[] $scopes - */ - public function setScopes(array $scopes): static - { - $this->fields['scopes'] = $scopes; - - return $this; - } - - public function getServerApiToken(): string - { - return $this->fields['serverApiToken']; - } - - public function setServerApiToken(string $serverApiToken): static - { - $this->fields['serverApiToken'] = $serverApiToken; - - return $this; - } - - public function getKey(): string - { - return $this->fields['key']; - } - - public function setKey(string $key): static - { - $this->fields['key'] = $key; - - return $this; - } - - public function getSecret(): string - { - return $this->fields['secret']; - } - - public function setSecret(string $secret): static - { - $this->fields['secret'] = $secret; - - return $this; - } - - public function getRegion(): string - { - return $this->fields['region']; - } - - public function setRegion(string $region): static - { - $this->fields['region'] = $region; - - return $this; - } - - public function getConfigurationSetName(): ?string - { - return $this->fields['configurationSetName'] ?? null; - } - - public function setConfigurationSetName(null|string $configurationSetName): static - { - $this->fields['configurationSetName'] = $configurationSetName; - - return $this; - } - - public function getApiToken(): string - { - return $this->fields['apiToken']; - } - - public function setApiToken(string $apiToken): static - { - $this->fields['apiToken'] = $apiToken; - - return $this; - } - - public function getOmitFromAddress(): ?bool - { - return $this->fields['omitFromAddress'] ?? null; - } - - public function setOmitFromAddress(null|bool $omitFromAddress): static - { - $this->fields['omitFromAddress'] = $omitFromAddress; - - return $this; - } - - public function getLicenseKey(): string - { - return $this->fields['licenseKey']; - } - - public function setLicenseKey(string $licenseKey): static - { - $this->fields['licenseKey'] = $licenseKey; - - return $this; - } - - public function getAccountId(): string - { - return $this->fields['accountId']; - } - - public function setAccountId(string $accountId): static - { - $this->fields['accountId'] = $accountId; - - return $this; - } - - public function getWebsiteId(): ?string - { - return $this->fields['websiteId'] ?? null; - } - - public function setWebsiteId(null|string $websiteId): static - { - $this->fields['websiteId'] = $websiteId; - - return $this; - } - - public function getClientId(): string - { - return $this->fields['clientId']; - } - - public function setClientId(string $clientId): static - { - $this->fields['clientId'] = $clientId; - - return $this; - } - - public function getSecretToken(): string - { - return $this->fields['secretToken']; - } - - public function setSecretToken(string $secretToken): static - { - $this->fields['secretToken'] = $secretToken; - - return $this; - } - - public function getUseStripe(): ?bool - { - return $this->fields['useStripe'] ?? null; - } - - public function setUseStripe(null|bool $useStripe): static - { - $this->fields['useStripe'] = $useStripe; - - return $this; - } - - public function jsonSerialize(): array - { - $data = []; - if (array_key_exists('id', $this->fields)) { - $data['id'] = $this->fields['id']; - } - if (array_key_exists('hash', $this->fields)) { - $data['hash'] = $this->fields['hash']; - } - if (array_key_exists('status', $this->fields)) { - $data['status'] = $this->fields['status']; - } - if (array_key_exists('deactivationTime', $this->fields)) { - $data['deactivationTime'] = $this->fields['deactivationTime']?->format(DateTimeInterface::RFC3339); - } - if (array_key_exists('type', $this->fields)) { - $data['type'] = $this->fields['type']; - } - if (array_key_exists('host', $this->fields)) { - $data['host'] = $this->fields['host']; - } - if (array_key_exists('port', $this->fields)) { - $data['port'] = $this->fields['port']; - } - if (array_key_exists('encryption', $this->fields)) { - $data['encryption'] = $this->fields['encryption']; - } - if (array_key_exists('auth', $this->fields)) { - $data['auth'] = $this->fields['auth']?->jsonSerialize(); - } - if (array_key_exists('_links', $this->fields)) { - $data['_links'] = $this->fields['_links']; - } - if (array_key_exists('username', $this->fields)) { - $data['username'] = $this->fields['username']; - } - if (array_key_exists('password', $this->fields)) { - $data['password'] = $this->fields['password']; - } - if (array_key_exists('hmacKey', $this->fields)) { - $data['hmacKey'] = $this->fields['hmacKey']; - } - if (array_key_exists('publicKey', $this->fields)) { - $data['publicKey'] = $this->fields['publicKey']; - } - if (array_key_exists('emailFrom', $this->fields)) { - $data['emailFrom'] = $this->fields['emailFrom']; - } - if (array_key_exists('apiKey', $this->fields)) { - $data['apiKey'] = $this->fields['apiKey']; - } - if (array_key_exists('domain', $this->fields)) { - $data['domain'] = $this->fields['domain']; - } - if (array_key_exists('service', $this->fields)) { - $data['service'] = $this->fields['service']; - } - if (array_key_exists('code', $this->fields)) { - $data['code'] = $this->fields['code']; - } - if (array_key_exists('accessToken', $this->fields)) { - $data['accessToken'] = $this->fields['accessToken']; - } - if (array_key_exists('refreshToken', $this->fields)) { - $data['refreshToken'] = $this->fields['refreshToken']; - } - if (array_key_exists('scopes', $this->fields)) { - $data['scopes'] = $this->fields['scopes']; - } - if (array_key_exists('serverApiToken', $this->fields)) { - $data['serverApiToken'] = $this->fields['serverApiToken']; - } - if (array_key_exists('key', $this->fields)) { - $data['key'] = $this->fields['key']; - } - if (array_key_exists('secret', $this->fields)) { - $data['secret'] = $this->fields['secret']; - } - if (array_key_exists('region', $this->fields)) { - $data['region'] = $this->fields['region']; - } - if (array_key_exists('configurationSetName', $this->fields)) { - $data['configurationSetName'] = $this->fields['configurationSetName']; - } - if (array_key_exists('apiToken', $this->fields)) { - $data['apiToken'] = $this->fields['apiToken']; - } - if (array_key_exists('omitFromAddress', $this->fields)) { - $data['omitFromAddress'] = $this->fields['omitFromAddress']; - } - if (array_key_exists('licenseKey', $this->fields)) { - $data['licenseKey'] = $this->fields['licenseKey']; - } - if (array_key_exists('accountId', $this->fields)) { - $data['accountId'] = $this->fields['accountId']; - } - if (array_key_exists('websiteId', $this->fields)) { - $data['websiteId'] = $this->fields['websiteId']; - } - if (array_key_exists('clientId', $this->fields)) { - $data['clientId'] = $this->fields['clientId']; - } - if (array_key_exists('secretToken', $this->fields)) { - $data['secretToken'] = $this->fields['secretToken']; - } - if (array_key_exists('useStripe', $this->fields)) { - $data['useStripe'] = $this->fields['useStripe']; - } - - return $data; - } - - private function setId(null|string $id): static - { - $this->fields['id'] = $id; - - return $this; - } - - private function setHash(null|string $hash): static - { - $this->fields['hash'] = $hash; - - return $this; - } - - private function setDeactivationTime(null|DateTimeImmutable|string $deactivationTime): static - { - if ($deactivationTime !== null && !($deactivationTime instanceof DateTimeImmutable)) { - $deactivationTime = new DateTimeImmutable($deactivationTime); - } - - $this->fields['deactivationTime'] = $deactivationTime; - - return $this; - } - - private function setType(string $type): static - { - $this->fields['type'] = $type; - - return $this; - } - - /** - * @param null|array[]|ResourceLink[] $links - */ - private function setLinks(null|array $links): static - { - $links = $links !== null ? array_map( - fn ($value) => $value instanceof ResourceLink ? $value : ResourceLink::from($value), - $links, - ) : null; - - $this->fields['_links'] = $links; - - return $this; - } - - private function setAccessToken(null|string $accessToken): static - { - $this->fields['accessToken'] = $accessToken; - - return $this; - } - - private function setRefreshToken(null|string $refreshToken): static - { - $this->fields['refreshToken'] = $refreshToken; - - return $this; - } -} diff --git a/src/Model/QuoteChangeOrder.php b/src/Model/QuoteChangeOrder.php index 7c927d854..115078c60 100644 --- a/src/Model/QuoteChangeOrder.php +++ b/src/Model/QuoteChangeOrder.php @@ -89,6 +89,9 @@ public function __construct(array $data = []) if (array_key_exists('keepTrial', $data)) { $this->setKeepTrial($data['keepTrial']); } + if (array_key_exists('interimOnly', $data)) { + $this->setInterimOnly($data['interimOnly']); + } if (array_key_exists('invoicePreview', $data)) { $this->setInvoicePreview($data['invoicePreview']); } @@ -315,6 +318,18 @@ public function setKeepTrial(null|bool $keepTrial): static return $this; } + public function getInterimOnly(): ?bool + { + return $this->fields['interimOnly'] ?? null; + } + + public function setInterimOnly(null|bool $interimOnly): static + { + $this->fields['interimOnly'] = $interimOnly; + + return $this; + } + public function getInvoicePreview(): ?QuoteCreateOrderInvoicePreview { return $this->fields['invoicePreview'] ?? null; @@ -600,6 +615,9 @@ public function jsonSerialize(): array if (array_key_exists('keepTrial', $this->fields)) { $data['keepTrial'] = $this->fields['keepTrial']; } + if (array_key_exists('interimOnly', $this->fields)) { + $data['interimOnly'] = $this->fields['interimOnly']; + } if (array_key_exists('invoicePreview', $this->fields)) { $data['invoicePreview'] = $this->fields['invoicePreview']?->jsonSerialize(); } diff --git a/src/Model/QuoteCreateOrder.php b/src/Model/QuoteCreateOrder.php index 6298a367b..bd1b2884d 100644 --- a/src/Model/QuoteCreateOrder.php +++ b/src/Model/QuoteCreateOrder.php @@ -128,6 +128,9 @@ public function __construct(array $data = []) if (array_key_exists('_embedded', $data)) { $this->setEmbedded($data['_embedded']); } + if (array_key_exists('interimOnly', $data)) { + $this->setInterimOnly($data['interimOnly']); + } if (array_key_exists('effectiveTime', $data)) { $this->setEffectiveTime($data['effectiveTime']); } @@ -466,6 +469,18 @@ public function setEmbedded(null|QuoteCreateOrderEmbedded|array $embedded): stat return $this; } + public function getInterimOnly(): ?bool + { + return $this->fields['interimOnly'] ?? null; + } + + public function setInterimOnly(null|bool $interimOnly): static + { + $this->fields['interimOnly'] = $interimOnly; + + return $this; + } + public function getEffectiveTime(): ?DateTimeImmutable { return $this->fields['effectiveTime'] ?? null; @@ -632,6 +647,9 @@ public function jsonSerialize(): array if (array_key_exists('_embedded', $this->fields)) { $data['_embedded'] = $this->fields['_embedded']?->jsonSerialize(); } + if (array_key_exists('interimOnly', $this->fields)) { + $data['interimOnly'] = $this->fields['interimOnly']; + } if (array_key_exists('effectiveTime', $this->fields)) { $data['effectiveTime'] = $this->fields['effectiveTime']?->format(DateTimeInterface::RFC3339); } diff --git a/src/Model/QuoteReactivateOrder.php b/src/Model/QuoteReactivateOrder.php index 847e5d7e1..756b0325c 100644 --- a/src/Model/QuoteReactivateOrder.php +++ b/src/Model/QuoteReactivateOrder.php @@ -131,6 +131,9 @@ public function __construct(array $data = []) if (array_key_exists('_embedded', $data)) { $this->setEmbedded($data['_embedded']); } + if (array_key_exists('interimOnly', $data)) { + $this->setInterimOnly($data['interimOnly']); + } if (array_key_exists('renewalPolicy', $data)) { $this->setRenewalPolicy($data['renewalPolicy']); } @@ -485,6 +488,18 @@ public function setEmbedded(null|QuoteCreateOrderEmbedded|array $embedded): stat return $this; } + public function getInterimOnly(): ?bool + { + return $this->fields['interimOnly'] ?? null; + } + + public function setInterimOnly(null|bool $interimOnly): static + { + $this->fields['interimOnly'] = $interimOnly; + + return $this; + } + public function getRenewalPolicy(): ?string { return $this->fields['renewalPolicy'] ?? null; @@ -642,6 +657,9 @@ public function jsonSerialize(): array if (array_key_exists('_embedded', $this->fields)) { $data['_embedded'] = $this->fields['_embedded']?->jsonSerialize(); } + if (array_key_exists('interimOnly', $this->fields)) { + $data['interimOnly'] = $this->fields['interimOnly']; + } if (array_key_exists('renewalPolicy', $this->fields)) { $data['renewalPolicy'] = $this->fields['renewalPolicy']; } diff --git a/src/Model/QuoteTrialConversionOrder.php b/src/Model/QuoteTrialConversionOrder.php index 9b2b24222..ed499c322 100644 --- a/src/Model/QuoteTrialConversionOrder.php +++ b/src/Model/QuoteTrialConversionOrder.php @@ -122,6 +122,9 @@ public function __construct(array $data = []) if (array_key_exists('_embedded', $data)) { $this->setEmbedded($data['_embedded']); } + if (array_key_exists('interimOnly', $data)) { + $this->setInterimOnly($data['interimOnly']); + } if (array_key_exists('effectiveTime', $data)) { $this->setEffectiveTime($data['effectiveTime']); } @@ -441,6 +444,18 @@ public function setEmbedded(null|QuoteCreateOrderEmbedded|array $embedded): stat return $this; } + public function getInterimOnly(): ?bool + { + return $this->fields['interimOnly'] ?? null; + } + + public function setInterimOnly(null|bool $interimOnly): static + { + $this->fields['interimOnly'] = $interimOnly; + + return $this; + } + public function getEffectiveTime(): ?DateTimeImmutable { return $this->fields['effectiveTime'] ?? null; @@ -633,6 +648,9 @@ public function jsonSerialize(): array if (array_key_exists('_embedded', $this->fields)) { $data['_embedded'] = $this->fields['_embedded']?->jsonSerialize(); } + if (array_key_exists('interimOnly', $this->fields)) { + $data['interimOnly'] = $this->fields['interimOnly']; + } if (array_key_exists('effectiveTime', $this->fields)) { $data['effectiveTime'] = $this->fields['effectiveTime']?->format(DateTimeInterface::RFC3339); } diff --git a/src/Model/ServiceCredential.php b/src/Model/ServiceCredential.php index ce693a2bf..46f0ae3b7 100644 --- a/src/Model/ServiceCredential.php +++ b/src/Model/ServiceCredential.php @@ -26,4 +26,6 @@ public function getStatus(): ?string; public function setStatus(null|string $status): static; public function getDeactivationTime(): ?DateTimeImmutable; + + public function getType(): string; } diff --git a/src/Model/Subscription.php b/src/Model/Subscription.php index bb09750ce..ed749c212 100644 --- a/src/Model/Subscription.php +++ b/src/Model/Subscription.php @@ -149,8 +149,8 @@ public function __construct(array $data = []) if (array_key_exists('startTime', $data)) { $this->setStartTime($data['startTime']); } - if (array_key_exists('endTime', $data)) { - $this->setEndTime($data['endTime']); + if (array_key_exists('churnTime', $data)) { + $this->setChurnTime($data['churnTime']); } if (array_key_exists('renewalTime', $data)) { $this->setRenewalTime($data['renewalTime']); @@ -230,6 +230,9 @@ public function __construct(array $data = []) if (array_key_exists('riskMetadata', $data)) { $this->setRiskMetadata($data['riskMetadata']); } + if (array_key_exists('billingPortalToken', $data)) { + $this->setBillingPortalToken($data['billingPortalToken']); + } if (array_key_exists('customFields', $data)) { $this->setCustomFields($data['customFields']); } @@ -419,9 +422,9 @@ public function setStartTime(null|DateTimeImmutable|string $startTime): static return $this; } - public function getEndTime(): ?DateTimeImmutable + public function getChurnTime(): ?DateTimeImmutable { - return $this->fields['endTime'] ?? null; + return $this->fields['churnTime'] ?? null; } public function getRenewalTime(): ?DateTimeImmutable @@ -707,6 +710,11 @@ public function setRiskMetadata(null|RiskMetadata|array $riskMetadata): static return $this; } + public function getBillingPortalToken(): ?string + { + return $this->fields['billingPortalToken'] ?? null; + } + public function getCustomFields(): ?array { return $this->fields['customFields'] ?? null; @@ -812,8 +820,8 @@ public function jsonSerialize(): array if (array_key_exists('startTime', $this->fields)) { $data['startTime'] = $this->fields['startTime']?->format(DateTimeInterface::RFC3339); } - if (array_key_exists('endTime', $this->fields)) { - $data['endTime'] = $this->fields['endTime']?->format(DateTimeInterface::RFC3339); + if (array_key_exists('churnTime', $this->fields)) { + $data['churnTime'] = $this->fields['churnTime']?->format(DateTimeInterface::RFC3339); } if (array_key_exists('renewalTime', $this->fields)) { $data['renewalTime'] = $this->fields['renewalTime']?->format(DateTimeInterface::RFC3339); @@ -893,6 +901,9 @@ public function jsonSerialize(): array if (array_key_exists('riskMetadata', $this->fields)) { $data['riskMetadata'] = $this->fields['riskMetadata']?->jsonSerialize(); } + if (array_key_exists('billingPortalToken', $this->fields)) { + $data['billingPortalToken'] = $this->fields['billingPortalToken']; + } if (array_key_exists('customFields', $this->fields)) { $data['customFields'] = $this->fields['customFields']; } @@ -994,13 +1005,13 @@ private function setIsTrialConverted(null|bool $isTrialConverted): static return $this; } - private function setEndTime(null|DateTimeImmutable|string $endTime): static + private function setChurnTime(null|DateTimeImmutable|string $churnTime): static { - if ($endTime !== null && !($endTime instanceof DateTimeImmutable)) { - $endTime = new DateTimeImmutable($endTime); + if ($churnTime !== null && !($churnTime instanceof DateTimeImmutable)) { + $churnTime = new DateTimeImmutable($churnTime); } - $this->fields['endTime'] = $endTime; + $this->fields['churnTime'] = $churnTime; return $this; } @@ -1098,6 +1109,13 @@ private function setRevision(null|int $revision): static return $this; } + private function setBillingPortalToken(null|string $billingPortalToken): static + { + $this->fields['billingPortalToken'] = $billingPortalToken; + + return $this; + } + private function setCreatedTime(null|DateTimeImmutable|string $createdTime): static { if ($createdTime !== null && !($createdTime instanceof DateTimeImmutable)) { diff --git a/src/Model/SubscriptionChangeItems.php b/src/Model/SubscriptionChangeItems.php index b2b74ee38..01f8cf230 100644 --- a/src/Model/SubscriptionChangeItems.php +++ b/src/Model/SubscriptionChangeItems.php @@ -53,12 +53,12 @@ public function setPlan(FlexiblePlan|array $plan): static return $this; } - public function getQuantity(): int + public function getQuantity(): ?int { - return $this->fields['quantity']; + return $this->fields['quantity'] ?? null; } - public function setQuantity(int $quantity): static + public function setQuantity(null|int $quantity): static { $this->fields['quantity'] = $quantity; diff --git a/src/Model/SubscriptionOrOneTimeSaleItemPlan.php b/src/Model/SubscriptionOrOneTimeSaleItemPlan.php index da1aba7d8..e7a94efcf 100644 --- a/src/Model/SubscriptionOrOneTimeSaleItemPlan.php +++ b/src/Model/SubscriptionOrOneTimeSaleItemPlan.php @@ -204,15 +204,15 @@ public function setPricing(PlanPriceFormula|array $pricing): static return $this; } - public function getSetup(): ?OneTimeSalePlanSetup + public function getSetup(): ?PlanSetup { return $this->fields['setup'] ?? null; } - public function setSetup(null|OneTimeSalePlanSetup|array $setup): static + public function setSetup(null|PlanSetup|array $setup): static { - if ($setup !== null && !($setup instanceof OneTimeSalePlanSetup)) { - $setup = OneTimeSalePlanSetup::from($setup); + if ($setup !== null && !($setup instanceof PlanSetup)) { + $setup = PlanSetup::from($setup); } $this->fields['setup'] = $setup; @@ -288,15 +288,15 @@ public function setRecurringInterval(SubscriptionPlanRecurringInterval|array $re return $this; } - public function getTrial(): TrialOnlyPlanTrial + public function getTrial(): PlanTrial { return $this->fields['trial']; } - public function setTrial(TrialOnlyPlanTrial|array $trial): static + public function setTrial(PlanTrial|array $trial): static { - if (!($trial instanceof TrialOnlyPlanTrial)) { - $trial = TrialOnlyPlanTrial::from($trial); + if (!($trial instanceof PlanTrial)) { + $trial = PlanTrial::from($trial); } $this->fields['trial'] = $trial;