From bbe2bc625cb35fc9520382c007a84977702d1dbe Mon Sep 17 00:00:00 2001 From: Rebilly Machine User Date: Sun, 5 Nov 2023 10:35:52 +0200 Subject: [PATCH] chore: update SDK from api-definitions (#657) Co-authored-by: rebilly-machine-user Co-authored-by: Arif Kurkchi <11618962+justnero@users.noreply.github.com> --- .changeset/gorgeous-bobcats-roll.md | 5 ++ src/Model/PostDepositRequest.php | 22 ++++++ src/Model/PostDepositRequestAmountLimits.php | 81 ++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 .changeset/gorgeous-bobcats-roll.md create mode 100644 src/Model/PostDepositRequestAmountLimits.php diff --git a/.changeset/gorgeous-bobcats-roll.md b/.changeset/gorgeous-bobcats-roll.md new file mode 100644 index 000000000..6e1ae9e42 --- /dev/null +++ b/.changeset/gorgeous-bobcats-roll.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add amount limits to deposit request Rebilly/api-definitions#1666 diff --git a/src/Model/PostDepositRequest.php b/src/Model/PostDepositRequest.php index 37dbc20e5..a903e3554 100644 --- a/src/Model/PostDepositRequest.php +++ b/src/Model/PostDepositRequest.php @@ -38,6 +38,9 @@ public function __construct(array $data = []) if (array_key_exists('amounts', $data)) { $this->setAmounts($data['amounts']); } + if (array_key_exists('amountLimits', $data)) { + $this->setAmountLimits($data['amountLimits']); + } if (array_key_exists('customAmount', $data)) { $this->setCustomAmount($data['customAmount']); } @@ -128,6 +131,22 @@ public function setAmounts(null|array $amounts): static return $this; } + public function getAmountLimits(): ?PostDepositRequestAmountLimits + { + return $this->fields['amountLimits'] ?? null; + } + + public function setAmountLimits(null|PostDepositRequestAmountLimits|array $amountLimits): static + { + if ($amountLimits !== null && !($amountLimits instanceof PostDepositRequestAmountLimits)) { + $amountLimits = PostDepositRequestAmountLimits::from($amountLimits); + } + + $this->fields['amountLimits'] = $amountLimits; + + return $this; + } + public function getCustomAmount(): ?DepositRequestCustomAmount { return $this->fields['customAmount'] ?? null; @@ -202,6 +221,9 @@ public function jsonSerialize(): array if (array_key_exists('amounts', $this->fields)) { $data['amounts'] = $this->fields['amounts']; } + if (array_key_exists('amountLimits', $this->fields)) { + $data['amountLimits'] = $this->fields['amountLimits']?->jsonSerialize(); + } if (array_key_exists('customAmount', $this->fields)) { $data['customAmount'] = $this->fields['customAmount']?->jsonSerialize(); } diff --git a/src/Model/PostDepositRequestAmountLimits.php b/src/Model/PostDepositRequestAmountLimits.php new file mode 100644 index 000000000..bf667771c --- /dev/null +++ b/src/Model/PostDepositRequestAmountLimits.php @@ -0,0 +1,81 @@ +setMinimum($data['minimum']); + } + if (array_key_exists('maximum', $data)) { + $this->setMaximum($data['maximum']); + } + } + + public static function from(array $data = []): self + { + return new self($data); + } + + public function getMinimum(): ?float + { + return $this->fields['minimum'] ?? null; + } + + public function setMinimum(null|float|string $minimum): static + { + if (is_string($minimum)) { + $minimum = (float) $minimum; + } + + $this->fields['minimum'] = $minimum; + + return $this; + } + + public function getMaximum(): ?float + { + return $this->fields['maximum'] ?? null; + } + + public function setMaximum(null|float|string $maximum): static + { + if (is_string($maximum)) { + $maximum = (float) $maximum; + } + + $this->fields['maximum'] = $maximum; + + return $this; + } + + public function jsonSerialize(): array + { + $data = []; + if (array_key_exists('minimum', $this->fields)) { + $data['minimum'] = $this->fields['minimum']; + } + if (array_key_exists('maximum', $this->fields)) { + $data['maximum'] = $this->fields['maximum']; + } + + return $data; + } +}