From bdce2a7440b65979af1cdb4fe6a81dfef198e4cd Mon Sep 17 00:00:00 2001 From: rebilly-machine-user Date: Mon, 27 Nov 2023 09:03:32 +0000 Subject: [PATCH] update SDK from api-definitions --- .changeset/fluffy-hotels-worry.md | 5 ++ .changeset/spotty-emus-drive.md | 5 ++ src/Api/ReportsApi.php | 29 ++++++ src/Model/OrderItem.php | 22 +++++ src/Model/OrderItemUsageLimits.php | 81 +++++++++++++++++ src/Model/OrderItemUsageLimitsHardLimit.php | 77 ++++++++++++++++ src/Model/OrderItemUsageLimitsSoftLimit.php | 77 ++++++++++++++++ src/Model/ReportDeclinedTransactions.php | 84 +++++++++++++++++ src/Model/ReportDeclinedTransactionsData.php | 95 ++++++++++++++++++++ 9 files changed, 475 insertions(+) create mode 100644 .changeset/fluffy-hotels-worry.md create mode 100644 .changeset/spotty-emus-drive.md create mode 100644 src/Model/OrderItemUsageLimits.php create mode 100644 src/Model/OrderItemUsageLimitsHardLimit.php create mode 100644 src/Model/OrderItemUsageLimitsSoftLimit.php create mode 100644 src/Model/ReportDeclinedTransactions.php create mode 100644 src/Model/ReportDeclinedTransactionsData.php diff --git a/.changeset/fluffy-hotels-worry.md b/.changeset/fluffy-hotels-worry.md new file mode 100644 index 000000000..f137615d9 --- /dev/null +++ b/.changeset/fluffy-hotels-worry.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +feat(experimental): Add declined transactions report Rebilly/api-definitions#1570 diff --git a/.changeset/spotty-emus-drive.md b/.changeset/spotty-emus-drive.md new file mode 100644 index 000000000..d18741e79 --- /dev/null +++ b/.changeset/spotty-emus-drive.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add usage limit configuration Rebilly/api-definitions#1650 diff --git a/src/Api/ReportsApi.php b/src/Api/ReportsApi.php index 3b767d04e..4576be76f 100644 --- a/src/Api/ReportsApi.php +++ b/src/Api/ReportsApi.php @@ -25,6 +25,7 @@ use Rebilly\Sdk\Model\FutureRenewals; use Rebilly\Sdk\Model\GetKycAcceptanceSummaryResponse; use Rebilly\Sdk\Model\RenewalSales; +use Rebilly\Sdk\Model\ReportDeclinedTransactions; use Rebilly\Sdk\Model\ReportDisputeDelays; use Rebilly\Sdk\Model\ReportDisputes; use Rebilly\Sdk\Model\ReportEventsTriggeredSummary; @@ -154,6 +155,34 @@ public function getDccMarkup( return DccMarkup::from($data); } + /** + * @return ReportDeclinedTransactions + */ + public function getDeclinedTransactions( + string $aggregationField, + DateTimeImmutable $periodStart, + DateTimeImmutable $periodEnd, + ?int $limit = null, + ?int $offset = null, + ?string $filter = null, + ): ReportDeclinedTransactions { + $queryParams = [ + 'aggregationField' => $aggregationField, + 'periodStart' => $periodStart->format('Y-m-d\TH:i:s\Z'), + 'periodEnd' => $periodEnd->format('Y-m-d\TH:i:s\Z'), + 'limit' => $limit, + 'offset' => $offset, + 'filter' => $filter, + ]; + $uri = '/experimental/reports/declined-transactions?' . http_build_query($queryParams); + + $request = new Request('GET', $uri); + $response = $this->client->send($request); + $data = Utils::jsonDecode((string) $response->getBody(), true); + + return ReportDeclinedTransactions::from($data); + } + /** * @return ReportDisputes */ diff --git a/src/Model/OrderItem.php b/src/Model/OrderItem.php index a5deaf623..653cc36bd 100644 --- a/src/Model/OrderItem.php +++ b/src/Model/OrderItem.php @@ -33,6 +33,9 @@ public function __construct(array $data = []) if (array_key_exists('plan', $data)) { $this->setPlan($data['plan']); } + if (array_key_exists('usageLimits', $data)) { + $this->setUsageLimits($data['usageLimits']); + } if (array_key_exists('revision', $data)) { $this->setRevision($data['revision']); } @@ -97,6 +100,22 @@ public function setPlan(OrderItemPlan|array $plan): static return $this; } + public function getUsageLimits(): ?OrderItemUsageLimits + { + return $this->fields['usageLimits'] ?? null; + } + + public function setUsageLimits(null|OrderItemUsageLimits|array $usageLimits): static + { + if ($usageLimits !== null && !($usageLimits instanceof OrderItemUsageLimits)) { + $usageLimits = OrderItemUsageLimits::from($usageLimits); + } + + $this->fields['usageLimits'] = $usageLimits; + + return $this; + } + public function getRevision(): ?int { return $this->fields['revision'] ?? null; @@ -143,6 +162,9 @@ public function jsonSerialize(): array if (array_key_exists('plan', $this->fields)) { $data['plan'] = $this->fields['plan']?->jsonSerialize(); } + if (array_key_exists('usageLimits', $this->fields)) { + $data['usageLimits'] = $this->fields['usageLimits']?->jsonSerialize(); + } if (array_key_exists('revision', $this->fields)) { $data['revision'] = $this->fields['revision']; } diff --git a/src/Model/OrderItemUsageLimits.php b/src/Model/OrderItemUsageLimits.php new file mode 100644 index 000000000..c5411a9e4 --- /dev/null +++ b/src/Model/OrderItemUsageLimits.php @@ -0,0 +1,81 @@ +setSoftLimit($data['softLimit']); + } + if (array_key_exists('hardLimit', $data)) { + $this->setHardLimit($data['hardLimit']); + } + } + + public static function from(array $data = []): self + { + return new self($data); + } + + public function getSoftLimit(): ?OrderItemUsageLimitsSoftLimit + { + return $this->fields['softLimit'] ?? null; + } + + public function setSoftLimit(null|OrderItemUsageLimitsSoftLimit|array $softLimit): static + { + if ($softLimit !== null && !($softLimit instanceof OrderItemUsageLimitsSoftLimit)) { + $softLimit = OrderItemUsageLimitsSoftLimit::from($softLimit); + } + + $this->fields['softLimit'] = $softLimit; + + return $this; + } + + public function getHardLimit(): ?OrderItemUsageLimitsHardLimit + { + return $this->fields['hardLimit'] ?? null; + } + + public function setHardLimit(null|OrderItemUsageLimitsHardLimit|array $hardLimit): static + { + if ($hardLimit !== null && !($hardLimit instanceof OrderItemUsageLimitsHardLimit)) { + $hardLimit = OrderItemUsageLimitsHardLimit::from($hardLimit); + } + + $this->fields['hardLimit'] = $hardLimit; + + return $this; + } + + public function jsonSerialize(): array + { + $data = []; + if (array_key_exists('softLimit', $this->fields)) { + $data['softLimit'] = $this->fields['softLimit']?->jsonSerialize(); + } + if (array_key_exists('hardLimit', $this->fields)) { + $data['hardLimit'] = $this->fields['hardLimit']?->jsonSerialize(); + } + + return $data; + } +} diff --git a/src/Model/OrderItemUsageLimitsHardLimit.php b/src/Model/OrderItemUsageLimitsHardLimit.php new file mode 100644 index 000000000..cafd099b3 --- /dev/null +++ b/src/Model/OrderItemUsageLimitsHardLimit.php @@ -0,0 +1,77 @@ +setQuantity($data['quantity']); + } + if (array_key_exists('amount', $data)) { + $this->setAmount($data['amount']); + } + } + + public static function from(array $data = []): self + { + return new self($data); + } + + public function getQuantity(): ?int + { + return $this->fields['quantity'] ?? null; + } + + public function setQuantity(null|int $quantity): static + { + $this->fields['quantity'] = $quantity; + + return $this; + } + + public function getAmount(): ?float + { + return $this->fields['amount'] ?? null; + } + + public function setAmount(null|float|string $amount): static + { + if (is_string($amount)) { + $amount = (float) $amount; + } + + $this->fields['amount'] = $amount; + + return $this; + } + + public function jsonSerialize(): array + { + $data = []; + if (array_key_exists('quantity', $this->fields)) { + $data['quantity'] = $this->fields['quantity']; + } + if (array_key_exists('amount', $this->fields)) { + $data['amount'] = $this->fields['amount']; + } + + return $data; + } +} diff --git a/src/Model/OrderItemUsageLimitsSoftLimit.php b/src/Model/OrderItemUsageLimitsSoftLimit.php new file mode 100644 index 000000000..8fd17e673 --- /dev/null +++ b/src/Model/OrderItemUsageLimitsSoftLimit.php @@ -0,0 +1,77 @@ +setQuantity($data['quantity']); + } + if (array_key_exists('amount', $data)) { + $this->setAmount($data['amount']); + } + } + + public static function from(array $data = []): self + { + return new self($data); + } + + public function getQuantity(): ?int + { + return $this->fields['quantity'] ?? null; + } + + public function setQuantity(null|int $quantity): static + { + $this->fields['quantity'] = $quantity; + + return $this; + } + + public function getAmount(): ?float + { + return $this->fields['amount'] ?? null; + } + + public function setAmount(null|float|string $amount): static + { + if (is_string($amount)) { + $amount = (float) $amount; + } + + $this->fields['amount'] = $amount; + + return $this; + } + + public function jsonSerialize(): array + { + $data = []; + if (array_key_exists('quantity', $this->fields)) { + $data['quantity'] = $this->fields['quantity']; + } + if (array_key_exists('amount', $this->fields)) { + $data['amount'] = $this->fields['amount']; + } + + return $data; + } +} diff --git a/src/Model/ReportDeclinedTransactions.php b/src/Model/ReportDeclinedTransactions.php new file mode 100644 index 000000000..226bc0ac6 --- /dev/null +++ b/src/Model/ReportDeclinedTransactions.php @@ -0,0 +1,84 @@ +setTotalCount($data['totalCount']); + } + if (array_key_exists('data', $data)) { + $this->setData($data['data']); + } + } + + public static function from(array $data = []): self + { + return new self($data); + } + + public function getTotalCount(): ?int + { + return $this->fields['totalCount'] ?? null; + } + + public function setTotalCount(null|int $totalCount): static + { + $this->fields['totalCount'] = $totalCount; + + return $this; + } + + /** + * @return null|ReportDeclinedTransactionsData[] + */ + public function getData(): ?array + { + return $this->fields['data'] ?? null; + } + + /** + * @param null|array[]|ReportDeclinedTransactionsData[] $data + */ + public function setData(null|array $data): static + { + $data = $data !== null ? array_map( + fn ($value) => $value !== null ? ($value instanceof ReportDeclinedTransactionsData ? $value : ReportDeclinedTransactionsData::from($value)) : null, + $data, + ) : null; + + $this->fields['data'] = $data; + + return $this; + } + + public function jsonSerialize(): array + { + $data = []; + if (array_key_exists('totalCount', $this->fields)) { + $data['totalCount'] = $this->fields['totalCount']; + } + if (array_key_exists('data', $this->fields)) { + $data['data'] = $this->fields['data']; + } + + return $data; + } +} diff --git a/src/Model/ReportDeclinedTransactionsData.php b/src/Model/ReportDeclinedTransactionsData.php new file mode 100644 index 000000000..82b2dfff6 --- /dev/null +++ b/src/Model/ReportDeclinedTransactionsData.php @@ -0,0 +1,95 @@ +setMessage($data['message']); + } + if (array_key_exists('count', $data)) { + $this->setCount($data['count']); + } + if (array_key_exists('percentage', $data)) { + $this->setPercentage($data['percentage']); + } + } + + public static function from(array $data = []): self + { + return new self($data); + } + + public function getMessage(): ?string + { + return $this->fields['message'] ?? null; + } + + public function setMessage(null|string $message): static + { + $this->fields['message'] = $message; + + return $this; + } + + public function getCount(): ?int + { + return $this->fields['count'] ?? null; + } + + public function setCount(null|int $count): static + { + $this->fields['count'] = $count; + + return $this; + } + + public function getPercentage(): ?float + { + return $this->fields['percentage'] ?? null; + } + + public function setPercentage(null|float|string $percentage): static + { + if (is_string($percentage)) { + $percentage = (float) $percentage; + } + + $this->fields['percentage'] = $percentage; + + return $this; + } + + public function jsonSerialize(): array + { + $data = []; + if (array_key_exists('message', $this->fields)) { + $data['message'] = $this->fields['message']; + } + if (array_key_exists('count', $this->fields)) { + $data['count'] = $this->fields['count']; + } + if (array_key_exists('percentage', $this->fields)) { + $data['percentage'] = $this->fields['percentage']; + } + + return $data; + } +}