From 534ee7be87a15104786e8c6c211d2a156b6da832 Mon Sep 17 00:00:00 2001 From: rebilly-machine-user Date: Wed, 10 Jul 2024 16:33:57 +0000 Subject: [PATCH] update SDK from api-definitions --- .changeset/early-pigs-raise.md | 5 + .changeset/smooth-rings-bathe.md | 5 + .changeset/two-stingrays-doubt.md | 5 + src/Model/DataExportFactory.php | 1 + src/Model/DisputesDataExport.php | 423 +++++++++++++++++++++++ src/Model/DisputesDataExportEmbedded.php | 81 +++++ src/Model/OneTimeSale.php | 18 - src/Model/Subscription.php | 18 - src/Model/SubscriptionOrOneTimeSale.php | 2 - 9 files changed, 520 insertions(+), 38 deletions(-) create mode 100644 .changeset/early-pigs-raise.md create mode 100644 .changeset/smooth-rings-bathe.md create mode 100644 .changeset/two-stingrays-doubt.md create mode 100644 src/Model/DisputesDataExport.php create mode 100644 src/Model/DisputesDataExportEmbedded.php diff --git a/.changeset/early-pigs-raise.md b/.changeset/early-pigs-raise.md new file mode 100644 index 000000000..22c95e99d --- /dev/null +++ b/.changeset/early-pigs-raise.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +refactor(api-definitions): Remove orderId from Subscription and OneTimeSale yaml files Rebilly/rebilly#6331 diff --git a/.changeset/smooth-rings-bathe.md b/.changeset/smooth-rings-bathe.md new file mode 100644 index 000000000..0a4032d51 --- /dev/null +++ b/.changeset/smooth-rings-bathe.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +feat(api-definitions): Add disputes resource to Data Exports Rebilly/rebilly#6175 diff --git a/.changeset/two-stingrays-doubt.md b/.changeset/two-stingrays-doubt.md new file mode 100644 index 000000000..cafc1795b --- /dev/null +++ b/.changeset/two-stingrays-doubt.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +fix(api-definitions): Fix incorrect links. Rebilly/rebilly#6415 diff --git a/src/Model/DataExportFactory.php b/src/Model/DataExportFactory.php index e1610424c..3b6b24964 100644 --- a/src/Model/DataExportFactory.php +++ b/src/Model/DataExportFactory.php @@ -22,6 +22,7 @@ public static function from(array $data = []): DataExport return match ($data['resource']) { 'amlChecks' => AmlChecksDataExport::from($data), 'customers' => CustomersDataExport::from($data), + 'disputes' => DisputesDataExport::from($data), 'invoiceItems' => InvoiceItemsDataExport::from($data), 'invoices' => InvoicesDataExport::from($data), 'revenueAudit' => RevenueAuditDataExport::from($data), diff --git a/src/Model/DisputesDataExport.php b/src/Model/DisputesDataExport.php new file mode 100644 index 000000000..6ffa76f39 --- /dev/null +++ b/src/Model/DisputesDataExport.php @@ -0,0 +1,423 @@ +setId($data['id']); + } + if (array_key_exists('name', $data)) { + $this->setName($data['name']); + } + if (array_key_exists('format', $data)) { + $this->setFormat($data['format']); + } + if (array_key_exists('arguments', $data)) { + $this->setArguments($data['arguments']); + } + if (array_key_exists('emailNotification', $data)) { + $this->setEmailNotification($data['emailNotification']); + } + if (array_key_exists('fields', $data)) { + $this->setFields($data['fields']); + } + if (array_key_exists('recurring', $data)) { + $this->setRecurring($data['recurring']); + } + if (array_key_exists('userId', $data)) { + $this->setUserId($data['userId']); + } + if (array_key_exists('fileId', $data)) { + $this->setFileId($data['fileId']); + } + if (array_key_exists('recordCount', $data)) { + $this->setRecordCount($data['recordCount']); + } + if (array_key_exists('scheduledTime', $data)) { + $this->setScheduledTime($data['scheduledTime']); + } + if (array_key_exists('createdTime', $data)) { + $this->setCreatedTime($data['createdTime']); + } + if (array_key_exists('updatedTime', $data)) { + $this->setUpdatedTime($data['updatedTime']); + } + if (array_key_exists('status', $data)) { + $this->setStatus($data['status']); + } + if (array_key_exists('dateRange', $data)) { + $this->setDateRange($data['dateRange']); + } + if (array_key_exists('_links', $data)) { + $this->setLinks($data['_links']); + } + if (array_key_exists('_embedded', $data)) { + $this->setEmbedded($data['_embedded']); + } + } + + public static function from(array $data = []): self + { + return new self($data); + } + + public function getResource(): string + { + return 'disputes'; + } + + public function getId(): ?string + { + return $this->fields['id'] ?? null; + } + + public function getName(): string + { + return $this->fields['name']; + } + + public function setName(string $name): static + { + $this->fields['name'] = $name; + + return $this; + } + + public function getFormat(): string + { + return $this->fields['format']; + } + + public function setFormat(string $format): static + { + $this->fields['format'] = $format; + + return $this; + } + + public function getArguments(): ?DataExportArguments + { + return $this->fields['arguments'] ?? null; + } + + public function setArguments(null|DataExportArguments|array $arguments): static + { + if ($arguments !== null && !($arguments instanceof DataExportArguments)) { + $arguments = DataExportArguments::from($arguments); + } + + $this->fields['arguments'] = $arguments; + + return $this; + } + + /** + * @return null|string[] + */ + public function getEmailNotification(): ?array + { + return $this->fields['emailNotification'] ?? null; + } + + /** + * @param null|string[] $emailNotification + */ + public function setEmailNotification(null|array $emailNotification): static + { + $this->fields['emailNotification'] = $emailNotification; + + return $this; + } + + /** + * @return null|string[] + */ + public function getFields(): ?array + { + return $this->fields['fields'] ?? null; + } + + /** + * @param null|string[] $fields + */ + public function setFields(null|array $fields): static + { + $this->fields['fields'] = $fields; + + return $this; + } + + public function getRecurring(): ?DataExportRecurring + { + return $this->fields['recurring'] ?? null; + } + + public function setRecurring(null|DataExportRecurring|array $recurring): static + { + if ($recurring !== null && !($recurring instanceof DataExportRecurring)) { + $recurring = DataExportRecurring::from($recurring); + } + + $this->fields['recurring'] = $recurring; + + return $this; + } + + public function getUserId(): ?string + { + return $this->fields['userId'] ?? null; + } + + public function getFileId(): ?string + { + return $this->fields['fileId'] ?? null; + } + + public function getRecordCount(): ?int + { + return $this->fields['recordCount'] ?? null; + } + + public function getScheduledTime(): ?DateTimeImmutable + { + return $this->fields['scheduledTime'] ?? null; + } + + public function getCreatedTime(): ?DateTimeImmutable + { + return $this->fields['createdTime'] ?? null; + } + + public function getUpdatedTime(): ?DateTimeImmutable + { + return $this->fields['updatedTime'] ?? null; + } + + public function getStatus(): ?string + { + return $this->fields['status'] ?? null; + } + + public function getDateRange(): ?DataExportDateRange + { + return $this->fields['dateRange'] ?? null; + } + + public function setDateRange(null|DataExportDateRange|array $dateRange): static + { + if ($dateRange !== null && !($dateRange instanceof DataExportDateRange)) { + $dateRange = DataExportDateRange::from($dateRange); + } + + $this->fields['dateRange'] = $dateRange; + + return $this; + } + + /** + * @return null|ResourceLink[] + */ + public function getLinks(): ?array + { + return $this->fields['_links'] ?? null; + } + + public function getEmbedded(): ?DisputesDataExportEmbedded + { + return $this->fields['_embedded'] ?? null; + } + + public function setEmbedded(null|DisputesDataExportEmbedded|array $embedded): static + { + if ($embedded !== null && !($embedded instanceof DisputesDataExportEmbedded)) { + $embedded = DisputesDataExportEmbedded::from($embedded); + } + + $this->fields['_embedded'] = $embedded; + + return $this; + } + + public function jsonSerialize(): array + { + $data = [ + 'resource' => 'disputes', + ]; + if (array_key_exists('id', $this->fields)) { + $data['id'] = $this->fields['id']; + } + if (array_key_exists('name', $this->fields)) { + $data['name'] = $this->fields['name']; + } + if (array_key_exists('format', $this->fields)) { + $data['format'] = $this->fields['format']; + } + if (array_key_exists('arguments', $this->fields)) { + $data['arguments'] = $this->fields['arguments']?->jsonSerialize(); + } + if (array_key_exists('emailNotification', $this->fields)) { + $data['emailNotification'] = $this->fields['emailNotification']; + } + if (array_key_exists('fields', $this->fields)) { + $data['fields'] = $this->fields['fields']; + } + if (array_key_exists('recurring', $this->fields)) { + $data['recurring'] = $this->fields['recurring']?->jsonSerialize(); + } + if (array_key_exists('userId', $this->fields)) { + $data['userId'] = $this->fields['userId']; + } + if (array_key_exists('fileId', $this->fields)) { + $data['fileId'] = $this->fields['fileId']; + } + if (array_key_exists('recordCount', $this->fields)) { + $data['recordCount'] = $this->fields['recordCount']; + } + if (array_key_exists('scheduledTime', $this->fields)) { + $data['scheduledTime'] = $this->fields['scheduledTime']?->format(DateTimeInterface::RFC3339); + } + if (array_key_exists('createdTime', $this->fields)) { + $data['createdTime'] = $this->fields['createdTime']?->format(DateTimeInterface::RFC3339); + } + if (array_key_exists('updatedTime', $this->fields)) { + $data['updatedTime'] = $this->fields['updatedTime']?->format(DateTimeInterface::RFC3339); + } + if (array_key_exists('status', $this->fields)) { + $data['status'] = $this->fields['status']; + } + if (array_key_exists('dateRange', $this->fields)) { + $data['dateRange'] = $this->fields['dateRange']?->jsonSerialize(); + } + if (array_key_exists('_links', $this->fields)) { + $data['_links'] = $this->fields['_links'] !== null + ? array_map( + static fn (ResourceLink $resourceLink) => $resourceLink->jsonSerialize(), + $this->fields['_links'], + ) + : null; + } + if (array_key_exists('_embedded', $this->fields)) { + $data['_embedded'] = $this->fields['_embedded']?->jsonSerialize(); + } + + return $data; + } + + private function setId(null|string $id): static + { + $this->fields['id'] = $id; + + return $this; + } + + private function setUserId(null|string $userId): static + { + $this->fields['userId'] = $userId; + + return $this; + } + + private function setFileId(null|string $fileId): static + { + $this->fields['fileId'] = $fileId; + + return $this; + } + + private function setRecordCount(null|int $recordCount): static + { + $this->fields['recordCount'] = $recordCount; + + return $this; + } + + private function setScheduledTime(null|DateTimeImmutable|string $scheduledTime): static + { + if ($scheduledTime !== null && !($scheduledTime instanceof DateTimeImmutable)) { + $scheduledTime = new DateTimeImmutable($scheduledTime); + } + + $this->fields['scheduledTime'] = $scheduledTime; + + return $this; + } + + private function setCreatedTime(null|DateTimeImmutable|string $createdTime): static + { + if ($createdTime !== null && !($createdTime instanceof DateTimeImmutable)) { + $createdTime = new DateTimeImmutable($createdTime); + } + + $this->fields['createdTime'] = $createdTime; + + return $this; + } + + private function setUpdatedTime(null|DateTimeImmutable|string $updatedTime): static + { + if ($updatedTime !== null && !($updatedTime instanceof DateTimeImmutable)) { + $updatedTime = new DateTimeImmutable($updatedTime); + } + + $this->fields['updatedTime'] = $updatedTime; + + return $this; + } + + private function setStatus(null|string $status): static + { + $this->fields['status'] = $status; + + 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; + } +} diff --git a/src/Model/DisputesDataExportEmbedded.php b/src/Model/DisputesDataExportEmbedded.php new file mode 100644 index 000000000..b012eb8af --- /dev/null +++ b/src/Model/DisputesDataExportEmbedded.php @@ -0,0 +1,81 @@ +setFile($data['file']); + } + if (array_key_exists('user', $data)) { + $this->setUser($data['user']); + } + } + + public static function from(array $data = []): self + { + return new self($data); + } + + public function getFile(): ?File + { + return $this->fields['file'] ?? null; + } + + public function setFile(null|File|array $file): static + { + if ($file !== null && !($file instanceof File)) { + $file = File::from($file); + } + + $this->fields['file'] = $file; + + return $this; + } + + public function getUser(): ?User + { + return $this->fields['user'] ?? null; + } + + public function setUser(null|User|array $user): static + { + if ($user !== null && !($user instanceof User)) { + $user = User::from($user); + } + + $this->fields['user'] = $user; + + return $this; + } + + public function jsonSerialize(): array + { + $data = []; + if (array_key_exists('file', $this->fields)) { + $data['file'] = $this->fields['file']?->jsonSerialize(); + } + if (array_key_exists('user', $this->fields)) { + $data['user'] = $this->fields['user']?->jsonSerialize(); + } + + return $data; + } +} diff --git a/src/Model/OneTimeSale.php b/src/Model/OneTimeSale.php index 58b176791..ef6b5ca2b 100644 --- a/src/Model/OneTimeSale.php +++ b/src/Model/OneTimeSale.php @@ -53,9 +53,6 @@ public function __construct(array $data = []) if (array_key_exists('id', $data)) { $this->setId($data['id']); } - if (array_key_exists('orderId', $data)) { - $this->setOrderId($data['orderId']); - } if (array_key_exists('customerId', $data)) { $this->setCustomerId($data['customerId']); } @@ -148,11 +145,6 @@ public function getId(): ?string return $this->fields['id'] ?? null; } - public function getOrderId(): ?string - { - return $this->fields['orderId'] ?? null; - } - public function getCustomerId(): string { return $this->fields['customerId']; @@ -421,9 +413,6 @@ public function jsonSerialize(): array if (array_key_exists('id', $this->fields)) { $data['id'] = $this->fields['id']; } - if (array_key_exists('orderId', $this->fields)) { - $data['orderId'] = $this->fields['orderId']; - } if (array_key_exists('customerId', $this->fields)) { $data['customerId'] = $this->fields['customerId']; } @@ -518,13 +507,6 @@ private function setId(null|string $id): static return $this; } - private function setOrderId(null|string $orderId): static - { - $this->fields['orderId'] = $orderId; - - return $this; - } - private function setOrganizationId(null|string $organizationId): static { $this->fields['organizationId'] = $organizationId; diff --git a/src/Model/Subscription.php b/src/Model/Subscription.php index ae63506eb..f402925f9 100644 --- a/src/Model/Subscription.php +++ b/src/Model/Subscription.php @@ -101,9 +101,6 @@ public function __construct(array $data = []) if (array_key_exists('id', $data)) { $this->setId($data['id']); } - if (array_key_exists('orderId', $data)) { - $this->setOrderId($data['orderId']); - } if (array_key_exists('customerId', $data)) { $this->setCustomerId($data['customerId']); } @@ -271,11 +268,6 @@ public function getId(): ?string return $this->fields['id'] ?? null; } - public function getOrderId(): ?string - { - return $this->fields['orderId'] ?? null; - } - public function getCustomerId(): string { return $this->fields['customerId']; @@ -766,9 +758,6 @@ public function jsonSerialize(): array if (array_key_exists('id', $this->fields)) { $data['id'] = $this->fields['id']; } - if (array_key_exists('orderId', $this->fields)) { - $data['orderId'] = $this->fields['orderId']; - } if (array_key_exists('customerId', $this->fields)) { $data['customerId'] = $this->fields['customerId']; } @@ -943,13 +932,6 @@ private function setId(null|string $id): static return $this; } - private function setOrderId(null|string $orderId): static - { - $this->fields['orderId'] = $orderId; - - return $this; - } - private function setRenewalReminderTime(null|DateTimeImmutable|string $renewalReminderTime): static { if ($renewalReminderTime !== null && !($renewalReminderTime instanceof DateTimeImmutable)) { diff --git a/src/Model/SubscriptionOrOneTimeSale.php b/src/Model/SubscriptionOrOneTimeSale.php index 94f5ca035..8375be6c1 100644 --- a/src/Model/SubscriptionOrOneTimeSale.php +++ b/src/Model/SubscriptionOrOneTimeSale.php @@ -22,8 +22,6 @@ public function getOrderType(): string; public function getId(): ?string; - public function getOrderId(): ?string; - public function getCustomerId(): string; public function setCustomerId(string $customerId): static;