diff --git a/changes.md b/changes.md index 9fb4eebee89..d0036a71175 100644 --- a/changes.md +++ b/changes.md @@ -14,18 +14,29 @@ - added type `CustomerRemoveCustomerGroupAssignmentAction` - added type `CustomerSetCustomerGroupAssignmentsAction` - added type `BaseEvent` +- added type `CheckoutOrderCreationFailedEvent` +- added type `CheckoutPaymentAuthorizationCancelledEvent` +- added type `CheckoutPaymentAuthorizationFailedEvent` +- added type `CheckoutPaymentAuthorizedEvent` +- added type `CheckoutPaymentCancelAuthorizationFailedEvent` +- added type `CheckoutPaymentChargeFailedEvent` +- added type `CheckoutPaymentChargedEvent` +- added type `CheckoutPaymentRefundFailedEvent` +- added type `CheckoutPaymentRefundedEvent` - added type `Event` - added type `ImportContainerCreatedEvent` -- added type `ImportContainerCreatedEventData` - added type `ImportContainerDeletedEvent` -- added type `ImportContainerDeletedEventData` - added type `ImportOperationRejectedEvent` -- added type `ImportOperationRejectedEventData` - added type `ImportUnresolvedEvent` -- added type `ImportUnresolvedEventData` - added type `ImportValidationFailedEvent` -- added type `ImportValidationFailedEventData` - added type `ImportWaitForMasterVariantEvent` +- added type `CheckoutMessageOrderPayloadBaseData` +- added type `CheckoutMessagePaymentsPayloadBaseData` +- added type `ImportContainerCreatedEventData` +- added type `ImportContainerDeletedEventData` +- added type `ImportOperationRejectedEventData` +- added type `ImportUnresolvedEventData` +- added type `ImportValidationFailedEventData` - added type `ImportWaitForMasterVariantEventData` - added type `AssociateRoleNameSetMessage` - added type `BusinessUnitTopLevelUnitSetMessage` diff --git a/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseData.php b/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseData.php new file mode 100644 index 00000000000..5de1f8ddb7f --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseData.php @@ -0,0 +1,75 @@ +key of the Project where the order would belong to.

