diff --git a/changes.md b/changes.md index faecfb724c2..938b93a9a8f 100644 --- a/changes.md +++ b/changes.md @@ -24,6 +24,12 @@ - added type `CountOnCustomLineItemUnits` - added type `CountOnLineItemUnits` - added type `PatternComponent` +- added type `ShoppingListLineItemAddedMessage` +- added type `ShoppingListLineItemRemovedMessage` +- added type `ShoppingListMessage` +- added type `ShoppingListLineItemAddedMessagePayload` +- added type `ShoppingListLineItemRemovedMessagePayload` +- added type `ShoppingListMessagePayload` @@ -31,6 +37,7 @@ Added Enum(s) - added enum `Canceled` to type `ShipmentState` +- added enum `shopping-list` to type `MessageSubscriptionResourceTypeId` diff --git a/lib/commercetools-api/src/Models/Common/BaseResource.php b/lib/commercetools-api/src/Models/Common/BaseResource.php index 04d148df18b..762876f4afa 100644 --- a/lib/commercetools-api/src/Models/Common/BaseResource.php +++ b/lib/commercetools-api/src/Models/Common/BaseResource.php @@ -189,6 +189,7 @@ use Commercetools\Api\Models\Message\ReviewCreatedMessage; use Commercetools\Api\Models\Message\ReviewRatingSetMessage; use Commercetools\Api\Models\Message\ReviewStateTransitionMessage; +use Commercetools\Api\Models\Message\ShoppingListMessage; use Commercetools\Api\Models\Message\StagedQuoteCreatedMessage; use Commercetools\Api\Models\Message\StagedQuoteDeletedMessage; use Commercetools\Api\Models\Message\StagedQuoteSellerCommentSetMessage; diff --git a/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php b/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php index 844267a875e..4782981e9e0 100644 --- a/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php +++ b/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php @@ -370,6 +370,8 @@ use Commercetools\Api\Models\Message\ReviewRatingSetMessageBuilder; use Commercetools\Api\Models\Message\ReviewStateTransitionMessage; use Commercetools\Api\Models\Message\ReviewStateTransitionMessageBuilder; +use Commercetools\Api\Models\Message\ShoppingListMessage; +use Commercetools\Api\Models\Message\ShoppingListMessageBuilder; use Commercetools\Api\Models\Message\StagedQuoteCreatedMessage; use Commercetools\Api\Models\Message\StagedQuoteCreatedMessageBuilder; use Commercetools\Api\Models\Message\StagedQuoteDeletedMessage; diff --git a/lib/commercetools-api/src/Models/Common/BaseResourceModel.php b/lib/commercetools-api/src/Models/Common/BaseResourceModel.php index cc20c0ff5db..c60bcc585ef 100644 --- a/lib/commercetools-api/src/Models/Common/BaseResourceModel.php +++ b/lib/commercetools-api/src/Models/Common/BaseResourceModel.php @@ -370,6 +370,8 @@ use Commercetools\Api\Models\Message\ReviewRatingSetMessageModel; use Commercetools\Api\Models\Message\ReviewStateTransitionMessage; use Commercetools\Api\Models\Message\ReviewStateTransitionMessageModel; +use Commercetools\Api\Models\Message\ShoppingListMessage; +use Commercetools\Api\Models\Message\ShoppingListMessageModel; use Commercetools\Api\Models\Message\StagedQuoteCreatedMessage; use Commercetools\Api\Models\Message\StagedQuoteCreatedMessageModel; use Commercetools\Api\Models\Message\StagedQuoteDeletedMessage; diff --git a/lib/commercetools-api/src/Models/Message/MessageModel.php b/lib/commercetools-api/src/Models/Message/MessageModel.php index 59ef6bdb299..fb3b4b9571b 100644 --- a/lib/commercetools-api/src/Models/Message/MessageModel.php +++ b/lib/commercetools-api/src/Models/Message/MessageModel.php @@ -314,6 +314,8 @@ final class MessageModel extends JsonObjectModel implements Message 'ReviewCreated' => ReviewCreatedMessageModel::class, 'ReviewRatingSet' => ReviewRatingSetMessageModel::class, 'ReviewStateTransition' => ReviewStateTransitionMessageModel::class, + 'ShoppingListLineItemAdded' => ShoppingListLineItemAddedMessageModel::class, + 'ShoppingListLineItemRemoved' => ShoppingListLineItemRemovedMessageModel::class, 'StagedQuoteCreated' => StagedQuoteCreatedMessageModel::class, 'StagedQuoteDeleted' => StagedQuoteDeletedMessageModel::class, 'StagedQuoteSellerCommentSet' => StagedQuoteSellerCommentSetMessageModel::class, diff --git a/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php index cd5a8bd8f17..401067fccf2 100644 --- a/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php +++ b/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php @@ -245,6 +245,8 @@ final class MessagePayloadModel extends JsonObjectModel implements MessagePayloa 'ReviewCreated' => ReviewCreatedMessagePayloadModel::class, 'ReviewRatingSet' => ReviewRatingSetMessagePayloadModel::class, 'ReviewStateTransition' => ReviewStateTransitionMessagePayloadModel::class, + 'ShoppingListLineItemAdded' => ShoppingListLineItemAddedMessagePayloadModel::class, + 'ShoppingListLineItemRemoved' => ShoppingListLineItemRemovedMessagePayloadModel::class, 'ShoppingListStoreSet' => ShoppingListStoreSetMessagePayloadModel::class, 'StagedQuoteCreated' => StagedQuoteCreatedMessagePayloadModel::class, 'StagedQuoteDeleted' => StagedQuoteDeletedMessagePayloadModel::class, diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessage.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessage.php new file mode 100644 index 00000000000..3cb2082b8c4 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessage.php @@ -0,0 +1,31 @@ +Line Item that was added to the ShoppingList.

