diff --git a/.changeset/forty-ties-think.md b/.changeset/forty-ties-think.md new file mode 100644 index 000000000..6f552c988 --- /dev/null +++ b/.changeset/forty-ties-think.md @@ -0,0 +1,5 @@ +--- +"@rebilly/client-php": patch +--- + +Make Plan.id readOnly Rebilly/api-definitions#1651 diff --git a/src/Model/FlexiblePlan.php b/src/Model/FlexiblePlan.php index adc03be7c..1ac5826a1 100644 --- a/src/Model/FlexiblePlan.php +++ b/src/Model/FlexiblePlan.php @@ -287,14 +287,14 @@ public function setLinks(null|array $links): static return $this; } - public function getRecurringInterval(): ?SubscriptionOrderPlanRecurringInterval + public function getRecurringInterval(): SubscriptionOrderPlanRecurringInterval { - return $this->fields['recurringInterval'] ?? null; + return $this->fields['recurringInterval']; } - public function setRecurringInterval(null|SubscriptionOrderPlanRecurringInterval|array $recurringInterval): static + public function setRecurringInterval(SubscriptionOrderPlanRecurringInterval|array $recurringInterval): static { - if ($recurringInterval !== null && !($recurringInterval instanceof SubscriptionOrderPlanRecurringInterval)) { + if (!($recurringInterval instanceof SubscriptionOrderPlanRecurringInterval)) { $recurringInterval = SubscriptionOrderPlanRecurringInterval::from($recurringInterval); } @@ -303,15 +303,15 @@ public function setRecurringInterval(null|SubscriptionOrderPlanRecurringInterval return $this; } - public function getTrial(): ?PlanTrial + public function getTrial(): TrialOnlyPlanTrial { - return $this->fields['trial'] ?? null; + return $this->fields['trial']; } - public function setTrial(null|PlanTrial|array $trial): static + public function setTrial(TrialOnlyPlanTrial|array $trial): static { - if ($trial !== null && !($trial instanceof PlanTrial)) { - $trial = PlanTrial::from($trial); + if (!($trial instanceof TrialOnlyPlanTrial)) { + $trial = TrialOnlyPlanTrial::from($trial); } $this->fields['trial'] = $trial; diff --git a/src/Model/OrderItemPlan.php b/src/Model/OrderItemPlan.php index 37938474d..4f0ad065c 100644 --- a/src/Model/OrderItemPlan.php +++ b/src/Model/OrderItemPlan.php @@ -287,14 +287,14 @@ public function setLinks(null|array $links): static return $this; } - public function getRecurringInterval(): ?SubscriptionOrderPlanRecurringInterval + public function getRecurringInterval(): SubscriptionOrderPlanRecurringInterval { - return $this->fields['recurringInterval'] ?? null; + return $this->fields['recurringInterval']; } - public function setRecurringInterval(null|SubscriptionOrderPlanRecurringInterval|array $recurringInterval): static + public function setRecurringInterval(SubscriptionOrderPlanRecurringInterval|array $recurringInterval): static { - if ($recurringInterval !== null && !($recurringInterval instanceof SubscriptionOrderPlanRecurringInterval)) { + if (!($recurringInterval instanceof SubscriptionOrderPlanRecurringInterval)) { $recurringInterval = SubscriptionOrderPlanRecurringInterval::from($recurringInterval); } @@ -303,15 +303,15 @@ public function setRecurringInterval(null|SubscriptionOrderPlanRecurringInterval return $this; } - public function getTrial(): ?PlanTrial + public function getTrial(): TrialOnlyPlanTrial { - return $this->fields['trial'] ?? null; + return $this->fields['trial']; } - public function setTrial(null|PlanTrial|array $trial): static + public function setTrial(TrialOnlyPlanTrial|array $trial): static { - if ($trial !== null && !($trial instanceof PlanTrial)) { - $trial = PlanTrial::from($trial); + if (!($trial instanceof TrialOnlyPlanTrial)) { + $trial = TrialOnlyPlanTrial::from($trial); } $this->fields['trial'] = $trial; diff --git a/src/Model/Plan.php b/src/Model/Plan.php index 0af62ad42..f99b6c690 100644 --- a/src/Model/Plan.php +++ b/src/Model/Plan.php @@ -98,13 +98,6 @@ public function getId(): ?string return $this->fields['id'] ?? null; } - public function setId(null|string $id): static - { - $this->fields['id'] = $id; - - return $this; - } - public function getName(): string { return $this->fields['name']; @@ -287,14 +280,14 @@ public function setLinks(null|array $links): static return $this; } - public function getRecurringInterval(): ?SubscriptionOrderPlanRecurringInterval + public function getRecurringInterval(): SubscriptionOrderPlanRecurringInterval { - return $this->fields['recurringInterval'] ?? null; + return $this->fields['recurringInterval']; } - public function setRecurringInterval(null|SubscriptionOrderPlanRecurringInterval|array $recurringInterval): static + public function setRecurringInterval(SubscriptionOrderPlanRecurringInterval|array $recurringInterval): static { - if ($recurringInterval !== null && !($recurringInterval instanceof SubscriptionOrderPlanRecurringInterval)) { + if (!($recurringInterval instanceof SubscriptionOrderPlanRecurringInterval)) { $recurringInterval = SubscriptionOrderPlanRecurringInterval::from($recurringInterval); } @@ -303,15 +296,15 @@ public function setRecurringInterval(null|SubscriptionOrderPlanRecurringInterval return $this; } - public function getTrial(): ?PlanTrial + public function getTrial(): TrialOnlyPlanTrial { - return $this->fields['trial'] ?? null; + return $this->fields['trial']; } - public function setTrial(null|PlanTrial|array $trial): static + public function setTrial(TrialOnlyPlanTrial|array $trial): static { - if ($trial !== null && !($trial instanceof PlanTrial)) { - $trial = PlanTrial::from($trial); + if (!($trial instanceof TrialOnlyPlanTrial)) { + $trial = TrialOnlyPlanTrial::from($trial); } $this->fields['trial'] = $trial; @@ -421,6 +414,13 @@ public function jsonSerialize(): array return $data; } + private function setId(null|string $id): static + { + $this->fields['id'] = $id; + + return $this; + } + private function setCurrencySign(null|string $currencySign): static { $this->fields['currencySign'] = $currencySign; diff --git a/src/Model/PlanTrial.php b/src/Model/TrialOnlyPlanTrial.php similarity index 97% rename from src/Model/PlanTrial.php rename to src/Model/TrialOnlyPlanTrial.php index 32b40b298..c2afbe7ba 100644 --- a/src/Model/PlanTrial.php +++ b/src/Model/TrialOnlyPlanTrial.php @@ -15,7 +15,7 @@ use JsonSerializable; -class PlanTrial implements JsonSerializable +class TrialOnlyPlanTrial implements JsonSerializable { private array $fields = [];