+ * + + * @return null|string + */ + public function getProjectKey(); + + /** + *

The Cart on which the change or action was performed.

+ * + + * @return null|CartReference + */ + public function getCart(); + + /** + *

The Payments on which the change or action was performed.

+ * + + * @return null|PaymentReferenceCollection + */ + public function getPayments(); + + /** + *

Errors associated with the order event.

+ * + + * @return null|ErrorObjectCollection + */ + public function getErrors(); + + /** + * @param ?string $projectKey + */ + public function setProjectKey(?string $projectKey): void; + + /** + * @param ?CartReference $cart + */ + public function setCart(?CartReference $cart): void; + + /** + * @param ?PaymentReferenceCollection $payments + */ + public function setPayments(?PaymentReferenceCollection $payments): void; + + /** + * @param ?ErrorObjectCollection $errors + */ + public function setErrors(?ErrorObjectCollection $errors): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseDataBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseDataBuilder.php new file mode 100644 index 00000000000..74be7fbf654 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseDataBuilder.php @@ -0,0 +1,164 @@ + + */ +final class CheckoutMessageOrderPayloadBaseDataBuilder implements Builder +{ + /** + + * @var ?string + */ + private $projectKey; + + /** + + * @var null|CartReference|CartReferenceBuilder + */ + private $cart; + + /** + + * @var ?PaymentReferenceCollection + */ + private $payments; + + /** + + * @var ?ErrorObjectCollection + */ + private $errors; + + /** + *

key of the Project where the order would belong to.

+ * + + * @return null|string + */ + public function getProjectKey() + { + return $this->projectKey; + } + + /** + *

The Cart on which the change or action was performed.

+ * + + * @return null|CartReference + */ + public function getCart() + { + return $this->cart instanceof CartReferenceBuilder ? $this->cart->build() : $this->cart; + } + + /** + *

The Payments on which the change or action was performed.

+ * + + * @return null|PaymentReferenceCollection + */ + public function getPayments() + { + return $this->payments; + } + + /** + *

Errors associated with the order event.

+ * + + * @return null|ErrorObjectCollection + */ + public function getErrors() + { + return $this->errors; + } + + /** + * @param ?string $projectKey + * @return $this + */ + public function withProjectKey(?string $projectKey) + { + $this->projectKey = $projectKey; + + return $this; + } + + /** + * @param ?CartReference $cart + * @return $this + */ + public function withCart(?CartReference $cart) + { + $this->cart = $cart; + + return $this; + } + + /** + * @param ?PaymentReferenceCollection $payments + * @return $this + */ + public function withPayments(?PaymentReferenceCollection $payments) + { + $this->payments = $payments; + + return $this; + } + + /** + * @param ?ErrorObjectCollection $errors + * @return $this + */ + public function withErrors(?ErrorObjectCollection $errors) + { + $this->errors = $errors; + + return $this; + } + + /** + * @deprecated use withCart() instead + * @return $this + */ + public function withCartBuilder(?CartReferenceBuilder $cart) + { + $this->cart = $cart; + + return $this; + } + + public function build(): CheckoutMessageOrderPayloadBaseData + { + return new CheckoutMessageOrderPayloadBaseDataModel( + $this->projectKey, + $this->cart instanceof CartReferenceBuilder ? $this->cart->build() : $this->cart, + $this->payments, + $this->errors + ); + } + + public static function of(): CheckoutMessageOrderPayloadBaseDataBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseDataCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseDataCollection.php new file mode 100644 index 00000000000..cddd15d26de --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseDataCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutMessageOrderPayloadBaseData current() + * @method CheckoutMessageOrderPayloadBaseData end() + * @method CheckoutMessageOrderPayloadBaseData at($offset) + */ +class CheckoutMessageOrderPayloadBaseDataCollection extends MapperSequence +{ + /** + * @psalm-assert CheckoutMessageOrderPayloadBaseData $value + * @psalm-param CheckoutMessageOrderPayloadBaseData|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutMessageOrderPayloadBaseDataCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutMessageOrderPayloadBaseData) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutMessageOrderPayloadBaseData + */ + protected function mapper() + { + return function (?int $index): ?CheckoutMessageOrderPayloadBaseData { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutMessageOrderPayloadBaseData $data */ + $data = CheckoutMessageOrderPayloadBaseDataModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseDataModel.php b/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseDataModel.php new file mode 100644 index 00000000000..b6f2704d443 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutMessageOrderPayloadBaseDataModel.php @@ -0,0 +1,179 @@ +projectKey = $projectKey; + $this->cart = $cart; + $this->payments = $payments; + $this->errors = $errors; + } + + /** + *

key of the Project where the order would belong to.

+ * + * + * @return null|string + */ + public function getProjectKey() + { + if (is_null($this->projectKey)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_PROJECT_KEY); + if (is_null($data)) { + return null; + } + $this->projectKey = (string) $data; + } + + return $this->projectKey; + } + + /** + *

The Cart on which the change or action was performed.

+ * + * + * @return null|CartReference + */ + public function getCart() + { + if (is_null($this->cart)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CART); + if (is_null($data)) { + return null; + } + + $this->cart = CartReferenceModel::of($data); + } + + return $this->cart; + } + + /** + *

The Payments on which the change or action was performed.

+ * + * + * @return null|PaymentReferenceCollection + */ + public function getPayments() + { + if (is_null($this->payments)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_PAYMENTS); + if (is_null($data)) { + return null; + } + $this->payments = PaymentReferenceCollection::fromArray($data); + } + + return $this->payments; + } + + /** + *

Errors associated with the order event.

+ * + * + * @return null|ErrorObjectCollection + */ + public function getErrors() + { + if (is_null($this->errors)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ERRORS); + if (is_null($data)) { + return null; + } + $this->errors = ErrorObjectCollection::fromArray($data); + } + + return $this->errors; + } + + + /** + * @param ?string $projectKey + */ + public function setProjectKey(?string $projectKey): void + { + $this->projectKey = $projectKey; + } + + /** + * @param ?CartReference $cart + */ + public function setCart(?CartReference $cart): void + { + $this->cart = $cart; + } + + /** + * @param ?PaymentReferenceCollection $payments + */ + public function setPayments(?PaymentReferenceCollection $payments): void + { + $this->payments = $payments; + } + + /** + * @param ?ErrorObjectCollection $errors + */ + public function setErrors(?ErrorObjectCollection $errors): void + { + $this->errors = $errors; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseData.php b/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseData.php new file mode 100644 index 00000000000..ecfe2c19e0b --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseData.php @@ -0,0 +1,89 @@ +key of the Project where the payment was made.

+ * + + * @return null|string + */ + public function getProjectKey(); + + /** + *

The Payment on which the change or action was performed.

+ * + + * @return null|PaymentReference + */ + public function getPayment(); + + /** + *

id of the Transaction.

+ * + + * @return null|string + */ + public function getTransactionId(); + + /** + *

The Cart on which the change or action was performed.

+ * + + * @return null|CartReference + */ + public function getCart(); + + /** + *

The Order on which the change or action was performed.

+ * + + * @return null|OrderReference + */ + public function getOrder(); + + /** + * @param ?string $projectKey + */ + public function setProjectKey(?string $projectKey): void; + + /** + * @param ?PaymentReference $payment + */ + public function setPayment(?PaymentReference $payment): void; + + /** + * @param ?string $transactionId + */ + public function setTransactionId(?string $transactionId): void; + + /** + * @param ?CartReference $cart + */ + public function setCart(?CartReference $cart): void; + + /** + * @param ?OrderReference $order + */ + public function setOrder(?OrderReference $order): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseDataBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseDataBuilder.php new file mode 100644 index 00000000000..05942400662 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseDataBuilder.php @@ -0,0 +1,217 @@ + + */ +final class CheckoutMessagePaymentsPayloadBaseDataBuilder implements Builder +{ + /** + + * @var ?string + */ + private $projectKey; + + /** + + * @var null|PaymentReference|PaymentReferenceBuilder + */ + private $payment; + + /** + + * @var ?string + */ + private $transactionId; + + /** + + * @var null|CartReference|CartReferenceBuilder + */ + private $cart; + + /** + + * @var null|OrderReference|OrderReferenceBuilder + */ + private $order; + + /** + *

key of the Project where the payment was made.

+ * + + * @return null|string + */ + public function getProjectKey() + { + return $this->projectKey; + } + + /** + *

The Payment on which the change or action was performed.

+ * + + * @return null|PaymentReference + */ + public function getPayment() + { + return $this->payment instanceof PaymentReferenceBuilder ? $this->payment->build() : $this->payment; + } + + /** + *

id of the Transaction.

+ * + + * @return null|string + */ + public function getTransactionId() + { + return $this->transactionId; + } + + /** + *

The Cart on which the change or action was performed.

+ * + + * @return null|CartReference + */ + public function getCart() + { + return $this->cart instanceof CartReferenceBuilder ? $this->cart->build() : $this->cart; + } + + /** + *

The Order on which the change or action was performed.

+ * + + * @return null|OrderReference + */ + public function getOrder() + { + return $this->order instanceof OrderReferenceBuilder ? $this->order->build() : $this->order; + } + + /** + * @param ?string $projectKey + * @return $this + */ + public function withProjectKey(?string $projectKey) + { + $this->projectKey = $projectKey; + + return $this; + } + + /** + * @param ?PaymentReference $payment + * @return $this + */ + public function withPayment(?PaymentReference $payment) + { + $this->payment = $payment; + + return $this; + } + + /** + * @param ?string $transactionId + * @return $this + */ + public function withTransactionId(?string $transactionId) + { + $this->transactionId = $transactionId; + + return $this; + } + + /** + * @param ?CartReference $cart + * @return $this + */ + public function withCart(?CartReference $cart) + { + $this->cart = $cart; + + return $this; + } + + /** + * @param ?OrderReference $order + * @return $this + */ + public function withOrder(?OrderReference $order) + { + $this->order = $order; + + return $this; + } + + /** + * @deprecated use withPayment() instead + * @return $this + */ + public function withPaymentBuilder(?PaymentReferenceBuilder $payment) + { + $this->payment = $payment; + + return $this; + } + + /** + * @deprecated use withCart() instead + * @return $this + */ + public function withCartBuilder(?CartReferenceBuilder $cart) + { + $this->cart = $cart; + + return $this; + } + + /** + * @deprecated use withOrder() instead + * @return $this + */ + public function withOrderBuilder(?OrderReferenceBuilder $order) + { + $this->order = $order; + + return $this; + } + + public function build(): CheckoutMessagePaymentsPayloadBaseData + { + return new CheckoutMessagePaymentsPayloadBaseDataModel( + $this->projectKey, + $this->payment instanceof PaymentReferenceBuilder ? $this->payment->build() : $this->payment, + $this->transactionId, + $this->cart instanceof CartReferenceBuilder ? $this->cart->build() : $this->cart, + $this->order instanceof OrderReferenceBuilder ? $this->order->build() : $this->order + ); + } + + public static function of(): CheckoutMessagePaymentsPayloadBaseDataBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseDataCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseDataCollection.php new file mode 100644 index 00000000000..19c356dd955 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseDataCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutMessagePaymentsPayloadBaseData current() + * @method CheckoutMessagePaymentsPayloadBaseData end() + * @method CheckoutMessagePaymentsPayloadBaseData at($offset) + */ +class CheckoutMessagePaymentsPayloadBaseDataCollection extends MapperSequence +{ + /** + * @psalm-assert CheckoutMessagePaymentsPayloadBaseData $value + * @psalm-param CheckoutMessagePaymentsPayloadBaseData|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutMessagePaymentsPayloadBaseDataCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutMessagePaymentsPayloadBaseData) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutMessagePaymentsPayloadBaseData + */ + protected function mapper() + { + return function (?int $index): ?CheckoutMessagePaymentsPayloadBaseData { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutMessagePaymentsPayloadBaseData $data */ + $data = CheckoutMessagePaymentsPayloadBaseDataModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseDataModel.php b/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseDataModel.php new file mode 100644 index 00000000000..ce70fdf032c --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutMessagePaymentsPayloadBaseDataModel.php @@ -0,0 +1,219 @@ +projectKey = $projectKey; + $this->payment = $payment; + $this->transactionId = $transactionId; + $this->cart = $cart; + $this->order = $order; + } + + /** + *

key of the Project where the payment was made.

+ * + * + * @return null|string + */ + public function getProjectKey() + { + if (is_null($this->projectKey)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_PROJECT_KEY); + if (is_null($data)) { + return null; + } + $this->projectKey = (string) $data; + } + + return $this->projectKey; + } + + /** + *

The Payment on which the change or action was performed.

+ * + * + * @return null|PaymentReference + */ + public function getPayment() + { + if (is_null($this->payment)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PAYMENT); + if (is_null($data)) { + return null; + } + + $this->payment = PaymentReferenceModel::of($data); + } + + return $this->payment; + } + + /** + *

id of the Transaction.

+ * + * + * @return null|string + */ + public function getTransactionId() + { + if (is_null($this->transactionId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TRANSACTION_ID); + if (is_null($data)) { + return null; + } + $this->transactionId = (string) $data; + } + + return $this->transactionId; + } + + /** + *

The Cart on which the change or action was performed.

+ * + * + * @return null|CartReference + */ + public function getCart() + { + if (is_null($this->cart)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CART); + if (is_null($data)) { + return null; + } + + $this->cart = CartReferenceModel::of($data); + } + + return $this->cart; + } + + /** + *

The Order on which the change or action was performed.

+ * + * + * @return null|OrderReference + */ + public function getOrder() + { + if (is_null($this->order)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_ORDER); + if (is_null($data)) { + return null; + } + + $this->order = OrderReferenceModel::of($data); + } + + return $this->order; + } + + + /** + * @param ?string $projectKey + */ + public function setProjectKey(?string $projectKey): void + { + $this->projectKey = $projectKey; + } + + /** + * @param ?PaymentReference $payment + */ + public function setPayment(?PaymentReference $payment): void + { + $this->payment = $payment; + } + + /** + * @param ?string $transactionId + */ + public function setTransactionId(?string $transactionId): void + { + $this->transactionId = $transactionId; + } + + /** + * @param ?CartReference $cart + */ + public function setCart(?CartReference $cart): void + { + $this->cart = $cart; + } + + /** + * @param ?OrderReference $order + */ + public function setOrder(?OrderReference $order): void + { + $this->order = $order; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEvent.php b/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEvent.php new file mode 100644 index 00000000000..1158e37f54f --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEvent.php @@ -0,0 +1,41 @@ +An object containing details of the order which could not be created.

+ * + + * @return null|CheckoutMessageOrderPayloadBaseData + */ + public function getData(); + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void; + + /** + * @param ?CheckoutMessageOrderPayloadBaseData $data + */ + public function setData(?CheckoutMessageOrderPayloadBaseData $data): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEventBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEventBuilder.php new file mode 100644 index 00000000000..a64a8880147 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEventBuilder.php @@ -0,0 +1,186 @@ + + */ +final class CheckoutOrderCreationFailedEventBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $notificationType; + + /** + + * @var ?string + */ + private $resourceType; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var null|CheckoutMessageOrderPayloadBaseData|CheckoutMessageOrderPayloadBaseDataBuilder + */ + private $data; + + /** + *

Unique identifier of the Event.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + + * @return null|string + */ + public function getNotificationType() + { + return $this->notificationType; + } + + /** + + * @return null|string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + *

An object containing details of the order which could not be created.

+ * + + * @return null|CheckoutMessageOrderPayloadBaseData + */ + public function getData() + { + return $this->data instanceof CheckoutMessageOrderPayloadBaseDataBuilder ? $this->data->build() : $this->data; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $notificationType + * @return $this + */ + public function withNotificationType(?string $notificationType) + { + $this->notificationType = $notificationType; + + return $this; + } + + /** + * @param ?string $resourceType + * @return $this + */ + public function withResourceType(?string $resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?CheckoutMessageOrderPayloadBaseData $data + * @return $this + */ + public function withData(?CheckoutMessageOrderPayloadBaseData $data) + { + $this->data = $data; + + return $this; + } + + /** + * @deprecated use withData() instead + * @return $this + */ + public function withDataBuilder(?CheckoutMessageOrderPayloadBaseDataBuilder $data) + { + $this->data = $data; + + return $this; + } + + public function build(): CheckoutOrderCreationFailedEvent + { + return new CheckoutOrderCreationFailedEventModel( + $this->id, + $this->notificationType, + $this->resourceType, + $this->createdAt, + $this->data instanceof CheckoutMessageOrderPayloadBaseDataBuilder ? $this->data->build() : $this->data + ); + } + + public static function of(): CheckoutOrderCreationFailedEventBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEventCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEventCollection.php new file mode 100644 index 00000000000..b31e2cba450 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEventCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutOrderCreationFailedEvent current() + * @method CheckoutOrderCreationFailedEvent end() + * @method CheckoutOrderCreationFailedEvent at($offset) + */ +class CheckoutOrderCreationFailedEventCollection extends EventCollection +{ + /** + * @psalm-assert CheckoutOrderCreationFailedEvent $value + * @psalm-param CheckoutOrderCreationFailedEvent|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutOrderCreationFailedEventCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutOrderCreationFailedEvent) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutOrderCreationFailedEvent + */ + protected function mapper() + { + return function (?int $index): ?CheckoutOrderCreationFailedEvent { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutOrderCreationFailedEvent $data */ + $data = CheckoutOrderCreationFailedEventModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEventModel.php b/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEventModel.php new file mode 100644 index 00000000000..332ae5fcbad --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutOrderCreationFailedEventModel.php @@ -0,0 +1,252 @@ +id = $id; + $this->notificationType = $notificationType; + $this->resourceType = $resourceType; + $this->createdAt = $createdAt; + $this->data = $data; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Event.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + * + * @return null|string + */ + public function getNotificationType() + { + if (is_null($this->notificationType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NOTIFICATION_TYPE); + if (is_null($data)) { + return null; + } + $this->notificationType = (string) $data; + } + + return $this->notificationType; + } + + /** + * + * @return null|string + */ + public function getResourceType() + { + if (is_null($this->resourceType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESOURCE_TYPE); + if (is_null($data)) { + return null; + } + $this->resourceType = (string) $data; + } + + return $this->resourceType; + } + + /** + *

The type of Event that has occurred.

+ * + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + * + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + if (is_null($this->createdAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CREATED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; + } + + return $this->createdAt; + } + + /** + *

An object containing details of the order which could not be created.

+ * + * + * @return null|CheckoutMessageOrderPayloadBaseData + */ + public function getData() + { + if (is_null($this->data)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DATA); + if (is_null($data)) { + return null; + } + + $this->data = CheckoutMessageOrderPayloadBaseDataModel::of($data); + } + + return $this->data; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $notificationType + */ + public function setNotificationType(?string $notificationType): void + { + $this->notificationType = $notificationType; + } + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void + { + $this->resourceType = $resourceType; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?CheckoutMessageOrderPayloadBaseData $data + */ + public function setData(?CheckoutMessageOrderPayloadBaseData $data): void + { + $this->data = $data; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Event::FIELD_CREATED_AT]) && $data[Event::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Event::FIELD_CREATED_AT] = $data[Event::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEvent.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEvent.php new file mode 100644 index 00000000000..231b2da17dc --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEvent.php @@ -0,0 +1,41 @@ +An object containing details of the payment authorization that was cancelled.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData(); + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void; + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEventBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEventBuilder.php new file mode 100644 index 00000000000..00be03421ea --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEventBuilder.php @@ -0,0 +1,186 @@ + + */ +final class CheckoutPaymentAuthorizationCancelledEventBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $notificationType; + + /** + + * @var ?string + */ + private $resourceType; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var null|CheckoutMessagePaymentsPayloadBaseData|CheckoutMessagePaymentsPayloadBaseDataBuilder + */ + private $data; + + /** + *

Unique identifier of the Event.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + + * @return null|string + */ + public function getNotificationType() + { + return $this->notificationType; + } + + /** + + * @return null|string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + *

An object containing details of the payment authorization that was cancelled.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + return $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $notificationType + * @return $this + */ + public function withNotificationType(?string $notificationType) + { + $this->notificationType = $notificationType; + + return $this; + } + + /** + * @param ?string $resourceType + * @return $this + */ + public function withResourceType(?string $resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + * @return $this + */ + public function withData(?CheckoutMessagePaymentsPayloadBaseData $data) + { + $this->data = $data; + + return $this; + } + + /** + * @deprecated use withData() instead + * @return $this + */ + public function withDataBuilder(?CheckoutMessagePaymentsPayloadBaseDataBuilder $data) + { + $this->data = $data; + + return $this; + } + + public function build(): CheckoutPaymentAuthorizationCancelledEvent + { + return new CheckoutPaymentAuthorizationCancelledEventModel( + $this->id, + $this->notificationType, + $this->resourceType, + $this->createdAt, + $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data + ); + } + + public static function of(): CheckoutPaymentAuthorizationCancelledEventBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEventCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEventCollection.php new file mode 100644 index 00000000000..3b2197f03c2 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEventCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutPaymentAuthorizationCancelledEvent current() + * @method CheckoutPaymentAuthorizationCancelledEvent end() + * @method CheckoutPaymentAuthorizationCancelledEvent at($offset) + */ +class CheckoutPaymentAuthorizationCancelledEventCollection extends EventCollection +{ + /** + * @psalm-assert CheckoutPaymentAuthorizationCancelledEvent $value + * @psalm-param CheckoutPaymentAuthorizationCancelledEvent|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutPaymentAuthorizationCancelledEventCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutPaymentAuthorizationCancelledEvent) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutPaymentAuthorizationCancelledEvent + */ + protected function mapper() + { + return function (?int $index): ?CheckoutPaymentAuthorizationCancelledEvent { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutPaymentAuthorizationCancelledEvent $data */ + $data = CheckoutPaymentAuthorizationCancelledEventModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEventModel.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEventModel.php new file mode 100644 index 00000000000..cfce26d75e6 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationCancelledEventModel.php @@ -0,0 +1,252 @@ +id = $id; + $this->notificationType = $notificationType; + $this->resourceType = $resourceType; + $this->createdAt = $createdAt; + $this->data = $data; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Event.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + * + * @return null|string + */ + public function getNotificationType() + { + if (is_null($this->notificationType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NOTIFICATION_TYPE); + if (is_null($data)) { + return null; + } + $this->notificationType = (string) $data; + } + + return $this->notificationType; + } + + /** + * + * @return null|string + */ + public function getResourceType() + { + if (is_null($this->resourceType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESOURCE_TYPE); + if (is_null($data)) { + return null; + } + $this->resourceType = (string) $data; + } + + return $this->resourceType; + } + + /** + *

The type of Event that has occurred.

+ * + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + * + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + if (is_null($this->createdAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CREATED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; + } + + return $this->createdAt; + } + + /** + *

An object containing details of the payment authorization that was cancelled.

+ * + * + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + if (is_null($this->data)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DATA); + if (is_null($data)) { + return null; + } + + $this->data = CheckoutMessagePaymentsPayloadBaseDataModel::of($data); + } + + return $this->data; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $notificationType + */ + public function setNotificationType(?string $notificationType): void + { + $this->notificationType = $notificationType; + } + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void + { + $this->resourceType = $resourceType; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void + { + $this->data = $data; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Event::FIELD_CREATED_AT]) && $data[Event::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Event::FIELD_CREATED_AT] = $data[Event::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEvent.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEvent.php new file mode 100644 index 00000000000..613f73f178b --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEvent.php @@ -0,0 +1,41 @@ +An object containing details of the payment authorization that failed.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData(); + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void; + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEventBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEventBuilder.php new file mode 100644 index 00000000000..f24c2fa9c62 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEventBuilder.php @@ -0,0 +1,186 @@ + + */ +final class CheckoutPaymentAuthorizationFailedEventBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $notificationType; + + /** + + * @var ?string + */ + private $resourceType; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var null|CheckoutMessagePaymentsPayloadBaseData|CheckoutMessagePaymentsPayloadBaseDataBuilder + */ + private $data; + + /** + *

Unique identifier of the Event.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + + * @return null|string + */ + public function getNotificationType() + { + return $this->notificationType; + } + + /** + + * @return null|string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + *

An object containing details of the payment authorization that failed.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + return $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $notificationType + * @return $this + */ + public function withNotificationType(?string $notificationType) + { + $this->notificationType = $notificationType; + + return $this; + } + + /** + * @param ?string $resourceType + * @return $this + */ + public function withResourceType(?string $resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + * @return $this + */ + public function withData(?CheckoutMessagePaymentsPayloadBaseData $data) + { + $this->data = $data; + + return $this; + } + + /** + * @deprecated use withData() instead + * @return $this + */ + public function withDataBuilder(?CheckoutMessagePaymentsPayloadBaseDataBuilder $data) + { + $this->data = $data; + + return $this; + } + + public function build(): CheckoutPaymentAuthorizationFailedEvent + { + return new CheckoutPaymentAuthorizationFailedEventModel( + $this->id, + $this->notificationType, + $this->resourceType, + $this->createdAt, + $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data + ); + } + + public static function of(): CheckoutPaymentAuthorizationFailedEventBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEventCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEventCollection.php new file mode 100644 index 00000000000..5e5cf0d78c3 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEventCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutPaymentAuthorizationFailedEvent current() + * @method CheckoutPaymentAuthorizationFailedEvent end() + * @method CheckoutPaymentAuthorizationFailedEvent at($offset) + */ +class CheckoutPaymentAuthorizationFailedEventCollection extends EventCollection +{ + /** + * @psalm-assert CheckoutPaymentAuthorizationFailedEvent $value + * @psalm-param CheckoutPaymentAuthorizationFailedEvent|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutPaymentAuthorizationFailedEventCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutPaymentAuthorizationFailedEvent) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutPaymentAuthorizationFailedEvent + */ + protected function mapper() + { + return function (?int $index): ?CheckoutPaymentAuthorizationFailedEvent { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutPaymentAuthorizationFailedEvent $data */ + $data = CheckoutPaymentAuthorizationFailedEventModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEventModel.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEventModel.php new file mode 100644 index 00000000000..545cd458096 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizationFailedEventModel.php @@ -0,0 +1,252 @@ +id = $id; + $this->notificationType = $notificationType; + $this->resourceType = $resourceType; + $this->createdAt = $createdAt; + $this->data = $data; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Event.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + * + * @return null|string + */ + public function getNotificationType() + { + if (is_null($this->notificationType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NOTIFICATION_TYPE); + if (is_null($data)) { + return null; + } + $this->notificationType = (string) $data; + } + + return $this->notificationType; + } + + /** + * + * @return null|string + */ + public function getResourceType() + { + if (is_null($this->resourceType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESOURCE_TYPE); + if (is_null($data)) { + return null; + } + $this->resourceType = (string) $data; + } + + return $this->resourceType; + } + + /** + *

The type of Event that has occurred.

+ * + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + * + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + if (is_null($this->createdAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CREATED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; + } + + return $this->createdAt; + } + + /** + *

An object containing details of the payment authorization that failed.

+ * + * + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + if (is_null($this->data)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DATA); + if (is_null($data)) { + return null; + } + + $this->data = CheckoutMessagePaymentsPayloadBaseDataModel::of($data); + } + + return $this->data; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $notificationType + */ + public function setNotificationType(?string $notificationType): void + { + $this->notificationType = $notificationType; + } + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void + { + $this->resourceType = $resourceType; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void + { + $this->data = $data; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Event::FIELD_CREATED_AT]) && $data[Event::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Event::FIELD_CREATED_AT] = $data[Event::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEvent.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEvent.php new file mode 100644 index 00000000000..ac8f37a4318 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEvent.php @@ -0,0 +1,41 @@ +An object containing details of the successful payment authorization.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData(); + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void; + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEventBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEventBuilder.php new file mode 100644 index 00000000000..90f8f7b3b93 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEventBuilder.php @@ -0,0 +1,186 @@ + + */ +final class CheckoutPaymentAuthorizedEventBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $notificationType; + + /** + + * @var ?string + */ + private $resourceType; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var null|CheckoutMessagePaymentsPayloadBaseData|CheckoutMessagePaymentsPayloadBaseDataBuilder + */ + private $data; + + /** + *

Unique identifier of the Event.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + + * @return null|string + */ + public function getNotificationType() + { + return $this->notificationType; + } + + /** + + * @return null|string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + *

An object containing details of the successful payment authorization.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + return $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $notificationType + * @return $this + */ + public function withNotificationType(?string $notificationType) + { + $this->notificationType = $notificationType; + + return $this; + } + + /** + * @param ?string $resourceType + * @return $this + */ + public function withResourceType(?string $resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + * @return $this + */ + public function withData(?CheckoutMessagePaymentsPayloadBaseData $data) + { + $this->data = $data; + + return $this; + } + + /** + * @deprecated use withData() instead + * @return $this + */ + public function withDataBuilder(?CheckoutMessagePaymentsPayloadBaseDataBuilder $data) + { + $this->data = $data; + + return $this; + } + + public function build(): CheckoutPaymentAuthorizedEvent + { + return new CheckoutPaymentAuthorizedEventModel( + $this->id, + $this->notificationType, + $this->resourceType, + $this->createdAt, + $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data + ); + } + + public static function of(): CheckoutPaymentAuthorizedEventBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEventCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEventCollection.php new file mode 100644 index 00000000000..46cb4a19129 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEventCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutPaymentAuthorizedEvent current() + * @method CheckoutPaymentAuthorizedEvent end() + * @method CheckoutPaymentAuthorizedEvent at($offset) + */ +class CheckoutPaymentAuthorizedEventCollection extends EventCollection +{ + /** + * @psalm-assert CheckoutPaymentAuthorizedEvent $value + * @psalm-param CheckoutPaymentAuthorizedEvent|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutPaymentAuthorizedEventCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutPaymentAuthorizedEvent) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutPaymentAuthorizedEvent + */ + protected function mapper() + { + return function (?int $index): ?CheckoutPaymentAuthorizedEvent { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutPaymentAuthorizedEvent $data */ + $data = CheckoutPaymentAuthorizedEventModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEventModel.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEventModel.php new file mode 100644 index 00000000000..ad7bbbff475 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentAuthorizedEventModel.php @@ -0,0 +1,252 @@ +id = $id; + $this->notificationType = $notificationType; + $this->resourceType = $resourceType; + $this->createdAt = $createdAt; + $this->data = $data; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Event.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + * + * @return null|string + */ + public function getNotificationType() + { + if (is_null($this->notificationType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NOTIFICATION_TYPE); + if (is_null($data)) { + return null; + } + $this->notificationType = (string) $data; + } + + return $this->notificationType; + } + + /** + * + * @return null|string + */ + public function getResourceType() + { + if (is_null($this->resourceType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESOURCE_TYPE); + if (is_null($data)) { + return null; + } + $this->resourceType = (string) $data; + } + + return $this->resourceType; + } + + /** + *

The type of Event that has occurred.

+ * + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + * + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + if (is_null($this->createdAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CREATED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; + } + + return $this->createdAt; + } + + /** + *

An object containing details of the successful payment authorization.

+ * + * + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + if (is_null($this->data)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DATA); + if (is_null($data)) { + return null; + } + + $this->data = CheckoutMessagePaymentsPayloadBaseDataModel::of($data); + } + + return $this->data; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $notificationType + */ + public function setNotificationType(?string $notificationType): void + { + $this->notificationType = $notificationType; + } + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void + { + $this->resourceType = $resourceType; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void + { + $this->data = $data; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Event::FIELD_CREATED_AT]) && $data[Event::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Event::FIELD_CREATED_AT] = $data[Event::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEvent.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEvent.php new file mode 100644 index 00000000000..b7582467181 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEvent.php @@ -0,0 +1,41 @@ +An object containing details of the payment authorization that could not be cancelled.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData(); + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void; + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEventBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEventBuilder.php new file mode 100644 index 00000000000..fe5257b455f --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEventBuilder.php @@ -0,0 +1,186 @@ + + */ +final class CheckoutPaymentCancelAuthorizationFailedEventBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $notificationType; + + /** + + * @var ?string + */ + private $resourceType; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var null|CheckoutMessagePaymentsPayloadBaseData|CheckoutMessagePaymentsPayloadBaseDataBuilder + */ + private $data; + + /** + *

Unique identifier of the Event.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + + * @return null|string + */ + public function getNotificationType() + { + return $this->notificationType; + } + + /** + + * @return null|string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + *

An object containing details of the payment authorization that could not be cancelled.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + return $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $notificationType + * @return $this + */ + public function withNotificationType(?string $notificationType) + { + $this->notificationType = $notificationType; + + return $this; + } + + /** + * @param ?string $resourceType + * @return $this + */ + public function withResourceType(?string $resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + * @return $this + */ + public function withData(?CheckoutMessagePaymentsPayloadBaseData $data) + { + $this->data = $data; + + return $this; + } + + /** + * @deprecated use withData() instead + * @return $this + */ + public function withDataBuilder(?CheckoutMessagePaymentsPayloadBaseDataBuilder $data) + { + $this->data = $data; + + return $this; + } + + public function build(): CheckoutPaymentCancelAuthorizationFailedEvent + { + return new CheckoutPaymentCancelAuthorizationFailedEventModel( + $this->id, + $this->notificationType, + $this->resourceType, + $this->createdAt, + $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data + ); + } + + public static function of(): CheckoutPaymentCancelAuthorizationFailedEventBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEventCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEventCollection.php new file mode 100644 index 00000000000..b5a251dc9b7 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEventCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutPaymentCancelAuthorizationFailedEvent current() + * @method CheckoutPaymentCancelAuthorizationFailedEvent end() + * @method CheckoutPaymentCancelAuthorizationFailedEvent at($offset) + */ +class CheckoutPaymentCancelAuthorizationFailedEventCollection extends EventCollection +{ + /** + * @psalm-assert CheckoutPaymentCancelAuthorizationFailedEvent $value + * @psalm-param CheckoutPaymentCancelAuthorizationFailedEvent|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutPaymentCancelAuthorizationFailedEventCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutPaymentCancelAuthorizationFailedEvent) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutPaymentCancelAuthorizationFailedEvent + */ + protected function mapper() + { + return function (?int $index): ?CheckoutPaymentCancelAuthorizationFailedEvent { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutPaymentCancelAuthorizationFailedEvent $data */ + $data = CheckoutPaymentCancelAuthorizationFailedEventModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEventModel.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEventModel.php new file mode 100644 index 00000000000..b2a4295c214 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentCancelAuthorizationFailedEventModel.php @@ -0,0 +1,252 @@ +id = $id; + $this->notificationType = $notificationType; + $this->resourceType = $resourceType; + $this->createdAt = $createdAt; + $this->data = $data; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Event.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + * + * @return null|string + */ + public function getNotificationType() + { + if (is_null($this->notificationType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NOTIFICATION_TYPE); + if (is_null($data)) { + return null; + } + $this->notificationType = (string) $data; + } + + return $this->notificationType; + } + + /** + * + * @return null|string + */ + public function getResourceType() + { + if (is_null($this->resourceType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESOURCE_TYPE); + if (is_null($data)) { + return null; + } + $this->resourceType = (string) $data; + } + + return $this->resourceType; + } + + /** + *

The type of Event that has occurred.

+ * + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + * + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + if (is_null($this->createdAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CREATED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; + } + + return $this->createdAt; + } + + /** + *

An object containing details of the payment authorization that could not be cancelled.

+ * + * + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + if (is_null($this->data)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DATA); + if (is_null($data)) { + return null; + } + + $this->data = CheckoutMessagePaymentsPayloadBaseDataModel::of($data); + } + + return $this->data; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $notificationType + */ + public function setNotificationType(?string $notificationType): void + { + $this->notificationType = $notificationType; + } + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void + { + $this->resourceType = $resourceType; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void + { + $this->data = $data; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Event::FIELD_CREATED_AT]) && $data[Event::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Event::FIELD_CREATED_AT] = $data[Event::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEvent.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEvent.php new file mode 100644 index 00000000000..19e3eb95df0 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEvent.php @@ -0,0 +1,41 @@ +An object containing details of the failed payment charge.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData(); + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void; + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEventBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEventBuilder.php new file mode 100644 index 00000000000..b17a7c79e3c --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEventBuilder.php @@ -0,0 +1,186 @@ + + */ +final class CheckoutPaymentChargeFailedEventBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $notificationType; + + /** + + * @var ?string + */ + private $resourceType; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var null|CheckoutMessagePaymentsPayloadBaseData|CheckoutMessagePaymentsPayloadBaseDataBuilder + */ + private $data; + + /** + *

Unique identifier of the Event.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + + * @return null|string + */ + public function getNotificationType() + { + return $this->notificationType; + } + + /** + + * @return null|string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + *

An object containing details of the failed payment charge.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + return $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $notificationType + * @return $this + */ + public function withNotificationType(?string $notificationType) + { + $this->notificationType = $notificationType; + + return $this; + } + + /** + * @param ?string $resourceType + * @return $this + */ + public function withResourceType(?string $resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + * @return $this + */ + public function withData(?CheckoutMessagePaymentsPayloadBaseData $data) + { + $this->data = $data; + + return $this; + } + + /** + * @deprecated use withData() instead + * @return $this + */ + public function withDataBuilder(?CheckoutMessagePaymentsPayloadBaseDataBuilder $data) + { + $this->data = $data; + + return $this; + } + + public function build(): CheckoutPaymentChargeFailedEvent + { + return new CheckoutPaymentChargeFailedEventModel( + $this->id, + $this->notificationType, + $this->resourceType, + $this->createdAt, + $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data + ); + } + + public static function of(): CheckoutPaymentChargeFailedEventBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEventCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEventCollection.php new file mode 100644 index 00000000000..703d34c9048 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEventCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutPaymentChargeFailedEvent current() + * @method CheckoutPaymentChargeFailedEvent end() + * @method CheckoutPaymentChargeFailedEvent at($offset) + */ +class CheckoutPaymentChargeFailedEventCollection extends EventCollection +{ + /** + * @psalm-assert CheckoutPaymentChargeFailedEvent $value + * @psalm-param CheckoutPaymentChargeFailedEvent|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutPaymentChargeFailedEventCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutPaymentChargeFailedEvent) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutPaymentChargeFailedEvent + */ + protected function mapper() + { + return function (?int $index): ?CheckoutPaymentChargeFailedEvent { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutPaymentChargeFailedEvent $data */ + $data = CheckoutPaymentChargeFailedEventModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEventModel.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEventModel.php new file mode 100644 index 00000000000..87918674763 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargeFailedEventModel.php @@ -0,0 +1,252 @@ +id = $id; + $this->notificationType = $notificationType; + $this->resourceType = $resourceType; + $this->createdAt = $createdAt; + $this->data = $data; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Event.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + * + * @return null|string + */ + public function getNotificationType() + { + if (is_null($this->notificationType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NOTIFICATION_TYPE); + if (is_null($data)) { + return null; + } + $this->notificationType = (string) $data; + } + + return $this->notificationType; + } + + /** + * + * @return null|string + */ + public function getResourceType() + { + if (is_null($this->resourceType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESOURCE_TYPE); + if (is_null($data)) { + return null; + } + $this->resourceType = (string) $data; + } + + return $this->resourceType; + } + + /** + *

The type of Event that has occurred.

+ * + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + * + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + if (is_null($this->createdAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CREATED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; + } + + return $this->createdAt; + } + + /** + *

An object containing details of the failed payment charge.

+ * + * + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + if (is_null($this->data)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DATA); + if (is_null($data)) { + return null; + } + + $this->data = CheckoutMessagePaymentsPayloadBaseDataModel::of($data); + } + + return $this->data; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $notificationType + */ + public function setNotificationType(?string $notificationType): void + { + $this->notificationType = $notificationType; + } + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void + { + $this->resourceType = $resourceType; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void + { + $this->data = $data; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Event::FIELD_CREATED_AT]) && $data[Event::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Event::FIELD_CREATED_AT] = $data[Event::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEvent.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEvent.php new file mode 100644 index 00000000000..803877f1271 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEvent.php @@ -0,0 +1,41 @@ +An object containing details of the successful payment charge.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData(); + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void; + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEventBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEventBuilder.php new file mode 100644 index 00000000000..642f200d4bf --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEventBuilder.php @@ -0,0 +1,186 @@ + + */ +final class CheckoutPaymentChargedEventBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $notificationType; + + /** + + * @var ?string + */ + private $resourceType; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var null|CheckoutMessagePaymentsPayloadBaseData|CheckoutMessagePaymentsPayloadBaseDataBuilder + */ + private $data; + + /** + *

Unique identifier of the Event.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + + * @return null|string + */ + public function getNotificationType() + { + return $this->notificationType; + } + + /** + + * @return null|string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + *

An object containing details of the successful payment charge.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + return $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $notificationType + * @return $this + */ + public function withNotificationType(?string $notificationType) + { + $this->notificationType = $notificationType; + + return $this; + } + + /** + * @param ?string $resourceType + * @return $this + */ + public function withResourceType(?string $resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + * @return $this + */ + public function withData(?CheckoutMessagePaymentsPayloadBaseData $data) + { + $this->data = $data; + + return $this; + } + + /** + * @deprecated use withData() instead + * @return $this + */ + public function withDataBuilder(?CheckoutMessagePaymentsPayloadBaseDataBuilder $data) + { + $this->data = $data; + + return $this; + } + + public function build(): CheckoutPaymentChargedEvent + { + return new CheckoutPaymentChargedEventModel( + $this->id, + $this->notificationType, + $this->resourceType, + $this->createdAt, + $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data + ); + } + + public static function of(): CheckoutPaymentChargedEventBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEventCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEventCollection.php new file mode 100644 index 00000000000..d7698573905 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEventCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutPaymentChargedEvent current() + * @method CheckoutPaymentChargedEvent end() + * @method CheckoutPaymentChargedEvent at($offset) + */ +class CheckoutPaymentChargedEventCollection extends EventCollection +{ + /** + * @psalm-assert CheckoutPaymentChargedEvent $value + * @psalm-param CheckoutPaymentChargedEvent|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutPaymentChargedEventCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutPaymentChargedEvent) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutPaymentChargedEvent + */ + protected function mapper() + { + return function (?int $index): ?CheckoutPaymentChargedEvent { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutPaymentChargedEvent $data */ + $data = CheckoutPaymentChargedEventModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEventModel.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEventModel.php new file mode 100644 index 00000000000..8fa28ac1710 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentChargedEventModel.php @@ -0,0 +1,252 @@ +id = $id; + $this->notificationType = $notificationType; + $this->resourceType = $resourceType; + $this->createdAt = $createdAt; + $this->data = $data; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Event.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + * + * @return null|string + */ + public function getNotificationType() + { + if (is_null($this->notificationType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NOTIFICATION_TYPE); + if (is_null($data)) { + return null; + } + $this->notificationType = (string) $data; + } + + return $this->notificationType; + } + + /** + * + * @return null|string + */ + public function getResourceType() + { + if (is_null($this->resourceType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESOURCE_TYPE); + if (is_null($data)) { + return null; + } + $this->resourceType = (string) $data; + } + + return $this->resourceType; + } + + /** + *

The type of Event that has occurred.

+ * + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + * + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + if (is_null($this->createdAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CREATED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; + } + + return $this->createdAt; + } + + /** + *

An object containing details of the successful payment charge.

+ * + * + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + if (is_null($this->data)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DATA); + if (is_null($data)) { + return null; + } + + $this->data = CheckoutMessagePaymentsPayloadBaseDataModel::of($data); + } + + return $this->data; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $notificationType + */ + public function setNotificationType(?string $notificationType): void + { + $this->notificationType = $notificationType; + } + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void + { + $this->resourceType = $resourceType; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void + { + $this->data = $data; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Event::FIELD_CREATED_AT]) && $data[Event::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Event::FIELD_CREATED_AT] = $data[Event::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEvent.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEvent.php new file mode 100644 index 00000000000..16da85ffdfb --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEvent.php @@ -0,0 +1,41 @@ +An object containing details of the failed payment refund attempt.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData(); + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void; + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEventBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEventBuilder.php new file mode 100644 index 00000000000..d6baf9c8371 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEventBuilder.php @@ -0,0 +1,186 @@ + + */ +final class CheckoutPaymentRefundFailedEventBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $notificationType; + + /** + + * @var ?string + */ + private $resourceType; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var null|CheckoutMessagePaymentsPayloadBaseData|CheckoutMessagePaymentsPayloadBaseDataBuilder + */ + private $data; + + /** + *

Unique identifier of the Event.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + + * @return null|string + */ + public function getNotificationType() + { + return $this->notificationType; + } + + /** + + * @return null|string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + *

An object containing details of the failed payment refund attempt.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + return $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $notificationType + * @return $this + */ + public function withNotificationType(?string $notificationType) + { + $this->notificationType = $notificationType; + + return $this; + } + + /** + * @param ?string $resourceType + * @return $this + */ + public function withResourceType(?string $resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + * @return $this + */ + public function withData(?CheckoutMessagePaymentsPayloadBaseData $data) + { + $this->data = $data; + + return $this; + } + + /** + * @deprecated use withData() instead + * @return $this + */ + public function withDataBuilder(?CheckoutMessagePaymentsPayloadBaseDataBuilder $data) + { + $this->data = $data; + + return $this; + } + + public function build(): CheckoutPaymentRefundFailedEvent + { + return new CheckoutPaymentRefundFailedEventModel( + $this->id, + $this->notificationType, + $this->resourceType, + $this->createdAt, + $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data + ); + } + + public static function of(): CheckoutPaymentRefundFailedEventBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEventCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEventCollection.php new file mode 100644 index 00000000000..aca463750c2 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEventCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutPaymentRefundFailedEvent current() + * @method CheckoutPaymentRefundFailedEvent end() + * @method CheckoutPaymentRefundFailedEvent at($offset) + */ +class CheckoutPaymentRefundFailedEventCollection extends EventCollection +{ + /** + * @psalm-assert CheckoutPaymentRefundFailedEvent $value + * @psalm-param CheckoutPaymentRefundFailedEvent|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutPaymentRefundFailedEventCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutPaymentRefundFailedEvent) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutPaymentRefundFailedEvent + */ + protected function mapper() + { + return function (?int $index): ?CheckoutPaymentRefundFailedEvent { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutPaymentRefundFailedEvent $data */ + $data = CheckoutPaymentRefundFailedEventModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEventModel.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEventModel.php new file mode 100644 index 00000000000..b1370597a7a --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundFailedEventModel.php @@ -0,0 +1,252 @@ +id = $id; + $this->notificationType = $notificationType; + $this->resourceType = $resourceType; + $this->createdAt = $createdAt; + $this->data = $data; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Event.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + * + * @return null|string + */ + public function getNotificationType() + { + if (is_null($this->notificationType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NOTIFICATION_TYPE); + if (is_null($data)) { + return null; + } + $this->notificationType = (string) $data; + } + + return $this->notificationType; + } + + /** + * + * @return null|string + */ + public function getResourceType() + { + if (is_null($this->resourceType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESOURCE_TYPE); + if (is_null($data)) { + return null; + } + $this->resourceType = (string) $data; + } + + return $this->resourceType; + } + + /** + *

The type of Event that has occurred.

+ * + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + * + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + if (is_null($this->createdAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CREATED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; + } + + return $this->createdAt; + } + + /** + *

An object containing details of the failed payment refund attempt.

+ * + * + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + if (is_null($this->data)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DATA); + if (is_null($data)) { + return null; + } + + $this->data = CheckoutMessagePaymentsPayloadBaseDataModel::of($data); + } + + return $this->data; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $notificationType + */ + public function setNotificationType(?string $notificationType): void + { + $this->notificationType = $notificationType; + } + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void + { + $this->resourceType = $resourceType; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void + { + $this->data = $data; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Event::FIELD_CREATED_AT]) && $data[Event::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Event::FIELD_CREATED_AT] = $data[Event::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEvent.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEvent.php new file mode 100644 index 00000000000..802c9425298 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEvent.php @@ -0,0 +1,41 @@ +An object containing details of the successful payment refund.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData(); + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void; + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void; +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEventBuilder.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEventBuilder.php new file mode 100644 index 00000000000..631695d21a3 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEventBuilder.php @@ -0,0 +1,186 @@ + + */ +final class CheckoutPaymentRefundedEventBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $notificationType; + + /** + + * @var ?string + */ + private $resourceType; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var null|CheckoutMessagePaymentsPayloadBaseData|CheckoutMessagePaymentsPayloadBaseDataBuilder + */ + private $data; + + /** + *

Unique identifier of the Event.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + + * @return null|string + */ + public function getNotificationType() + { + return $this->notificationType; + } + + /** + + * @return null|string + */ + public function getResourceType() + { + return $this->resourceType; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + *

An object containing details of the successful payment refund.

+ * + + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + return $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $notificationType + * @return $this + */ + public function withNotificationType(?string $notificationType) + { + $this->notificationType = $notificationType; + + return $this; + } + + /** + * @param ?string $resourceType + * @return $this + */ + public function withResourceType(?string $resourceType) + { + $this->resourceType = $resourceType; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + * @return $this + */ + public function withData(?CheckoutMessagePaymentsPayloadBaseData $data) + { + $this->data = $data; + + return $this; + } + + /** + * @deprecated use withData() instead + * @return $this + */ + public function withDataBuilder(?CheckoutMessagePaymentsPayloadBaseDataBuilder $data) + { + $this->data = $data; + + return $this; + } + + public function build(): CheckoutPaymentRefundedEvent + { + return new CheckoutPaymentRefundedEventModel( + $this->id, + $this->notificationType, + $this->resourceType, + $this->createdAt, + $this->data instanceof CheckoutMessagePaymentsPayloadBaseDataBuilder ? $this->data->build() : $this->data + ); + } + + public static function of(): CheckoutPaymentRefundedEventBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEventCollection.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEventCollection.php new file mode 100644 index 00000000000..0f092e5fd2a --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEventCollection.php @@ -0,0 +1,56 @@ + + * @method CheckoutPaymentRefundedEvent current() + * @method CheckoutPaymentRefundedEvent end() + * @method CheckoutPaymentRefundedEvent at($offset) + */ +class CheckoutPaymentRefundedEventCollection extends EventCollection +{ + /** + * @psalm-assert CheckoutPaymentRefundedEvent $value + * @psalm-param CheckoutPaymentRefundedEvent|stdClass $value + * @throws InvalidArgumentException + * + * @return CheckoutPaymentRefundedEventCollection + */ + public function add($value) + { + if (!$value instanceof CheckoutPaymentRefundedEvent) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CheckoutPaymentRefundedEvent + */ + protected function mapper() + { + return function (?int $index): ?CheckoutPaymentRefundedEvent { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CheckoutPaymentRefundedEvent $data */ + $data = CheckoutPaymentRefundedEventModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEventModel.php b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEventModel.php new file mode 100644 index 00000000000..2750931e1c2 --- /dev/null +++ b/lib/commercetools-api/src/Models/Event/CheckoutPaymentRefundedEventModel.php @@ -0,0 +1,252 @@ +id = $id; + $this->notificationType = $notificationType; + $this->resourceType = $resourceType; + $this->createdAt = $createdAt; + $this->data = $data; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Event.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + * + * @return null|string + */ + public function getNotificationType() + { + if (is_null($this->notificationType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NOTIFICATION_TYPE); + if (is_null($data)) { + return null; + } + $this->notificationType = (string) $data; + } + + return $this->notificationType; + } + + /** + * + * @return null|string + */ + public function getResourceType() + { + if (is_null($this->resourceType)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESOURCE_TYPE); + if (is_null($data)) { + return null; + } + $this->resourceType = (string) $data; + } + + return $this->resourceType; + } + + /** + *

The type of Event that has occurred.

+ * + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } + + /** + *

Date and time (UTC) the Event was generated.

+ * + * + * @return null|DateTimeImmutable + */ + public function getCreatedAt() + { + if (is_null($this->createdAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CREATED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; + } + + return $this->createdAt; + } + + /** + *

An object containing details of the successful payment refund.

+ * + * + * @return null|CheckoutMessagePaymentsPayloadBaseData + */ + public function getData() + { + if (is_null($this->data)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DATA); + if (is_null($data)) { + return null; + } + + $this->data = CheckoutMessagePaymentsPayloadBaseDataModel::of($data); + } + + return $this->data; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $notificationType + */ + public function setNotificationType(?string $notificationType): void + { + $this->notificationType = $notificationType; + } + + /** + * @param ?string $resourceType + */ + public function setResourceType(?string $resourceType): void + { + $this->resourceType = $resourceType; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?CheckoutMessagePaymentsPayloadBaseData $data + */ + public function setData(?CheckoutMessagePaymentsPayloadBaseData $data): void + { + $this->data = $data; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Event::FIELD_CREATED_AT]) && $data[Event::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Event::FIELD_CREATED_AT] = $data[Event::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Event/EventModel.php b/lib/commercetools-api/src/Models/Event/EventModel.php index 783b06a2b62..8509a7cbbee 100644 --- a/lib/commercetools-api/src/Models/Event/EventModel.php +++ b/lib/commercetools-api/src/Models/Event/EventModel.php @@ -56,6 +56,15 @@ final class EventModel extends JsonObjectModel implements Event * */ private static $discriminatorClasses = [ + 'CheckoutOrderCreationFailed' => CheckoutOrderCreationFailedEventModel::class, + 'CheckoutPaymentAuthorizationCancelled' => CheckoutPaymentAuthorizationCancelledEventModel::class, + 'CheckoutPaymentAuthorizationFailed' => CheckoutPaymentAuthorizationFailedEventModel::class, + 'CheckoutPaymentAuthorized' => CheckoutPaymentAuthorizedEventModel::class, + 'CheckoutPaymentCancelAuthorizationFailed' => CheckoutPaymentCancelAuthorizationFailedEventModel::class, + 'CheckoutPaymentChargeFailed' => CheckoutPaymentChargeFailedEventModel::class, + 'CheckoutPaymentCharged' => CheckoutPaymentChargedEventModel::class, + 'CheckoutPaymentRefundFailed' => CheckoutPaymentRefundFailedEventModel::class, + 'CheckoutPaymentRefunded' => CheckoutPaymentRefundedEventModel::class, 'ImportContainerCreated' => ImportContainerCreatedEventModel::class, 'ImportContainerDeleted' => ImportContainerDeletedEventModel::class, 'ImportOperationRejected' => ImportOperationRejectedEventModel::class, diff --git a/lib/commercetools-api/src/Models/Subscription/EventSubscription.php b/lib/commercetools-api/src/Models/Subscription/EventSubscription.php index 98049c31b00..e892f89ae07 100644 --- a/lib/commercetools-api/src/Models/Subscription/EventSubscription.php +++ b/lib/commercetools-api/src/Models/Subscription/EventSubscription.php @@ -17,7 +17,7 @@ interface EventSubscription extends JsonObject public const FIELD_TYPES = 'types'; /** - *

Unique identifier for the type of resource, for example, import-api.

+ *

Unique identifier for the type of resource.

* * @return null|string @@ -27,7 +27,7 @@ public function getResourceTypeId(); /** *

Must contain valid event types for the resource. * For example, for resource type import-api the event type ImportContainerCreated is valid. - * If no types are given, the Subscription will receive all events for this resource.

+ * If no types are given, the Subscription will receive all events for the defined resource type.

* * @return null|array diff --git a/lib/commercetools-api/src/Models/Subscription/EventSubscriptionBuilder.php b/lib/commercetools-api/src/Models/Subscription/EventSubscriptionBuilder.php index 23d9549d331..ae28a9c0294 100644 --- a/lib/commercetools-api/src/Models/Subscription/EventSubscriptionBuilder.php +++ b/lib/commercetools-api/src/Models/Subscription/EventSubscriptionBuilder.php @@ -33,7 +33,7 @@ final class EventSubscriptionBuilder implements Builder private $types; /** - *

Unique identifier for the type of resource, for example, import-api.

+ *

Unique identifier for the type of resource.

* * @return null|string @@ -46,7 +46,7 @@ public function getResourceTypeId() /** *

Must contain valid event types for the resource. * For example, for resource type import-api the event type ImportContainerCreated is valid. - * If no types are given, the Subscription will receive all events for this resource.

+ * If no types are given, the Subscription will receive all events for the defined resource type.

* * @return null|array diff --git a/lib/commercetools-api/src/Models/Subscription/EventSubscriptionModel.php b/lib/commercetools-api/src/Models/Subscription/EventSubscriptionModel.php index 512cd6d3893..c3efcd78329 100644 --- a/lib/commercetools-api/src/Models/Subscription/EventSubscriptionModel.php +++ b/lib/commercetools-api/src/Models/Subscription/EventSubscriptionModel.php @@ -44,7 +44,7 @@ public function __construct( } /** - *

Unique identifier for the type of resource, for example, import-api.

+ *

Unique identifier for the type of resource.

* * * @return null|string @@ -66,7 +66,7 @@ public function getResourceTypeId() /** *

Must contain valid event types for the resource. * For example, for resource type import-api the event type ImportContainerCreated is valid. - * If no types are given, the Subscription will receive all events for this resource.

+ * If no types are given, the Subscription will receive all events for the defined resource type.

* * * @return null|array diff --git a/references.txt b/references.txt index d1dbb4f80ba..0ad3129253d 100644 --- a/references.txt +++ b/references.txt @@ -417,3 +417,4 @@ ab2859c84d9f146e5d8556e905538b92af4aa044 5f7c0bef26fa70b6a3ec382455b56146e3088e0e 5f7c0bef26fa70b6a3ec382455b56146e3088e0e 7c59b29681399c1a3000934fd59a46c10cbe5401 +dd595db3882a9eef83a47515f013be37deae6bff