+ * + + * @return null|ShoppingListLineItem + */ + public function getLineItem(); + + /** + * @param ?ShoppingListLineItem $lineItem + */ + public function setLineItem(?ShoppingListLineItem $lineItem): void; +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessageBuilder.php new file mode 100644 index 00000000000..cbad4623266 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessageBuilder.php @@ -0,0 +1,417 @@ + + */ +final class ShoppingListLineItemAddedMessageBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?int + */ + private $version; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var ?DateTimeImmutable + */ + private $lastModifiedAt; + + /** + + * @var null|LastModifiedBy|LastModifiedByBuilder + */ + private $lastModifiedBy; + + /** + + * @var null|CreatedBy|CreatedByBuilder + */ + private $createdBy; + + /** + + * @var ?int + */ + private $sequenceNumber; + + /** + + * @var null|Reference|ReferenceBuilder + */ + private $resource; + + /** + + * @var ?int + */ + private $resourceVersion; + + /** + + * @var null|UserProvidedIdentifiers|UserProvidedIdentifiersBuilder + */ + private $resourceUserProvidedIdentifiers; + + /** + + * @var null|ShoppingListLineItem|ShoppingListLineItemBuilder + */ + private $lineItem; + + /** + *

Unique identifier of the Message. Can be used to track which Messages have been processed.

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

Version of a resource. In case of Messages, this is always 1.

+ * + + * @return null|int + */ + public function getVersion() + { + return $this->version; + } + + /** + *

Date and time (UTC) the Message was generated.

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

Value of createdAt.

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

IDs and references that last modified the Message.

+ * + + * @return null|LastModifiedBy + */ + public function getLastModifiedBy() + { + return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy; + } + + /** + *

IDs and references that created the Message.

+ * + + * @return null|CreatedBy + */ + public function getCreatedBy() + { + return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy; + } + + /** + *

Message number in relation to other Messages for a given resource. The sequenceNumber of the next Message for the resource is the successor of the sequenceNumber of the current Message. Meaning, the sequenceNumber of the next Message equals the sequenceNumber of the current Message + 1. + * sequenceNumber can be used to ensure that Messages are processed in the correct order for a particular resource.

+ * + + * @return null|int + */ + public function getSequenceNumber() + { + return $this->sequenceNumber; + } + + /** + *

Reference to the resource on which the change or action was performed.

+ * + + * @return null|Reference + */ + public function getResource() + { + return $this->resource instanceof ReferenceBuilder ? $this->resource->build() : $this->resource; + } + + /** + *

Version of the resource on which the change or action was performed.

+ * + + * @return null|int + */ + public function getResourceVersion() + { + return $this->resourceVersion; + } + + /** + *

User-provided identifiers of the resource, such as key or externalId. Only present if the resource has such identifiers.

+ * + + * @return null|UserProvidedIdentifiers + */ + public function getResourceUserProvidedIdentifiers() + { + return $this->resourceUserProvidedIdentifiers instanceof UserProvidedIdentifiersBuilder ? $this->resourceUserProvidedIdentifiers->build() : $this->resourceUserProvidedIdentifiers; + } + + /** + *

Line Item that was added to the ShoppingList.

+ * + + * @return null|ShoppingListLineItem + */ + public function getLineItem() + { + return $this->lineItem instanceof ShoppingListLineItemBuilder ? $this->lineItem->build() : $this->lineItem; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?int $version + * @return $this + */ + public function withVersion(?int $version) + { + $this->version = $version; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + * @return $this + */ + public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt) + { + $this->lastModifiedAt = $lastModifiedAt; + + return $this; + } + + /** + * @param ?LastModifiedBy $lastModifiedBy + * @return $this + */ + public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy) + { + $this->lastModifiedBy = $lastModifiedBy; + + return $this; + } + + /** + * @param ?CreatedBy $createdBy + * @return $this + */ + public function withCreatedBy(?CreatedBy $createdBy) + { + $this->createdBy = $createdBy; + + return $this; + } + + /** + * @param ?int $sequenceNumber + * @return $this + */ + public function withSequenceNumber(?int $sequenceNumber) + { + $this->sequenceNumber = $sequenceNumber; + + return $this; + } + + /** + * @param ?Reference $resource + * @return $this + */ + public function withResource(?Reference $resource) + { + $this->resource = $resource; + + return $this; + } + + /** + * @param ?int $resourceVersion + * @return $this + */ + public function withResourceVersion(?int $resourceVersion) + { + $this->resourceVersion = $resourceVersion; + + return $this; + } + + /** + * @param ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers + * @return $this + */ + public function withResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers) + { + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + + return $this; + } + + /** + * @param ?ShoppingListLineItem $lineItem + * @return $this + */ + public function withLineItem(?ShoppingListLineItem $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @deprecated use withLastModifiedBy() instead + * @return $this + */ + public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy) + { + $this->lastModifiedBy = $lastModifiedBy; + + return $this; + } + + /** + * @deprecated use withCreatedBy() instead + * @return $this + */ + public function withCreatedByBuilder(?CreatedByBuilder $createdBy) + { + $this->createdBy = $createdBy; + + return $this; + } + + /** + * @deprecated use withResource() instead + * @return $this + */ + public function withResourceBuilder(?ReferenceBuilder $resource) + { + $this->resource = $resource; + + return $this; + } + + /** + * @deprecated use withResourceUserProvidedIdentifiers() instead + * @return $this + */ + public function withResourceUserProvidedIdentifiersBuilder(?UserProvidedIdentifiersBuilder $resourceUserProvidedIdentifiers) + { + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + + return $this; + } + + /** + * @deprecated use withLineItem() instead + * @return $this + */ + public function withLineItemBuilder(?ShoppingListLineItemBuilder $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + public function build(): ShoppingListLineItemAddedMessage + { + return new ShoppingListLineItemAddedMessageModel( + $this->id, + $this->version, + $this->createdAt, + $this->lastModifiedAt, + $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy, + $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy, + $this->sequenceNumber, + $this->resource instanceof ReferenceBuilder ? $this->resource->build() : $this->resource, + $this->resourceVersion, + $this->resourceUserProvidedIdentifiers instanceof UserProvidedIdentifiersBuilder ? $this->resourceUserProvidedIdentifiers->build() : $this->resourceUserProvidedIdentifiers, + $this->lineItem instanceof ShoppingListLineItemBuilder ? $this->lineItem->build() : $this->lineItem + ); + } + + public static function of(): ShoppingListLineItemAddedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessageCollection.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessageCollection.php new file mode 100644 index 00000000000..ce01fe5a76d --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method ShoppingListLineItemAddedMessage current() + * @method ShoppingListLineItemAddedMessage end() + * @method ShoppingListLineItemAddedMessage at($offset) + */ +class ShoppingListLineItemAddedMessageCollection extends ShoppingListMessageCollection +{ + /** + * @psalm-assert ShoppingListLineItemAddedMessage $value + * @psalm-param ShoppingListLineItemAddedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return ShoppingListLineItemAddedMessageCollection + */ + public function add($value) + { + if (!$value instanceof ShoppingListLineItemAddedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ShoppingListLineItemAddedMessage + */ + protected function mapper() + { + return function (?int $index): ?ShoppingListLineItemAddedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ShoppingListLineItemAddedMessage $data */ + $data = ShoppingListLineItemAddedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessageModel.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessageModel.php new file mode 100644 index 00000000000..bede32af206 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessageModel.php @@ -0,0 +1,493 @@ +id = $id; + $this->version = $version; + $this->createdAt = $createdAt; + $this->lastModifiedAt = $lastModifiedAt; + $this->lastModifiedBy = $lastModifiedBy; + $this->createdBy = $createdBy; + $this->sequenceNumber = $sequenceNumber; + $this->resource = $resource; + $this->resourceVersion = $resourceVersion; + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + $this->lineItem = $lineItem; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Message. Can be used to track which Messages have been processed.

+ * + * + * @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; + } + + /** + *

Version of a resource. In case of Messages, this is always 1.

+ * + * + * @return null|int + */ + public function getVersion() + { + if (is_null($this->version)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_VERSION); + if (is_null($data)) { + return null; + } + $this->version = (int) $data; + } + + return $this->version; + } + + /** + *

Date and time (UTC) the Message 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; + } + + /** + *

Value of createdAt.

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

IDs and references that last modified the Message.

+ * + * + * @return null|LastModifiedBy + */ + public function getLastModifiedBy() + { + if (is_null($this->lastModifiedBy)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_LAST_MODIFIED_BY); + if (is_null($data)) { + return null; + } + + $this->lastModifiedBy = LastModifiedByModel::of($data); + } + + return $this->lastModifiedBy; + } + + /** + *

IDs and references that created the Message.

+ * + * + * @return null|CreatedBy + */ + public function getCreatedBy() + { + if (is_null($this->createdBy)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CREATED_BY); + if (is_null($data)) { + return null; + } + + $this->createdBy = CreatedByModel::of($data); + } + + return $this->createdBy; + } + + /** + *

Message number in relation to other Messages for a given resource. The sequenceNumber of the next Message for the resource is the successor of the sequenceNumber of the current Message. Meaning, the sequenceNumber of the next Message equals the sequenceNumber of the current Message + 1. + * sequenceNumber can be used to ensure that Messages are processed in the correct order for a particular resource.

+ * + * + * @return null|int + */ + public function getSequenceNumber() + { + if (is_null($this->sequenceNumber)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_SEQUENCE_NUMBER); + if (is_null($data)) { + return null; + } + $this->sequenceNumber = (int) $data; + } + + return $this->sequenceNumber; + } + + /** + *

Reference to the resource on which the change or action was performed.

+ * + * + * @return null|Reference + */ + public function getResource() + { + if (is_null($this->resource)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RESOURCE); + if (is_null($data)) { + return null; + } + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->resource = $className::of($data); + } + + return $this->resource; + } + + /** + *

Version of the resource on which the change or action was performed.

+ * + * + * @return null|int + */ + public function getResourceVersion() + { + if (is_null($this->resourceVersion)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_RESOURCE_VERSION); + if (is_null($data)) { + return null; + } + $this->resourceVersion = (int) $data; + } + + return $this->resourceVersion; + } + + /** + *

Message Type of the Message.

+ * + * + * @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; + } + + /** + *

User-provided identifiers of the resource, such as key or externalId. Only present if the resource has such identifiers.

+ * + * + * @return null|UserProvidedIdentifiers + */ + public function getResourceUserProvidedIdentifiers() + { + if (is_null($this->resourceUserProvidedIdentifiers)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS); + if (is_null($data)) { + return null; + } + + $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data); + } + + return $this->resourceUserProvidedIdentifiers; + } + + /** + *

Line Item that was added to the ShoppingList.

+ * + * + * @return null|ShoppingListLineItem + */ + public function getLineItem() + { + if (is_null($this->lineItem)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_LINE_ITEM); + if (is_null($data)) { + return null; + } + + $this->lineItem = ShoppingListLineItemModel::of($data); + } + + return $this->lineItem; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void + { + $this->version = $version; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + */ + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void + { + $this->lastModifiedAt = $lastModifiedAt; + } + + /** + * @param ?LastModifiedBy $lastModifiedBy + */ + public function setLastModifiedBy(?LastModifiedBy $lastModifiedBy): void + { + $this->lastModifiedBy = $lastModifiedBy; + } + + /** + * @param ?CreatedBy $createdBy + */ + public function setCreatedBy(?CreatedBy $createdBy): void + { + $this->createdBy = $createdBy; + } + + /** + * @param ?int $sequenceNumber + */ + public function setSequenceNumber(?int $sequenceNumber): void + { + $this->sequenceNumber = $sequenceNumber; + } + + /** + * @param ?Reference $resource + */ + public function setResource(?Reference $resource): void + { + $this->resource = $resource; + } + + /** + * @param ?int $resourceVersion + */ + public function setResourceVersion(?int $resourceVersion): void + { + $this->resourceVersion = $resourceVersion; + } + + /** + * @param ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers + */ + public function setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers): void + { + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + } + + /** + * @param ?ShoppingListLineItem $lineItem + */ + public function setLineItem(?ShoppingListLineItem $lineItem): void + { + $this->lineItem = $lineItem; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) { + $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayload.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayload.php new file mode 100644 index 00000000000..49ee4ea94f4 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayload.php @@ -0,0 +1,31 @@ +Line Item that was added to the ShoppingList.

+ * + + * @return null|ShoppingListLineItem + */ + public function getLineItem(); + + /** + * @param ?ShoppingListLineItem $lineItem + */ + public function setLineItem(?ShoppingListLineItem $lineItem): void; +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayloadBuilder.php new file mode 100644 index 00000000000..33298d536e9 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayloadBuilder.php @@ -0,0 +1,75 @@ + + */ +final class ShoppingListLineItemAddedMessagePayloadBuilder implements Builder +{ + /** + + * @var null|ShoppingListLineItem|ShoppingListLineItemBuilder + */ + private $lineItem; + + /** + *

Line Item that was added to the ShoppingList.

+ * + + * @return null|ShoppingListLineItem + */ + public function getLineItem() + { + return $this->lineItem instanceof ShoppingListLineItemBuilder ? $this->lineItem->build() : $this->lineItem; + } + + /** + * @param ?ShoppingListLineItem $lineItem + * @return $this + */ + public function withLineItem(?ShoppingListLineItem $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @deprecated use withLineItem() instead + * @return $this + */ + public function withLineItemBuilder(?ShoppingListLineItemBuilder $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + public function build(): ShoppingListLineItemAddedMessagePayload + { + return new ShoppingListLineItemAddedMessagePayloadModel( + $this->lineItem instanceof ShoppingListLineItemBuilder ? $this->lineItem->build() : $this->lineItem + ); + } + + public static function of(): ShoppingListLineItemAddedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayloadCollection.php new file mode 100644 index 00000000000..31781d1e940 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method ShoppingListLineItemAddedMessagePayload current() + * @method ShoppingListLineItemAddedMessagePayload end() + * @method ShoppingListLineItemAddedMessagePayload at($offset) + */ +class ShoppingListLineItemAddedMessagePayloadCollection extends ShoppingListMessagePayloadCollection +{ + /** + * @psalm-assert ShoppingListLineItemAddedMessagePayload $value + * @psalm-param ShoppingListLineItemAddedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return ShoppingListLineItemAddedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof ShoppingListLineItemAddedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ShoppingListLineItemAddedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?ShoppingListLineItemAddedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ShoppingListLineItemAddedMessagePayload $data */ + $data = ShoppingListLineItemAddedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayloadModel.php new file mode 100644 index 00000000000..da9b8c53e42 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemAddedMessagePayloadModel.php @@ -0,0 +1,96 @@ +lineItem = $lineItem; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + * + * @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; + } + + /** + *

Line Item that was added to the ShoppingList.

+ * + * + * @return null|ShoppingListLineItem + */ + public function getLineItem() + { + if (is_null($this->lineItem)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_LINE_ITEM); + if (is_null($data)) { + return null; + } + + $this->lineItem = ShoppingListLineItemModel::of($data); + } + + return $this->lineItem; + } + + + /** + * @param ?ShoppingListLineItem $lineItem + */ + public function setLineItem(?ShoppingListLineItem $lineItem): void + { + $this->lineItem = $lineItem; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessage.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessage.php new file mode 100644 index 00000000000..5b74c4c4e30 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessage.php @@ -0,0 +1,31 @@ +Line Item that was removed from the ShoppingList.

+ * + + * @return null|ShoppingListLineItem + */ + public function getLineItem(); + + /** + * @param ?ShoppingListLineItem $lineItem + */ + public function setLineItem(?ShoppingListLineItem $lineItem): void; +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessageBuilder.php new file mode 100644 index 00000000000..2bb5e8bc8ec --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessageBuilder.php @@ -0,0 +1,417 @@ + + */ +final class ShoppingListLineItemRemovedMessageBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?int + */ + private $version; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var ?DateTimeImmutable + */ + private $lastModifiedAt; + + /** + + * @var null|LastModifiedBy|LastModifiedByBuilder + */ + private $lastModifiedBy; + + /** + + * @var null|CreatedBy|CreatedByBuilder + */ + private $createdBy; + + /** + + * @var ?int + */ + private $sequenceNumber; + + /** + + * @var null|Reference|ReferenceBuilder + */ + private $resource; + + /** + + * @var ?int + */ + private $resourceVersion; + + /** + + * @var null|UserProvidedIdentifiers|UserProvidedIdentifiersBuilder + */ + private $resourceUserProvidedIdentifiers; + + /** + + * @var null|ShoppingListLineItem|ShoppingListLineItemBuilder + */ + private $lineItem; + + /** + *

Unique identifier of the Message. Can be used to track which Messages have been processed.

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

Version of a resource. In case of Messages, this is always 1.

+ * + + * @return null|int + */ + public function getVersion() + { + return $this->version; + } + + /** + *

Date and time (UTC) the Message was generated.

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

Value of createdAt.

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

IDs and references that last modified the Message.

+ * + + * @return null|LastModifiedBy + */ + public function getLastModifiedBy() + { + return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy; + } + + /** + *

IDs and references that created the Message.

+ * + + * @return null|CreatedBy + */ + public function getCreatedBy() + { + return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy; + } + + /** + *

Message number in relation to other Messages for a given resource. The sequenceNumber of the next Message for the resource is the successor of the sequenceNumber of the current Message. Meaning, the sequenceNumber of the next Message equals the sequenceNumber of the current Message + 1. + * sequenceNumber can be used to ensure that Messages are processed in the correct order for a particular resource.

+ * + + * @return null|int + */ + public function getSequenceNumber() + { + return $this->sequenceNumber; + } + + /** + *

Reference to the resource on which the change or action was performed.

+ * + + * @return null|Reference + */ + public function getResource() + { + return $this->resource instanceof ReferenceBuilder ? $this->resource->build() : $this->resource; + } + + /** + *

Version of the resource on which the change or action was performed.

+ * + + * @return null|int + */ + public function getResourceVersion() + { + return $this->resourceVersion; + } + + /** + *

User-provided identifiers of the resource, such as key or externalId. Only present if the resource has such identifiers.

+ * + + * @return null|UserProvidedIdentifiers + */ + public function getResourceUserProvidedIdentifiers() + { + return $this->resourceUserProvidedIdentifiers instanceof UserProvidedIdentifiersBuilder ? $this->resourceUserProvidedIdentifiers->build() : $this->resourceUserProvidedIdentifiers; + } + + /** + *

Line Item that was removed from the ShoppingList.

+ * + + * @return null|ShoppingListLineItem + */ + public function getLineItem() + { + return $this->lineItem instanceof ShoppingListLineItemBuilder ? $this->lineItem->build() : $this->lineItem; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?int $version + * @return $this + */ + public function withVersion(?int $version) + { + $this->version = $version; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + * @return $this + */ + public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt) + { + $this->lastModifiedAt = $lastModifiedAt; + + return $this; + } + + /** + * @param ?LastModifiedBy $lastModifiedBy + * @return $this + */ + public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy) + { + $this->lastModifiedBy = $lastModifiedBy; + + return $this; + } + + /** + * @param ?CreatedBy $createdBy + * @return $this + */ + public function withCreatedBy(?CreatedBy $createdBy) + { + $this->createdBy = $createdBy; + + return $this; + } + + /** + * @param ?int $sequenceNumber + * @return $this + */ + public function withSequenceNumber(?int $sequenceNumber) + { + $this->sequenceNumber = $sequenceNumber; + + return $this; + } + + /** + * @param ?Reference $resource + * @return $this + */ + public function withResource(?Reference $resource) + { + $this->resource = $resource; + + return $this; + } + + /** + * @param ?int $resourceVersion + * @return $this + */ + public function withResourceVersion(?int $resourceVersion) + { + $this->resourceVersion = $resourceVersion; + + return $this; + } + + /** + * @param ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers + * @return $this + */ + public function withResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers) + { + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + + return $this; + } + + /** + * @param ?ShoppingListLineItem $lineItem + * @return $this + */ + public function withLineItem(?ShoppingListLineItem $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @deprecated use withLastModifiedBy() instead + * @return $this + */ + public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy) + { + $this->lastModifiedBy = $lastModifiedBy; + + return $this; + } + + /** + * @deprecated use withCreatedBy() instead + * @return $this + */ + public function withCreatedByBuilder(?CreatedByBuilder $createdBy) + { + $this->createdBy = $createdBy; + + return $this; + } + + /** + * @deprecated use withResource() instead + * @return $this + */ + public function withResourceBuilder(?ReferenceBuilder $resource) + { + $this->resource = $resource; + + return $this; + } + + /** + * @deprecated use withResourceUserProvidedIdentifiers() instead + * @return $this + */ + public function withResourceUserProvidedIdentifiersBuilder(?UserProvidedIdentifiersBuilder $resourceUserProvidedIdentifiers) + { + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + + return $this; + } + + /** + * @deprecated use withLineItem() instead + * @return $this + */ + public function withLineItemBuilder(?ShoppingListLineItemBuilder $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + public function build(): ShoppingListLineItemRemovedMessage + { + return new ShoppingListLineItemRemovedMessageModel( + $this->id, + $this->version, + $this->createdAt, + $this->lastModifiedAt, + $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy, + $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy, + $this->sequenceNumber, + $this->resource instanceof ReferenceBuilder ? $this->resource->build() : $this->resource, + $this->resourceVersion, + $this->resourceUserProvidedIdentifiers instanceof UserProvidedIdentifiersBuilder ? $this->resourceUserProvidedIdentifiers->build() : $this->resourceUserProvidedIdentifiers, + $this->lineItem instanceof ShoppingListLineItemBuilder ? $this->lineItem->build() : $this->lineItem + ); + } + + public static function of(): ShoppingListLineItemRemovedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessageCollection.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessageCollection.php new file mode 100644 index 00000000000..721e5ca9b64 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method ShoppingListLineItemRemovedMessage current() + * @method ShoppingListLineItemRemovedMessage end() + * @method ShoppingListLineItemRemovedMessage at($offset) + */ +class ShoppingListLineItemRemovedMessageCollection extends ShoppingListMessageCollection +{ + /** + * @psalm-assert ShoppingListLineItemRemovedMessage $value + * @psalm-param ShoppingListLineItemRemovedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return ShoppingListLineItemRemovedMessageCollection + */ + public function add($value) + { + if (!$value instanceof ShoppingListLineItemRemovedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ShoppingListLineItemRemovedMessage + */ + protected function mapper() + { + return function (?int $index): ?ShoppingListLineItemRemovedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ShoppingListLineItemRemovedMessage $data */ + $data = ShoppingListLineItemRemovedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessageModel.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessageModel.php new file mode 100644 index 00000000000..6afb6e63ef0 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessageModel.php @@ -0,0 +1,493 @@ +id = $id; + $this->version = $version; + $this->createdAt = $createdAt; + $this->lastModifiedAt = $lastModifiedAt; + $this->lastModifiedBy = $lastModifiedBy; + $this->createdBy = $createdBy; + $this->sequenceNumber = $sequenceNumber; + $this->resource = $resource; + $this->resourceVersion = $resourceVersion; + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + $this->lineItem = $lineItem; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Unique identifier of the Message. Can be used to track which Messages have been processed.

+ * + * + * @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; + } + + /** + *

Version of a resource. In case of Messages, this is always 1.

+ * + * + * @return null|int + */ + public function getVersion() + { + if (is_null($this->version)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_VERSION); + if (is_null($data)) { + return null; + } + $this->version = (int) $data; + } + + return $this->version; + } + + /** + *

Date and time (UTC) the Message 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; + } + + /** + *

Value of createdAt.

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

IDs and references that last modified the Message.

+ * + * + * @return null|LastModifiedBy + */ + public function getLastModifiedBy() + { + if (is_null($this->lastModifiedBy)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_LAST_MODIFIED_BY); + if (is_null($data)) { + return null; + } + + $this->lastModifiedBy = LastModifiedByModel::of($data); + } + + return $this->lastModifiedBy; + } + + /** + *

IDs and references that created the Message.

+ * + * + * @return null|CreatedBy + */ + public function getCreatedBy() + { + if (is_null($this->createdBy)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CREATED_BY); + if (is_null($data)) { + return null; + } + + $this->createdBy = CreatedByModel::of($data); + } + + return $this->createdBy; + } + + /** + *

Message number in relation to other Messages for a given resource. The sequenceNumber of the next Message for the resource is the successor of the sequenceNumber of the current Message. Meaning, the sequenceNumber of the next Message equals the sequenceNumber of the current Message + 1. + * sequenceNumber can be used to ensure that Messages are processed in the correct order for a particular resource.

+ * + * + * @return null|int + */ + public function getSequenceNumber() + { + if (is_null($this->sequenceNumber)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_SEQUENCE_NUMBER); + if (is_null($data)) { + return null; + } + $this->sequenceNumber = (int) $data; + } + + return $this->sequenceNumber; + } + + /** + *

Reference to the resource on which the change or action was performed.

+ * + * + * @return null|Reference + */ + public function getResource() + { + if (is_null($this->resource)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RESOURCE); + if (is_null($data)) { + return null; + } + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->resource = $className::of($data); + } + + return $this->resource; + } + + /** + *

Version of the resource on which the change or action was performed.

+ * + * + * @return null|int + */ + public function getResourceVersion() + { + if (is_null($this->resourceVersion)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_RESOURCE_VERSION); + if (is_null($data)) { + return null; + } + $this->resourceVersion = (int) $data; + } + + return $this->resourceVersion; + } + + /** + *

Message Type of the Message.

+ * + * + * @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; + } + + /** + *

User-provided identifiers of the resource, such as key or externalId. Only present if the resource has such identifiers.

+ * + * + * @return null|UserProvidedIdentifiers + */ + public function getResourceUserProvidedIdentifiers() + { + if (is_null($this->resourceUserProvidedIdentifiers)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS); + if (is_null($data)) { + return null; + } + + $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data); + } + + return $this->resourceUserProvidedIdentifiers; + } + + /** + *

Line Item that was removed from the ShoppingList.

+ * + * + * @return null|ShoppingListLineItem + */ + public function getLineItem() + { + if (is_null($this->lineItem)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_LINE_ITEM); + if (is_null($data)) { + return null; + } + + $this->lineItem = ShoppingListLineItemModel::of($data); + } + + return $this->lineItem; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void + { + $this->version = $version; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + */ + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void + { + $this->lastModifiedAt = $lastModifiedAt; + } + + /** + * @param ?LastModifiedBy $lastModifiedBy + */ + public function setLastModifiedBy(?LastModifiedBy $lastModifiedBy): void + { + $this->lastModifiedBy = $lastModifiedBy; + } + + /** + * @param ?CreatedBy $createdBy + */ + public function setCreatedBy(?CreatedBy $createdBy): void + { + $this->createdBy = $createdBy; + } + + /** + * @param ?int $sequenceNumber + */ + public function setSequenceNumber(?int $sequenceNumber): void + { + $this->sequenceNumber = $sequenceNumber; + } + + /** + * @param ?Reference $resource + */ + public function setResource(?Reference $resource): void + { + $this->resource = $resource; + } + + /** + * @param ?int $resourceVersion + */ + public function setResourceVersion(?int $resourceVersion): void + { + $this->resourceVersion = $resourceVersion; + } + + /** + * @param ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers + */ + public function setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers): void + { + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + } + + /** + * @param ?ShoppingListLineItem $lineItem + */ + public function setLineItem(?ShoppingListLineItem $lineItem): void + { + $this->lineItem = $lineItem; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) { + $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayload.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayload.php new file mode 100644 index 00000000000..3874997b673 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayload.php @@ -0,0 +1,31 @@ +Line Item that was removed from the ShoppingList.

+ * + + * @return null|ShoppingListLineItem + */ + public function getLineItem(); + + /** + * @param ?ShoppingListLineItem $lineItem + */ + public function setLineItem(?ShoppingListLineItem $lineItem): void; +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayloadBuilder.php new file mode 100644 index 00000000000..ab266499c0f --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayloadBuilder.php @@ -0,0 +1,75 @@ + + */ +final class ShoppingListLineItemRemovedMessagePayloadBuilder implements Builder +{ + /** + + * @var null|ShoppingListLineItem|ShoppingListLineItemBuilder + */ + private $lineItem; + + /** + *

Line Item that was removed from the ShoppingList.

+ * + + * @return null|ShoppingListLineItem + */ + public function getLineItem() + { + return $this->lineItem instanceof ShoppingListLineItemBuilder ? $this->lineItem->build() : $this->lineItem; + } + + /** + * @param ?ShoppingListLineItem $lineItem + * @return $this + */ + public function withLineItem(?ShoppingListLineItem $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @deprecated use withLineItem() instead + * @return $this + */ + public function withLineItemBuilder(?ShoppingListLineItemBuilder $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + public function build(): ShoppingListLineItemRemovedMessagePayload + { + return new ShoppingListLineItemRemovedMessagePayloadModel( + $this->lineItem instanceof ShoppingListLineItemBuilder ? $this->lineItem->build() : $this->lineItem + ); + } + + public static function of(): ShoppingListLineItemRemovedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayloadCollection.php new file mode 100644 index 00000000000..ca2d9d55132 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method ShoppingListLineItemRemovedMessagePayload current() + * @method ShoppingListLineItemRemovedMessagePayload end() + * @method ShoppingListLineItemRemovedMessagePayload at($offset) + */ +class ShoppingListLineItemRemovedMessagePayloadCollection extends ShoppingListMessagePayloadCollection +{ + /** + * @psalm-assert ShoppingListLineItemRemovedMessagePayload $value + * @psalm-param ShoppingListLineItemRemovedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return ShoppingListLineItemRemovedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof ShoppingListLineItemRemovedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ShoppingListLineItemRemovedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?ShoppingListLineItemRemovedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ShoppingListLineItemRemovedMessagePayload $data */ + $data = ShoppingListLineItemRemovedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayloadModel.php new file mode 100644 index 00000000000..09b07351df8 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListLineItemRemovedMessagePayloadModel.php @@ -0,0 +1,96 @@ +lineItem = $lineItem; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + * + * @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; + } + + /** + *

Line Item that was removed from the ShoppingList.

+ * + * + * @return null|ShoppingListLineItem + */ + public function getLineItem() + { + if (is_null($this->lineItem)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_LINE_ITEM); + if (is_null($data)) { + return null; + } + + $this->lineItem = ShoppingListLineItemModel::of($data); + } + + return $this->lineItem; + } + + + /** + * @param ?ShoppingListLineItem $lineItem + */ + public function setLineItem(?ShoppingListLineItem $lineItem): void + { + $this->lineItem = $lineItem; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListMessage.php b/lib/commercetools-api/src/Models/Message/ShoppingListMessage.php new file mode 100644 index 00000000000..5122298c4d7 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListMessage.php @@ -0,0 +1,16 @@ + + */ +final class ShoppingListMessageBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?int + */ + private $version; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var ?DateTimeImmutable + */ + private $lastModifiedAt; + + /** + + * @var null|LastModifiedBy|LastModifiedByBuilder + */ + private $lastModifiedBy; + + /** + + * @var null|CreatedBy|CreatedByBuilder + */ + private $createdBy; + + /** + + * @var ?int + */ + private $sequenceNumber; + + /** + + * @var null|Reference|ReferenceBuilder + */ + private $resource; + + /** + + * @var ?int + */ + private $resourceVersion; + + /** + + * @var null|UserProvidedIdentifiers|UserProvidedIdentifiersBuilder + */ + private $resourceUserProvidedIdentifiers; + + /** + *

Unique identifier of the Message. Can be used to track which Messages have been processed.

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

Version of a resource. In case of Messages, this is always 1.

+ * + + * @return null|int + */ + public function getVersion() + { + return $this->version; + } + + /** + *

Date and time (UTC) the Message was generated.

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

Value of createdAt.

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

IDs and references that last modified the Message.

+ * + + * @return null|LastModifiedBy + */ + public function getLastModifiedBy() + { + return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy; + } + + /** + *

IDs and references that created the Message.

+ * + + * @return null|CreatedBy + */ + public function getCreatedBy() + { + return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy; + } + + /** + *

Message number in relation to other Messages for a given resource. The sequenceNumber of the next Message for the resource is the successor of the sequenceNumber of the current Message. Meaning, the sequenceNumber of the next Message equals the sequenceNumber of the current Message + 1. + * sequenceNumber can be used to ensure that Messages are processed in the correct order for a particular resource.

+ * + + * @return null|int + */ + public function getSequenceNumber() + { + return $this->sequenceNumber; + } + + /** + *

Reference to the resource on which the change or action was performed.

+ * + + * @return null|Reference + */ + public function getResource() + { + return $this->resource instanceof ReferenceBuilder ? $this->resource->build() : $this->resource; + } + + /** + *

Version of the resource on which the change or action was performed.

+ * + + * @return null|int + */ + public function getResourceVersion() + { + return $this->resourceVersion; + } + + /** + *

User-provided identifiers of the resource, such as key or externalId. Only present if the resource has such identifiers.

+ * + + * @return null|UserProvidedIdentifiers + */ + public function getResourceUserProvidedIdentifiers() + { + return $this->resourceUserProvidedIdentifiers instanceof UserProvidedIdentifiersBuilder ? $this->resourceUserProvidedIdentifiers->build() : $this->resourceUserProvidedIdentifiers; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?int $version + * @return $this + */ + public function withVersion(?int $version) + { + $this->version = $version; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt + * @return $this + */ + public function withCreatedAt(?DateTimeImmutable $createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + * @return $this + */ + public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt) + { + $this->lastModifiedAt = $lastModifiedAt; + + return $this; + } + + /** + * @param ?LastModifiedBy $lastModifiedBy + * @return $this + */ + public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy) + { + $this->lastModifiedBy = $lastModifiedBy; + + return $this; + } + + /** + * @param ?CreatedBy $createdBy + * @return $this + */ + public function withCreatedBy(?CreatedBy $createdBy) + { + $this->createdBy = $createdBy; + + return $this; + } + + /** + * @param ?int $sequenceNumber + * @return $this + */ + public function withSequenceNumber(?int $sequenceNumber) + { + $this->sequenceNumber = $sequenceNumber; + + return $this; + } + + /** + * @param ?Reference $resource + * @return $this + */ + public function withResource(?Reference $resource) + { + $this->resource = $resource; + + return $this; + } + + /** + * @param ?int $resourceVersion + * @return $this + */ + public function withResourceVersion(?int $resourceVersion) + { + $this->resourceVersion = $resourceVersion; + + return $this; + } + + /** + * @param ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers + * @return $this + */ + public function withResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers) + { + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + + return $this; + } + + /** + * @deprecated use withLastModifiedBy() instead + * @return $this + */ + public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy) + { + $this->lastModifiedBy = $lastModifiedBy; + + return $this; + } + + /** + * @deprecated use withCreatedBy() instead + * @return $this + */ + public function withCreatedByBuilder(?CreatedByBuilder $createdBy) + { + $this->createdBy = $createdBy; + + return $this; + } + + /** + * @deprecated use withResource() instead + * @return $this + */ + public function withResourceBuilder(?ReferenceBuilder $resource) + { + $this->resource = $resource; + + return $this; + } + + /** + * @deprecated use withResourceUserProvidedIdentifiers() instead + * @return $this + */ + public function withResourceUserProvidedIdentifiersBuilder(?UserProvidedIdentifiersBuilder $resourceUserProvidedIdentifiers) + { + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + + return $this; + } + + public function build(): ShoppingListMessage + { + return new ShoppingListMessageModel( + $this->id, + $this->version, + $this->createdAt, + $this->lastModifiedAt, + $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy, + $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy, + $this->sequenceNumber, + $this->resource instanceof ReferenceBuilder ? $this->resource->build() : $this->resource, + $this->resourceVersion, + $this->resourceUserProvidedIdentifiers instanceof UserProvidedIdentifiersBuilder ? $this->resourceUserProvidedIdentifiers->build() : $this->resourceUserProvidedIdentifiers + ); + } + + public static function of(): ShoppingListMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListMessageCollection.php b/lib/commercetools-api/src/Models/Message/ShoppingListMessageCollection.php new file mode 100644 index 00000000000..8a484d33717 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListMessageCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method ShoppingListMessage current() + * @method ShoppingListMessage end() + * @method ShoppingListMessage at($offset) + */ +class ShoppingListMessageCollection extends MessageCollection +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return ShoppingListMessageCollection + */ + public function add($value) + { + if (!$value instanceof ShoppingListMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?ShoppingListMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = ShoppingListMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListMessageModel.php b/lib/commercetools-api/src/Models/Message/ShoppingListMessageModel.php new file mode 100644 index 00000000000..102d9f4a50a --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListMessageModel.php @@ -0,0 +1,453 @@ +id = $id; + $this->version = $version; + $this->createdAt = $createdAt; + $this->lastModifiedAt = $lastModifiedAt; + $this->lastModifiedBy = $lastModifiedBy; + $this->createdBy = $createdBy; + $this->sequenceNumber = $sequenceNumber; + $this->resource = $resource; + $this->resourceVersion = $resourceVersion; + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + $this->type = $type; + } + + /** + *

Unique identifier of the Message. Can be used to track which Messages have been processed.

+ * + * + * @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; + } + + /** + *

Version of a resource. In case of Messages, this is always 1.

+ * + * + * @return null|int + */ + public function getVersion() + { + if (is_null($this->version)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_VERSION); + if (is_null($data)) { + return null; + } + $this->version = (int) $data; + } + + return $this->version; + } + + /** + *

Date and time (UTC) the Message 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; + } + + /** + *

Value of createdAt.

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

IDs and references that last modified the Message.

+ * + * + * @return null|LastModifiedBy + */ + public function getLastModifiedBy() + { + if (is_null($this->lastModifiedBy)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_LAST_MODIFIED_BY); + if (is_null($data)) { + return null; + } + + $this->lastModifiedBy = LastModifiedByModel::of($data); + } + + return $this->lastModifiedBy; + } + + /** + *

IDs and references that created the Message.

+ * + * + * @return null|CreatedBy + */ + public function getCreatedBy() + { + if (is_null($this->createdBy)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CREATED_BY); + if (is_null($data)) { + return null; + } + + $this->createdBy = CreatedByModel::of($data); + } + + return $this->createdBy; + } + + /** + *

Message number in relation to other Messages for a given resource. The sequenceNumber of the next Message for the resource is the successor of the sequenceNumber of the current Message. Meaning, the sequenceNumber of the next Message equals the sequenceNumber of the current Message + 1. + * sequenceNumber can be used to ensure that Messages are processed in the correct order for a particular resource.

+ * + * + * @return null|int + */ + public function getSequenceNumber() + { + if (is_null($this->sequenceNumber)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_SEQUENCE_NUMBER); + if (is_null($data)) { + return null; + } + $this->sequenceNumber = (int) $data; + } + + return $this->sequenceNumber; + } + + /** + *

Reference to the resource on which the change or action was performed.

+ * + * + * @return null|Reference + */ + public function getResource() + { + if (is_null($this->resource)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RESOURCE); + if (is_null($data)) { + return null; + } + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->resource = $className::of($data); + } + + return $this->resource; + } + + /** + *

Version of the resource on which the change or action was performed.

+ * + * + * @return null|int + */ + public function getResourceVersion() + { + if (is_null($this->resourceVersion)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_RESOURCE_VERSION); + if (is_null($data)) { + return null; + } + $this->resourceVersion = (int) $data; + } + + return $this->resourceVersion; + } + + /** + *

Message Type of the Message.

+ * + * + * @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; + } + + /** + *

User-provided identifiers of the resource, such as key or externalId. Only present if the resource has such identifiers.

+ * + * + * @return null|UserProvidedIdentifiers + */ + public function getResourceUserProvidedIdentifiers() + { + if (is_null($this->resourceUserProvidedIdentifiers)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS); + if (is_null($data)) { + return null; + } + + $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data); + } + + return $this->resourceUserProvidedIdentifiers; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void + { + $this->version = $version; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void + { + $this->createdAt = $createdAt; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + */ + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void + { + $this->lastModifiedAt = $lastModifiedAt; + } + + /** + * @param ?LastModifiedBy $lastModifiedBy + */ + public function setLastModifiedBy(?LastModifiedBy $lastModifiedBy): void + { + $this->lastModifiedBy = $lastModifiedBy; + } + + /** + * @param ?CreatedBy $createdBy + */ + public function setCreatedBy(?CreatedBy $createdBy): void + { + $this->createdBy = $createdBy; + } + + /** + * @param ?int $sequenceNumber + */ + public function setSequenceNumber(?int $sequenceNumber): void + { + $this->sequenceNumber = $sequenceNumber; + } + + /** + * @param ?Reference $resource + */ + public function setResource(?Reference $resource): void + { + $this->resource = $resource; + } + + /** + * @param ?int $resourceVersion + */ + public function setResourceVersion(?int $resourceVersion): void + { + $this->resourceVersion = $resourceVersion; + } + + /** + * @param ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers + */ + public function setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers): void + { + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) { + $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListMessagePayload.php b/lib/commercetools-api/src/Models/Message/ShoppingListMessagePayload.php new file mode 100644 index 00000000000..64cc957518c --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListMessagePayload.php @@ -0,0 +1,16 @@ + + */ +final class ShoppingListMessagePayloadBuilder implements Builder +{ + public function build(): ShoppingListMessagePayload + { + return new ShoppingListMessagePayloadModel( + ); + } + + public static function of(): ShoppingListMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/ShoppingListMessagePayloadCollection.php new file mode 100644 index 00000000000..fb187d80201 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListMessagePayloadCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method ShoppingListMessagePayload current() + * @method ShoppingListMessagePayload end() + * @method ShoppingListMessagePayload at($offset) + */ +class ShoppingListMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return ShoppingListMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof ShoppingListMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?ShoppingListMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = ShoppingListMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/ShoppingListMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/ShoppingListMessagePayloadModel.php new file mode 100644 index 00000000000..ad06ea4d0d2 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/ShoppingListMessagePayloadModel.php @@ -0,0 +1,55 @@ +type = $type; + } + + /** + * + * @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; + } +} diff --git a/references.txt b/references.txt index 824ad884690..02daa1420a9 100644 --- a/references.txt +++ b/references.txt @@ -338,3 +338,4 @@ df53588d26d7953dfdf44166866ca03045f0a70b 6a47ba84abccefcacaf90152614687e121660c5c 9066fb1012d20a92037e102e18a6295bdbcb82e3 4025ec42d633ae6b77320e24f6244d9dce608e6e +7abe530c4e76020a59ffb61623f20b87ae406e02