diff --git a/.changeset/healthy-guests-reply.md b/.changeset/healthy-guests-reply.md new file mode 100644 index 00000000..d0158216 --- /dev/null +++ b/.changeset/healthy-guests-reply.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Add SecureTrading recurring settings Rebilly/api-definitions#1889 diff --git a/src/Model/SecureTrading.php b/src/Model/SecureTrading.php index 0640bad5..f40b59d4 100644 --- a/src/Model/SecureTrading.php +++ b/src/Model/SecureTrading.php @@ -26,6 +26,9 @@ public function __construct(array $data = []) if (array_key_exists('credentials', $data)) { $this->setCredentials($data['credentials']); } + if (array_key_exists('settings', $data)) { + $this->setSettings($data['settings']); + } if (array_key_exists('threeDSecureServer', $data)) { $this->setThreeDSecureServer($data['threeDSecureServer']); } @@ -52,6 +55,22 @@ public function setCredentials(SecureTradingCredentials|array $credentials): sta return $this; } + public function getSettings(): ?SecureTradingSettings + { + return $this->fields['settings'] ?? null; + } + + public function setSettings(null|SecureTradingSettings|array $settings): static + { + if ($settings !== null && !($settings instanceof SecureTradingSettings)) { + $settings = SecureTradingSettings::from($settings); + } + + $this->fields['settings'] = $settings; + + return $this; + } + public function getThreeDSecureServer(): ?ThreeDSecureIO3dsServer { return $this->fields['threeDSecureServer'] ?? null; @@ -74,6 +93,9 @@ public function jsonSerialize(): array if (array_key_exists('credentials', $this->fields)) { $data['credentials'] = $this->fields['credentials']->jsonSerialize(); } + if (array_key_exists('settings', $this->fields)) { + $data['settings'] = $this->fields['settings']?->jsonSerialize(); + } if (array_key_exists('threeDSecureServer', $this->fields)) { $data['threeDSecureServer'] = $this->fields['threeDSecureServer']?->jsonSerialize(); } diff --git a/src/Model/SecureTradingSettings.php b/src/Model/SecureTradingSettings.php new file mode 100644 index 00000000..ababcb86 --- /dev/null +++ b/src/Model/SecureTradingSettings.php @@ -0,0 +1,55 @@ +setEnableRecurring($data['enableRecurring']); + } + } + + public static function from(array $data = []): self + { + return new self($data); + } + + public function getEnableRecurring(): ?bool + { + return $this->fields['enableRecurring'] ?? null; + } + + public function setEnableRecurring(null|bool $enableRecurring): static + { + $this->fields['enableRecurring'] = $enableRecurring; + + return $this; + } + + public function jsonSerialize(): array + { + $data = []; + if (array_key_exists('enableRecurring', $this->fields)) { + $data['enableRecurring'] = $this->fields['enableRecurring']; + } + + return $data; + } +}