diff --git a/changes.md b/changes.md index 270731b83ab..ff121811cf2 100644 --- a/changes.md +++ b/changes.md @@ -7,7 +7,9 @@ - added type `BusinessUnitSetUnitTypeAction` - added type `CartDiscountSetDiscountGroupAction` - added type `BestDeal` +- added type `CartMergeMode` - added type `DiscountTypeCombination` +- added type `MergeCartDraft` - added type `Stacking` - added type `CartChangePriceRoundingModeAction` - added type `CartSetCustomLineItemRecurrenceInfoAction` @@ -32,9 +34,11 @@ - added type `ExpiredCustomerEmailTokenError` - added type `ExpiredCustomerPasswordTokenError` - added type `MaxDiscountGroupsReachedError` +- added type `RecurringOrderFailureError` - added type `GraphQLExpiredCustomerEmailTokenError` - added type `GraphQLExpiredCustomerPasswordTokenError` - added type `GraphQLMaxDiscountGroupsReachedError` +- added type `GraphQLRecurringOrderFailureError` - added type `BaseEvent` - added type `CheckoutOrderCreationFailedEvent` - added type `CheckoutPaymentAuthorizationCancelledEvent` @@ -69,6 +73,8 @@ - added type `AssociateRoleNameSetMessage` - added type `BusinessUnitTopLevelUnitSetMessage` - added type `BusinessUnitTypeSetMessage` +- added type `CartFrozenMessage` +- added type `CartUnfrozenMessage` - added type `CustomerDefaultBillingAddressSetMessage` - added type `CustomerDefaultShippingAddressSetMessage` - added type `CustomerGroupAssignmentAddedMessage` @@ -82,6 +88,7 @@ - added type `DiscountGroupSortOrderSetMessage` - added type `OrderBusinessUnitSetMessage` - added type `OrderCreatedFromRecurringOrderMessage` +- added type `OrderPaymentRemovedMessage` - added type `PaymentInterfaceIdSetMessage` - added type `PaymentMethodCreatedMessage` - added type `PaymentMethodCustomFieldAddedMessage` @@ -116,6 +123,7 @@ - added type `RecurringOrderCustomTypeSetMessage` - added type `RecurringOrderDeletedMessage` - added type `RecurringOrderExpiresAtSetMessage` +- added type `RecurringOrderFailedMessage` - added type `RecurringOrderKeySetMessage` - added type `RecurringOrderScheduleSetMessage` - added type `RecurringOrderStartsAtSetMessage` @@ -124,6 +132,8 @@ - added type `AssociateRoleNameSetMessagePayload` - added type `BusinessUnitTopLevelUnitSetMessagePayload` - added type `BusinessUnitTypeSetMessagePayload` +- added type `CartFrozenMessagePayload` +- added type `CartUnfrozenMessagePayload` - added type `CustomerDefaultBillingAddressSetMessagePayload` - added type `CustomerDefaultShippingAddressSetMessagePayload` - added type `CustomerGroupAssignmentAddedMessagePayload` @@ -137,6 +147,7 @@ - added type `DiscountGroupSortOrderSetMessagePayload` - added type `OrderBusinessUnitSetMessagePayload` - added type `OrderCreatedFromRecurringOrderMessagePayload` +- added type `OrderPaymentRemovedMessagePayload` - added type `PaymentInterfaceIdSetMessagePayload` - added type `PaymentMethodCreatedMessagePayload` - added type `PaymentMethodCustomFieldAddedMessagePayload` @@ -171,6 +182,7 @@ - added type `RecurringOrderCustomTypeSetMessagePayload` - added type `RecurringOrderDeletedMessagePayload` - added type `RecurringOrderExpiresAtSetMessagePayload` +- added type `RecurringOrderFailedMessagePayload` - added type `RecurringOrderKeySetMessagePayload` - added type `RecurringOrderScheduleSetMessagePayload` - added type `RecurringOrderStartsAtSetMessagePayload` @@ -282,6 +294,13 @@ +
+Deprecated Type(s) + +- type `ProductLegacySetSkuAction` is removed +
+ +
Removed Type(s) @@ -407,8 +426,11 @@
Removed Property(s) +- :warning: removed property `payment` from type `OrderPaymentAddedMessage` +- :warning: removed property `payment` from type `OrderPaymentAddedMessagePayload` - :warning: removed property `/[0-9].[0-9]*[1-9]/` from type `CategoryOrderHints` - :warning: removed property `//` from type `ProductVariantChannelAvailabilityMap` +- :warning: removed property `tierMinimumQuantity` from type `StandalonePriceRemovePriceTierAction`
@@ -450,11 +472,15 @@ - added property `invalidateOlderTokens` to type `CustomerEmailTokenCreatedMessage` - added property `value` to type `CustomerPasswordTokenCreatedMessage` - added property `invalidateOlderTokens` to type `CustomerPasswordTokenCreatedMessage` +- added property `sku` to type `InventoryEntryQuantitySetMessage` +- added property `paymentRef` to type `OrderPaymentAddedMessage` - added property `attributes` to type `ProductTailoringCreatedMessage` - added property `value` to type `CustomerEmailTokenCreatedMessagePayload` - added property `invalidateOlderTokens` to type `CustomerEmailTokenCreatedMessagePayload` - added property `value` to type `CustomerPasswordTokenCreatedMessagePayload` - added property `invalidateOlderTokens` to type `CustomerPasswordTokenCreatedMessagePayload` +- added property `sku` to type `InventoryEntryQuantitySetMessagePayload` +- added property `paymentRef` to type `OrderPaymentAddedMessagePayload` - added property `attributes` to type `ProductTailoringCreatedMessagePayload` - added property `priceRoundingMode` to type `StagedOrder` - added property `recurringOrder` to type `StagedOrder` @@ -492,6 +518,7 @@ - added property `published` to type `ShoppingListLineItem` - added property `recurrencePolicy` to type `StandalonePrice` - added property `recurrencePolicy` to type `StandalonePriceDraft` +- added property `minimumQuantity` to type `StandalonePriceRemovePriceTierAction` - added property `events` to type `Subscription` - added property `events` to type `SubscriptionDraft`
@@ -525,6 +552,7 @@ - added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withId()->delete()` - added method `$apiRoot->withProjectKey()->businessUnits()->keyWithKeyValueAssociatesWithAssociateIdValue()->get()` - added method `$apiRoot->withProjectKey()->businessUnits()->withBusinessUnitIdValueAssociatesWithAssociateIdValue()->get()` +- added method `$apiRoot->withProjectKey()->carts()->customerIdWithCustomerIdValueMerge()->post()` - added method `$apiRoot->withProjectKey()->discountGroups()->withKey()->get()` - added method `$apiRoot->withProjectKey()->discountGroups()->withKey()->head()` - added method `$apiRoot->withProjectKey()->discountGroups()->withKey()->post()` @@ -570,6 +598,7 @@ - added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withId()->delete()` - added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->keyWithKeyValueAssociatesWithAssociateIdValue()->get()` - added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withBusinessUnitIdValueAssociatesWithAssociateIdValue()->get()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->carts()->customerIdWithCustomerIdValueMerge()->post()` @@ -585,6 +614,7 @@ - added resource `/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}` - added resource `/{projectKey}/business-units/key={key}/associates/{associateId}` - added resource `/{projectKey}/business-units/{businessUnitId}/associates/{associateId}` +- added resource `/{projectKey}/carts/customer-id={customerId}/merge` - added resource `/{projectKey}/discount-groups/key={key}` - added resource `/{projectKey}/discount-groups/{ID}` - added resource `/{projectKey}/payment-methods/key={key}` @@ -598,6 +628,7 @@ - added resource `/{projectKey}/in-store/key={storeKey}/business-units/{ID}` - added resource `/{projectKey}/in-store/key={storeKey}/business-units/key={key}/associates/{associateId}` - added resource `/{projectKey}/in-store/key={storeKey}/business-units/{businessUnitId}/associates/{associateId}` +- added resource `/{projectKey}/in-store/key={storeKey}/carts/customer-id={customerId}/merge` **Import changes** @@ -677,20 +708,20 @@
Added Method(s) -- added method `$apiRoot->withProjectKeyValue()->productSelections()->importContainers()->withImportContainerKeyValue()->post()` - added method `$apiRoot->withProjectKeyValue()->businessUnits()->importContainers()->withImportContainerKeyValue()->post()` +- added method `$apiRoot->withProjectKeyValue()->productSelections()->importContainers()->withImportContainerKeyValue()->post()`
Added Resource(s) -- added resource `/{projectKey}/product-selections` - added resource `/{projectKey}/business-units` -- added resource `/{projectKey}/product-selections/import-containers` -- added resource `/{projectKey}/product-selections/import-containers/{importContainerKey}` +- added resource `/{projectKey}/product-selections` - added resource `/{projectKey}/business-units/import-containers` - added resource `/{projectKey}/business-units/import-containers/{importContainerKey}` +- added resource `/{projectKey}/product-selections/import-containers` +- added resource `/{projectKey}/product-selections/import-containers/{importContainerKey}`
**History changes** @@ -700,15 +731,193 @@ - added type `TooManyRequestsError` - added type `GraphQLTooManyRequestsError` +- added type `AddShippingChange` +- added type `ChangeApprovalRuleModeChange` +- added type `ChangeCustomerChange` +- added type `ChangeIncludedInStatisticsChange` +- added type `ChangeLastVariantIdChange` +- added type `ChangeLineItemNameChange` +- added type `ChangeLineItemPublishedChange` +- added type `ExcludeProductChange` +- added type `RemoveShippingChange` +- added type `ReplaceTaxRateChange` +- added type `RevertStagedChangesChange` +- added type `RevertStagedVariantChangesChange` +- added type `SetAncestorsChange` +- added type `SetBillingAddressCustomFieldChange` +- added type `SetBillingAddressCustomTypeChange` +- added type `SetBusinessUnitChange` +- added type `SetCustomLineItemDiscountedPriceChange` +- added type `SetCustomLineItemDiscountedPricePerQuantityChange` +- added type `SetCustomerGroupAssignmentsChange` +- added type `SetDeliveryAddressCustomFieldChange` +- added type `SetDeliveryAddressCustomTypeChange` +- added type `SetDeliveryCustomFieldChange` +- added type `SetDeliveryCustomTypeChange` +- added type `SetDiscountOnTotalPriceChange` +- added type `SetInheritedStoresChange` +- added type `SetItemShippingAddressCustomFieldChange` +- added type `SetItemShippingAddressCustomTypeChange` +- added type `SetMaxCartQuantityChange` +- added type `SetMinCartQuantityChange` +- added type `SetParcelCustomFieldChange` +- added type `SetParcelCustomTypeChange` +- added type `SetPasswordChange` +- added type `SetPriceKeyChange` +- added type `SetPriceModeChange` +- added type `SetProductAttributeChange` +- added type `SetReturnInfoChange` +- added type `SetReturnItemCustomLineItemCustomFieldChange` +- added type `SetReturnItemCustomLineItemCustomTypeChange` +- added type `SetReturnItemLineItemCustomFieldChange` +- added type `SetReturnItemLineItemCustomTypeChange` +- added type `SetShippingAddressCustomFieldChange` +- added type `SetShippingAddressCustomTypeChange` +- added type `SetShippingCustomFieldChange` +- added type `SetShippingCustomTypeChange` +- added type `SetTransactionCustomFieldChange` +- added type `SetTransactionCustomTypeChange` +- added type `SetUnitTypeChange` +- added type `SetVariantExclusionChange` +- added type `UpdateItemShippingAddressChange` +- added type `SetAssociatesChange` +- added type `SetInheritedAssociatesChange` +- added type `ChangeTopLevelUnitChange` +- added type `Attribute` +- added type `BusinessUnitApprovalRuleMode` +- added type `BusinessUnitResourceIdentifier` +- added type `BusinessUnitType` +- added type `CustomFieldEnumValue` +- added type `CustomFieldLocalizedEnumValue` +- added type `CustomerGroupAssignment` +- added type `DiscountOnTotalPrice` +- added type `DiscountedTotalPricePortion` +- added type `ProductPriceModeEnum` +- added type `ProductVariantExclusion` +- added type `Shipping` +- added type `ShippingInfo` +- added type `ShippingRateInput` +- added type `ShoppingListLineItem` +- added type `TypeTextInputHint` +- added type `TypedMoney` +- added type `CentPrecisionMoney` +- added type `DiscountedPrice` +- added type `ShippingMethodState` +- added type `AssociateRoleDeprecated` +- added type `AssociateRoleKeyReference` +- added type `AttributeLevelEnum` +- added type `BaseAddress` +- added type `BusinessUnitKeyReference` +- added type `CartDiscountReference` +- added type `CartDiscountTarget` +- added type `CartDiscountValue` +- added type `CategoryReference` +- added type `ChannelReference` +- added type `CustomFieldValue` +- added type `CustomLineItemPriceMode` +- added type `CustomLineItemRecurrenceInfo` +- added type `CustomerGroupReference` +- added type `CustomerReference` +- added type `DiscountCodeReference` +- added type `FieldContainer` +- added type `GeoJson` +- added type `InventoryMode` +- added type `LineItemMode` +- added type `LineItemPriceMode` +- added type `LineItemRecurrenceInfo` +- added type `MethodTaxRate` +- added type `MethodTaxedPrice` +- added type `PaymentReference` +- added type `PriceSelectionMode` +- added type `PriceTier` +- added type `ProductDiscountReference` +- added type `ProductDiscountValue` +- added type `ProductReference` +- added type `ProductSelectionReference` +- added type `ProductTypeReference` +- added type `ProductVariant` +- added type `RecurrencePolicyReference` +- added type `ResourceTypeId` +- added type `ScopedPrice` +- added type `ShippingMethodReference` +- added type `StateReference` +- added type `StoreKeyReference` +- added type `TaxCategoryReference` +- added type `TaxPortion` +- added type `TypeReference` +- added type `ClientLogging` +- added type `ChangePriceRoundingModeChange` + + + +
+Changed Type(s) + +- :warning: changed type `Address` from type `object` to `BaseAddress` +- :warning: changed type `GeoLocation` from type `object` to `GeoJson` +
+ + +
+MarkDeprecated Type(s) + +- marked type `AddAssociateChange` as deprecated +- marked type `AddPriceChange` as deprecated +- marked type `AddProductSelectionChange` as deprecated +- marked type `AddStateRolesChange` as deprecated +- marked type `ChangeAmountAuthorizedChange` as deprecated +- marked type `RemoveAssociateChange` as deprecated +- marked type `RemovePriceChange` as deprecated +- marked type `RemoveProductSelectionChange` as deprecated +- marked type `RemoveStateRolesChange` as deprecated
Added Enum(s) +- added enum `addInheritedAssociate` to type `PlatformInitiatedChange` +- added enum `changeIncludedInStatistics` to type `PlatformInitiatedChange` +- added enum `changeInheritedAssociate` to type `PlatformInitiatedChange` +- added enum `changeLastVariantId` to type `PlatformInitiatedChange` +- added enum `changeLineItemPublished` to type `PlatformInitiatedChange` +- added enum `changeTopLevelUnit` to type `PlatformInitiatedChange` +- added enum `removeInheritedAssociate` to type `PlatformInitiatedChange` +- added enum `setAncestors` to type `PlatformInitiatedChange` +- added enum `setInheritedAssociates` to type `PlatformInitiatedChange` +- added enum `setInheritedStores` to type `PlatformInitiatedChange` +- added enum `setLineItemDeactivatedAt` to type `PlatformInitiatedChange` +- added enum `setProductCount` to type `PlatformInitiatedChange` +- added enum `setReservations` to type `PlatformInitiatedChange` - added enum `setAssetKey` to type `UpdateType` - added enum `ApplicationStoppedByGroupBestDeal` to type `DiscountCodeState` +- added enum `CreateApprovalRules` to type `Permission` +- added enum `UpdateApprovalRules` to type `Permission` +- added enum `UpdateApprovalFlows` to type `Permission` +- added enum `ViewMyShoppingLists` to type `Permission` +- added enum `ViewOthersShoppingLists` to type `Permission` +- added enum `UpdateMyShoppingLists` to type `Permission` +- added enum `UpdateOthersShoppingLists` to type `Permission` +- added enum `CreateMyShoppingLists` to type `Permission` +- added enum `CreateOthersShoppingLists` to type `Permission` +- added enum `DeleteMyShoppingLists` to type `Permission` +- added enum `DeleteOthersShoppingLists` to type `Permission` +- added enum `includeOnly` to type `ProductVariantSelectionTypeEnum` +- added enum `includeAllExcept` to type `ProductVariantSelectionTypeEnum` +- added enum `RenegotiationAddressed` to type `QuoteState` +- added enum `approval-flow` to type `ReferenceTypeId` +- added enum `approval-rule` to type `ReferenceTypeId` +- added enum `attribute-group` to type `ReferenceTypeId` +- added enum `direct-discount` to type `ReferenceTypeId` +- added enum `discount-group` to type `ReferenceTypeId` - added enum `payment-method` to type `ReferenceTypeId` +- added enum `product-price` to type `ReferenceTypeId` +- added enum `product-tailoring` to type `ReferenceTypeId` +- added enum `recurrence-policy` to type `ReferenceTypeId` +- added enum `recurring-order` to type `ReferenceTypeId` +- added enum `standalone-price` to type `ReferenceTypeId` +- added enum `Delivered` to type `ShipmentState` +- added enum `Canceled` to type `ShipmentState` - added enum `RecurringOrderState` to type `StateTypeEnum`
@@ -716,21 +925,447 @@
Removed Enum(s) +- :warning: removed enum `changeAmountAuthorized` from type `UpdateType` - :warning: removed enum `setAsssetKey` from type `UpdateType` +- :warning: removed enum `Failed` from type `QuoteState`
Required Property(s) +- changed property `id` of type `Address` to be optional +- changed property `key` of type `Address` to be optional +- changed property `title` of type `Address` to be optional +- changed property `salutation` of type `Address` to be optional +- changed property `firstName` of type `Address` to be optional +- changed property `lastName` of type `Address` to be optional +- changed property `streetName` of type `Address` to be optional +- changed property `streetNumber` of type `Address` to be optional +- changed property `additionalStreetInfo` of type `Address` to be optional +- changed property `postalCode` of type `Address` to be optional +- changed property `city` of type `Address` to be optional +- changed property `region` of type `Address` to be optional +- changed property `state` of type `Address` to be optional +- changed property `company` of type `Address` to be optional +- changed property `department` of type `Address` to be optional +- changed property `building` of type `Address` to be optional +- changed property `apartment` of type `Address` to be optional +- changed property `pOBox` of type `Address` to be optional +- changed property `phone` of type `Address` to be optional +- changed property `mobile` of type `Address` to be optional +- changed property `email` of type `Address` to be optional +- changed property `fax` of type `Address` to be optional +- changed property `additionalAddressInfo` of type `Address` to be optional +- changed property `externalId` of type `Address` to be optional +- changed property `description` of type `Asset` to be optional +- changed property `custom` of type `Asset` to be optional +- changed property `key` of type `Asset` to be optional +- changed property `key` of type `AssetSource` to be optional +- changed property `dimensions` of type `AssetSource` to be optional +- changed property `contentType` of type `AssetSource` to be optional +- changed property `inputTip` of type `AttributeDefinition` to be optional +- changed property `taxedPrice` of type `CustomLineItem` to be optional +- changed property `inputHint` of type `FieldDefinition` to be optional +- changed property `label` of type `Image` to be optional +- changed property `productSlug` of type `LineItem` to be optional +- changed property `custom` of type `LineItem` to be optional +- changed property `addedAt` of type `LineItem` to be optional +- changed property `state` of type `Location` to be optional +- changed property `measurements` of type `Parcel` to be optional +- changed property `trackingData` of type `Parcel` to be optional +- changed property `items` of type `Parcel` to be optional +- changed property `heightInMillimeter` of type `ParcelMeasurements` to be optional +- changed property `lengthInMillimeter` of type `ParcelMeasurements` to be optional +- changed property `widthInMillimeter` of type `ParcelMeasurements` to be optional +- changed property `weightInGram` of type `ParcelMeasurements` to be optional +- changed property `channels` of type `ProductVariantAvailability` to be optional +- changed property `isOnStock` of type `ProductVariantAvailability` to be optional +- changed property `restockableInDays` of type `ProductVariantAvailability` to be optional +- changed property `availableQuantity` of type `ProductVariantAvailability` to be optional +- changed property `isOnStock` of type `ProductVariantChannelAvailability` to be optional +- changed property `restockableInDays` of type `ProductVariantChannelAvailability` to be optional +- changed property `availableQuantity` of type `ProductVariantChannelAvailability` to be optional +- changed property `id` of type `ResourceIdentifier` to be optional +- changed property `key` of type `ResourceIdentifier` to be optional +- changed property `returnTrackingId` of type `ReturnInfo` to be optional +- changed property `returnDate` of type `ReturnInfo` to be optional +- changed property `comment` of type `ReturnItem` to be optional +- changed property `suggestTokenizer` of type `SearchKeyword` to be optional +- changed property `freeAbove` of type `ShippingRate` to be optional +- changed property `isMatching` of type `ShippingRate` to be optional +- changed property `externalId` of type `SyncInfo` to be optional +- changed property `id` of type `TaxRate` to be optional +- changed property `state` of type `TaxRate` to be optional +- changed property `subRates` of type `TaxRate` to be optional +- changed property `custom` of type `TextLineItem` to be optional +- changed property `description` of type `TextLineItem` to be optional +- changed property `trackingId` of type `TrackingData` to be optional +- changed property `carrier` of type `TrackingData` to be optional +- changed property `provider` of type `TrackingData` to be optional +- changed property `providerTransaction` of type `TrackingData` to be optional +- changed property `isReturn` of type `TrackingData` to be optional +- changed property `timestamp` of type `Transaction` to be optional +- changed property `interactionId` of type `Transaction` to be optional - :warning: changed property `triggerPattern` of type `ChangeTargetPatternChangeValue` to be required
+ +
+Changed Property(s) + +- :warning: changed property `nextValue` of type `AddEnumValueChange` from type `EnumValue` to `CustomFieldEnumValue` +- :warning: changed property `nextValue` of type `AddInterfaceInteractionChange` from type `CustomFieldExpandedValue` to `CustomFields` +- :warning: changed property `nextValue` of type `AddLocalizedEnumValueChange` from type `AttributeLocalizedEnumValue` to `CustomFieldLocalizedEnumValue` +- :warning: changed property `previousValue` of type `AddShoppingListLineItemChange` from type `LineItem` to `ShoppingListLineItem` +- :warning: changed property `nextValue` of type `AddShoppingListLineItemChange` from type `LineItem` to `ShoppingListLineItem` +- :warning: changed property `w` of type `AssetDimensions` from type `integer` to `number` +- :warning: changed property `h` of type `AssetDimensions` from type `integer` to `number` +- :warning: changed property `customer` of type `Associate` from type `Reference` to `CustomerReference` +- :warning: changed property `associateRole` of type `AssociateRoleAssignment` from type `KeyReference` to `AssociateRoleKeyReference` +- :warning: changed property `previousValue` of type `ChangeEnumValueOrderChange` from type `EnumValue[]` to `CustomFieldEnumValue[]` +- :warning: changed property `nextValue` of type `ChangeEnumValueOrderChange` from type `EnumValue[]` to `CustomFieldEnumValue[]` +- :warning: changed property `previousValue` of type `ChangeInputHintChange` from type `TextInputHint` to `TypeTextInputHint` +- :warning: changed property `nextValue` of type `ChangeInputHintChange` from type `TextInputHint` to `TypeTextInputHint` +- :warning: changed property `previousValue` of type `ChangeLocalizedEnumValueOrderChange` from type `LocalizedEnumValue[]` to `AttributeLocalizedEnumValue[]` +- :warning: changed property `nextValue` of type `ChangeLocalizedEnumValueOrderChange` from type `LocalizedEnumValue[]` to `AttributeLocalizedEnumValue[]` +- :warning: changed property `previousValue` of type `ChangePlainEnumValueOrderChange` from type `EnumValue[]` to `AttributePlainEnumValue[]` +- :warning: changed property `nextValue` of type `ChangePlainEnumValueOrderChange` from type `EnumValue[]` to `AttributePlainEnumValue[]` +- :warning: changed property `type` of type `CustomFields` from type `Reference` to `TypeReference` +- :warning: changed property `fields` of type `CustomFields` from type `object` to `FieldContainer` +- :warning: changed property `money` of type `CustomLineItem` from type `Money` to `TypedMoney` +- :warning: changed property `totalPrice` of type `CustomLineItem` from type `Money` to `CentPrecisionMoney` +- :warning: changed property `quantity` of type `CustomLineItem` from type `integer` to `number` +- :warning: changed property `createdAt` of type `Delivery` from type `string` to `datetime` +- :warning: changed property `quantity` of type `DeliveryItem` from type `integer` to `number` +- :warning: changed property `discountCode` of type `DiscountCodeInfo` from type `Reference` to `DiscountCodeReference` +- :warning: changed property `discountedAmount` of type `DiscountedLineItemPortion` from type `Money` to `TypedMoney` +- :warning: changed property `value` of type `DiscountedLineItemPrice` from type `Money` to `TypedMoney` +- :warning: changed property `quantity` of type `DiscountedLineItemPriceForQuantity` from type `integer` to `number` +- :warning: changed property `inputHint` of type `FieldDefinition` from type `TextInputHint` to `TypeTextInputHint` +- :warning: changed property `w` of type `ImageDimensions` from type `integer` to `number` +- :warning: changed property `h` of type `ImageDimensions` from type `integer` to `number` +- :warning: changed property `customer` of type `InheritedAssociate` from type `Reference` to `CustomerReference` +- :warning: changed property `associateRole` of type `InheritedAssociateRoleAssignment` from type `KeyReference` to `AssociateRoleKeyReference` +- :warning: changed property `source` of type `InheritedAssociateRoleAssignment` from type `KeyReference` to `BusinessUnitKeyReference` +- :warning: changed property `quantity` of type `ItemShippingTarget` from type `integer` to `number` +- :warning: changed property `quantity` of type `ItemState` from type `integer` to `number` +- :warning: changed property `state` of type `ItemState` from type `Reference` to `StateReference` +- :warning: changed property `productType` of type `LineItem` from type `Reference` to `ProductTypeReference` +- :warning: changed property `variant` of type `LineItem` from type `Variant` to `ProductVariant` +- :warning: changed property `quantity` of type `LineItem` from type `integer` to `number` +- :warning: changed property `addedAt` of type `LineItem` from type `string` to `datetime` +- :warning: changed property `centAmount` of type `Money` from type `integer` to `number` +- :warning: changed property `createdAt` of type `Parcel` from type `string` to `datetime` +- :warning: changed property `heightInMillimeter` of type `ParcelMeasurements` from type `integer` to `number` +- :warning: changed property `lengthInMillimeter` of type `ParcelMeasurements` from type `integer` to `number` +- :warning: changed property `widthInMillimeter` of type `ParcelMeasurements` from type `integer` to `number` +- :warning: changed property `weightInGram` of type `ParcelMeasurements` from type `integer` to `number` +- :warning: changed property `payments` of type `PaymentInfo` from type `Reference[]` to `PaymentReference[]` +- :warning: changed property `value` of type `Price` from type `Money` to `TypedMoney` +- :warning: changed property `productSelection` of type `ProductSelectionSetting` from type `Reference` to `ProductSelectionReference` +- :warning: changed property `restockableInDays` of type `ProductVariantAvailability` from type `integer` to `number` +- :warning: changed property `availableQuantity` of type `ProductVariantAvailability` from type `integer` to `number` +- :warning: changed property `restockableInDays` of type `ProductVariantChannelAvailability` from type `integer` to `number` +- :warning: changed property `availableQuantity` of type `ProductVariantChannelAvailability` from type `integer` to `number` +- :warning: changed property `previousValue` of type `RemoveDeliveryItemsChange` from type `Delivery` to `DeliveryChangeValue` +- :warning: changed property `previousValue` of type `RemoveEnumValuesChange` from type `EnumValue` to `AttributePlainEnumValue` +- :warning: changed property `previousValue` of type `RemoveLocalizedEnumValuesChange` from type `LocalizedEnumValue` to `AttributeLocalizedEnumValue` +- :warning: changed property `previousValue` of type `RemoveShoppingListLineItemChange` from type `LineItem` to `ShoppingListLineItem` +- :warning: changed property `nextValue` of type `RemoveShoppingListLineItemChange` from type `LineItem` to `ShoppingListLineItem` +- :warning: changed property `returnDate` of type `ReturnInfo` from type `string` to `datetime` +- :warning: changed property `quantity` of type `ReturnItem` from type `integer` to `number` +- :warning: changed property `lastModifiedAt` of type `ReturnItem` from type `string` to `datetime` +- :warning: changed property `createdAt` of type `ReturnItem` from type `string` to `datetime` +- :warning: changed property `averageRating` of type `ReviewRatingStatistics` from type `integer` to `number` +- :warning: changed property `highestRating` of type `ReviewRatingStatistics` from type `integer` to `number` +- :warning: changed property `lowestRating` of type `ReviewRatingStatistics` from type `integer` to `number` +- :warning: changed property `previousValue` of type `SetAttributeChange` from type `AttributeValue` to `Attribute` +- :warning: changed property `nextValue` of type `SetAttributeChange` from type `AttributeValue` to `Attribute` +- :warning: changed property `previousValue` of type `SetCustomLineItemTaxedPriceChange` from type `Money` to `TaxedItemPrice` +- :warning: changed property `nextValue` of type `SetCustomLineItemTaxedPriceChange` from type `Money` to `TaxedItemPrice` +- :warning: changed property `previousValue` of type `SetDiscountedPriceChange` from type `Price` to `DiscountedPrice` +- :warning: changed property `nextValue` of type `SetDiscountedPriceChange` from type `Price` to `DiscountedPrice` +- :warning: changed property `previousValue` of type `SetOrderTaxedPriceChange` from type `TaxedItemPrice` to `TaxedPrice` +- :warning: changed property `nextValue` of type `SetOrderTaxedPriceChange` from type `TaxedItemPrice` to `TaxedPrice` +- :warning: changed property `previousValue` of type `SetShippingInfoTaxedPriceChange` from type `TaxedPrice` to `TaxedItemPrice` +- :warning: changed property `nextValue` of type `SetShippingInfoTaxedPriceChange` from type `TaxedPrice` to `TaxedItemPrice` +- :warning: changed property `previousValue` of type `SetShippingRateChange` from type `Money` to `ShippingRate` +- :warning: changed property `nextValue` of type `SetShippingRateChange` from type `Money` to `ShippingRate` +- :warning: changed property `previousValue` of type `SetStoreChange` from type `Reference` to `KeyReference` +- :warning: changed property `nextValue` of type `SetStoreChange` from type `Reference` to `KeyReference` +- :warning: changed property `price` of type `ShippingRate` from type `Money` to `CentPrecisionMoney` +- :warning: changed property `freeAbove` of type `ShippingRate` from type `Money` to `CentPrecisionMoney` +- :warning: changed property `amount` of type `SubRate` from type `integer` to `number` +- :warning: changed property `channel` of type `SyncInfo` from type `Reference` to `ChannelReference` +- :warning: changed property `syncedAt` of type `SyncInfo` from type `string` to `datetime` +- :warning: changed property `amount` of type `TaxRate` from type `integer` to `number` +- :warning: changed property `totalNet` of type `TaxedItemPrice` from type `Money` to `CentPrecisionMoney` +- :warning: changed property `totalGross` of type `TaxedItemPrice` from type `Money` to `CentPrecisionMoney` +- :warning: changed property `totalNet` of type `TaxedPrice` from type `Money` to `CentPrecisionMoney` +- :warning: changed property `totalGross` of type `TaxedPrice` from type `Money` to `CentPrecisionMoney` +- :warning: changed property `addedAt` of type `TextLineItem` from type `string` to `datetime` +- :warning: changed property `quantity` of type `TextLineItem` from type `integer` to `number` +- :warning: changed property `timestamp` of type `Transaction` from type `string` to `datetime` +- :warning: changed property `amount` of type `Transaction` from type `Money` to `CentPrecisionMoney` +
+ + +
+Removed Property(s) + +- :warning: removed property `/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/` from type `CategoryOrderHints` +- :warning: removed property `variantId` from type `LineItem` +- :warning: removed property `fractionDigits` from type `Money` +- :warning: removed property `type` from type `Money` +- :warning: removed property `//` from type `ProductVariantChannelAvailabilityMap` +- :warning: removed property `skus` from type `ProductVariantSelection` +
+ + +
+Added Property(s) + +- added property `catalogData` to type `AddAssetChange` +- added property `variant` to type `AddAssetChange` +- added property `attributeName` to type `AddEnumValueChange` +- added property `variant` to type `AddExternalImageChange` +- added property `variant` to type `AddPriceChange` +- added property `catalogData` to type `AddToCategoryChange` +- added property `custom` to type `Address` +- added property `sources` to type `Asset` +- added property `tags` to type `Asset` +- added property `roles` to type `Associate` +- added property `level` to type `AttributeDefinition` +- added property `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/` to type `CategoryOrderHints` +- added property `catalogData` to type `ChangeAssetNameChange` +- added property `variant` to type `ChangeAssetNameChange` +- added property `catalogData` to type `ChangeAssetOrderChange` +- added property `variant` to type `ChangeAssetOrderChange` +- added property `addedItems` to type `ChangeCartDiscountsChange` +- added property `removedItems` to type `ChangeCartDiscountsChange` +- added property `attributeName` to type `ChangeEnumValueLabelChange` +- added property `attributeName` to type `ChangeEnumValueOrderChange` +- added property `addedItems` to type `ChangeGroupsChange` +- added property `removedItems` to type `ChangeGroupsChange` +- added property `variant` to type `ChangePriceChange` +- added property `catalogData` to type `ChangeSlugChange` +- added property `key` to type `CustomLineItem` +- added property `taxedPricePortions` to type `CustomLineItem` +- added property `state` to type `CustomLineItem` +- added property `taxCategory` to type `CustomLineItem` +- added property `taxRate` to type `CustomLineItem` +- added property `perMethodTaxRate` to type `CustomLineItem` +- added property `discountedPricePerQuantity` to type `CustomLineItem` +- added property `custom` to type `CustomLineItem` +- added property `shippingDetails` to type `CustomLineItem` +- added property `priceMode` to type `CustomLineItem` +- added property `recurrenceInfo` to type `CustomLineItem` +- added property `key` to type `Delivery` +- added property `required` to type `FieldDefinition` +- added property `shippingMethodKey` to type `ItemShippingTarget` +- added property `key` to type `LineItem` +- added property `productKey` to type `LineItem` +- added property `price` to type `LineItem` +- added property `totalPrice` to type `LineItem` +- added property `discountedPricePerQuantity` to type `LineItem` +- added property `taxedPrice` to type `LineItem` +- added property `taxedPricePortions` to type `LineItem` +- added property `state` to type `LineItem` +- added property `taxRate` to type `LineItem` +- added property `perMethodTaxRate` to type `LineItem` +- added property `supplyChannel` to type `LineItem` +- added property `distributionChannel` to type `LineItem` +- added property `priceMode` to type `LineItem` +- added property `lineItemMode` to type `LineItem` +- added property `inventoryMode` to type `LineItem` +- added property `shippingDetails` to type `LineItem` +- added property `lastModifiedAt` to type `LineItem` +- added property `recurrenceInfo` to type `LineItem` +- added property `variant` to type `MoveImageToPositionChange` +- added property `key` to type `Parcel` +- added property `custom` to type `Parcel` +- added property `key` to type `Price` +- added property `country` to type `Price` +- added property `customerGroup` to type `Price` +- added property `channel` to type `Price` +- added property `validFrom` to type `Price` +- added property `validUntil` to type `Price` +- added property `discounted` to type `Price` +- added property `tiers` to type `Price` +- added property `custom` to type `Price` +- added property `recurrencePolicy` to type `Price` +- added property `id` to type `ProductVariantAvailability` +- added property `version` to type `ProductVariantAvailability` +- added property `id` to type `ProductVariantChannelAvailability` +- added property `version` to type `ProductVariantChannelAvailability` +- added property `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/` to type `ProductVariantChannelAvailabilityMap` +- added property `catalogData` to type `RemoveAssetChange` +- added property `variant` to type `RemoveAssetChange` +- added property `catalogData` to type `RemoveFromCategoryChange` +- added property `variant` to type `RemoveImageChange` +- added property `variant` to type `RemovePriceChange` +- added property `key` to type `ReturnItem` +- added property `custom` to type `ReturnItem` +- added property `catalogData` to type `SetAssetCustomFieldChange` +- added property `variant` to type `SetAssetCustomFieldChange` +- added property `catalogData` to type `SetAssetCustomTypeChange` +- added property `variant` to type `SetAssetCustomTypeChange` +- added property `catalogData` to type `SetAssetDescriptionChange` +- added property `variant` to type `SetAssetDescriptionChange` +- added property `catalogData` to type `SetAssetKeyChange` +- added property `variant` to type `SetAssetKeyChange` +- added property `catalogData` to type `SetAssetSourcesChange` +- added property `variant` to type `SetAssetSourcesChange` +- added property `catalogData` to type `SetAssetTagsChange` +- added property `variant` to type `SetAssetTagsChange` +- added property `variant` to type `SetAttributeChange` +- added property `addedItems` to type `SetChannelRolesChange` +- added property `removedItems` to type `SetChannelRolesChange` +- added property `addedItems` to type `SetCountriesChange` +- added property `removedItems` to type `SetCountriesChange` +- added property `customTypeId` to type `SetCustomLineItemCustomFieldChange` +- added property `customLineItem` to type `SetCustomLineItemShippingDetailsChange` +- added property `price` to type `SetDiscountedPriceChange` +- added property `addedItems` to type `SetDistributionChannelsChange` +- added property `removedItems` to type `SetDistributionChannelsChange` +- added property `variant` to type `SetImageLabelChange` +- added property `addedItems` to type `SetLanguagesChange` +- added property `removedItems` to type `SetLanguagesChange` +- added property `lineItemId` to type `SetLineItemDiscountedPriceChange` +- added property `lineItemId` to type `SetLineItemDiscountedPricePerQuantityChange` +- added property `lineItemId` to type `SetLineItemPriceChange` +- added property `lineItemId` to type `SetLineItemProductSlugChange` +- added property `lineItem` to type `SetLineItemShippingDetailsChange` +- added property `variant` to type `SetLineItemShippingDetailsChange` +- added property `lineItemId` to type `SetLineItemTaxAmountChange` +- added property `lineItemId` to type `SetLineItemTaxRateChange` +- added property `variant` to type `SetLineItemTaxedPriceChange` +- added property `lineItemId` to type `SetLineItemTotalPriceChange` +- added property `variant` to type `SetLineItemTotalPriceChange` +- added property `catalogData` to type `SetMetaDescriptionChange` +- added property `catalogData` to type `SetMetaKeywordsChange` +- added property `catalogData` to type `SetMetaTitleChange` +- added property `lineItemId` to type `SetOrderLineItemCustomFieldChange` +- added property `lineItemId` to type `SetOrderLineItemCustomTypeChange` +- added property `addedItems` to type `SetPermissionsChange` +- added property `removedItems` to type `SetPermissionsChange` +- added property `addedItems` to type `SetPricesChange` +- added property `removedItems` to type `SetPricesChange` +- added property `variant` to type `SetProductPriceCustomFieldChange` +- added property `priceId` to type `SetProductPriceCustomFieldChange` +- added property `customTypeId` to type `SetProductPriceCustomFieldChange` +- added property `name` to type `SetProductPriceCustomFieldChange` +- added property `variant` to type `SetProductPriceCustomTypeChange` +- added property `priceId` to type `SetProductPriceCustomTypeChange` +- added property `addedItems` to type `SetProductSelectionsChange` +- added property `removedItems` to type `SetProductSelectionsChange` +- added property `variant` to type `SetProductVariantKeyChange` +- added property `addedItems` to type `SetReservationsChange` +- added property `removedItems` to type `SetReservationsChange` +- added property `variant` to type `SetSkuChange` +- added property `addedItems` to type `SetStateRolesChange` +- added property `removedItems` to type `SetStateRolesChange` +- added property `addedItems` to type `SetStoresChange` +- added property `removedItems` to type `SetStoresChange` +- added property `addedItems` to type `SetSupplyChannelsChange` +- added property `removedItems` to type `SetSupplyChannelsChange` +- added property `addedItems` to type `SetTransitionsChange` +- added property `removedItems` to type `SetTransitionsChange` +- added property `key` to type `TaxRate` +- added property `taxPortions` to type `TaxedItemPrice` +- added property `totalTax` to type `TaxedItemPrice` +- added property `taxPortions` to type `TaxedPrice` +- added property `totalTax` to type `TaxedPrice` +- added property `key` to type `TextLineItem` +- added property `custom` to type `Transaction` +- added property `customLineItemId` to type `TransitionCustomLineItemStateChange` +
+ **Checkout changes**
Added Type(s) +- added type `AllowedOrigins` +- added type `Application` +- added type `ApplicationAgreement` +- added type `ApplicationAgreementDraft` +- added type `ApplicationAgreementStatus` +- added type `ApplicationAgreementType` +- added type `ApplicationDraft` +- added type `ApplicationLogo` +- added type `ApplicationMode` +- added type `ApplicationStatus` +- added type `ApplicationUpdateAction` +- added type `ApplicationUpdateActions` +- added type `DiscountsConfiguration` +- added type `PaginatedApplication` +- added type `PaymentsConfiguration` +- added type `AddAllowedOriginUpdateAction` +- added type `AddApplicationAgreementUpdateAction` +- added type `AddCountryUpdateAction` +- added type `RemoveAllowedOriginUpdateAction` +- added type `RemoveApplicationAgreementUpdateAction` +- added type `RemoveCountryUpdateAction` +- added type `ReorderApplicationAgreementUpdateAction` +- added type `SetActivePaymentComponentTypeUpdateAction` +- added type `SetAllowAllOriginsUpdateAction` +- added type `SetAllowedOriginsUpdateAction` +- added type `SetApplicationAgreementNameUpdateAction` +- added type `SetApplicationAgreementStatusUpdateAction` +- added type `SetApplicationAgreementTextUpdateAction` +- added type `SetApplicationAgreementTypeUpdateAction` +- added type `SetApplicationAgreementsUpdateAction` +- added type `SetApplicationLogoUpdateAction` +- added type `SetApplicationNameUpdateAction` +- added type `SetApplicationStatusUpdateAction` +- added type `SetCountriesUpdateAction` +- added type `SetDescriptionUpdateAction` +- added type `SetDiscountsConfigurationUpdateAction` +- added type `SetPaymentReturnUrlUpdateAction` +- added type `SetPaymentsConfigurationUpdateAction` +- added type `CreatedBy` +- added type `LastModifiedBy` +- added type `LocalizedString` +- added type `LocalizedUrl` +- added type `ConcurrentModificationError` +- added type `DuplicateFieldWithConflictingResourceError` +- added type `ErrorResponse` +- added type `InvalidFieldError` +- added type `InvalidOperationError` +- added type `MaxResourceLimitExceededError` +- added type `MissingProjectKeyError` +- added type `ReferencedResourceNotFoundError` +- added type `ServiceUnavailableError` +- added type `SyntaxErrorError` +- added type `AutomatedReversalConfiguration` +- added type `ConnectorDeploymentReference` +- added type `DisplayInfo` +- added type `PaginatedPaymentIntegration` +- added type `PaymentComponentType` +- added type `PaymentIntegration` +- added type `PaymentIntegrationDraft` +- added type `PaymentIntegrationStatus` +- added type `PaymentIntegrationType` +- added type `SortingInfo` +- added type `PaymentIntegrationUpdateAction` +- added type `PaymentIntegrationUpdateActions` +- added type `SetAutomatedReversalConfigurationPredicateUpdateAction` +- added type `SetAutomatedReversalConfigurationStatusUpdateAction` +- added type `SetAutomatedReversalConfigurationUpdateAction` +- added type `SetConnectorDeploymentUpdateAction` +- added type `SetDisplayInfoDescriptionUpdateAction` +- added type `SetDisplayInfoLabelUpdateAction` +- added type `SetDisplayInfoLogoUrlUpdateAction` +- added type `SetDisplayInfoPayButtonTextUpdateAction` +- added type `SetDisplayInfoUpdateAction` +- added type `SetKeyUpdateAction` +- added type `SetNameUpdateAction` +- added type `SetPredicateUpdateAction` +- added type `SetSortingInfoUpdateAction` +- added type `SetStatusUpdateAction` +- added type `SetTypeUpdateAction` - added type `PaymentIntentReverseAction` - added type `ConnectorError` - added type `ErrorLoadingAllPaymentIntegrations` @@ -794,23 +1429,26 @@
Added Enum(s) +- added enum `deployment` to type `ReferenceTypeId` - added enum `reversePayment` to type `PaymentIntentOperation`
-Changed Property(s) +Required Property(s) -- :warning: changed property `action` of type `PaymentIntentCancelAction` from type `string` to `PaymentIntentOperation` -- :warning: changed property `action` of type `PaymentIntentCaptureAction` from type `string` to `PaymentIntentOperation` -- :warning: changed property `action` of type `PaymentIntentRefundAction` from type `string` to `PaymentIntentOperation` +- changed property `detailedErrorMessage` of type `InvalidJsonInputError` to be optional +- :warning: changed property `amount` of type `PaymentIntentRefundAction` to be required
-Required Property(s) +Changed Property(s) -- :warning: changed property `amount` of type `PaymentIntentRefundAction` to be required +- :warning: changed property `action` of type `PaymentIntentCancelAction` from type `string` to `PaymentIntentOperation` +- :warning: changed property `action` of type `PaymentIntentCaptureAction` from type `string` to `PaymentIntentOperation` +- :warning: changed property `action` of type `PaymentIntentRefundAction` from type `string` to `PaymentIntentOperation` +- :warning: changed property `application` of type `Transaction` from type `ApplicationResourceIdentifier` to `ApplicationReference`
@@ -825,6 +1463,8 @@
Added Property(s) +- added property `resourceIdentifier` to type `ResourceNotFoundError` +- added property `resourceId` to type `ResourceNotFoundError` - added property `merchantReference` to type `PaymentIntentCancelAction` - added property `merchantReference` to type `PaymentIntentCaptureAction` - added property `transactionId` to type `PaymentIntentRefundAction` @@ -834,3 +1474,51 @@ - added property `payload` to type `PaymentValidationFailed`
+ +
+Changed MethodResponseBody(s) + +- :warning: changed response body for `400: application/json` of method `post /{projectKey}/transactions` from type `null` to `ErrorResponse` +- :warning: changed response body for `400: application/json` of method `post /{projectKey}/payment-intents/{paymentId}` from type `null` to `ErrorResponse` +- :warning: changed response body for `400: application/json` of method `get /{projectKey}/transactions/{id}` from type `null` to `ErrorResponse` +- :warning: changed response body for `400: application/json` of method `get /{projectKey}/transactions/key={key}` from type `null` to `ErrorResponse` +
+ + +
+Added Method(s) + +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->get()` +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->post()` +- added method `$apiRoot->withProjectKey()->applications()->get()` +- added method `$apiRoot->withProjectKey()->applications()->post()` +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->withId()->get()` +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->withId()->head()` +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->withId()->post()` +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->withId()->delete()` +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->withKey()->get()` +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->withKey()->post()` +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->withKey()->head()` +- added method `$apiRoot->withProjectKey()->paymentIntegrations()->withKey()->delete()` +- added method `$apiRoot->withProjectKey()->applications()->withId()->get()` +- added method `$apiRoot->withProjectKey()->applications()->withId()->head()` +- added method `$apiRoot->withProjectKey()->applications()->withId()->post()` +- added method `$apiRoot->withProjectKey()->applications()->withId()->delete()` +- added method `$apiRoot->withProjectKey()->applications()->withKey()->get()` +- added method `$apiRoot->withProjectKey()->applications()->withKey()->post()` +- added method `$apiRoot->withProjectKey()->applications()->withKey()->head()` +- added method `$apiRoot->withProjectKey()->applications()->withKey()->delete()` +
+ + +
+Added Resource(s) + +- added resource `/{projectKey}/payment-integrations` +- added resource `/{projectKey}/applications` +- added resource `/{projectKey}/payment-integrations/{id}` +- added resource `/{projectKey}/payment-integrations/key={key}` +- added resource `/{projectKey}/applications/{id}` +- added resource `/{projectKey}/applications/key={key}` +
+ diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyCartsCustomerIdByCustomerIdMergeTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyCartsCustomerIdByCustomerIdMergeTest.php new file mode 100644 index 00000000000..7a15d358f86 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyCartsCustomerIdByCustomerIdMergeTest.php @@ -0,0 +1,223 @@ +assertSame(strtolower($method), strtolower($request->getMethod())); + $this->assertSame($relativeUri, (string) $request->getUri()); + if (!is_null($body)) { + $this->assertJsonStringEqualsJsonString($body, (string) $request->getBody()); + } else { + $this->assertSame("", (string) $request->getBody()); + } + } + + + + /** + * @dataProvider getRequestBuilderResponses() + */ + public function testMapFromResponse(callable $builderFunction, $statusCode) + { + $builder = new ApiRequestBuilder(); + $request = $builderFunction($builder); + $this->assertInstanceOf(ApiRequest::class, $request); + + $response = new Response($statusCode, [], "{}"); + $this->assertInstanceOf(JsonObject::class, $request->mapFromResponse($response)); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteClientException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ClientException("Oops!", $request, new Response(400))); + + $this->expectException(ApiClientException::class); + $request->execute(); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteServerException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ServerException("Oops!", $request, new Response(500))); + + $this->expectException(ApiServerException::class); + $request->execute(); + } + + public function getRequests() + { + return [ + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("test_customerId") + ->post(null); + }, + 'post', + 'test_projectKey/carts/customer-id=test_customerId/merge', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 200 + ], + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 400 + ], + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 401 + ], + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 403 + ], + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 404 + ], + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 500 + ], + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 502 + ], + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 503 + ], + 'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyCartsTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyCartsTest.php index 47c8dea079d..f2752871e47 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyCartsTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyCartsTest.php @@ -11,6 +11,7 @@ use Commercetools\Api\Client\ApiRequestBuilder; use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsByID; use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsCustomerIdByCustomerId; +use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge; use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsKeyByKey; use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsReplicate; use Commercetools\Base\JsonObject; @@ -262,6 +263,17 @@ function (ApiRequestBuilder $builder): ResourceByProjectKeyCartsCustomerIdByCust ['projectKey' => 'test_projectKey', 'customerId' => 'test_customerId'], '/{projectKey}/carts/customer-id={customerId}' ], + 'ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge { + return $builder + ->withProjectKey("test_projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("test_customerId"); + }, + ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge::class, + ['projectKey' => 'test_projectKey', 'customerId' => 'test_customerId'], + '/{projectKey}/carts/customer-id={customerId}/merge' + ], 'ResourceByProjectKeyCartsKeyByKey' => [ function (ApiRequestBuilder $builder): ResourceByProjectKeyCartsKeyByKey { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergeTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergeTest.php new file mode 100644 index 00000000000..6b7d119fda0 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergeTest.php @@ -0,0 +1,234 @@ +assertSame(strtolower($method), strtolower($request->getMethod())); + $this->assertSame($relativeUri, (string) $request->getUri()); + if (!is_null($body)) { + $this->assertJsonStringEqualsJsonString($body, (string) $request->getBody()); + } else { + $this->assertSame("", (string) $request->getBody()); + } + } + + + + /** + * @dataProvider getRequestBuilderResponses() + */ + public function testMapFromResponse(callable $builderFunction, $statusCode) + { + $builder = new ApiRequestBuilder(); + $request = $builderFunction($builder); + $this->assertInstanceOf(ApiRequest::class, $request); + + $response = new Response($statusCode, [], "{}"); + $this->assertInstanceOf(JsonObject::class, $request->mapFromResponse($response)); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteClientException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ClientException("Oops!", $request, new Response(400))); + + $this->expectException(ApiClientException::class); + $request->execute(); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteServerException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ServerException("Oops!", $request, new Response(500))); + + $this->expectException(ApiServerException::class); + $request->execute(); + } + + public function getRequests() + { + return [ + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("test_customerId") + ->post(null); + }, + 'post', + 'test_projectKey/in-store/key=test_storeKey/carts/customer-id=test_customerId/merge', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsTest.php index 95c7b66292f..368e6ecb998 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsTest.php @@ -11,6 +11,7 @@ use Commercetools\Api\Client\ApiRequestBuilder; use Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyCartsByID; use Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerId; +use Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMerge; use Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyCartsKeyByKey; use Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyCartsReplicate; use Commercetools\Base\JsonObject; @@ -264,6 +265,18 @@ function (ApiRequestBuilder $builder): ResourceByProjectKeyInStoreKeyByStoreKeyC ['projectKey' => 'test_projectKey', 'storeKey' => 'test_storeKey', 'customerId' => 'test_customerId'], '/{projectKey}/in-store/key={storeKey}/carts/customer-id={customerId}' ], + 'ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMerge' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMerge { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("test_customerId"); + }, + ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMerge::class, + ['projectKey' => 'test_projectKey', 'storeKey' => 'test_storeKey', 'customerId' => 'test_customerId'], + '/{projectKey}/in-store/key={storeKey}/carts/customer-id={customerId}/merge' + ], 'ResourceByProjectKeyInStoreKeyByStoreKeyCartsKeyByKey' => [ function (ApiRequestBuilder $builder): ResourceByProjectKeyInStoreKeyByStoreKeyCartsKeyByKey { return $builder diff --git a/lib/commercetools-api/docs/RequestBuilder.md b/lib/commercetools-api/docs/RequestBuilder.md index 50920f248bc..29d4ad2b12b 100644 --- a/lib/commercetools-api/docs/RequestBuilder.md +++ b/lib/commercetools-api/docs/RequestBuilder.md @@ -2293,6 +2293,23 @@ $request = $builder ->withCustomerId("customerId") ->head(); ``` +## `withProjectKey("projectKey")->carts()->customerIdWithCustomerIdValueMerge("customerId")->post(null)` + +Merges items from an anonymous Cart into the most recently modified active Cart of a Customer. If no active Cart exists, the anonymous Cart becomes the Customer's active Cart. +For more information, see [Merge behavior](/../api/carts-orders-overview#merge-behavior). + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); +``` ## `withProjectKey("projectKey")->carts()->withKey("key")->get()` Retrieves a Cart with the provided `key`. @@ -2727,6 +2744,8 @@ $request = $builder For performance reasons, it is highly advisable to query for Custom Objects in a container by using the `container` field in the `where` predicate. +This endpoint is deprecated and replaced by the [Query CustomObjects in Container](/../apis/ctp:api:endpoint:/{projectKey}/custom-objects/{container}:GET) endpoint. + ### Example ```php @@ -3007,6 +3026,8 @@ $request = $builder ``` ## `withProjectKey("projectKey")->customers()->post(null)` +Allows converting an anonymous Cart to the active Cart of a Customer with [cart merge](/../api/customers-overview#cart-merge-during-sign-in-and-sign-up). + Creating a Customer produces the [CustomerCreated](ctp:api:type:CustomerCreatedMessage) Message. Simultaneously creating two Customers with the same email address can return a [LockedField](ctp:api:type:LockedFieldError) error. @@ -4428,6 +4449,27 @@ $request = $builder ->withCustomerId("customerId") ->head(); ``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->carts()->customerIdWithCustomerIdValueMerge("customerId")->post(null)` + +Merges items from an anonymous Cart into the most recently modified active Cart of a Customer. If no active Cart exists, the anonymous Cart becomes the Customer's active Cart. + +If the Cart exists in the Project but does not have a `store` specified, or the `store` field references a different Store, a [ResourceNotFound](ctp:api:type:ResourceNotFoundError) error is returned. + +For more information, see [Merge behavior](/../api/carts-orders-overview#merge-behavior). + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->carts() + ->customerIdWithCustomerIdValueMerge("customerId") + ->post(null); +``` ## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->carts()->withKey("key")->get()` @@ -4573,7 +4615,8 @@ When using this endpoint, if omitted, the Customer `stores` field is set to the If a Cart with a `store` field specified, the `store` field must reference the same [Store](ctp:api:type:Store) specified in the `{storeKey}` path parameter. -If the Customer has multiple active Carts, the anonymous Cart is [merged](/../api/customers-overview#cart-merge-during-sign-in-and-sign-up) into the most recently modified active Cart. +Allows converting an anonymous Cart to the active Cart of a Customer with [cart merge](/../api/customers-overview#cart-merge-during-sign-in-and-sign-up). +If the Customer has multiple active Carts, the anonymous Cart is merged into the most recently modified active Cart. Creating a Customer produces the [CustomerCreated](ctp:api:type:CustomerCreatedMessage) Message. Simultaneously creating two Customers with the same email address can return a [LockedField](ctp:api:type:LockedFieldError) error. @@ -4880,7 +4923,9 @@ $request = $builder Authenticates a Customer associated with a [Store](ctp:api:type:Store). -If the Customer has multiple active Carts, the anonymous Cart is [merged](/../api/customers-overview#cart-merge-during-sign-in-and-sign-up) into the most recently modified active Cart. +Allows [merging](/../api/customers-overview#cart-merge-during-sign-in-and-sign-up) items from an anonymous Cart into the most recently modified active Cart of a Customer. +If no active Cart exists, the anonymous Cart becomes the Customer's active Cart. +If the Customer has multiple active Carts, the anonymous Cart is merged into the most recently modified active Cart. If the Customer exists in the Project but the `stores` field references a different [Store](ctp:api:type:Store), this method returns an [InvalidCredentials](ctp:api:type:InvalidCredentialsError) error. @@ -7125,7 +7170,9 @@ $request = $builder Authenticates a global Customer. -If the Customer has multiple active Carts, the anonymous Cart is [merged](/../api/customers-overview#cart-merge-during-sign-in-and-sign-up) into the most recently modified active Cart. +Allows [merging](/../api/customers-overview#cart-merge-during-sign-in-and-sign-up) items from an anonymous Cart into the most recently modified active Cart of a Customer. +If no active Cart exists, the anonymous Cart becomes the Customer's active Cart. +If the Customer has multiple active Carts, the anonymous Cart is merged into the most recently modified active Cart. If an account with the given credentials is not found, an [InvalidCredentials](ctp:api:type:InvalidCredentialsError) error is returned. diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyCartsCustomerIdByCustomerIdMergePost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyCartsCustomerIdByCustomerIdMergePost.php new file mode 100644 index 00000000000..0bef48a9daf --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyCartsCustomerIdByCustomerIdMergePost.php @@ -0,0 +1,144 @@ + + */ +class ByProjectKeyCartsCustomerIdByCustomerIdMergePost extends ApiRequest implements Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $customerId, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{customerId}'], [$projectKey, $customerId], '{projectKey}/carts/customer-id={customerId}/merge'); + parent::__construct($client, 'POST', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return Cart|ErrorResponse|JsonObject|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '200': + $resultType = CartModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|Cart|ErrorResponse|JsonObject + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost.php new file mode 100644 index 00000000000..3027adb86d9 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost.php @@ -0,0 +1,144 @@ + + */ +class ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost extends ApiRequest implements Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, string $customerId, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}', '{customerId}'], [$projectKey, $storeKey, $customerId], '{projectKey}/in-store/key={storeKey}/carts/customer-id={customerId}/merge'); + parent::__construct($client, 'POST', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return Cart|ErrorResponse|JsonObject|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '200': + $resultType = CartModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|Cart|ErrorResponse|JsonObject + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyCarts.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyCarts.php index 52323eed862..d45e6de952c 100644 --- a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyCarts.php +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyCarts.php @@ -45,6 +45,17 @@ public function withCustomerId(?string $customerId = null): ResourceByProjectKey return new ResourceByProjectKeyCartsCustomerIdByCustomerId($args, $this->getClient()); } + /** + */ + public function customerIdWithCustomerIdValueMerge(?string $customerId = null): ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge + { + $args = $this->getArgs(); + if (!is_null($customerId)) { + $args['customerId'] = $customerId; + } + + return new ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge($args, $this->getClient()); + } /** */ public function withKey(?string $key = null): ResourceByProjectKeyCartsKeyByKey diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge.php new file mode 100644 index 00000000000..4b586cfcac2 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge.php @@ -0,0 +1,39 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/carts/customer-id={customerId}/merge', $args, $client); + } + + /** + * @psalm-param ?MergeCartDraft $body + * @psalm-param array $headers + */ + public function post(?MergeCartDraft $body = null, array $headers = []): ByProjectKeyCartsCustomerIdByCustomerIdMergePost + { + $args = $this->getArgs(); + + return new ByProjectKeyCartsCustomerIdByCustomerIdMergePost($args['projectKey'], $args['customerId'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCarts.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCarts.php index b4debcd7131..edd1dc08576 100644 --- a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCarts.php +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCarts.php @@ -37,6 +37,17 @@ public function withCustomerId(?string $customerId = null): ResourceByProjectKey return new ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerId($args, $this->getClient()); } + /** + */ + public function customerIdWithCustomerIdValueMerge(?string $customerId = null): ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMerge + { + $args = $this->getArgs(); + if (!is_null($customerId)) { + $args['customerId'] = $customerId; + } + + return new ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMerge($args, $this->getClient()); + } /** */ public function withKey(?string $key = null): ResourceByProjectKeyInStoreKeyByStoreKeyCartsKeyByKey diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMerge.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMerge.php new file mode 100644 index 00000000000..7043935ca53 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMerge.php @@ -0,0 +1,39 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/in-store/key={storeKey}/carts/customer-id={customerId}/merge', $args, $client); + } + + /** + * @psalm-param ?MergeCartDraft $body + * @psalm-param array $headers + */ + public function post(?MergeCartDraft $body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyCartsCustomerIdByCustomerIdMergePost($args['projectKey'], $args['storeKey'], $args['customerId'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemAction.php b/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemAction.php index 48d6c7ed2eb..5a9b08cf705 100644 --- a/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemAction.php +++ b/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemAction.php @@ -38,8 +38,8 @@ public function getLineItemId(); public function getLineItemKey(); /** - *

Amount to subtract from the LineItem's quantity. - * If absent, the LineItem is removed from the Cart.

+ *

Amount to subtract from the LineItem quantity. + * If omitted, the LineItem is removed from the Cart.

* * @return null|int diff --git a/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemActionBuilder.php b/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemActionBuilder.php index bffbf567a23..be46bfe2942 100644 --- a/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemActionBuilder.php +++ b/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemActionBuilder.php @@ -81,8 +81,8 @@ public function getLineItemKey() } /** - *

Amount to subtract from the LineItem's quantity. - * If absent, the LineItem is removed from the Cart.

+ *

Amount to subtract from the LineItem quantity. + * If omitted, the LineItem is removed from the Cart.

* * @return null|int diff --git a/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemActionModel.php b/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemActionModel.php index e12b604ec1c..edd1dc49dd3 100644 --- a/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemActionModel.php +++ b/lib/commercetools-api/src/Models/Cart/CartRemoveLineItemActionModel.php @@ -145,8 +145,8 @@ public function getLineItemKey() } /** - *

Amount to subtract from the LineItem's quantity. - * If absent, the LineItem is removed from the Cart.

+ *

Amount to subtract from the LineItem quantity. + * If omitted, the LineItem is removed from the Cart.

* * * @return null|int diff --git a/lib/commercetools-api/src/Models/Cart/MergeCartDraft.php b/lib/commercetools-api/src/Models/Cart/MergeCartDraft.php new file mode 100644 index 00000000000..d06840cf1b9 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/MergeCartDraft.php @@ -0,0 +1,76 @@ +ResourceIdentifier to the anonymous Cart to be merged. Required if anonymousId is not provided.

+ * + + * @return null|CartResourceIdentifier + */ + public function getAnonymousCart(); + + /** + *

Determines how to merge the anonymous Cart with the existing Customer Cart.

+ * + + * @return null|string + */ + public function getMergeMode(); + + /** + *
    + *
  • If true, the LineItem Product data (name, variant, and productType) of the returned Cart will be updated.
  • + *
  • If false, only the prices, discounts, and tax rates will be updated.
  • + *
+ * + + * @return null|bool + */ + public function getUpdateProductData(); + + /** + *

Assigns the Customer to the Carts that have the same anonymousId. Required if anonymousCart is not provided. + * If both anonymousCart and anonymousId are provided, this value must match the anonymousId of the anonymous Cart otherwise, an InvalidOperation error is returned.

+ * + + * @return null|string + */ + public function getAnonymousId(); + + /** + * @param ?CartResourceIdentifier $anonymousCart + */ + public function setAnonymousCart(?CartResourceIdentifier $anonymousCart): void; + + /** + * @param ?string $mergeMode + */ + public function setMergeMode(?string $mergeMode): void; + + /** + * @param ?bool $updateProductData + */ + public function setUpdateProductData(?bool $updateProductData): void; + + /** + * @param ?string $anonymousId + */ + public function setAnonymousId(?string $anonymousId): void; +} diff --git a/lib/commercetools-api/src/Models/Cart/MergeCartDraftBuilder.php b/lib/commercetools-api/src/Models/Cart/MergeCartDraftBuilder.php new file mode 100644 index 00000000000..2864c717cd5 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/MergeCartDraftBuilder.php @@ -0,0 +1,164 @@ + + */ +final class MergeCartDraftBuilder implements Builder +{ + /** + + * @var null|CartResourceIdentifier|CartResourceIdentifierBuilder + */ + private $anonymousCart; + + /** + + * @var ?string + */ + private $mergeMode; + + /** + + * @var ?bool + */ + private $updateProductData; + + /** + + * @var ?string + */ + private $anonymousId; + + /** + *

ResourceIdentifier to the anonymous Cart to be merged. Required if anonymousId is not provided.

+ * + + * @return null|CartResourceIdentifier + */ + public function getAnonymousCart() + { + return $this->anonymousCart instanceof CartResourceIdentifierBuilder ? $this->anonymousCart->build() : $this->anonymousCart; + } + + /** + *

Determines how to merge the anonymous Cart with the existing Customer Cart.

+ * + + * @return null|string + */ + public function getMergeMode() + { + return $this->mergeMode; + } + + /** + *
    + *
  • If true, the LineItem Product data (name, variant, and productType) of the returned Cart will be updated.
  • + *
  • If false, only the prices, discounts, and tax rates will be updated.
  • + *
+ * + + * @return null|bool + */ + public function getUpdateProductData() + { + return $this->updateProductData; + } + + /** + *

Assigns the Customer to the Carts that have the same anonymousId. Required if anonymousCart is not provided. + * If both anonymousCart and anonymousId are provided, this value must match the anonymousId of the anonymous Cart otherwise, an InvalidOperation error is returned.

+ * + + * @return null|string + */ + public function getAnonymousId() + { + return $this->anonymousId; + } + + /** + * @param ?CartResourceIdentifier $anonymousCart + * @return $this + */ + public function withAnonymousCart(?CartResourceIdentifier $anonymousCart) + { + $this->anonymousCart = $anonymousCart; + + return $this; + } + + /** + * @param ?string $mergeMode + * @return $this + */ + public function withMergeMode(?string $mergeMode) + { + $this->mergeMode = $mergeMode; + + return $this; + } + + /** + * @param ?bool $updateProductData + * @return $this + */ + public function withUpdateProductData(?bool $updateProductData) + { + $this->updateProductData = $updateProductData; + + return $this; + } + + /** + * @param ?string $anonymousId + * @return $this + */ + public function withAnonymousId(?string $anonymousId) + { + $this->anonymousId = $anonymousId; + + return $this; + } + + /** + * @deprecated use withAnonymousCart() instead + * @return $this + */ + public function withAnonymousCartBuilder(?CartResourceIdentifierBuilder $anonymousCart) + { + $this->anonymousCart = $anonymousCart; + + return $this; + } + + public function build(): MergeCartDraft + { + return new MergeCartDraftModel( + $this->anonymousCart instanceof CartResourceIdentifierBuilder ? $this->anonymousCart->build() : $this->anonymousCart, + $this->mergeMode, + $this->updateProductData, + $this->anonymousId + ); + } + + public static function of(): MergeCartDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Cart/MergeCartDraftCollection.php b/lib/commercetools-api/src/Models/Cart/MergeCartDraftCollection.php new file mode 100644 index 00000000000..54185ec7aa6 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/MergeCartDraftCollection.php @@ -0,0 +1,56 @@ + + * @method MergeCartDraft current() + * @method MergeCartDraft end() + * @method MergeCartDraft at($offset) + */ +class MergeCartDraftCollection extends MapperSequence +{ + /** + * @psalm-assert MergeCartDraft $value + * @psalm-param MergeCartDraft|stdClass $value + * @throws InvalidArgumentException + * + * @return MergeCartDraftCollection + */ + public function add($value) + { + if (!$value instanceof MergeCartDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?MergeCartDraft + */ + protected function mapper() + { + return function (?int $index): ?MergeCartDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var MergeCartDraft $data */ + $data = MergeCartDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Cart/MergeCartDraftModel.php b/lib/commercetools-api/src/Models/Cart/MergeCartDraftModel.php new file mode 100644 index 00000000000..160e9f97d44 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/MergeCartDraftModel.php @@ -0,0 +1,179 @@ +anonymousCart = $anonymousCart; + $this->mergeMode = $mergeMode; + $this->updateProductData = $updateProductData; + $this->anonymousId = $anonymousId; + } + + /** + *

ResourceIdentifier to the anonymous Cart to be merged. Required if anonymousId is not provided.

+ * + * + * @return null|CartResourceIdentifier + */ + public function getAnonymousCart() + { + if (is_null($this->anonymousCart)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_ANONYMOUS_CART); + if (is_null($data)) { + return null; + } + + $this->anonymousCart = CartResourceIdentifierModel::of($data); + } + + return $this->anonymousCart; + } + + /** + *

Determines how to merge the anonymous Cart with the existing Customer Cart.

+ * + * + * @return null|string + */ + public function getMergeMode() + { + if (is_null($this->mergeMode)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_MERGE_MODE); + if (is_null($data)) { + return null; + } + $this->mergeMode = (string) $data; + } + + return $this->mergeMode; + } + + /** + *
    + *
  • If true, the LineItem Product data (name, variant, and productType) of the returned Cart will be updated.
  • + *
  • If false, only the prices, discounts, and tax rates will be updated.
  • + *
+ * + * + * @return null|bool + */ + public function getUpdateProductData() + { + if (is_null($this->updateProductData)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_UPDATE_PRODUCT_DATA); + if (is_null($data)) { + return null; + } + $this->updateProductData = (bool) $data; + } + + return $this->updateProductData; + } + + /** + *

Assigns the Customer to the Carts that have the same anonymousId. Required if anonymousCart is not provided. + * If both anonymousCart and anonymousId are provided, this value must match the anonymousId of the anonymous Cart otherwise, an InvalidOperation error is returned.

+ * + * + * @return null|string + */ + public function getAnonymousId() + { + if (is_null($this->anonymousId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ANONYMOUS_ID); + if (is_null($data)) { + return null; + } + $this->anonymousId = (string) $data; + } + + return $this->anonymousId; + } + + + /** + * @param ?CartResourceIdentifier $anonymousCart + */ + public function setAnonymousCart(?CartResourceIdentifier $anonymousCart): void + { + $this->anonymousCart = $anonymousCart; + } + + /** + * @param ?string $mergeMode + */ + public function setMergeMode(?string $mergeMode): void + { + $this->mergeMode = $mergeMode; + } + + /** + * @param ?bool $updateProductData + */ + public function setUpdateProductData(?bool $updateProductData): void + { + $this->updateProductData = $updateProductData; + } + + /** + * @param ?string $anonymousId + */ + public function setAnonymousId(?string $anonymousId): void + { + $this->anonymousId = $anonymousId; + } +} diff --git a/lib/commercetools-api/src/Models/CartDiscount/CartDiscount.php b/lib/commercetools-api/src/Models/CartDiscount/CartDiscount.php index 2eac8ea8e13..73ce7ef8005 100644 --- a/lib/commercetools-api/src/Models/CartDiscount/CartDiscount.php +++ b/lib/commercetools-api/src/Models/CartDiscount/CartDiscount.php @@ -192,8 +192,8 @@ public function getValidUntil(); public function getRequiresDiscountCode(); /** - *

References of all resources that are addressed in the predicate. - * The API generates this array from the predicate.

+ *

References to all resources addressed in the cartPredicate by their IDs. + * This value is generated by the platform.

* * @return null|ReferenceCollection diff --git a/lib/commercetools-api/src/Models/CartDiscount/CartDiscountBuilder.php b/lib/commercetools-api/src/Models/CartDiscount/CartDiscountBuilder.php index 851b9aa2dab..010060b7560 100644 --- a/lib/commercetools-api/src/Models/CartDiscount/CartDiscountBuilder.php +++ b/lib/commercetools-api/src/Models/CartDiscount/CartDiscountBuilder.php @@ -372,8 +372,8 @@ public function getRequiresDiscountCode() } /** - *

References of all resources that are addressed in the predicate. - * The API generates this array from the predicate.

+ *

References to all resources addressed in the cartPredicate by their IDs. + * This value is generated by the platform.

* * @return null|ReferenceCollection diff --git a/lib/commercetools-api/src/Models/CartDiscount/CartDiscountModel.php b/lib/commercetools-api/src/Models/CartDiscount/CartDiscountModel.php index 59be9d69acf..e1dd5ee13aa 100644 --- a/lib/commercetools-api/src/Models/CartDiscount/CartDiscountModel.php +++ b/lib/commercetools-api/src/Models/CartDiscount/CartDiscountModel.php @@ -607,8 +607,8 @@ public function getRequiresDiscountCode() } /** - *

References of all resources that are addressed in the predicate. - * The API generates this array from the predicate.

+ *

References to all resources addressed in the cartPredicate by their IDs. + * This value is generated by the platform.

* * * @return null|ReferenceCollection diff --git a/lib/commercetools-api/src/Models/Common/BaseResource.php b/lib/commercetools-api/src/Models/Common/BaseResource.php index 2a826eecd77..e96bdc11336 100644 --- a/lib/commercetools-api/src/Models/Common/BaseResource.php +++ b/lib/commercetools-api/src/Models/Common/BaseResource.php @@ -87,6 +87,8 @@ use Commercetools\Api\Models\Message\CartDiscountStoreAddedMessage; use Commercetools\Api\Models\Message\CartDiscountStoreRemovedMessage; use Commercetools\Api\Models\Message\CartDiscountStoresSetMessage; +use Commercetools\Api\Models\Message\CartFrozenMessage; +use Commercetools\Api\Models\Message\CartUnfrozenMessage; use Commercetools\Api\Models\Message\CategoryCreatedMessage; use Commercetools\Api\Models\Message\CategorySlugChangedMessage; use Commercetools\Api\Models\Message\CustomerAddressAddedMessage; @@ -140,6 +142,7 @@ use Commercetools\Api\Models\Message\Message; use Commercetools\Api\Models\Message\OrderMessage; use Commercetools\Api\Models\Message\OrderPaymentAddedMessage; +use Commercetools\Api\Models\Message\OrderPaymentRemovedMessage; use Commercetools\Api\Models\Message\PaymentCreatedMessage; use Commercetools\Api\Models\Message\PaymentInteractionAddedMessage; use Commercetools\Api\Models\Message\PaymentInterfaceIdSetMessage; @@ -234,6 +237,7 @@ use Commercetools\Api\Models\Message\RecurringOrderCustomTypeSetMessage; use Commercetools\Api\Models\Message\RecurringOrderDeletedMessage; use Commercetools\Api\Models\Message\RecurringOrderExpiresAtSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderFailedMessage; use Commercetools\Api\Models\Message\RecurringOrderKeySetMessage; use Commercetools\Api\Models\Message\RecurringOrderScheduleSetMessage; use Commercetools\Api\Models\Message\RecurringOrderStartsAtSetMessage; diff --git a/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php b/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php index 197762de6b1..51e2f2014fd 100644 --- a/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php +++ b/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php @@ -166,6 +166,10 @@ use Commercetools\Api\Models\Message\CartDiscountStoreRemovedMessageBuilder; use Commercetools\Api\Models\Message\CartDiscountStoresSetMessage; use Commercetools\Api\Models\Message\CartDiscountStoresSetMessageBuilder; +use Commercetools\Api\Models\Message\CartFrozenMessage; +use Commercetools\Api\Models\Message\CartFrozenMessageBuilder; +use Commercetools\Api\Models\Message\CartUnfrozenMessage; +use Commercetools\Api\Models\Message\CartUnfrozenMessageBuilder; use Commercetools\Api\Models\Message\CategoryCreatedMessage; use Commercetools\Api\Models\Message\CategoryCreatedMessageBuilder; use Commercetools\Api\Models\Message\CategorySlugChangedMessage; @@ -272,6 +276,8 @@ use Commercetools\Api\Models\Message\OrderMessageBuilder; use Commercetools\Api\Models\Message\OrderPaymentAddedMessage; use Commercetools\Api\Models\Message\OrderPaymentAddedMessageBuilder; +use Commercetools\Api\Models\Message\OrderPaymentRemovedMessage; +use Commercetools\Api\Models\Message\OrderPaymentRemovedMessageBuilder; use Commercetools\Api\Models\Message\PaymentCreatedMessage; use Commercetools\Api\Models\Message\PaymentCreatedMessageBuilder; use Commercetools\Api\Models\Message\PaymentInteractionAddedMessage; @@ -460,6 +466,8 @@ use Commercetools\Api\Models\Message\RecurringOrderDeletedMessageBuilder; use Commercetools\Api\Models\Message\RecurringOrderExpiresAtSetMessage; use Commercetools\Api\Models\Message\RecurringOrderExpiresAtSetMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderFailedMessage; +use Commercetools\Api\Models\Message\RecurringOrderFailedMessageBuilder; use Commercetools\Api\Models\Message\RecurringOrderKeySetMessage; use Commercetools\Api\Models\Message\RecurringOrderKeySetMessageBuilder; use Commercetools\Api\Models\Message\RecurringOrderScheduleSetMessage; diff --git a/lib/commercetools-api/src/Models/Common/BaseResourceModel.php b/lib/commercetools-api/src/Models/Common/BaseResourceModel.php index 52d91da4676..f5d2e80fa92 100644 --- a/lib/commercetools-api/src/Models/Common/BaseResourceModel.php +++ b/lib/commercetools-api/src/Models/Common/BaseResourceModel.php @@ -166,6 +166,10 @@ use Commercetools\Api\Models\Message\CartDiscountStoreRemovedMessageModel; use Commercetools\Api\Models\Message\CartDiscountStoresSetMessage; use Commercetools\Api\Models\Message\CartDiscountStoresSetMessageModel; +use Commercetools\Api\Models\Message\CartFrozenMessage; +use Commercetools\Api\Models\Message\CartFrozenMessageModel; +use Commercetools\Api\Models\Message\CartUnfrozenMessage; +use Commercetools\Api\Models\Message\CartUnfrozenMessageModel; use Commercetools\Api\Models\Message\CategoryCreatedMessage; use Commercetools\Api\Models\Message\CategoryCreatedMessageModel; use Commercetools\Api\Models\Message\CategorySlugChangedMessage; @@ -272,6 +276,8 @@ use Commercetools\Api\Models\Message\OrderMessageModel; use Commercetools\Api\Models\Message\OrderPaymentAddedMessage; use Commercetools\Api\Models\Message\OrderPaymentAddedMessageModel; +use Commercetools\Api\Models\Message\OrderPaymentRemovedMessage; +use Commercetools\Api\Models\Message\OrderPaymentRemovedMessageModel; use Commercetools\Api\Models\Message\PaymentCreatedMessage; use Commercetools\Api\Models\Message\PaymentCreatedMessageModel; use Commercetools\Api\Models\Message\PaymentInteractionAddedMessage; @@ -460,6 +466,8 @@ use Commercetools\Api\Models\Message\RecurringOrderDeletedMessageModel; use Commercetools\Api\Models\Message\RecurringOrderExpiresAtSetMessage; use Commercetools\Api\Models\Message\RecurringOrderExpiresAtSetMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderFailedMessage; +use Commercetools\Api\Models\Message\RecurringOrderFailedMessageModel; use Commercetools\Api\Models\Message\RecurringOrderKeySetMessage; use Commercetools\Api\Models\Message\RecurringOrderKeySetMessageModel; use Commercetools\Api\Models\Message\RecurringOrderScheduleSetMessage; diff --git a/lib/commercetools-api/src/Models/Common/Price.php b/lib/commercetools-api/src/Models/Common/Price.php index 757dd3f0bcd..c3ffb715625 100644 --- a/lib/commercetools-api/src/Models/Common/Price.php +++ b/lib/commercetools-api/src/Models/Common/Price.php @@ -98,7 +98,7 @@ public function getValidUntil(); /** *

Is set if a ProductDiscount has been applied. * If set, the API uses the DiscountedPrice value for the Line Item price selection. - * When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

+ * When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

*

If an absolute discount value exceeds the price of the Product Variant, the discounted price is a negative value.

* diff --git a/lib/commercetools-api/src/Models/Common/PriceBuilder.php b/lib/commercetools-api/src/Models/Common/PriceBuilder.php index f071f23ba73..d2da28e3825 100644 --- a/lib/commercetools-api/src/Models/Common/PriceBuilder.php +++ b/lib/commercetools-api/src/Models/Common/PriceBuilder.php @@ -192,7 +192,7 @@ public function getValidUntil() /** *

Is set if a ProductDiscount has been applied. * If set, the API uses the DiscountedPrice value for the Line Item price selection. - * When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

+ * When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

*

If an absolute discount value exceeds the price of the Product Variant, the discounted price is a negative value.

* diff --git a/lib/commercetools-api/src/Models/Common/PriceModel.php b/lib/commercetools-api/src/Models/Common/PriceModel.php index f4de6f9f169..367c53e845e 100644 --- a/lib/commercetools-api/src/Models/Common/PriceModel.php +++ b/lib/commercetools-api/src/Models/Common/PriceModel.php @@ -306,7 +306,7 @@ public function getValidUntil() /** *

Is set if a ProductDiscount has been applied. * If set, the API uses the DiscountedPrice value for the Line Item price selection. - * When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

+ * When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

*

If an absolute discount value exceeds the price of the Product Variant, the discounted price is a negative value.

* * diff --git a/lib/commercetools-api/src/Models/Common/ScopedPrice.php b/lib/commercetools-api/src/Models/Common/ScopedPrice.php index 0352edf2714..4b3f3df157b 100644 --- a/lib/commercetools-api/src/Models/Common/ScopedPrice.php +++ b/lib/commercetools-api/src/Models/Common/ScopedPrice.php @@ -94,7 +94,7 @@ public function getValidUntil(); /** *

Is set when a matching ProductDiscount exists. If set, the Cart uses the discounted value for the Cart Price calculation.

- *

When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

+ *

When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

* * @return null|DiscountedPrice diff --git a/lib/commercetools-api/src/Models/Common/ScopedPriceBuilder.php b/lib/commercetools-api/src/Models/Common/ScopedPriceBuilder.php index d7b78a10b44..83ee84227ba 100644 --- a/lib/commercetools-api/src/Models/Common/ScopedPriceBuilder.php +++ b/lib/commercetools-api/src/Models/Common/ScopedPriceBuilder.php @@ -177,7 +177,7 @@ public function getValidUntil() /** *

Is set when a matching ProductDiscount exists. If set, the Cart uses the discounted value for the Cart Price calculation.

- *

When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

+ *

When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

* * @return null|DiscountedPrice diff --git a/lib/commercetools-api/src/Models/Common/ScopedPriceModel.php b/lib/commercetools-api/src/Models/Common/ScopedPriceModel.php index c4602e4b6c6..f36001a629e 100644 --- a/lib/commercetools-api/src/Models/Common/ScopedPriceModel.php +++ b/lib/commercetools-api/src/Models/Common/ScopedPriceModel.php @@ -288,7 +288,7 @@ public function getValidUntil() /** *

Is set when a matching ProductDiscount exists. If set, the Cart uses the discounted value for the Cart Price calculation.

- *

When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

+ *

When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

* * * @return null|DiscountedPrice diff --git a/lib/commercetools-api/src/Models/DiscountCode/DiscountCode.php b/lib/commercetools-api/src/Models/DiscountCode/DiscountCode.php index bc805d40159..1eb3bb2b5ca 100644 --- a/lib/commercetools-api/src/Models/DiscountCode/DiscountCode.php +++ b/lib/commercetools-api/src/Models/DiscountCode/DiscountCode.php @@ -144,8 +144,8 @@ public function getCartPredicate(); public function getIsActive(); /** - *

Array generated from the Cart predicate. - * It contains the references of all the resources that are addressed in the predicate.

+ *

References to all resources addressed in the cartPredicate by their IDs. + * This value is generated by the platform.

* * @return null|ReferenceCollection diff --git a/lib/commercetools-api/src/Models/DiscountCode/DiscountCodeBuilder.php b/lib/commercetools-api/src/Models/DiscountCode/DiscountCodeBuilder.php index be833d4d38e..36594a979b2 100644 --- a/lib/commercetools-api/src/Models/DiscountCode/DiscountCodeBuilder.php +++ b/lib/commercetools-api/src/Models/DiscountCode/DiscountCodeBuilder.php @@ -303,8 +303,8 @@ public function getIsActive() } /** - *

Array generated from the Cart predicate. - * It contains the references of all the resources that are addressed in the predicate.

+ *

References to all resources addressed in the cartPredicate by their IDs. + * This value is generated by the platform.

* * @return null|ReferenceCollection diff --git a/lib/commercetools-api/src/Models/DiscountCode/DiscountCodeModel.php b/lib/commercetools-api/src/Models/DiscountCode/DiscountCodeModel.php index 02311e51eff..3241305d090 100644 --- a/lib/commercetools-api/src/Models/DiscountCode/DiscountCodeModel.php +++ b/lib/commercetools-api/src/Models/DiscountCode/DiscountCodeModel.php @@ -481,8 +481,8 @@ public function getIsActive() } /** - *

Array generated from the Cart predicate. - * It contains the references of all the resources that are addressed in the predicate.

+ *

References to all resources addressed in the cartPredicate by their IDs. + * This value is generated by the platform.

* * * @return null|ReferenceCollection diff --git a/lib/commercetools-api/src/Models/Error/ErrorObjectModel.php b/lib/commercetools-api/src/Models/Error/ErrorObjectModel.php index b65283f2e19..912fb86c79a 100644 --- a/lib/commercetools-api/src/Models/Error/ErrorObjectModel.php +++ b/lib/commercetools-api/src/Models/Error/ErrorObjectModel.php @@ -101,6 +101,7 @@ final class ErrorObjectModel extends JsonObjectModel implements ErrorObject 'ProjectNotConfiguredForLanguages' => ProjectNotConfiguredForLanguagesErrorModel::class, 'QueryComplexityLimitExceeded' => QueryComplexityLimitExceededErrorModel::class, 'QueryTimedOut' => QueryTimedOutErrorModel::class, + 'RecurringOrderFailure' => RecurringOrderFailureErrorModel::class, 'ReferenceExists' => ReferenceExistsErrorModel::class, 'ReferencedResourceNotFound' => ReferencedResourceNotFoundErrorModel::class, 'RequiredField' => RequiredFieldErrorModel::class, diff --git a/lib/commercetools-api/src/Models/Error/GraphQLErrorObjectModel.php b/lib/commercetools-api/src/Models/Error/GraphQLErrorObjectModel.php index 120c06f4a16..e93d2943097 100644 --- a/lib/commercetools-api/src/Models/Error/GraphQLErrorObjectModel.php +++ b/lib/commercetools-api/src/Models/Error/GraphQLErrorObjectModel.php @@ -95,6 +95,7 @@ final class GraphQLErrorObjectModel extends JsonObjectModel implements GraphQLEr 'ProjectNotConfiguredForLanguages' => GraphQLProjectNotConfiguredForLanguagesErrorModel::class, 'QueryComplexityLimitExceeded' => GraphQLQueryComplexityLimitExceededErrorModel::class, 'QueryTimedOut' => GraphQLQueryTimedOutErrorModel::class, + 'RecurringOrderFailure' => GraphQLRecurringOrderFailureErrorModel::class, 'ReferenceExists' => GraphQLReferenceExistsErrorModel::class, 'ReferencedResourceNotFound' => GraphQLReferencedResourceNotFoundErrorModel::class, 'RequiredField' => GraphQLRequiredFieldErrorModel::class, diff --git a/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureError.php b/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureError.php new file mode 100644 index 00000000000..3c80870ace5 --- /dev/null +++ b/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureError.php @@ -0,0 +1,36 @@ +Details about the error's cause and the entities involved.

+ * + + * @return null|mixed + */ + public function getDetails(); + + /** + * @param mixed $details + */ + public function setDetails($details): void; +} diff --git a/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureErrorBuilder.php b/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureErrorBuilder.php new file mode 100644 index 00000000000..836e2a6cd52 --- /dev/null +++ b/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureErrorBuilder.php @@ -0,0 +1,63 @@ + + */ +final class GraphQLRecurringOrderFailureErrorBuilder implements Builder +{ + /** + + * @var null|mixed|mixed + */ + private $details; + + /** + *

Details about the error's cause and the entities involved.

+ * + + * @return null|mixed + */ + public function getDetails() + { + return $this->details; + } + + /** + * @param mixed $details + * @return $this + */ + public function withDetails($details) + { + $this->details = $details; + + return $this; + } + + + public function build(): GraphQLRecurringOrderFailureError + { + return new GraphQLRecurringOrderFailureErrorModel( + $this->details + ); + } + + public static function of(): GraphQLRecurringOrderFailureErrorBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureErrorCollection.php b/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureErrorCollection.php new file mode 100644 index 00000000000..8a6de74e3ab --- /dev/null +++ b/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureErrorCollection.php @@ -0,0 +1,56 @@ + + * @method GraphQLRecurringOrderFailureError current() + * @method GraphQLRecurringOrderFailureError end() + * @method GraphQLRecurringOrderFailureError at($offset) + */ +class GraphQLRecurringOrderFailureErrorCollection extends GraphQLErrorObjectCollection +{ + /** + * @psalm-assert GraphQLRecurringOrderFailureError $value + * @psalm-param GraphQLRecurringOrderFailureError|stdClass $value + * @throws InvalidArgumentException + * + * @return GraphQLRecurringOrderFailureErrorCollection + */ + public function add($value) + { + if (!$value instanceof GraphQLRecurringOrderFailureError) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?GraphQLRecurringOrderFailureError + */ + protected function mapper() + { + return function (?int $index): ?GraphQLRecurringOrderFailureError { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var GraphQLRecurringOrderFailureError $data */ + $data = GraphQLRecurringOrderFailureErrorModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureErrorModel.php b/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureErrorModel.php new file mode 100644 index 00000000000..babfdca03be --- /dev/null +++ b/lib/commercetools-api/src/Models/Error/GraphQLRecurringOrderFailureErrorModel.php @@ -0,0 +1,106 @@ +details = $details; + $this->code = $code ?? self::DISCRIMINATOR_VALUE; + } + + /** + * + * @return null|string + */ + public function getCode() + { + if (is_null($this->code)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CODE); + if (is_null($data)) { + return null; + } + $this->code = (string) $data; + } + + return $this->code; + } + + /** + *

Details about the error's cause and the entities involved.

+ * + * + * @return null|mixed + */ + public function getDetails() + { + if (is_null($this->details)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_DETAILS); + if (is_null($data)) { + return null; + } + $this->details = $data; + } + + return $this->details; + } + + + /** + * @param mixed $details + */ + public function setDetails($details): void + { + $this->details = $details; + } + + /** + * @return mixed + */ + public function by(string $key) + { + $data = $this->raw($key); + if (is_null($data)) { + return null; + } + + return $data; + } +} diff --git a/lib/commercetools-api/src/Models/Error/RecurringOrderFailureError.php b/lib/commercetools-api/src/Models/Error/RecurringOrderFailureError.php new file mode 100644 index 00000000000..268b91dec35 --- /dev/null +++ b/lib/commercetools-api/src/Models/Error/RecurringOrderFailureError.php @@ -0,0 +1,49 @@ +Plain text description of the error.

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

Details about the error's cause and the entities involved.

+ * + + * @return null|mixed + */ + public function getDetails(); + + /** + * @param ?string $message + */ + public function setMessage(?string $message): void; + + /** + * @param mixed $details + */ + public function setDetails($details): void; +} diff --git a/lib/commercetools-api/src/Models/Error/RecurringOrderFailureErrorBuilder.php b/lib/commercetools-api/src/Models/Error/RecurringOrderFailureErrorBuilder.php new file mode 100644 index 00000000000..2844a0148ae --- /dev/null +++ b/lib/commercetools-api/src/Models/Error/RecurringOrderFailureErrorBuilder.php @@ -0,0 +1,92 @@ + + */ +final class RecurringOrderFailureErrorBuilder implements Builder +{ + /** + + * @var ?string + */ + private $message; + + /** + + * @var null|mixed|mixed + */ + private $details; + + /** + *

Plain text description of the error.

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

Details about the error's cause and the entities involved.

+ * + + * @return null|mixed + */ + public function getDetails() + { + return $this->details; + } + + /** + * @param ?string $message + * @return $this + */ + public function withMessage(?string $message) + { + $this->message = $message; + + return $this; + } + + /** + * @param mixed $details + * @return $this + */ + public function withDetails($details) + { + $this->details = $details; + + return $this; + } + + + public function build(): RecurringOrderFailureError + { + return new RecurringOrderFailureErrorModel( + $this->message, + $this->details + ); + } + + public static function of(): RecurringOrderFailureErrorBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Error/RecurringOrderFailureErrorCollection.php b/lib/commercetools-api/src/Models/Error/RecurringOrderFailureErrorCollection.php new file mode 100644 index 00000000000..0272041f839 --- /dev/null +++ b/lib/commercetools-api/src/Models/Error/RecurringOrderFailureErrorCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderFailureError current() + * @method RecurringOrderFailureError end() + * @method RecurringOrderFailureError at($offset) + */ +class RecurringOrderFailureErrorCollection extends ErrorObjectCollection +{ + /** + * @psalm-assert RecurringOrderFailureError $value + * @psalm-param RecurringOrderFailureError|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderFailureErrorCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderFailureError) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderFailureError + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderFailureError { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderFailureError $data */ + $data = RecurringOrderFailureErrorModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Error/RecurringOrderFailureErrorModel.php b/lib/commercetools-api/src/Models/Error/RecurringOrderFailureErrorModel.php new file mode 100644 index 00000000000..e13a4064e25 --- /dev/null +++ b/lib/commercetools-api/src/Models/Error/RecurringOrderFailureErrorModel.php @@ -0,0 +1,142 @@ +message = $message; + $this->details = $details; + $this->code = $code ?? self::DISCRIMINATOR_VALUE; + } + + /** + * + * @return null|string + */ + public function getCode() + { + if (is_null($this->code)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CODE); + if (is_null($data)) { + return null; + } + $this->code = (string) $data; + } + + return $this->code; + } + + /** + *

Plain text description of the error.

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

Details about the error's cause and the entities involved.

+ * + * + * @return null|mixed + */ + public function getDetails() + { + if (is_null($this->details)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_DETAILS); + if (is_null($data)) { + return null; + } + $this->details = $data; + } + + return $this->details; + } + + + /** + * @param ?string $message + */ + public function setMessage(?string $message): void + { + $this->message = $message; + } + + /** + * @param mixed $details + */ + public function setDetails($details): void + { + $this->details = $details; + } + + /** + * @return mixed + */ + public function by(string $key) + { + $data = $this->raw($key); + if (is_null($data)) { + return null; + } + + return $data; + } +} diff --git a/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemAction.php b/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemAction.php index f0cf71230ea..83fc75662e6 100644 --- a/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemAction.php +++ b/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemAction.php @@ -40,8 +40,8 @@ public function getLineItemId(); public function getLineItemKey(); /** - *

Amount to subtract from the LineItem's quantity. - * If absent, the LineItem is removed from the Cart.

+ *

Amount to subtract from the LineItem quantity. + * If omitted, the LineItem is removed from the Cart.

* * @return null|int diff --git a/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemActionBuilder.php b/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemActionBuilder.php index 00a15a291bb..54855707e6a 100644 --- a/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemActionBuilder.php +++ b/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemActionBuilder.php @@ -85,8 +85,8 @@ public function getLineItemKey() } /** - *

Amount to subtract from the LineItem's quantity. - * If absent, the LineItem is removed from the Cart.

+ *

Amount to subtract from the LineItem quantity. + * If omitted, the LineItem is removed from the Cart.

* * @return null|int diff --git a/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemActionModel.php b/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemActionModel.php index a180ea76aa0..83766758d5d 100644 --- a/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemActionModel.php +++ b/lib/commercetools-api/src/Models/Me/MyCartRemoveLineItemActionModel.php @@ -149,8 +149,8 @@ public function getLineItemKey() } /** - *

Amount to subtract from the LineItem's quantity. - * If absent, the LineItem is removed from the Cart.

+ *

Amount to subtract from the LineItem quantity. + * If omitted, the LineItem is removed from the Cart.

* * * @return null|int diff --git a/lib/commercetools-api/src/Models/Message/CartFrozenMessage.php b/lib/commercetools-api/src/Models/Message/CartFrozenMessage.php new file mode 100644 index 00000000000..39eeb551804 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartFrozenMessage.php @@ -0,0 +1,16 @@ + + */ +final class CartFrozenMessageBuilder 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(): CartFrozenMessage + { + return new CartFrozenMessageModel( + $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(): CartFrozenMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/CartFrozenMessageCollection.php b/lib/commercetools-api/src/Models/Message/CartFrozenMessageCollection.php new file mode 100644 index 00000000000..f23951ba903 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartFrozenMessageCollection.php @@ -0,0 +1,56 @@ + + * @method CartFrozenMessage current() + * @method CartFrozenMessage end() + * @method CartFrozenMessage at($offset) + */ +class CartFrozenMessageCollection extends MessageCollection +{ + /** + * @psalm-assert CartFrozenMessage $value + * @psalm-param CartFrozenMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return CartFrozenMessageCollection + */ + public function add($value) + { + if (!$value instanceof CartFrozenMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CartFrozenMessage + */ + protected function mapper() + { + return function (?int $index): ?CartFrozenMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CartFrozenMessage $data */ + $data = CartFrozenMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/CartFrozenMessageModel.php b/lib/commercetools-api/src/Models/Message/CartFrozenMessageModel.php new file mode 100644 index 00000000000..a4ac8af85e3 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartFrozenMessageModel.php @@ -0,0 +1,454 @@ +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 ?? 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; + } + + + /** + * @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/CartFrozenMessagePayload.php b/lib/commercetools-api/src/Models/Message/CartFrozenMessagePayload.php new file mode 100644 index 00000000000..0de421697ae --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartFrozenMessagePayload.php @@ -0,0 +1,16 @@ + + */ +final class CartFrozenMessagePayloadBuilder implements Builder +{ + public function build(): CartFrozenMessagePayload + { + return new CartFrozenMessagePayloadModel( + ); + } + + public static function of(): CartFrozenMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/CartFrozenMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/CartFrozenMessagePayloadCollection.php new file mode 100644 index 00000000000..41f4291ce7b --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartFrozenMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method CartFrozenMessagePayload current() + * @method CartFrozenMessagePayload end() + * @method CartFrozenMessagePayload at($offset) + */ +class CartFrozenMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert CartFrozenMessagePayload $value + * @psalm-param CartFrozenMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return CartFrozenMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof CartFrozenMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CartFrozenMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?CartFrozenMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CartFrozenMessagePayload $data */ + $data = CartFrozenMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/CartFrozenMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/CartFrozenMessagePayloadModel.php new file mode 100644 index 00000000000..55c505ca70b --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartFrozenMessagePayloadModel.php @@ -0,0 +1,56 @@ +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; + } +} diff --git a/lib/commercetools-api/src/Models/Message/CartUnfrozenMessage.php b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessage.php new file mode 100644 index 00000000000..9e8a59cbce4 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessage.php @@ -0,0 +1,16 @@ + + */ +final class CartUnfrozenMessageBuilder 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(): CartUnfrozenMessage + { + return new CartUnfrozenMessageModel( + $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(): CartUnfrozenMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/CartUnfrozenMessageCollection.php b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessageCollection.php new file mode 100644 index 00000000000..7c7c2c7b456 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessageCollection.php @@ -0,0 +1,56 @@ + + * @method CartUnfrozenMessage current() + * @method CartUnfrozenMessage end() + * @method CartUnfrozenMessage at($offset) + */ +class CartUnfrozenMessageCollection extends MessageCollection +{ + /** + * @psalm-assert CartUnfrozenMessage $value + * @psalm-param CartUnfrozenMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return CartUnfrozenMessageCollection + */ + public function add($value) + { + if (!$value instanceof CartUnfrozenMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CartUnfrozenMessage + */ + protected function mapper() + { + return function (?int $index): ?CartUnfrozenMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CartUnfrozenMessage $data */ + $data = CartUnfrozenMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/CartUnfrozenMessageModel.php b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessageModel.php new file mode 100644 index 00000000000..4cb2ffed3d6 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessageModel.php @@ -0,0 +1,454 @@ +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 ?? 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; + } + + + /** + * @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/CartUnfrozenMessagePayload.php b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessagePayload.php new file mode 100644 index 00000000000..43b77ddd52e --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessagePayload.php @@ -0,0 +1,16 @@ + + */ +final class CartUnfrozenMessagePayloadBuilder implements Builder +{ + public function build(): CartUnfrozenMessagePayload + { + return new CartUnfrozenMessagePayloadModel( + ); + } + + public static function of(): CartUnfrozenMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/CartUnfrozenMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessagePayloadCollection.php new file mode 100644 index 00000000000..ff7da7e5cb4 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method CartUnfrozenMessagePayload current() + * @method CartUnfrozenMessagePayload end() + * @method CartUnfrozenMessagePayload at($offset) + */ +class CartUnfrozenMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert CartUnfrozenMessagePayload $value + * @psalm-param CartUnfrozenMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return CartUnfrozenMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof CartUnfrozenMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CartUnfrozenMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?CartUnfrozenMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CartUnfrozenMessagePayload $data */ + $data = CartUnfrozenMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/CartUnfrozenMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessagePayloadModel.php new file mode 100644 index 00000000000..7028e26aa27 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/CartUnfrozenMessagePayloadModel.php @@ -0,0 +1,56 @@ +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; + } +} diff --git a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessage.php b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessage.php index b8766f92ab7..a4c32292354 100644 --- a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessage.php +++ b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessage.php @@ -18,6 +18,7 @@ interface InventoryEntryQuantitySetMessage extends Message public const FIELD_NEW_QUANTITY_ON_STOCK = 'newQuantityOnStock'; public const FIELD_OLD_AVAILABLE_QUANTITY = 'oldAvailableQuantity'; public const FIELD_NEW_AVAILABLE_QUANTITY = 'newAvailableQuantity'; + public const FIELD_SKU = 'sku'; public const FIELD_SUPPLY_CHANNEL = 'supplyChannel'; /** @@ -52,6 +53,14 @@ public function getOldAvailableQuantity(); */ public function getNewAvailableQuantity(); + /** + *

SKU of the InventoryEntry for which the quantity was updated.

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

Reference to the Channel where the InventoryEntry quantity was set.

* @@ -80,6 +89,11 @@ public function setOldAvailableQuantity(?int $oldAvailableQuantity): void; */ public function setNewAvailableQuantity(?int $newAvailableQuantity): void; + /** + * @param ?string $sku + */ + public function setSku(?string $sku): void; + /** * @param ?ChannelReference $supplyChannel */ diff --git a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessageBuilder.php b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessageBuilder.php index 8754530bf48..12550178bd7 100644 --- a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessageBuilder.php +++ b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessageBuilder.php @@ -113,6 +113,12 @@ final class InventoryEntryQuantitySetMessageBuilder implements Builder */ private $newAvailableQuantity; + /** + + * @var ?string + */ + private $sku; + /** * @var null|ChannelReference|ChannelReferenceBuilder @@ -274,6 +280,17 @@ public function getNewAvailableQuantity() return $this->newAvailableQuantity; } + /** + *

SKU of the InventoryEntry for which the quantity was updated.

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

Reference to the Channel where the InventoryEntry quantity was set.

* @@ -439,6 +456,17 @@ public function withNewAvailableQuantity(?int $newAvailableQuantity) return $this; } + /** + * @param ?string $sku + * @return $this + */ + public function withSku(?string $sku) + { + $this->sku = $sku; + + return $this; + } + /** * @param ?ChannelReference $supplyChannel * @return $this @@ -522,6 +550,7 @@ public function build(): InventoryEntryQuantitySetMessage $this->newQuantityOnStock, $this->oldAvailableQuantity, $this->newAvailableQuantity, + $this->sku, $this->supplyChannel instanceof ChannelReferenceBuilder ? $this->supplyChannel->build() : $this->supplyChannel ); } diff --git a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessageModel.php b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessageModel.php index 972a718b8f3..81b65e8e84b 100644 --- a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessageModel.php +++ b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessageModel.php @@ -119,6 +119,12 @@ final class InventoryEntryQuantitySetMessageModel extends JsonObjectModel implem */ protected $newAvailableQuantity; + /** + * + * @var ?string + */ + protected $sku; + /** * * @var ?ChannelReference @@ -144,6 +150,7 @@ public function __construct( ?int $newQuantityOnStock = null, ?int $oldAvailableQuantity = null, ?int $newAvailableQuantity = null, + ?string $sku = null, ?ChannelReference $supplyChannel = null, ?string $type = null ) { @@ -161,6 +168,7 @@ public function __construct( $this->newQuantityOnStock = $newQuantityOnStock; $this->oldAvailableQuantity = $oldAvailableQuantity; $this->newAvailableQuantity = $newAvailableQuantity; + $this->sku = $sku; $this->supplyChannel = $supplyChannel; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -478,6 +486,26 @@ public function getNewAvailableQuantity() return $this->newAvailableQuantity; } + /** + *

SKU of the InventoryEntry for which the quantity was updated.

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

Reference to the Channel where the InventoryEntry quantity was set.

* @@ -612,6 +640,14 @@ public function setNewAvailableQuantity(?int $newAvailableQuantity): void $this->newAvailableQuantity = $newAvailableQuantity; } + /** + * @param ?string $sku + */ + public function setSku(?string $sku): void + { + $this->sku = $sku; + } + /** * @param ?ChannelReference $supplyChannel */ diff --git a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayload.php b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayload.php index 9c5569ea6cf..a160b56847d 100644 --- a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayload.php +++ b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayload.php @@ -18,6 +18,7 @@ interface InventoryEntryQuantitySetMessagePayload extends MessagePayload public const FIELD_NEW_QUANTITY_ON_STOCK = 'newQuantityOnStock'; public const FIELD_OLD_AVAILABLE_QUANTITY = 'oldAvailableQuantity'; public const FIELD_NEW_AVAILABLE_QUANTITY = 'newAvailableQuantity'; + public const FIELD_SKU = 'sku'; public const FIELD_SUPPLY_CHANNEL = 'supplyChannel'; /** @@ -52,6 +53,14 @@ public function getOldAvailableQuantity(); */ public function getNewAvailableQuantity(); + /** + *

SKU of the InventoryEntry for which the quantity was updated.

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

Reference to the Channel where the InventoryEntry quantity was set.

* @@ -80,6 +89,11 @@ public function setOldAvailableQuantity(?int $oldAvailableQuantity): void; */ public function setNewAvailableQuantity(?int $newAvailableQuantity): void; + /** + * @param ?string $sku + */ + public function setSku(?string $sku): void; + /** * @param ?ChannelReference $supplyChannel */ diff --git a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayloadBuilder.php index 6695d5dd451..f8c0fcd08a9 100644 --- a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayloadBuilder.php +++ b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayloadBuilder.php @@ -46,6 +46,12 @@ final class InventoryEntryQuantitySetMessagePayloadBuilder implements Builder */ private $newAvailableQuantity; + /** + + * @var ?string + */ + private $sku; + /** * @var null|ChannelReference|ChannelReferenceBuilder @@ -96,6 +102,17 @@ public function getNewAvailableQuantity() return $this->newAvailableQuantity; } + /** + *

SKU of the InventoryEntry for which the quantity was updated.

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

Reference to the Channel where the InventoryEntry quantity was set.

* @@ -151,6 +168,17 @@ public function withNewAvailableQuantity(?int $newAvailableQuantity) return $this; } + /** + * @param ?string $sku + * @return $this + */ + public function withSku(?string $sku) + { + $this->sku = $sku; + + return $this; + } + /** * @param ?ChannelReference $supplyChannel * @return $this @@ -180,6 +208,7 @@ public function build(): InventoryEntryQuantitySetMessagePayload $this->newQuantityOnStock, $this->oldAvailableQuantity, $this->newAvailableQuantity, + $this->sku, $this->supplyChannel instanceof ChannelReferenceBuilder ? $this->supplyChannel->build() : $this->supplyChannel ); } diff --git a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayloadModel.php index ab7345d98df..88999b705f1 100644 --- a/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayloadModel.php +++ b/lib/commercetools-api/src/Models/Message/InventoryEntryQuantitySetMessagePayloadModel.php @@ -52,6 +52,12 @@ final class InventoryEntryQuantitySetMessagePayloadModel extends JsonObjectModel */ protected $newAvailableQuantity; + /** + * + * @var ?string + */ + protected $sku; + /** * * @var ?ChannelReference @@ -67,6 +73,7 @@ public function __construct( ?int $newQuantityOnStock = null, ?int $oldAvailableQuantity = null, ?int $newAvailableQuantity = null, + ?string $sku = null, ?ChannelReference $supplyChannel = null, ?string $type = null ) { @@ -74,6 +81,7 @@ public function __construct( $this->newQuantityOnStock = $newQuantityOnStock; $this->oldAvailableQuantity = $oldAvailableQuantity; $this->newAvailableQuantity = $newAvailableQuantity; + $this->sku = $sku; $this->supplyChannel = $supplyChannel; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -176,6 +184,26 @@ public function getNewAvailableQuantity() return $this->newAvailableQuantity; } + /** + *

SKU of the InventoryEntry for which the quantity was updated.

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

Reference to the Channel where the InventoryEntry quantity was set.

* @@ -230,6 +258,14 @@ public function setNewAvailableQuantity(?int $newAvailableQuantity): void $this->newAvailableQuantity = $newAvailableQuantity; } + /** + * @param ?string $sku + */ + public function setSku(?string $sku): void + { + $this->sku = $sku; + } + /** * @param ?ChannelReference $supplyChannel */ diff --git a/lib/commercetools-api/src/Models/Message/MessageModel.php b/lib/commercetools-api/src/Models/Message/MessageModel.php index 64ce0dca592..4a022a0a335 100644 --- a/lib/commercetools-api/src/Models/Message/MessageModel.php +++ b/lib/commercetools-api/src/Models/Message/MessageModel.php @@ -161,6 +161,8 @@ final class MessageModel extends JsonObjectModel implements Message 'CartDiscountStoreAdded' => CartDiscountStoreAddedMessageModel::class, 'CartDiscountStoreRemoved' => CartDiscountStoreRemovedMessageModel::class, 'CartDiscountStoresSet' => CartDiscountStoresSetMessageModel::class, + 'CartFrozen' => CartFrozenMessageModel::class, + 'CartUnfrozen' => CartUnfrozenMessageModel::class, 'CategoryCreated' => CategoryCreatedMessageModel::class, 'CategorySlugChanged' => CategorySlugChangedMessageModel::class, 'CustomLineItemStateTransition' => CustomLineItemStateTransitionMessageModel::class, @@ -249,6 +251,7 @@ final class MessageModel extends JsonObjectModel implements Message 'OrderLineItemDistributionChannelSet' => OrderLineItemDistributionChannelSetMessageModel::class, 'OrderLineItemRemoved' => OrderLineItemRemovedMessageModel::class, 'OrderPaymentAdded' => OrderPaymentAddedMessageModel::class, + 'OrderPaymentRemoved' => OrderPaymentRemovedMessageModel::class, 'OrderPaymentStateChanged' => OrderPaymentStateChangedMessageModel::class, 'OrderPurchaseOrderNumberSet' => OrderPurchaseOrderNumberSetMessageModel::class, 'OrderReturnShipmentStateChanged' => OrderReturnShipmentStateChangedMessageModel::class, @@ -358,6 +361,7 @@ final class MessageModel extends JsonObjectModel implements Message 'RecurringOrderCustomTypeSet' => RecurringOrderCustomTypeSetMessageModel::class, 'RecurringOrderDeleted' => RecurringOrderDeletedMessageModel::class, 'RecurringOrderExpiresAtSet' => RecurringOrderExpiresAtSetMessageModel::class, + 'RecurringOrderFailed' => RecurringOrderFailedMessageModel::class, 'RecurringOrderKeySet' => RecurringOrderKeySetMessageModel::class, 'RecurringOrderScheduleSet' => RecurringOrderScheduleSetMessageModel::class, 'RecurringOrderStartsAtSet' => RecurringOrderStartsAtSetMessageModel::class, diff --git a/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php index 67df04d0f06..1c3bb387b88 100644 --- a/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php +++ b/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php @@ -92,6 +92,8 @@ final class MessagePayloadModel extends JsonObjectModel implements MessagePayloa 'CartDiscountStoreAdded' => CartDiscountStoreAddedMessagePayloadModel::class, 'CartDiscountStoreRemoved' => CartDiscountStoreRemovedMessagePayloadModel::class, 'CartDiscountStoresSet' => CartDiscountStoresSetMessagePayloadModel::class, + 'CartFrozen' => CartFrozenMessagePayloadModel::class, + 'CartUnfrozen' => CartUnfrozenMessagePayloadModel::class, 'CategoryCreated' => CategoryCreatedMessagePayloadModel::class, 'CategorySlugChanged' => CategorySlugChangedMessagePayloadModel::class, 'CustomLineItemStateTransition' => CustomLineItemStateTransitionMessagePayloadModel::class, @@ -180,6 +182,7 @@ final class MessagePayloadModel extends JsonObjectModel implements MessagePayloa 'OrderLineItemDistributionChannelSet' => OrderLineItemDistributionChannelSetMessagePayloadModel::class, 'OrderLineItemRemoved' => OrderLineItemRemovedMessagePayloadModel::class, 'OrderPaymentAdded' => OrderPaymentAddedMessagePayloadModel::class, + 'OrderPaymentRemoved' => OrderPaymentRemovedMessagePayloadModel::class, 'OrderPaymentStateChanged' => OrderPaymentStateChangedMessagePayloadModel::class, 'OrderPurchaseOrderNumberSet' => OrderPurchaseOrderNumberSetMessagePayloadModel::class, 'OrderReturnShipmentStateChanged' => OrderReturnShipmentStateChangedMessagePayloadModel::class, @@ -289,6 +292,7 @@ final class MessagePayloadModel extends JsonObjectModel implements MessagePayloa 'RecurringOrderCustomTypeSet' => RecurringOrderCustomTypeSetMessagePayloadModel::class, 'RecurringOrderDeleted' => RecurringOrderDeletedMessagePayloadModel::class, 'RecurringOrderExpiresAtSet' => RecurringOrderExpiresAtSetMessagePayloadModel::class, + 'RecurringOrderFailed' => RecurringOrderFailedMessagePayloadModel::class, 'RecurringOrderKeySet' => RecurringOrderKeySetMessagePayloadModel::class, 'RecurringOrderScheduleSet' => RecurringOrderScheduleSetMessagePayloadModel::class, 'RecurringOrderStartsAtSet' => RecurringOrderStartsAtSetMessagePayloadModel::class, diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessage.php b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessage.php index af80115dc0b..d10d5be8f92 100644 --- a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessage.php +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessage.php @@ -14,7 +14,7 @@ interface OrderPaymentAddedMessage extends Message { - public const FIELD_PAYMENT = 'payment'; + public const FIELD_PAYMENT_REF = 'paymentRef'; /** *

Payment that was added to the Order.

@@ -22,10 +22,10 @@ interface OrderPaymentAddedMessage extends Message * @return null|PaymentReference */ - public function getPayment(); + public function getPaymentRef(); /** - * @param ?PaymentReference $payment + * @param ?PaymentReference $paymentRef */ - public function setPayment(?PaymentReference $payment): void; + public function setPaymentRef(?PaymentReference $paymentRef): void; } diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessageBuilder.php index 32be5012290..afa19432788 100644 --- a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessageBuilder.php +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessageBuilder.php @@ -93,7 +93,7 @@ final class OrderPaymentAddedMessageBuilder implements Builder * @var null|PaymentReference|PaymentReferenceBuilder */ - private $payment; + private $paymentRef; /** *

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

@@ -212,9 +212,9 @@ public function getResourceUserProvidedIdentifiers() * @return null|PaymentReference */ - public function getPayment() + public function getPaymentRef() { - return $this->payment instanceof PaymentReferenceBuilder ? $this->payment->build() : $this->payment; + return $this->paymentRef instanceof PaymentReferenceBuilder ? $this->paymentRef->build() : $this->paymentRef; } /** @@ -328,12 +328,12 @@ public function withResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $re } /** - * @param ?PaymentReference $payment + * @param ?PaymentReference $paymentRef * @return $this */ - public function withPayment(?PaymentReference $payment) + public function withPaymentRef(?PaymentReference $paymentRef) { - $this->payment = $payment; + $this->paymentRef = $paymentRef; return $this; } @@ -383,12 +383,12 @@ public function withResourceUserProvidedIdentifiersBuilder(?UserProvidedIdentifi } /** - * @deprecated use withPayment() instead + * @deprecated use withPaymentRef() instead * @return $this */ - public function withPaymentBuilder(?PaymentReferenceBuilder $payment) + public function withPaymentRefBuilder(?PaymentReferenceBuilder $paymentRef) { - $this->payment = $payment; + $this->paymentRef = $paymentRef; return $this; } @@ -406,7 +406,7 @@ public function build(): OrderPaymentAddedMessage $this->resource instanceof ReferenceBuilder ? $this->resource->build() : $this->resource, $this->resourceVersion, $this->resourceUserProvidedIdentifiers instanceof UserProvidedIdentifiersBuilder ? $this->resourceUserProvidedIdentifiers->build() : $this->resourceUserProvidedIdentifiers, - $this->payment instanceof PaymentReferenceBuilder ? $this->payment->build() : $this->payment + $this->paymentRef instanceof PaymentReferenceBuilder ? $this->paymentRef->build() : $this->paymentRef ); } diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessageModel.php b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessageModel.php index 9bd0c9e42a7..2fad38b7ad6 100644 --- a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessageModel.php +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessageModel.php @@ -99,7 +99,7 @@ final class OrderPaymentAddedMessageModel extends JsonObjectModel implements Ord * * @var ?PaymentReference */ - protected $payment; + protected $paymentRef; /** @@ -116,7 +116,7 @@ public function __construct( ?Reference $resource = null, ?int $resourceVersion = null, ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers = null, - ?PaymentReference $payment = null, + ?PaymentReference $paymentRef = null, ?string $type = null ) { $this->id = $id; @@ -129,7 +129,7 @@ public function __construct( $this->resource = $resource; $this->resourceVersion = $resourceVersion; $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; - $this->payment = $payment; + $this->paymentRef = $paymentRef; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -372,19 +372,19 @@ public function getResourceUserProvidedIdentifiers() * * @return null|PaymentReference */ - public function getPayment() + public function getPaymentRef() { - if (is_null($this->payment)) { + if (is_null($this->paymentRef)) { /** @psalm-var stdClass|array|null $data */ - $data = $this->raw(self::FIELD_PAYMENT); + $data = $this->raw(self::FIELD_PAYMENT_REF); if (is_null($data)) { return null; } - $this->payment = PaymentReferenceModel::of($data); + $this->paymentRef = PaymentReferenceModel::of($data); } - return $this->payment; + return $this->paymentRef; } @@ -469,11 +469,11 @@ public function setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $res } /** - * @param ?PaymentReference $payment + * @param ?PaymentReference $paymentRef */ - public function setPayment(?PaymentReference $payment): void + public function setPaymentRef(?PaymentReference $paymentRef): void { - $this->payment = $payment; + $this->paymentRef = $paymentRef; } diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayload.php b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayload.php index 1df95eea8eb..dff43d883cb 100644 --- a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayload.php +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayload.php @@ -14,7 +14,7 @@ interface OrderPaymentAddedMessagePayload extends MessagePayload { - public const FIELD_PAYMENT = 'payment'; + public const FIELD_PAYMENT_REF = 'paymentRef'; /** *

Payment that was added to the Order.

@@ -22,10 +22,10 @@ interface OrderPaymentAddedMessagePayload extends MessagePayload * @return null|PaymentReference */ - public function getPayment(); + public function getPaymentRef(); /** - * @param ?PaymentReference $payment + * @param ?PaymentReference $paymentRef */ - public function setPayment(?PaymentReference $payment): void; + public function setPaymentRef(?PaymentReference $paymentRef): void; } diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayloadBuilder.php index 47ba9b0f8c5..9a475f8edb2 100644 --- a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayloadBuilder.php +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayloadBuilder.php @@ -26,7 +26,7 @@ final class OrderPaymentAddedMessagePayloadBuilder implements Builder * @var null|PaymentReference|PaymentReferenceBuilder */ - private $payment; + private $paymentRef; /** *

Payment that was added to the Order.

@@ -34,29 +34,29 @@ final class OrderPaymentAddedMessagePayloadBuilder implements Builder * @return null|PaymentReference */ - public function getPayment() + public function getPaymentRef() { - return $this->payment instanceof PaymentReferenceBuilder ? $this->payment->build() : $this->payment; + return $this->paymentRef instanceof PaymentReferenceBuilder ? $this->paymentRef->build() : $this->paymentRef; } /** - * @param ?PaymentReference $payment + * @param ?PaymentReference $paymentRef * @return $this */ - public function withPayment(?PaymentReference $payment) + public function withPaymentRef(?PaymentReference $paymentRef) { - $this->payment = $payment; + $this->paymentRef = $paymentRef; return $this; } /** - * @deprecated use withPayment() instead + * @deprecated use withPaymentRef() instead * @return $this */ - public function withPaymentBuilder(?PaymentReferenceBuilder $payment) + public function withPaymentRefBuilder(?PaymentReferenceBuilder $paymentRef) { - $this->payment = $payment; + $this->paymentRef = $paymentRef; return $this; } @@ -64,7 +64,7 @@ public function withPaymentBuilder(?PaymentReferenceBuilder $payment) public function build(): OrderPaymentAddedMessagePayload { return new OrderPaymentAddedMessagePayloadModel( - $this->payment instanceof PaymentReferenceBuilder ? $this->payment->build() : $this->payment + $this->paymentRef instanceof PaymentReferenceBuilder ? $this->paymentRef->build() : $this->paymentRef ); } diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayloadModel.php index 56a00eb57d8..49f8034212a 100644 --- a/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayloadModel.php +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentAddedMessagePayloadModel.php @@ -32,17 +32,17 @@ final class OrderPaymentAddedMessagePayloadModel extends JsonObjectModel impleme * * @var ?PaymentReference */ - protected $payment; + protected $paymentRef; /** * @psalm-suppress MissingParamType */ public function __construct( - ?PaymentReference $payment = null, + ?PaymentReference $paymentRef = null, ?string $type = null ) { - $this->payment = $payment; + $this->paymentRef = $paymentRef; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -70,27 +70,27 @@ public function getType() * * @return null|PaymentReference */ - public function getPayment() + public function getPaymentRef() { - if (is_null($this->payment)) { + if (is_null($this->paymentRef)) { /** @psalm-var stdClass|array|null $data */ - $data = $this->raw(self::FIELD_PAYMENT); + $data = $this->raw(self::FIELD_PAYMENT_REF); if (is_null($data)) { return null; } - $this->payment = PaymentReferenceModel::of($data); + $this->paymentRef = PaymentReferenceModel::of($data); } - return $this->payment; + return $this->paymentRef; } /** - * @param ?PaymentReference $payment + * @param ?PaymentReference $paymentRef */ - public function setPayment(?PaymentReference $payment): void + public function setPaymentRef(?PaymentReference $paymentRef): void { - $this->payment = $payment; + $this->paymentRef = $paymentRef; } } diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessage.php b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessage.php new file mode 100644 index 00000000000..7d3914a17b8 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessage.php @@ -0,0 +1,45 @@ +Payment that was removed from the Order.

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

Indicates whether the removal of the Payment resulted in no Payments remaining on the Order. The value is true if all Payments have been removed (none remain), and false if there are still Payments associated with the Order after the removal.

+ * + + * @return null|bool + */ + public function getRemovedPaymentInfo(); + + /** + * @param ?PaymentReference $paymentRef + */ + public function setPaymentRef(?PaymentReference $paymentRef): void; + + /** + * @param ?bool $removedPaymentInfo + */ + public function setRemovedPaymentInfo(?bool $removedPaymentInfo): void; +} diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessageBuilder.php new file mode 100644 index 00000000000..1d590107124 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessageBuilder.php @@ -0,0 +1,446 @@ + + */ +final class OrderPaymentRemovedMessageBuilder 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|PaymentReference|PaymentReferenceBuilder + */ + private $paymentRef; + + /** + + * @var ?bool + */ + private $removedPaymentInfo; + + /** + *

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

Payment that was removed from the Order.

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

Indicates whether the removal of the Payment resulted in no Payments remaining on the Order. The value is true if all Payments have been removed (none remain), and false if there are still Payments associated with the Order after the removal.

+ * + + * @return null|bool + */ + public function getRemovedPaymentInfo() + { + return $this->removedPaymentInfo; + } + + /** + * @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 ?PaymentReference $paymentRef + * @return $this + */ + public function withPaymentRef(?PaymentReference $paymentRef) + { + $this->paymentRef = $paymentRef; + + return $this; + } + + /** + * @param ?bool $removedPaymentInfo + * @return $this + */ + public function withRemovedPaymentInfo(?bool $removedPaymentInfo) + { + $this->removedPaymentInfo = $removedPaymentInfo; + + 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 withPaymentRef() instead + * @return $this + */ + public function withPaymentRefBuilder(?PaymentReferenceBuilder $paymentRef) + { + $this->paymentRef = $paymentRef; + + return $this; + } + + public function build(): OrderPaymentRemovedMessage + { + return new OrderPaymentRemovedMessageModel( + $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->paymentRef instanceof PaymentReferenceBuilder ? $this->paymentRef->build() : $this->paymentRef, + $this->removedPaymentInfo + ); + } + + public static function of(): OrderPaymentRemovedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessageCollection.php b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessageCollection.php new file mode 100644 index 00000000000..c1b8f37e4a3 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method OrderPaymentRemovedMessage current() + * @method OrderPaymentRemovedMessage end() + * @method OrderPaymentRemovedMessage at($offset) + */ +class OrderPaymentRemovedMessageCollection extends MessageCollection +{ + /** + * @psalm-assert OrderPaymentRemovedMessage $value + * @psalm-param OrderPaymentRemovedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return OrderPaymentRemovedMessageCollection + */ + public function add($value) + { + if (!$value instanceof OrderPaymentRemovedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?OrderPaymentRemovedMessage + */ + protected function mapper() + { + return function (?int $index): ?OrderPaymentRemovedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var OrderPaymentRemovedMessage $data */ + $data = OrderPaymentRemovedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessageModel.php b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessageModel.php new file mode 100644 index 00000000000..aa63ec081b4 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessageModel.php @@ -0,0 +1,529 @@ +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->paymentRef = $paymentRef; + $this->removedPaymentInfo = $removedPaymentInfo; + $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; + } + + /** + *

Payment that was removed from the Order.

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

Indicates whether the removal of the Payment resulted in no Payments remaining on the Order. The value is true if all Payments have been removed (none remain), and false if there are still Payments associated with the Order after the removal.

+ * + * + * @return null|bool + */ + public function getRemovedPaymentInfo() + { + if (is_null($this->removedPaymentInfo)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_REMOVED_PAYMENT_INFO); + if (is_null($data)) { + return null; + } + $this->removedPaymentInfo = (bool) $data; + } + + return $this->removedPaymentInfo; + } + + + /** + * @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 ?PaymentReference $paymentRef + */ + public function setPaymentRef(?PaymentReference $paymentRef): void + { + $this->paymentRef = $paymentRef; + } + + /** + * @param ?bool $removedPaymentInfo + */ + public function setRemovedPaymentInfo(?bool $removedPaymentInfo): void + { + $this->removedPaymentInfo = $removedPaymentInfo; + } + + + #[\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/OrderPaymentRemovedMessagePayload.php b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayload.php new file mode 100644 index 00000000000..15fe3f163e0 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayload.php @@ -0,0 +1,45 @@ +Payment that was removed from the Order.

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

Indicates whether the removal of the Payment resulted in no Payments remaining on the Order. The value is true if all Payments have been removed (none remain), and false if there are still Payments associated with the Order after the removal.

+ * + + * @return null|bool + */ + public function getRemovedPaymentInfo(); + + /** + * @param ?PaymentReference $paymentRef + */ + public function setPaymentRef(?PaymentReference $paymentRef): void; + + /** + * @param ?bool $removedPaymentInfo + */ + public function setRemovedPaymentInfo(?bool $removedPaymentInfo): void; +} diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayloadBuilder.php new file mode 100644 index 00000000000..3de4b44dec4 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayloadBuilder.php @@ -0,0 +1,104 @@ + + */ +final class OrderPaymentRemovedMessagePayloadBuilder implements Builder +{ + /** + + * @var null|PaymentReference|PaymentReferenceBuilder + */ + private $paymentRef; + + /** + + * @var ?bool + */ + private $removedPaymentInfo; + + /** + *

Payment that was removed from the Order.

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

Indicates whether the removal of the Payment resulted in no Payments remaining on the Order. The value is true if all Payments have been removed (none remain), and false if there are still Payments associated with the Order after the removal.

+ * + + * @return null|bool + */ + public function getRemovedPaymentInfo() + { + return $this->removedPaymentInfo; + } + + /** + * @param ?PaymentReference $paymentRef + * @return $this + */ + public function withPaymentRef(?PaymentReference $paymentRef) + { + $this->paymentRef = $paymentRef; + + return $this; + } + + /** + * @param ?bool $removedPaymentInfo + * @return $this + */ + public function withRemovedPaymentInfo(?bool $removedPaymentInfo) + { + $this->removedPaymentInfo = $removedPaymentInfo; + + return $this; + } + + /** + * @deprecated use withPaymentRef() instead + * @return $this + */ + public function withPaymentRefBuilder(?PaymentReferenceBuilder $paymentRef) + { + $this->paymentRef = $paymentRef; + + return $this; + } + + public function build(): OrderPaymentRemovedMessagePayload + { + return new OrderPaymentRemovedMessagePayloadModel( + $this->paymentRef instanceof PaymentReferenceBuilder ? $this->paymentRef->build() : $this->paymentRef, + $this->removedPaymentInfo + ); + } + + public static function of(): OrderPaymentRemovedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayloadCollection.php new file mode 100644 index 00000000000..8b6c040df6f --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method OrderPaymentRemovedMessagePayload current() + * @method OrderPaymentRemovedMessagePayload end() + * @method OrderPaymentRemovedMessagePayload at($offset) + */ +class OrderPaymentRemovedMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert OrderPaymentRemovedMessagePayload $value + * @psalm-param OrderPaymentRemovedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return OrderPaymentRemovedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof OrderPaymentRemovedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?OrderPaymentRemovedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?OrderPaymentRemovedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var OrderPaymentRemovedMessagePayload $data */ + $data = OrderPaymentRemovedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayloadModel.php new file mode 100644 index 00000000000..ddaf953eb49 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderPaymentRemovedMessagePayloadModel.php @@ -0,0 +1,132 @@ +paymentRef = $paymentRef; + $this->removedPaymentInfo = $removedPaymentInfo; + $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; + } + + /** + *

Payment that was removed from the Order.

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

Indicates whether the removal of the Payment resulted in no Payments remaining on the Order. The value is true if all Payments have been removed (none remain), and false if there are still Payments associated with the Order after the removal.

+ * + * + * @return null|bool + */ + public function getRemovedPaymentInfo() + { + if (is_null($this->removedPaymentInfo)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_REMOVED_PAYMENT_INFO); + if (is_null($data)) { + return null; + } + $this->removedPaymentInfo = (bool) $data; + } + + return $this->removedPaymentInfo; + } + + + /** + * @param ?PaymentReference $paymentRef + */ + public function setPaymentRef(?PaymentReference $paymentRef): void + { + $this->paymentRef = $paymentRef; + } + + /** + * @param ?bool $removedPaymentInfo + */ + public function setRemovedPaymentInfo(?bool $removedPaymentInfo): void + { + $this->removedPaymentInfo = $removedPaymentInfo; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessage.php new file mode 100644 index 00000000000..37154c11562 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessage.php @@ -0,0 +1,88 @@ +ID of the Cart used in the failed Order creation attempt.

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

Date and time (UTC) when the Order creation attempt failed.

+ * + + * @return null|DateTimeImmutable + */ + public function getFailedAt(); + + /** + *

Description of why the Order creation failed, such as insufficient stock.

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

Date and time (UTC) the Order was scheduled to be created.

+ * + + * @return null|DateTimeImmutable + */ + public function getOrderScheduledAt(); + + /** + *

Errors due to which the Order creation failed.

+ * + + * @return null|RecurringOrderFailureErrorCollection + */ + public function getErrors(); + + /** + * @param ?string $cartId + */ + public function setCartId(?string $cartId): void; + + /** + * @param ?DateTimeImmutable $failedAt + */ + public function setFailedAt(?DateTimeImmutable $failedAt): void; + + /** + * @param ?string $failureReason + */ + public function setFailureReason(?string $failureReason): void; + + /** + * @param ?DateTimeImmutable $orderScheduledAt + */ + public function setOrderScheduledAt(?DateTimeImmutable $orderScheduledAt): void; + + /** + * @param ?RecurringOrderFailureErrorCollection $errors + */ + public function setErrors(?RecurringOrderFailureErrorCollection $errors): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessageBuilder.php new file mode 100644 index 00000000000..c98883b6822 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessageBuilder.php @@ -0,0 +1,521 @@ + + */ +final class RecurringOrderFailedMessageBuilder 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 ?string + */ + private $cartId; + + /** + + * @var ?DateTimeImmutable + */ + private $failedAt; + + /** + + * @var ?string + */ + private $failureReason; + + /** + + * @var ?DateTimeImmutable + */ + private $orderScheduledAt; + + /** + + * @var ?RecurringOrderFailureErrorCollection + */ + private $errors; + + /** + *

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

ID of the Cart used in the failed Order creation attempt.

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

Date and time (UTC) when the Order creation attempt failed.

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

Description of why the Order creation failed, such as insufficient stock.

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

Date and time (UTC) the Order was scheduled to be created.

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

Errors due to which the Order creation failed.

+ * + + * @return null|RecurringOrderFailureErrorCollection + */ + public function getErrors() + { + return $this->errors; + } + + /** + * @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 ?string $cartId + * @return $this + */ + public function withCartId(?string $cartId) + { + $this->cartId = $cartId; + + return $this; + } + + /** + * @param ?DateTimeImmutable $failedAt + * @return $this + */ + public function withFailedAt(?DateTimeImmutable $failedAt) + { + $this->failedAt = $failedAt; + + return $this; + } + + /** + * @param ?string $failureReason + * @return $this + */ + public function withFailureReason(?string $failureReason) + { + $this->failureReason = $failureReason; + + return $this; + } + + /** + * @param ?DateTimeImmutable $orderScheduledAt + * @return $this + */ + public function withOrderScheduledAt(?DateTimeImmutable $orderScheduledAt) + { + $this->orderScheduledAt = $orderScheduledAt; + + return $this; + } + + /** + * @param ?RecurringOrderFailureErrorCollection $errors + * @return $this + */ + public function withErrors(?RecurringOrderFailureErrorCollection $errors) + { + $this->errors = $errors; + + 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(): RecurringOrderFailedMessage + { + return new RecurringOrderFailedMessageModel( + $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->cartId, + $this->failedAt, + $this->failureReason, + $this->orderScheduledAt, + $this->errors + ); + } + + public static function of(): RecurringOrderFailedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessageCollection.php new file mode 100644 index 00000000000..57d4dbea150 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderFailedMessage current() + * @method RecurringOrderFailedMessage end() + * @method RecurringOrderFailedMessage at($offset) + */ +class RecurringOrderFailedMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderFailedMessage $value + * @psalm-param RecurringOrderFailedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderFailedMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderFailedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderFailedMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderFailedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderFailedMessage $data */ + $data = RecurringOrderFailedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessageModel.php new file mode 100644 index 00000000000..aaaf91515f7 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessageModel.php @@ -0,0 +1,651 @@ +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->cartId = $cartId; + $this->failedAt = $failedAt; + $this->failureReason = $failureReason; + $this->orderScheduledAt = $orderScheduledAt; + $this->errors = $errors; + $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; + } + + /** + *

ID of the Cart used in the failed Order creation attempt.

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

Date and time (UTC) when the Order creation attempt failed.

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

Description of why the Order creation failed, such as insufficient stock.

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

Date and time (UTC) the Order was scheduled to be created.

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

Errors due to which the Order creation failed.

+ * + * + * @return null|RecurringOrderFailureErrorCollection + */ + 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 = RecurringOrderFailureErrorCollection::fromArray($data); + } + + return $this->errors; + } + + + /** + * @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 ?string $cartId + */ + public function setCartId(?string $cartId): void + { + $this->cartId = $cartId; + } + + /** + * @param ?DateTimeImmutable $failedAt + */ + public function setFailedAt(?DateTimeImmutable $failedAt): void + { + $this->failedAt = $failedAt; + } + + /** + * @param ?string $failureReason + */ + public function setFailureReason(?string $failureReason): void + { + $this->failureReason = $failureReason; + } + + /** + * @param ?DateTimeImmutable $orderScheduledAt + */ + public function setOrderScheduledAt(?DateTimeImmutable $orderScheduledAt): void + { + $this->orderScheduledAt = $orderScheduledAt; + } + + /** + * @param ?RecurringOrderFailureErrorCollection $errors + */ + public function setErrors(?RecurringOrderFailureErrorCollection $errors): void + { + $this->errors = $errors; + } + + + #[\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'); + } + + if (isset($data[RecurringOrderFailedMessage::FIELD_FAILED_AT]) && $data[RecurringOrderFailedMessage::FIELD_FAILED_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderFailedMessage::FIELD_FAILED_AT] = $data[RecurringOrderFailedMessage::FIELD_FAILED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrderFailedMessage::FIELD_ORDER_SCHEDULED_AT]) && $data[RecurringOrderFailedMessage::FIELD_ORDER_SCHEDULED_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderFailedMessage::FIELD_ORDER_SCHEDULED_AT] = $data[RecurringOrderFailedMessage::FIELD_ORDER_SCHEDULED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayload.php new file mode 100644 index 00000000000..ebd28ed29cb --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayload.php @@ -0,0 +1,88 @@ +ID of the Cart used in the failed Order creation attempt.

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

Date and time (UTC) when the Order creation attempt failed.

+ * + + * @return null|DateTimeImmutable + */ + public function getFailedAt(); + + /** + *

Description of why the Order creation failed, such as insufficient stock.

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

Date and time (UTC) the Order was scheduled to be created.

+ * + + * @return null|DateTimeImmutable + */ + public function getOrderScheduledAt(); + + /** + *

Errors due to which the Order creation failed.

+ * + + * @return null|RecurringOrderFailureErrorCollection + */ + public function getErrors(); + + /** + * @param ?string $cartId + */ + public function setCartId(?string $cartId): void; + + /** + * @param ?DateTimeImmutable $failedAt + */ + public function setFailedAt(?DateTimeImmutable $failedAt): void; + + /** + * @param ?string $failureReason + */ + public function setFailureReason(?string $failureReason): void; + + /** + * @param ?DateTimeImmutable $orderScheduledAt + */ + public function setOrderScheduledAt(?DateTimeImmutable $orderScheduledAt): void; + + /** + * @param ?RecurringOrderFailureErrorCollection $errors + */ + public function setErrors(?RecurringOrderFailureErrorCollection $errors): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayloadBuilder.php new file mode 100644 index 00000000000..dad3eda80e8 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayloadBuilder.php @@ -0,0 +1,181 @@ + + */ +final class RecurringOrderFailedMessagePayloadBuilder implements Builder +{ + /** + + * @var ?string + */ + private $cartId; + + /** + + * @var ?DateTimeImmutable + */ + private $failedAt; + + /** + + * @var ?string + */ + private $failureReason; + + /** + + * @var ?DateTimeImmutable + */ + private $orderScheduledAt; + + /** + + * @var ?RecurringOrderFailureErrorCollection + */ + private $errors; + + /** + *

ID of the Cart used in the failed Order creation attempt.

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

Date and time (UTC) when the Order creation attempt failed.

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

Description of why the Order creation failed, such as insufficient stock.

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

Date and time (UTC) the Order was scheduled to be created.

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

Errors due to which the Order creation failed.

+ * + + * @return null|RecurringOrderFailureErrorCollection + */ + public function getErrors() + { + return $this->errors; + } + + /** + * @param ?string $cartId + * @return $this + */ + public function withCartId(?string $cartId) + { + $this->cartId = $cartId; + + return $this; + } + + /** + * @param ?DateTimeImmutable $failedAt + * @return $this + */ + public function withFailedAt(?DateTimeImmutable $failedAt) + { + $this->failedAt = $failedAt; + + return $this; + } + + /** + * @param ?string $failureReason + * @return $this + */ + public function withFailureReason(?string $failureReason) + { + $this->failureReason = $failureReason; + + return $this; + } + + /** + * @param ?DateTimeImmutable $orderScheduledAt + * @return $this + */ + public function withOrderScheduledAt(?DateTimeImmutable $orderScheduledAt) + { + $this->orderScheduledAt = $orderScheduledAt; + + return $this; + } + + /** + * @param ?RecurringOrderFailureErrorCollection $errors + * @return $this + */ + public function withErrors(?RecurringOrderFailureErrorCollection $errors) + { + $this->errors = $errors; + + return $this; + } + + + public function build(): RecurringOrderFailedMessagePayload + { + return new RecurringOrderFailedMessagePayloadModel( + $this->cartId, + $this->failedAt, + $this->failureReason, + $this->orderScheduledAt, + $this->errors + ); + } + + public static function of(): RecurringOrderFailedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayloadCollection.php new file mode 100644 index 00000000000..da0ee79c072 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderFailedMessagePayload current() + * @method RecurringOrderFailedMessagePayload end() + * @method RecurringOrderFailedMessagePayload at($offset) + */ +class RecurringOrderFailedMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderFailedMessagePayload $value + * @psalm-param RecurringOrderFailedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderFailedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderFailedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderFailedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderFailedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderFailedMessagePayload $data */ + $data = RecurringOrderFailedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayloadModel.php new file mode 100644 index 00000000000..ef0f5c3252f --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderFailedMessagePayloadModel.php @@ -0,0 +1,262 @@ +cartId = $cartId; + $this->failedAt = $failedAt; + $this->failureReason = $failureReason; + $this->orderScheduledAt = $orderScheduledAt; + $this->errors = $errors; + $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; + } + + /** + *

ID of the Cart used in the failed Order creation attempt.

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

Date and time (UTC) when the Order creation attempt failed.

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

Description of why the Order creation failed, such as insufficient stock.

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

Date and time (UTC) the Order was scheduled to be created.

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

Errors due to which the Order creation failed.

+ * + * + * @return null|RecurringOrderFailureErrorCollection + */ + 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 = RecurringOrderFailureErrorCollection::fromArray($data); + } + + return $this->errors; + } + + + /** + * @param ?string $cartId + */ + public function setCartId(?string $cartId): void + { + $this->cartId = $cartId; + } + + /** + * @param ?DateTimeImmutable $failedAt + */ + public function setFailedAt(?DateTimeImmutable $failedAt): void + { + $this->failedAt = $failedAt; + } + + /** + * @param ?string $failureReason + */ + public function setFailureReason(?string $failureReason): void + { + $this->failureReason = $failureReason; + } + + /** + * @param ?DateTimeImmutable $orderScheduledAt + */ + public function setOrderScheduledAt(?DateTimeImmutable $orderScheduledAt): void + { + $this->orderScheduledAt = $orderScheduledAt; + } + + /** + * @param ?RecurringOrderFailureErrorCollection $errors + */ + public function setErrors(?RecurringOrderFailureErrorCollection $errors): void + { + $this->errors = $errors; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[RecurringOrderFailedMessagePayload::FIELD_FAILED_AT]) && $data[RecurringOrderFailedMessagePayload::FIELD_FAILED_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderFailedMessagePayload::FIELD_FAILED_AT] = $data[RecurringOrderFailedMessagePayload::FIELD_FAILED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrderFailedMessagePayload::FIELD_ORDER_SCHEDULED_AT]) && $data[RecurringOrderFailedMessagePayload::FIELD_ORDER_SCHEDULED_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderFailedMessagePayload::FIELD_ORDER_SCHEDULED_AT] = $data[RecurringOrderFailedMessagePayload::FIELD_ORDER_SCHEDULED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Order/CustomLineItemReturnItemBuilder.php b/lib/commercetools-api/src/Models/Order/CustomLineItemReturnItemBuilder.php index 31d6d0a87c2..38957c90415 100644 --- a/lib/commercetools-api/src/Models/Order/CustomLineItemReturnItemBuilder.php +++ b/lib/commercetools-api/src/Models/Order/CustomLineItemReturnItemBuilder.php @@ -176,7 +176,7 @@ public function getLastModifiedAt() } /** - *

Date and time (UTC) the Return Item was intitially created.

+ *

Date and time (UTC) the Return Item was initially created.

* * @return null|DateTimeImmutable diff --git a/lib/commercetools-api/src/Models/Order/CustomLineItemReturnItemModel.php b/lib/commercetools-api/src/Models/Order/CustomLineItemReturnItemModel.php index cd53e829878..b58432aa524 100644 --- a/lib/commercetools-api/src/Models/Order/CustomLineItemReturnItemModel.php +++ b/lib/commercetools-api/src/Models/Order/CustomLineItemReturnItemModel.php @@ -307,7 +307,7 @@ public function getLastModifiedAt() } /** - *

Date and time (UTC) the Return Item was intitially created.

+ *

Date and time (UTC) the Return Item was initially created.

* * * @return null|DateTimeImmutable diff --git a/lib/commercetools-api/src/Models/Order/LineItemReturnItemBuilder.php b/lib/commercetools-api/src/Models/Order/LineItemReturnItemBuilder.php index 86acf674464..108635f57e2 100644 --- a/lib/commercetools-api/src/Models/Order/LineItemReturnItemBuilder.php +++ b/lib/commercetools-api/src/Models/Order/LineItemReturnItemBuilder.php @@ -176,7 +176,7 @@ public function getLastModifiedAt() } /** - *

Date and time (UTC) the Return Item was intitially created.

+ *

Date and time (UTC) the Return Item was initially created.

* * @return null|DateTimeImmutable diff --git a/lib/commercetools-api/src/Models/Order/LineItemReturnItemModel.php b/lib/commercetools-api/src/Models/Order/LineItemReturnItemModel.php index 498ee6ec085..083f5cef135 100644 --- a/lib/commercetools-api/src/Models/Order/LineItemReturnItemModel.php +++ b/lib/commercetools-api/src/Models/Order/LineItemReturnItemModel.php @@ -307,7 +307,7 @@ public function getLastModifiedAt() } /** - *

Date and time (UTC) the Return Item was intitially created.

+ *

Date and time (UTC) the Return Item was initially created.

* * * @return null|DateTimeImmutable diff --git a/lib/commercetools-api/src/Models/Order/ReturnItem.php b/lib/commercetools-api/src/Models/Order/ReturnItem.php index 12e2ac692c0..5f4362f2ac4 100644 --- a/lib/commercetools-api/src/Models/Order/ReturnItem.php +++ b/lib/commercetools-api/src/Models/Order/ReturnItem.php @@ -102,7 +102,7 @@ public function getCustom(); public function getLastModifiedAt(); /** - *

Date and time (UTC) the Return Item was intitially created.

+ *

Date and time (UTC) the Return Item was initially created.

* * @return null|DateTimeImmutable diff --git a/lib/commercetools-api/src/Models/Order/ReturnItemBuilder.php b/lib/commercetools-api/src/Models/Order/ReturnItemBuilder.php index e796b2acb86..31fd269bdf9 100644 --- a/lib/commercetools-api/src/Models/Order/ReturnItemBuilder.php +++ b/lib/commercetools-api/src/Models/Order/ReturnItemBuilder.php @@ -170,7 +170,7 @@ public function getLastModifiedAt() } /** - *

Date and time (UTC) the Return Item was intitially created.

+ *

Date and time (UTC) the Return Item was initially created.

* * @return null|DateTimeImmutable diff --git a/lib/commercetools-api/src/Models/Order/ReturnItemModel.php b/lib/commercetools-api/src/Models/Order/ReturnItemModel.php index 4a9ffcb7b23..33f1344e5e1 100644 --- a/lib/commercetools-api/src/Models/Order/ReturnItemModel.php +++ b/lib/commercetools-api/src/Models/Order/ReturnItemModel.php @@ -307,7 +307,7 @@ public function getLastModifiedAt() } /** - *

Date and time (UTC) the Return Item was intitially created.

+ *

Date and time (UTC) the Return Item was initially created.

* * * @return null|DateTimeImmutable diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemAction.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemAction.php index dcf7b4d9403..c8897e5e149 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemAction.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemAction.php @@ -41,8 +41,8 @@ public function getLineItemId(); public function getLineItemKey(); /** - *

New value to set. - * If absent or 0, the Line Item is removed from the Cart.

+ *

Amount to subtract from the LineItem quantity. + * If omitted, the LineItem is removed from the Order.

* * @return null|int diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemActionBuilder.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemActionBuilder.php index 5618692084d..99cbdc844e1 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemActionBuilder.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemActionBuilder.php @@ -87,8 +87,8 @@ public function getLineItemKey() } /** - *

New value to set. - * If absent or 0, the Line Item is removed from the Cart.

+ *

Amount to subtract from the LineItem quantity. + * If omitted, the LineItem is removed from the Order.

* * @return null|int diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemActionModel.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemActionModel.php index ba0d0c01e03..b5b387d6ce7 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemActionModel.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderRemoveLineItemActionModel.php @@ -151,8 +151,8 @@ public function getLineItemKey() } /** - *

New value to set. - * If absent or 0, the Line Item is removed from the Cart.

+ *

Amount to subtract from the LineItem quantity. + * If omitted, the LineItem is removed from the Order.

* * * @return null|int diff --git a/lib/commercetools-api/src/Models/Product/ProductLegacySetSkuAction.php b/lib/commercetools-api/src/Models/Product/ProductLegacySetSkuAction.php deleted file mode 100644 index 8bcce652959..00000000000 --- a/lib/commercetools-api/src/Models/Product/ProductLegacySetSkuAction.php +++ /dev/null @@ -1,40 +0,0 @@ - - */ -final class ProductLegacySetSkuActionBuilder implements Builder -{ - /** - - * @var ?string - */ - private $sku; - - /** - - * @var ?int - */ - private $variantId; - - /** - - * @return null|string - */ - public function getSku() - { - return $this->sku; - } - - /** - - * @return null|int - */ - public function getVariantId() - { - return $this->variantId; - } - - /** - * @param ?string $sku - * @return $this - */ - public function withSku(?string $sku) - { - $this->sku = $sku; - - return $this; - } - - /** - * @param ?int $variantId - * @return $this - */ - public function withVariantId(?int $variantId) - { - $this->variantId = $variantId; - - return $this; - } - - - public function build(): ProductLegacySetSkuAction - { - return new ProductLegacySetSkuActionModel( - $this->sku, - $this->variantId - ); - } - - public static function of(): ProductLegacySetSkuActionBuilder - { - return new self(); - } -} diff --git a/lib/commercetools-api/src/Models/Product/ProductLegacySetSkuActionCollection.php b/lib/commercetools-api/src/Models/Product/ProductLegacySetSkuActionCollection.php deleted file mode 100644 index f8d91183d9c..00000000000 --- a/lib/commercetools-api/src/Models/Product/ProductLegacySetSkuActionCollection.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @method ProductLegacySetSkuAction current() - * @method ProductLegacySetSkuAction end() - * @method ProductLegacySetSkuAction at($offset) - */ -class ProductLegacySetSkuActionCollection extends ProductUpdateActionCollection -{ - /** - * @psalm-assert ProductLegacySetSkuAction $value - * @psalm-param ProductLegacySetSkuAction|stdClass $value - * @throws InvalidArgumentException - * - * @return ProductLegacySetSkuActionCollection - */ - public function add($value) - { - if (!$value instanceof ProductLegacySetSkuAction) { - throw new InvalidArgumentException(); - } - $this->store($value); - - return $this; - } - - /** - * @psalm-return callable(int):?ProductLegacySetSkuAction - */ - protected function mapper() - { - return function (?int $index): ?ProductLegacySetSkuAction { - $data = $this->get($index); - if ($data instanceof stdClass) { - /** @var ProductLegacySetSkuAction $data */ - $data = ProductLegacySetSkuActionModel::of($data); - $this->set($data, $index); - } - - return $data; - }; - } -} diff --git a/lib/commercetools-api/src/Models/Product/ProductLegacySetSkuActionModel.php b/lib/commercetools-api/src/Models/Product/ProductLegacySetSkuActionModel.php deleted file mode 100644 index 59fadf6fe0f..00000000000 --- a/lib/commercetools-api/src/Models/Product/ProductLegacySetSkuActionModel.php +++ /dev/null @@ -1,125 +0,0 @@ -sku = $sku; - $this->variantId = $variantId; - $this->action = $action ?? self::DISCRIMINATOR_VALUE; - } - - /** - * - * @return null|string - */ - public function getAction() - { - if (is_null($this->action)) { - /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_ACTION); - if (is_null($data)) { - return null; - } - $this->action = (string) $data; - } - - return $this->action; - } - - /** - * - * @return null|string - */ - public function getSku() - { - if (is_null($this->sku)) { - /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_SKU); - if (is_null($data)) { - return null; - } - $this->sku = (string) $data; - } - - return $this->sku; - } - - /** - * - * @return null|int - */ - public function getVariantId() - { - if (is_null($this->variantId)) { - /** @psalm-var ?int $data */ - $data = $this->raw(self::FIELD_VARIANT_ID); - if (is_null($data)) { - return null; - } - $this->variantId = (int) $data; - } - - return $this->variantId; - } - - - /** - * @param ?string $sku - */ - public function setSku(?string $sku): void - { - $this->sku = $sku; - } - - /** - * @param ?int $variantId - */ - public function setVariantId(?int $variantId): void - { - $this->variantId = $variantId; - } -} diff --git a/lib/commercetools-api/src/Models/Product/ProductUpdateActionModel.php b/lib/commercetools-api/src/Models/Product/ProductUpdateActionModel.php index bf9695a8277..6e7b98950bd 100644 --- a/lib/commercetools-api/src/Models/Product/ProductUpdateActionModel.php +++ b/lib/commercetools-api/src/Models/Product/ProductUpdateActionModel.php @@ -42,7 +42,6 @@ final class ProductUpdateActionModel extends JsonObjectModel implements ProductU 'changeName' => ProductChangeNameActionModel::class, 'changePrice' => ProductChangePriceActionModel::class, 'changeSlug' => ProductChangeSlugActionModel::class, - 'legacySetSku' => ProductLegacySetSkuActionModel::class, 'moveImageToPosition' => ProductMoveImageToPositionActionModel::class, 'publish' => ProductPublishActionModel::class, 'removeAsset' => ProductRemoveAssetActionModel::class, diff --git a/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscount.php b/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscount.php index a686ea5f2cb..ae0935248f2 100644 --- a/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscount.php +++ b/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscount.php @@ -138,7 +138,8 @@ public function getSortOrder(); public function getIsActive(); /** - *

References of all the resources that are addressed in the predicate.

+ *

References to all resources addressed in the predicate by their IDs. + * This value is generated by the platform.

* * @return null|ReferenceCollection diff --git a/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscountBuilder.php b/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscountBuilder.php index d48ebff7c0a..cb8c6ed5c01 100644 --- a/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscountBuilder.php +++ b/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscountBuilder.php @@ -271,7 +271,8 @@ public function getIsActive() } /** - *

References of all the resources that are addressed in the predicate.

+ *

References to all resources addressed in the predicate by their IDs. + * This value is generated by the platform.

* * @return null|ReferenceCollection diff --git a/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscountModel.php b/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscountModel.php index 8311ff54709..e93fe8cad4b 100644 --- a/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscountModel.php +++ b/lib/commercetools-api/src/Models/ProductDiscount/ProductDiscountModel.php @@ -440,7 +440,8 @@ public function getIsActive() } /** - *

References of all the resources that are addressed in the predicate.

+ *

References to all resources addressed in the predicate by their IDs. + * This value is generated by the platform.

* * * @return null|ReferenceCollection diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePrice.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePrice.php index e0549882787..a2b5a016ffd 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePrice.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePrice.php @@ -164,7 +164,7 @@ public function getTiers(); /** *

Set if a matching ProductDiscount exists. If set, the API uses the discounted value for the Line Item price selection. - * When a relative discount is applied and the fraction part of the discounted price is 0.5, the discounted price is rounded in favor of the customer with the half down rounding.

+ * When a relative discount is applied and the fraction part of the discounted price is 0.5, the discounted price is rounded in favor of the customer with the half down rounding.

*

If an absolute discount value exceeds the price of the Product Variant, the discounted price is a negative value.

* diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceBuilder.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceBuilder.php index af607d96df7..d945c202ff4 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceBuilder.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceBuilder.php @@ -328,7 +328,7 @@ public function getTiers() /** *

Set if a matching ProductDiscount exists. If set, the API uses the discounted value for the Line Item price selection. - * When a relative discount is applied and the fraction part of the discounted price is 0.5, the discounted price is rounded in favor of the customer with the half down rounding.

+ * When a relative discount is applied and the fraction part of the discounted price is 0.5, the discounted price is rounded in favor of the customer with the half down rounding.

*

If an absolute discount value exceeds the price of the Product Variant, the discounted price is a negative value.

* diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceModel.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceModel.php index 51a9b059a37..523863d3a18 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceModel.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceModel.php @@ -531,7 +531,7 @@ public function getTiers() /** *

Set if a matching ProductDiscount exists. If set, the API uses the discounted value for the Line Item price selection. - * When a relative discount is applied and the fraction part of the discounted price is 0.5, the discounted price is rounded in favor of the customer with the half down rounding.

+ * When a relative discount is applied and the fraction part of the discounted price is 0.5, the discounted price is rounded in favor of the customer with the half down rounding.

*

If an absolute discount value exceeds the price of the Product Variant, the discounted price is a negative value.

* * diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierAction.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierAction.php index 2c6ee876e42..a0516c3244f 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierAction.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierAction.php @@ -13,7 +13,7 @@ interface StandalonePriceRemovePriceTierAction extends StandalonePriceUpdateAction { - public const FIELD_TIER_MINIMUM_QUANTITY = 'tierMinimumQuantity'; + public const FIELD_MINIMUM_QUANTITY = 'minimumQuantity'; /** *

The minimumQuantity of the PriceTier to be removed from the tiers field of the StandalonePrice.

@@ -21,10 +21,10 @@ interface StandalonePriceRemovePriceTierAction extends StandalonePriceUpdateActi * @return null|int */ - public function getTierMinimumQuantity(); + public function getMinimumQuantity(); /** - * @param ?int $tierMinimumQuantity + * @param ?int $minimumQuantity */ - public function setTierMinimumQuantity(?int $tierMinimumQuantity): void; + public function setMinimumQuantity(?int $minimumQuantity): void; } diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierActionBuilder.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierActionBuilder.php index e6ba2e03dd2..d0f06526809 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierActionBuilder.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierActionBuilder.php @@ -24,7 +24,7 @@ final class StandalonePriceRemovePriceTierActionBuilder implements Builder * @var ?int */ - private $tierMinimumQuantity; + private $minimumQuantity; /** *

The minimumQuantity of the PriceTier to be removed from the tiers field of the StandalonePrice.

@@ -32,18 +32,18 @@ final class StandalonePriceRemovePriceTierActionBuilder implements Builder * @return null|int */ - public function getTierMinimumQuantity() + public function getMinimumQuantity() { - return $this->tierMinimumQuantity; + return $this->minimumQuantity; } /** - * @param ?int $tierMinimumQuantity + * @param ?int $minimumQuantity * @return $this */ - public function withTierMinimumQuantity(?int $tierMinimumQuantity) + public function withMinimumQuantity(?int $minimumQuantity) { - $this->tierMinimumQuantity = $tierMinimumQuantity; + $this->minimumQuantity = $minimumQuantity; return $this; } @@ -52,7 +52,7 @@ public function withTierMinimumQuantity(?int $tierMinimumQuantity) public function build(): StandalonePriceRemovePriceTierAction { return new StandalonePriceRemovePriceTierActionModel( - $this->tierMinimumQuantity + $this->minimumQuantity ); } diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierActionModel.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierActionModel.php index ebd2fc7fd5d..1549c70bbd5 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierActionModel.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceRemovePriceTierActionModel.php @@ -30,17 +30,17 @@ final class StandalonePriceRemovePriceTierActionModel extends JsonObjectModel im * * @var ?int */ - protected $tierMinimumQuantity; + protected $minimumQuantity; /** * @psalm-suppress MissingParamType */ public function __construct( - ?int $tierMinimumQuantity = null, + ?int $minimumQuantity = null, ?string $action = null ) { - $this->tierMinimumQuantity = $tierMinimumQuantity; + $this->minimumQuantity = $minimumQuantity; $this->action = $action ?? self::DISCRIMINATOR_VALUE; } @@ -68,26 +68,26 @@ public function getAction() * * @return null|int */ - public function getTierMinimumQuantity() + public function getMinimumQuantity() { - if (is_null($this->tierMinimumQuantity)) { + if (is_null($this->minimumQuantity)) { /** @psalm-var ?int $data */ - $data = $this->raw(self::FIELD_TIER_MINIMUM_QUANTITY); + $data = $this->raw(self::FIELD_MINIMUM_QUANTITY); if (is_null($data)) { return null; } - $this->tierMinimumQuantity = (int) $data; + $this->minimumQuantity = (int) $data; } - return $this->tierMinimumQuantity; + return $this->minimumQuantity; } /** - * @param ?int $tierMinimumQuantity + * @param ?int $minimumQuantity */ - public function setTierMinimumQuantity(?int $tierMinimumQuantity): void + public function setMinimumQuantity(?int $minimumQuantity): void { - $this->tierMinimumQuantity = $tierMinimumQuantity; + $this->minimumQuantity = $minimumQuantity; } } diff --git a/lib/commercetools-api/src/Models/Store/Store.php b/lib/commercetools-api/src/Models/Store/Store.php index f8e741552c0..d6d2e3956ed 100644 --- a/lib/commercetools-api/src/Models/Store/Store.php +++ b/lib/commercetools-api/src/Models/Store/Store.php @@ -134,7 +134,7 @@ public function getSupplyChannels(); *
  • Leave empty if all Products in the Project should be available in this Store.
  • *
  • If only inactive Product Selections with IndividualExclusion ProductSelectionMode are provided, all the Products are available in this Store.
  • *
  • If all the Product Selections provided are inactive and there's at least a Product Selection of mode Individual, no Product is available in this Store.
  • - *
  • If at least an active Product Selection is provided, only active Product Selections are considered to compute the availlability in this Store.
  • + *
  • If at least an active Product Selection is provided, only active Product Selections are considered to compute the availability in this Store.
  • * * diff --git a/lib/commercetools-api/src/Models/Store/StoreBuilder.php b/lib/commercetools-api/src/Models/Store/StoreBuilder.php index d87e43661c7..1ef014b2a19 100644 --- a/lib/commercetools-api/src/Models/Store/StoreBuilder.php +++ b/lib/commercetools-api/src/Models/Store/StoreBuilder.php @@ -255,7 +255,7 @@ public function getSupplyChannels() *
  • Leave empty if all Products in the Project should be available in this Store.
  • *
  • If only inactive Product Selections with IndividualExclusion ProductSelectionMode are provided, all the Products are available in this Store.
  • *
  • If all the Product Selections provided are inactive and there's at least a Product Selection of mode Individual, no Product is available in this Store.
  • - *
  • If at least an active Product Selection is provided, only active Product Selections are considered to compute the availlability in this Store.
  • + *
  • If at least an active Product Selection is provided, only active Product Selections are considered to compute the availability in this Store.
  • * * diff --git a/lib/commercetools-api/src/Models/Store/StoreModel.php b/lib/commercetools-api/src/Models/Store/StoreModel.php index 2d6569101f5..71698150a53 100644 --- a/lib/commercetools-api/src/Models/Store/StoreModel.php +++ b/lib/commercetools-api/src/Models/Store/StoreModel.php @@ -409,7 +409,7 @@ public function getSupplyChannels() *
  • Leave empty if all Products in the Project should be available in this Store.
  • *
  • If only inactive Product Selections with IndividualExclusion ProductSelectionMode are provided, all the Products are available in this Store.
  • *
  • If all the Product Selections provided are inactive and there's at least a Product Selection of mode Individual, no Product is available in this Store.
  • - *
  • If at least an active Product Selection is provided, only active Product Selections are considered to compute the availlability in this Store.
  • + *
  • If at least an active Product Selection is provided, only active Product Selections are considered to compute the availability in this Store.
  • * * * diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldBooleanTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldBooleanTypeModel.php index 53ca81e2616..3e418c960f0 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldBooleanTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldBooleanTypeModel.php @@ -37,6 +37,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldDateTimeTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldDateTimeTypeModel.php index bbd70dbbc82..6e22ee39444 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldDateTimeTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldDateTimeTypeModel.php @@ -37,6 +37,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldDateTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldDateTypeModel.php index ce23913ff16..a352c4bd164 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldDateTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldDateTypeModel.php @@ -37,6 +37,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldEnumTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldEnumTypeModel.php index 9a53b3040e7..840570ddaf9 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldEnumTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldEnumTypeModel.php @@ -45,6 +45,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldLocalizedEnumTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldLocalizedEnumTypeModel.php index 5b5769f750d..709ecd333f5 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldLocalizedEnumTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldLocalizedEnumTypeModel.php @@ -45,6 +45,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldLocalizedStringTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldLocalizedStringTypeModel.php index 82dfb2d0a05..25df048c842 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldLocalizedStringTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldLocalizedStringTypeModel.php @@ -37,6 +37,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldMoneyTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldMoneyTypeModel.php index d3de097b155..5b9258f9bce 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldMoneyTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldMoneyTypeModel.php @@ -37,6 +37,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldNumberTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldNumberTypeModel.php index f652bea1f11..95793e118d7 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldNumberTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldNumberTypeModel.php @@ -37,6 +37,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldReferenceTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldReferenceTypeModel.php index baade1f749a..10264c2ca92 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldReferenceTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldReferenceTypeModel.php @@ -45,6 +45,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldSetTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldSetTypeModel.php index 4351a3b3095..a149079d736 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldSetTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldSetTypeModel.php @@ -45,6 +45,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldStringTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldStringTypeModel.php index a009ecb2355..5254a68ddc9 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldStringTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldStringTypeModel.php @@ -37,6 +37,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/CustomFieldTimeTypeModel.php b/lib/commercetools-api/src/Models/Type/CustomFieldTimeTypeModel.php index ec1f3d7924d..417fbbde42a 100644 --- a/lib/commercetools-api/src/Models/Type/CustomFieldTimeTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/CustomFieldTimeTypeModel.php @@ -37,6 +37,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/FieldDefinition.php b/lib/commercetools-api/src/Models/Type/FieldDefinition.php index d68516d99a1..9bc76343c89 100644 --- a/lib/commercetools-api/src/Models/Type/FieldDefinition.php +++ b/lib/commercetools-api/src/Models/Type/FieldDefinition.php @@ -31,7 +31,7 @@ public function getType(); /** *

    Name of the Custom Field to define. * Must be unique for a given ResourceTypeId. - * In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type.

    + * If a FieldDefinition with the same name is defined in another Type for the same ResourceTypeId, then both FieldDefinitions must have the same type.

    * * @return null|string diff --git a/lib/commercetools-api/src/Models/Type/FieldDefinitionBuilder.php b/lib/commercetools-api/src/Models/Type/FieldDefinitionBuilder.php index 84a15312dd9..7ab861f9923 100644 --- a/lib/commercetools-api/src/Models/Type/FieldDefinitionBuilder.php +++ b/lib/commercetools-api/src/Models/Type/FieldDefinitionBuilder.php @@ -66,7 +66,7 @@ public function getType() /** *

    Name of the Custom Field to define. * Must be unique for a given ResourceTypeId. - * In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type.

    + * If a FieldDefinition with the same name is defined in another Type for the same ResourceTypeId, then both FieldDefinitions must have the same type.

    * * @return null|string diff --git a/lib/commercetools-api/src/Models/Type/FieldDefinitionModel.php b/lib/commercetools-api/src/Models/Type/FieldDefinitionModel.php index e05522d2a9e..fc2148f656d 100644 --- a/lib/commercetools-api/src/Models/Type/FieldDefinitionModel.php +++ b/lib/commercetools-api/src/Models/Type/FieldDefinitionModel.php @@ -93,7 +93,7 @@ public function getType() /** *

    Name of the Custom Field to define. * Must be unique for a given ResourceTypeId. - * In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type.

    + * If a FieldDefinition with the same name is defined in another Type for the same ResourceTypeId, then both FieldDefinitions must have the same type.

    * * * @return null|string diff --git a/lib/commercetools-api/src/Models/Type/FieldType.php b/lib/commercetools-api/src/Models/Type/FieldType.php index 8ecd30ee78a..6f3aaf9587f 100644 --- a/lib/commercetools-api/src/Models/Type/FieldType.php +++ b/lib/commercetools-api/src/Models/Type/FieldType.php @@ -17,6 +17,8 @@ interface FieldType extends JsonObject public const FIELD_NAME = 'name'; /** + *

    Discriminator that determines the type of the field.

    + * * @return null|string */ diff --git a/lib/commercetools-api/src/Models/Type/FieldTypeModel.php b/lib/commercetools-api/src/Models/Type/FieldTypeModel.php index 6006658d26e..2b6e8fd07a0 100644 --- a/lib/commercetools-api/src/Models/Type/FieldTypeModel.php +++ b/lib/commercetools-api/src/Models/Type/FieldTypeModel.php @@ -55,6 +55,8 @@ public function __construct( } /** + *

    Discriminator that determines the type of the field.

    + * * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Change/AddAssetChange.php b/lib/commercetools-history/src/Models/Change/AddAssetChange.php index ddda66f50c8..cd46e291204 100644 --- a/lib/commercetools-history/src/Models/Change/AddAssetChange.php +++ b/lib/commercetools-history/src/Models/Change/AddAssetChange.php @@ -17,6 +17,8 @@ interface AddAssetChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -46,6 +48,27 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

    Product data that was updated.

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

    Identifier of the updated Product Variant.

    + *

    This field holds the SKU, if defined; otherwise the key; otherwise the ID.

    + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -60,4 +83,14 @@ public function setPreviousValue(?Asset $previousValue): void; * @param ?Asset $nextValue */ public function setNextValue(?Asset $nextValue): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/AddAssetChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddAssetChangeBuilder.php index ba3e6bebbb6..266d17c97b1 100644 --- a/lib/commercetools-history/src/Models/Change/AddAssetChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/AddAssetChangeBuilder.php @@ -40,6 +40,18 @@ final class AddAssetChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -71,6 +83,33 @@ public function getNextValue() return $this->nextValue instanceof AssetBuilder ? $this->nextValue->build() : $this->nextValue; } + /** + *

    Product data that was updated.

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

    Identifier of the updated Product Variant.

    + *

    This field holds the SKU, if defined; otherwise the key; otherwise the ID.

    + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -104,6 +143,28 @@ public function withNextValue(?Asset $nextValue) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -131,7 +192,9 @@ public function build(): AddAssetChange return new AddAssetChangeModel( $this->change, $this->previousValue instanceof AssetBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof AssetBuilder ? $this->nextValue->build() : $this->nextValue + $this->nextValue instanceof AssetBuilder ? $this->nextValue->build() : $this->nextValue, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/AddAssetChangeModel.php b/lib/commercetools-history/src/Models/Change/AddAssetChangeModel.php index 9638e1d299e..747476d1fbb 100644 --- a/lib/commercetools-history/src/Models/Change/AddAssetChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddAssetChangeModel.php @@ -47,6 +47,18 @@ final class AddAssetChangeModel extends JsonObjectModel implements AddAssetChang */ protected $nextValue; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -55,11 +67,15 @@ public function __construct( ?string $change = null, ?Asset $previousValue = null, ?Asset $nextValue = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -141,6 +157,51 @@ public function getNextValue() return $this->nextValue; } + /** + *

    Product data that was updated.

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

    Identifier of the updated Product Variant.

    + *

    This field holds the SKU, if defined; otherwise the key; otherwise the ID.

    + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -166,6 +227,22 @@ public function setNextValue(?Asset $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/AddEnumValueChange.php b/lib/commercetools-history/src/Models/Change/AddEnumValueChange.php index 30eaedf8360..f2f57ee743b 100644 --- a/lib/commercetools-history/src/Models/Change/AddEnumValueChange.php +++ b/lib/commercetools-history/src/Models/Change/AddEnumValueChange.php @@ -10,13 +10,14 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\ChangeValue\EnumValue; +use Commercetools\History\Models\Common\CustomFieldEnumValue; interface AddEnumValueChange extends Change { public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_FIELD_NAME = 'fieldName'; + public const FIELD_ATTRIBUTE_NAME = 'attributeName'; /** @@ -34,7 +35,7 @@ public function getChange(); *

    Value after the change.

    * - * @return null|EnumValue + * @return null|CustomFieldEnumValue */ public function getNextValue(); @@ -46,18 +47,31 @@ public function getNextValue(); */ public function getFieldName(); + /** + *

    Name of the updated AttributeDefinition.

    + * + + * @return null|string + */ + public function getAttributeName(); + /** * @param ?string $change */ public function setChange(?string $change): void; /** - * @param ?EnumValue $nextValue + * @param ?CustomFieldEnumValue $nextValue */ - public function setNextValue(?EnumValue $nextValue): void; + public function setNextValue(?CustomFieldEnumValue $nextValue): void; /** * @param ?string $fieldName */ public function setFieldName(?string $fieldName): void; + + /** + * @param ?string $attributeName + */ + public function setAttributeName(?string $attributeName): void; } diff --git a/lib/commercetools-history/src/Models/Change/AddEnumValueChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddEnumValueChangeBuilder.php index fe5ab815d3c..23d35a5d535 100644 --- a/lib/commercetools-history/src/Models/Change/AddEnumValueChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/AddEnumValueChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\EnumValue; -use Commercetools\History\Models\ChangeValue\EnumValueBuilder; +use Commercetools\History\Models\Common\CustomFieldEnumValue; +use Commercetools\History\Models\Common\CustomFieldEnumValueBuilder; /** * @implements Builder @@ -30,7 +30,7 @@ final class AddEnumValueChangeBuilder implements Builder /** - * @var null|EnumValue|EnumValueBuilder + * @var null|CustomFieldEnumValue|CustomFieldEnumValueBuilder */ private $nextValue; @@ -40,6 +40,12 @@ final class AddEnumValueChangeBuilder implements Builder */ private $fieldName; + /** + + * @var ?string + */ + private $attributeName; + /** * @return null|string @@ -53,11 +59,11 @@ public function getChange() *

    Value after the change.

    * - * @return null|EnumValue + * @return null|CustomFieldEnumValue */ public function getNextValue() { - return $this->nextValue instanceof EnumValueBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof CustomFieldEnumValueBuilder ? $this->nextValue->build() : $this->nextValue; } /** @@ -71,6 +77,17 @@ public function getFieldName() return $this->fieldName; } + /** + *

    Name of the updated AttributeDefinition.

    + * + + * @return null|string + */ + public function getAttributeName() + { + return $this->attributeName; + } + /** * @param ?string $change * @return $this @@ -83,10 +100,10 @@ public function withChange(?string $change) } /** - * @param ?EnumValue $nextValue + * @param ?CustomFieldEnumValue $nextValue * @return $this */ - public function withNextValue(?EnumValue $nextValue) + public function withNextValue(?CustomFieldEnumValue $nextValue) { $this->nextValue = $nextValue; @@ -104,11 +121,22 @@ public function withFieldName(?string $fieldName) return $this; } + /** + * @param ?string $attributeName + * @return $this + */ + public function withAttributeName(?string $attributeName) + { + $this->attributeName = $attributeName; + + return $this; + } + /** * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?EnumValueBuilder $nextValue) + public function withNextValueBuilder(?CustomFieldEnumValueBuilder $nextValue) { $this->nextValue = $nextValue; @@ -119,8 +147,9 @@ public function build(): AddEnumValueChange { return new AddEnumValueChangeModel( $this->change, - $this->nextValue instanceof EnumValueBuilder ? $this->nextValue->build() : $this->nextValue, - $this->fieldName + $this->nextValue instanceof CustomFieldEnumValueBuilder ? $this->nextValue->build() : $this->nextValue, + $this->fieldName, + $this->attributeName ); } diff --git a/lib/commercetools-history/src/Models/Change/AddEnumValueChangeModel.php b/lib/commercetools-history/src/Models/Change/AddEnumValueChangeModel.php index 4579bad968a..42453c4a25d 100644 --- a/lib/commercetools-history/src/Models/Change/AddEnumValueChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddEnumValueChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\EnumValue; -use Commercetools\History\Models\ChangeValue\EnumValueModel; +use Commercetools\History\Models\Common\CustomFieldEnumValue; +use Commercetools\History\Models\Common\CustomFieldEnumValueModel; /** * @internal @@ -37,7 +37,7 @@ final class AddEnumValueChangeModel extends JsonObjectModel implements AddEnumVa /** * - * @var ?EnumValue + * @var ?CustomFieldEnumValue */ protected $nextValue; @@ -47,19 +47,27 @@ final class AddEnumValueChangeModel extends JsonObjectModel implements AddEnumVa */ protected $fieldName; + /** + * + * @var ?string + */ + protected $attributeName; + /** * @psalm-suppress MissingParamType */ public function __construct( ?string $change = null, - ?EnumValue $nextValue = null, + ?CustomFieldEnumValue $nextValue = null, ?string $fieldName = null, + ?string $attributeName = null, ?string $type = null ) { $this->change = $change; $this->nextValue = $nextValue; $this->fieldName = $fieldName; + $this->attributeName = $attributeName; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -103,7 +111,7 @@ public function getChange() *

    Value after the change.

    * * - * @return null|EnumValue + * @return null|CustomFieldEnumValue */ public function getNextValue() { @@ -114,7 +122,7 @@ public function getNextValue() return null; } - $this->nextValue = EnumValueModel::of($data); + $this->nextValue = CustomFieldEnumValueModel::of($data); } return $this->nextValue; @@ -140,6 +148,26 @@ public function getFieldName() return $this->fieldName; } + /** + *

    Name of the updated AttributeDefinition.

    + * + * + * @return null|string + */ + public function getAttributeName() + { + if (is_null($this->attributeName)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ATTRIBUTE_NAME); + if (is_null($data)) { + return null; + } + $this->attributeName = (string) $data; + } + + return $this->attributeName; + } + /** * @param ?string $change @@ -150,9 +178,9 @@ public function setChange(?string $change): void } /** - * @param ?EnumValue $nextValue + * @param ?CustomFieldEnumValue $nextValue */ - public function setNextValue(?EnumValue $nextValue): void + public function setNextValue(?CustomFieldEnumValue $nextValue): void { $this->nextValue = $nextValue; } @@ -165,6 +193,14 @@ public function setFieldName(?string $fieldName): void $this->fieldName = $fieldName; } + /** + * @param ?string $attributeName + */ + public function setAttributeName(?string $attributeName): void + { + $this->attributeName = $attributeName; + } + } diff --git a/lib/commercetools-history/src/Models/Change/AddExternalImageChange.php b/lib/commercetools-history/src/Models/Change/AddExternalImageChange.php index e149b94d9bb..c58e9f51169 100644 --- a/lib/commercetools-history/src/Models/Change/AddExternalImageChange.php +++ b/lib/commercetools-history/src/Models/Change/AddExternalImageChange.php @@ -18,6 +18,7 @@ interface AddExternalImageChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -48,6 +49,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

    Product data that was updated.

    *
      *
    • staged, if the staged ProductCatalogData was updated.
    • *
    • current, if the current ProductCatalogData was updated.
    • @@ -58,6 +60,15 @@ public function getNextValue(); */ public function getCatalogData(); + /** + *

      Identifier of the updated Product Variant.

      + *

      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

      + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -77,4 +88,9 @@ public function setNextValue(?ImageCollection $nextValue): void; * @param ?string $catalogData */ public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/AddExternalImageChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddExternalImageChangeBuilder.php index df2e7f6a919..64342dc2d4b 100644 --- a/lib/commercetools-history/src/Models/Change/AddExternalImageChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/AddExternalImageChangeBuilder.php @@ -45,6 +45,12 @@ final class AddExternalImageChangeBuilder implements Builder */ private $catalogData; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -77,6 +83,7 @@ public function getNextValue() } /** + *

      Product data that was updated.

      *
        *
      • staged, if the staged ProductCatalogData was updated.
      • *
      • current, if the current ProductCatalogData was updated.
      • @@ -90,6 +97,18 @@ public function getCatalogData() return $this->catalogData; } + /** + *

        Identifier of the updated Product Variant.

        + *

        This field holds the SKU, if defined; otherwise the key; otherwise the ID.

        + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -134,6 +153,17 @@ public function withCatalogData(?string $catalogData) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + public function build(): AddExternalImageChange { @@ -141,7 +171,8 @@ public function build(): AddExternalImageChange $this->change, $this->previousValue, $this->nextValue, - $this->catalogData + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/AddExternalImageChangeModel.php b/lib/commercetools-history/src/Models/Change/AddExternalImageChangeModel.php index bf5bdef3a8c..434357dc9cb 100644 --- a/lib/commercetools-history/src/Models/Change/AddExternalImageChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddExternalImageChangeModel.php @@ -52,6 +52,12 @@ final class AddExternalImageChangeModel extends JsonObjectModel implements AddEx */ protected $catalogData; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -61,12 +67,14 @@ public function __construct( ?ImageCollection $previousValue = null, ?ImageCollection $nextValue = null, ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -147,6 +155,7 @@ public function getNextValue() } /** + *

        Product data that was updated.

        *
          *
        • staged, if the staged ProductCatalogData was updated.
        • *
        • current, if the current ProductCatalogData was updated.
        • @@ -169,6 +178,27 @@ public function getCatalogData() return $this->catalogData; } + /** + *

          Identifier of the updated Product Variant.

          + *

          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

          + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -202,6 +232,14 @@ public function setCatalogData(?string $catalogData): void $this->catalogData = $catalogData; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChange.php b/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChange.php index e616cb3760d..917c6cfd407 100644 --- a/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChange.php +++ b/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\ChangeValue\CustomFieldExpandedValue; +use Commercetools\History\Models\Common\CustomFields; interface AddInterfaceInteractionChange extends Change { @@ -33,7 +33,7 @@ public function getChange(); *

          Value after the change.

          * - * @return null|CustomFieldExpandedValue + * @return null|CustomFields */ public function getNextValue(); @@ -43,7 +43,7 @@ public function getNextValue(); public function setChange(?string $change): void; /** - * @param ?CustomFieldExpandedValue $nextValue + * @param ?CustomFields $nextValue */ - public function setNextValue(?CustomFieldExpandedValue $nextValue): void; + public function setNextValue(?CustomFields $nextValue): void; } diff --git a/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChangeBuilder.php index 505c49f55b6..aba25eb4946 100644 --- a/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\CustomFieldExpandedValue; -use Commercetools\History\Models\ChangeValue\CustomFieldExpandedValueBuilder; +use Commercetools\History\Models\Common\CustomFields; +use Commercetools\History\Models\Common\CustomFieldsBuilder; /** * @implements Builder @@ -30,7 +30,7 @@ final class AddInterfaceInteractionChangeBuilder implements Builder /** - * @var null|CustomFieldExpandedValue|CustomFieldExpandedValueBuilder + * @var null|CustomFields|CustomFieldsBuilder */ private $nextValue; @@ -47,11 +47,11 @@ public function getChange() *

          Value after the change.

          * - * @return null|CustomFieldExpandedValue + * @return null|CustomFields */ public function getNextValue() { - return $this->nextValue instanceof CustomFieldExpandedValueBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; } /** @@ -66,10 +66,10 @@ public function withChange(?string $change) } /** - * @param ?CustomFieldExpandedValue $nextValue + * @param ?CustomFields $nextValue * @return $this */ - public function withNextValue(?CustomFieldExpandedValue $nextValue) + public function withNextValue(?CustomFields $nextValue) { $this->nextValue = $nextValue; @@ -80,7 +80,7 @@ public function withNextValue(?CustomFieldExpandedValue $nextValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?CustomFieldExpandedValueBuilder $nextValue) + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) { $this->nextValue = $nextValue; @@ -91,7 +91,7 @@ public function build(): AddInterfaceInteractionChange { return new AddInterfaceInteractionChangeModel( $this->change, - $this->nextValue instanceof CustomFieldExpandedValueBuilder ? $this->nextValue->build() : $this->nextValue + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue ); } diff --git a/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChangeModel.php b/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChangeModel.php index 3c109e0ff54..0a9896de100 100644 --- a/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddInterfaceInteractionChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\CustomFieldExpandedValue; -use Commercetools\History\Models\ChangeValue\CustomFieldExpandedValueModel; +use Commercetools\History\Models\Common\CustomFields; +use Commercetools\History\Models\Common\CustomFieldsModel; /** * @internal @@ -37,7 +37,7 @@ final class AddInterfaceInteractionChangeModel extends JsonObjectModel implement /** * - * @var ?CustomFieldExpandedValue + * @var ?CustomFields */ protected $nextValue; @@ -47,7 +47,7 @@ final class AddInterfaceInteractionChangeModel extends JsonObjectModel implement */ public function __construct( ?string $change = null, - ?CustomFieldExpandedValue $nextValue = null, + ?CustomFields $nextValue = null, ?string $type = null ) { $this->change = $change; @@ -95,7 +95,7 @@ public function getChange() *

          Value after the change.

          * * - * @return null|CustomFieldExpandedValue + * @return null|CustomFields */ public function getNextValue() { @@ -106,7 +106,7 @@ public function getNextValue() return null; } - $this->nextValue = CustomFieldExpandedValueModel::of($data); + $this->nextValue = CustomFieldsModel::of($data); } return $this->nextValue; @@ -122,9 +122,9 @@ public function setChange(?string $change): void } /** - * @param ?CustomFieldExpandedValue $nextValue + * @param ?CustomFields $nextValue */ - public function setNextValue(?CustomFieldExpandedValue $nextValue): void + public function setNextValue(?CustomFields $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChange.php b/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChange.php index cf7b3950bc2..bf3f3374b6c 100644 --- a/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChange.php +++ b/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\Common\AttributeLocalizedEnumValue; +use Commercetools\History\Models\Common\CustomFieldLocalizedEnumValue; interface AddLocalizedEnumValueChange extends Change { @@ -35,7 +35,7 @@ public function getChange(); *

          Value after the change.

          * - * @return null|AttributeLocalizedEnumValue + * @return null|CustomFieldLocalizedEnumValue */ public function getNextValue(); @@ -61,9 +61,9 @@ public function getAttributeName(); public function setChange(?string $change): void; /** - * @param ?AttributeLocalizedEnumValue $nextValue + * @param ?CustomFieldLocalizedEnumValue $nextValue */ - public function setNextValue(?AttributeLocalizedEnumValue $nextValue): void; + public function setNextValue(?CustomFieldLocalizedEnumValue $nextValue): void; /** * @param ?string $fieldName diff --git a/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChangeBuilder.php index 52d919106f6..8874aa8eff7 100644 --- a/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\AttributeLocalizedEnumValue; -use Commercetools\History\Models\Common\AttributeLocalizedEnumValueBuilder; +use Commercetools\History\Models\Common\CustomFieldLocalizedEnumValue; +use Commercetools\History\Models\Common\CustomFieldLocalizedEnumValueBuilder; /** * @implements Builder @@ -30,7 +30,7 @@ final class AddLocalizedEnumValueChangeBuilder implements Builder /** - * @var null|AttributeLocalizedEnumValue|AttributeLocalizedEnumValueBuilder + * @var null|CustomFieldLocalizedEnumValue|CustomFieldLocalizedEnumValueBuilder */ private $nextValue; @@ -59,11 +59,11 @@ public function getChange() *

          Value after the change.

          * - * @return null|AttributeLocalizedEnumValue + * @return null|CustomFieldLocalizedEnumValue */ public function getNextValue() { - return $this->nextValue instanceof AttributeLocalizedEnumValueBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof CustomFieldLocalizedEnumValueBuilder ? $this->nextValue->build() : $this->nextValue; } /** @@ -100,10 +100,10 @@ public function withChange(?string $change) } /** - * @param ?AttributeLocalizedEnumValue $nextValue + * @param ?CustomFieldLocalizedEnumValue $nextValue * @return $this */ - public function withNextValue(?AttributeLocalizedEnumValue $nextValue) + public function withNextValue(?CustomFieldLocalizedEnumValue $nextValue) { $this->nextValue = $nextValue; @@ -136,7 +136,7 @@ public function withAttributeName(?string $attributeName) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?AttributeLocalizedEnumValueBuilder $nextValue) + public function withNextValueBuilder(?CustomFieldLocalizedEnumValueBuilder $nextValue) { $this->nextValue = $nextValue; @@ -147,7 +147,7 @@ public function build(): AddLocalizedEnumValueChange { return new AddLocalizedEnumValueChangeModel( $this->change, - $this->nextValue instanceof AttributeLocalizedEnumValueBuilder ? $this->nextValue->build() : $this->nextValue, + $this->nextValue instanceof CustomFieldLocalizedEnumValueBuilder ? $this->nextValue->build() : $this->nextValue, $this->fieldName, $this->attributeName ); diff --git a/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChangeModel.php b/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChangeModel.php index fcbf32abbd2..52ccff9c213 100644 --- a/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddLocalizedEnumValueChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\AttributeLocalizedEnumValue; -use Commercetools\History\Models\Common\AttributeLocalizedEnumValueModel; +use Commercetools\History\Models\Common\CustomFieldLocalizedEnumValue; +use Commercetools\History\Models\Common\CustomFieldLocalizedEnumValueModel; /** * @internal @@ -37,7 +37,7 @@ final class AddLocalizedEnumValueChangeModel extends JsonObjectModel implements /** * - * @var ?AttributeLocalizedEnumValue + * @var ?CustomFieldLocalizedEnumValue */ protected $nextValue; @@ -59,7 +59,7 @@ final class AddLocalizedEnumValueChangeModel extends JsonObjectModel implements */ public function __construct( ?string $change = null, - ?AttributeLocalizedEnumValue $nextValue = null, + ?CustomFieldLocalizedEnumValue $nextValue = null, ?string $fieldName = null, ?string $attributeName = null, ?string $type = null @@ -111,7 +111,7 @@ public function getChange() *

          Value after the change.

          * * - * @return null|AttributeLocalizedEnumValue + * @return null|CustomFieldLocalizedEnumValue */ public function getNextValue() { @@ -122,7 +122,7 @@ public function getNextValue() return null; } - $this->nextValue = AttributeLocalizedEnumValueModel::of($data); + $this->nextValue = CustomFieldLocalizedEnumValueModel::of($data); } return $this->nextValue; @@ -178,9 +178,9 @@ public function setChange(?string $change): void } /** - * @param ?AttributeLocalizedEnumValue $nextValue + * @param ?CustomFieldLocalizedEnumValue $nextValue */ - public function setNextValue(?AttributeLocalizedEnumValue $nextValue): void + public function setNextValue(?CustomFieldLocalizedEnumValue $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/AddPriceChange.php b/lib/commercetools-history/src/Models/Change/AddPriceChange.php index 2254f5d0cbb..801ef91c894 100644 --- a/lib/commercetools-history/src/Models/Change/AddPriceChange.php +++ b/lib/commercetools-history/src/Models/Change/AddPriceChange.php @@ -18,6 +18,7 @@ interface AddPriceChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; public const FIELD_PRICE_ID = 'priceId'; + public const FIELD_VARIANT = 'variant'; /** @@ -40,6 +41,7 @@ public function getChange(); public function getNextValue(); /** + *

          Product data that was updated.

          *
            *
          • staged, if the staged ProductCatalogData was updated.
          • *
          • current, if the current ProductCatalogData was updated.
          • @@ -58,6 +60,15 @@ public function getCatalogData(); */ public function getPriceId(); + /** + *

            Identifier of the updated Product Variant.

            + *

            This field holds the SKU, if defined; otherwise the key; otherwise the ID.

            + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -77,4 +88,9 @@ public function setCatalogData(?string $catalogData): void; * @param ?string $priceId */ public function setPriceId(?string $priceId): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/AddPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddPriceChangeBuilder.php index fedb03391a5..e6cd55a8f94 100644 --- a/lib/commercetools-history/src/Models/Change/AddPriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/AddPriceChangeBuilder.php @@ -46,6 +46,12 @@ final class AddPriceChangeBuilder implements Builder */ private $priceId; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -67,6 +73,7 @@ public function getNextValue() } /** + *

            Product data that was updated.

            *
              *
            • staged, if the staged ProductCatalogData was updated.
            • *
            • current, if the current ProductCatalogData was updated.
            • @@ -91,6 +98,18 @@ public function getPriceId() return $this->priceId; } + /** + *

              Identifier of the updated Product Variant.

              + *

              This field holds the SKU, if defined; otherwise the key; otherwise the ID.

              + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -135,6 +154,17 @@ public function withPriceId(?string $priceId) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withNextValue() instead * @return $this @@ -152,7 +182,8 @@ public function build(): AddPriceChange $this->change, $this->nextValue instanceof PriceBuilder ? $this->nextValue->build() : $this->nextValue, $this->catalogData, - $this->priceId + $this->priceId, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/AddPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/AddPriceChangeModel.php index 9f9ce0fe99d..59716d53fa2 100644 --- a/lib/commercetools-history/src/Models/Change/AddPriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddPriceChangeModel.php @@ -53,6 +53,12 @@ final class AddPriceChangeModel extends JsonObjectModel implements AddPriceChang */ protected $priceId; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -62,12 +68,14 @@ public function __construct( ?Price $nextValue = null, ?string $catalogData = null, ?string $priceId = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->nextValue = $nextValue; $this->catalogData = $catalogData; $this->priceId = $priceId; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -129,6 +137,7 @@ public function getNextValue() } /** + *

              Product data that was updated.

              *
                *
              • staged, if the staged ProductCatalogData was updated.
              • *
              • current, if the current ProductCatalogData was updated.
              • @@ -171,6 +180,27 @@ public function getPriceId() return $this->priceId; } + /** + *

                Identifier of the updated Product Variant.

                + *

                This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -204,6 +234,14 @@ public function setPriceId(?string $priceId): void $this->priceId = $priceId; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/AddProductChangeModel.php b/lib/commercetools-history/src/Models/Change/AddProductChangeModel.php index e68a84d63a7..d5a121cb370 100644 --- a/lib/commercetools-history/src/Models/Change/AddProductChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddProductChangeModel.php @@ -115,8 +115,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/AddShippingChange.php b/lib/commercetools-history/src/Models/Change/AddShippingChange.php new file mode 100644 index 00000000000..763749a291d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/AddShippingChange.php @@ -0,0 +1,49 @@ +Value after the change.

                + * + + * @return null|Shipping + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?Shipping $nextValue + */ + public function setNextValue(?Shipping $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/AddShippingChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddShippingChangeBuilder.php new file mode 100644 index 00000000000..a619014c69c --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/AddShippingChangeBuilder.php @@ -0,0 +1,102 @@ + + */ +final class AddShippingChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|Shipping|ShippingBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                Value after the change.

                + * + + * @return null|Shipping + */ + public function getNextValue() + { + return $this->nextValue instanceof ShippingBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?Shipping $nextValue + * @return $this + */ + public function withNextValue(?Shipping $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?ShippingBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): AddShippingChange + { + return new AddShippingChangeModel( + $this->change, + $this->nextValue instanceof ShippingBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): AddShippingChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/AddShippingChangeCollection.php b/lib/commercetools-history/src/Models/Change/AddShippingChangeCollection.php new file mode 100644 index 00000000000..cf3395dd3dc --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/AddShippingChangeCollection.php @@ -0,0 +1,56 @@ + + * @method AddShippingChange current() + * @method AddShippingChange end() + * @method AddShippingChange at($offset) + */ +class AddShippingChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert AddShippingChange $value + * @psalm-param AddShippingChange|stdClass $value + * @throws InvalidArgumentException + * + * @return AddShippingChangeCollection + */ + public function add($value) + { + if (!$value instanceof AddShippingChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?AddShippingChange + */ + protected function mapper() + { + return function (?int $index): ?AddShippingChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var AddShippingChange $data */ + $data = AddShippingChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/AddShippingChangeModel.php b/lib/commercetools-history/src/Models/Change/AddShippingChangeModel.php new file mode 100644 index 00000000000..a050a807387 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/AddShippingChangeModel.php @@ -0,0 +1,134 @@ +change = $change; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                Value after the change.

                + * + * + * @return null|Shipping + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = ShippingModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?Shipping $nextValue + */ + public function setNextValue(?Shipping $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChange.php b/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChange.php index 24135239f84..95d66730dfc 100644 --- a/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChange.php +++ b/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\Common\LineItem; +use Commercetools\History\Models\Common\ShoppingListLineItem; interface AddShoppingListLineItemChange extends Change { @@ -34,7 +34,7 @@ public function getChange(); *

                Value before the change.

                * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getPreviousValue(); @@ -42,7 +42,7 @@ public function getPreviousValue(); *

                Value after the change.

                * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getNextValue(); @@ -52,12 +52,12 @@ public function getNextValue(); public function setChange(?string $change): void; /** - * @param ?LineItem $previousValue + * @param ?ShoppingListLineItem $previousValue */ - public function setPreviousValue(?LineItem $previousValue): void; + public function setPreviousValue(?ShoppingListLineItem $previousValue): void; /** - * @param ?LineItem $nextValue + * @param ?ShoppingListLineItem $nextValue */ - public function setNextValue(?LineItem $nextValue): void; + public function setNextValue(?ShoppingListLineItem $nextValue): void; } diff --git a/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChangeBuilder.php index 876e5a813eb..65caf6b0cfd 100644 --- a/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\LineItem; -use Commercetools\History\Models\Common\LineItemBuilder; +use Commercetools\History\Models\Common\ShoppingListLineItem; +use Commercetools\History\Models\Common\ShoppingListLineItemBuilder; /** * @implements Builder @@ -30,13 +30,13 @@ final class AddShoppingListLineItemChangeBuilder implements Builder /** - * @var null|LineItem|LineItemBuilder + * @var null|ShoppingListLineItem|ShoppingListLineItemBuilder */ private $previousValue; /** - * @var null|LineItem|LineItemBuilder + * @var null|ShoppingListLineItem|ShoppingListLineItemBuilder */ private $nextValue; @@ -53,22 +53,22 @@ public function getChange() *

                Value before the change.

                * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getPreviousValue() { - return $this->previousValue instanceof LineItemBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof ShoppingListLineItemBuilder ? $this->previousValue->build() : $this->previousValue; } /** *

                Value after the change.

                * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getNextValue() { - return $this->nextValue instanceof LineItemBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof ShoppingListLineItemBuilder ? $this->nextValue->build() : $this->nextValue; } /** @@ -83,10 +83,10 @@ public function withChange(?string $change) } /** - * @param ?LineItem $previousValue + * @param ?ShoppingListLineItem $previousValue * @return $this */ - public function withPreviousValue(?LineItem $previousValue) + public function withPreviousValue(?ShoppingListLineItem $previousValue) { $this->previousValue = $previousValue; @@ -94,10 +94,10 @@ public function withPreviousValue(?LineItem $previousValue) } /** - * @param ?LineItem $nextValue + * @param ?ShoppingListLineItem $nextValue * @return $this */ - public function withNextValue(?LineItem $nextValue) + public function withNextValue(?ShoppingListLineItem $nextValue) { $this->nextValue = $nextValue; @@ -108,7 +108,7 @@ public function withNextValue(?LineItem $nextValue) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?LineItemBuilder $previousValue) + public function withPreviousValueBuilder(?ShoppingListLineItemBuilder $previousValue) { $this->previousValue = $previousValue; @@ -119,7 +119,7 @@ public function withPreviousValueBuilder(?LineItemBuilder $previousValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?LineItemBuilder $nextValue) + public function withNextValueBuilder(?ShoppingListLineItemBuilder $nextValue) { $this->nextValue = $nextValue; @@ -130,8 +130,8 @@ public function build(): AddShoppingListLineItemChange { return new AddShoppingListLineItemChangeModel( $this->change, - $this->previousValue instanceof LineItemBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof LineItemBuilder ? $this->nextValue->build() : $this->nextValue + $this->previousValue instanceof ShoppingListLineItemBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof ShoppingListLineItemBuilder ? $this->nextValue->build() : $this->nextValue ); } diff --git a/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChangeModel.php b/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChangeModel.php index a2d5bffb503..dc7a9c275b2 100644 --- a/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddShoppingListLineItemChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\LineItem; -use Commercetools\History\Models\Common\LineItemModel; +use Commercetools\History\Models\Common\ShoppingListLineItem; +use Commercetools\History\Models\Common\ShoppingListLineItemModel; /** * @internal @@ -37,13 +37,13 @@ final class AddShoppingListLineItemChangeModel extends JsonObjectModel implement /** * - * @var ?LineItem + * @var ?ShoppingListLineItem */ protected $previousValue; /** * - * @var ?LineItem + * @var ?ShoppingListLineItem */ protected $nextValue; @@ -53,8 +53,8 @@ final class AddShoppingListLineItemChangeModel extends JsonObjectModel implement */ public function __construct( ?string $change = null, - ?LineItem $previousValue = null, - ?LineItem $nextValue = null, + ?ShoppingListLineItem $previousValue = null, + ?ShoppingListLineItem $nextValue = null, ?string $type = null ) { $this->change = $change; @@ -103,7 +103,7 @@ public function getChange() *

                Value before the change.

                * * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getPreviousValue() { @@ -114,7 +114,7 @@ public function getPreviousValue() return null; } - $this->previousValue = LineItemModel::of($data); + $this->previousValue = ShoppingListLineItemModel::of($data); } return $this->previousValue; @@ -124,7 +124,7 @@ public function getPreviousValue() *

                Value after the change.

                * * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getNextValue() { @@ -135,7 +135,7 @@ public function getNextValue() return null; } - $this->nextValue = LineItemModel::of($data); + $this->nextValue = ShoppingListLineItemModel::of($data); } return $this->nextValue; @@ -151,17 +151,17 @@ public function setChange(?string $change): void } /** - * @param ?LineItem $previousValue + * @param ?ShoppingListLineItem $previousValue */ - public function setPreviousValue(?LineItem $previousValue): void + public function setPreviousValue(?ShoppingListLineItem $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?LineItem $nextValue + * @param ?ShoppingListLineItem $nextValue */ - public function setNextValue(?LineItem $nextValue): void + public function setNextValue(?ShoppingListLineItem $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/AddToCategoryChange.php b/lib/commercetools-history/src/Models/Change/AddToCategoryChange.php index 468d3abe1ad..5ada7b14772 100644 --- a/lib/commercetools-history/src/Models/Change/AddToCategoryChange.php +++ b/lib/commercetools-history/src/Models/Change/AddToCategoryChange.php @@ -19,6 +19,7 @@ interface AddToCategoryChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATEGORY = 'category'; + public const FIELD_CATALOG_DATA = 'catalogData'; /** @@ -56,6 +57,18 @@ public function getNextValue(); */ public function getCategory(); + /** + *

                Product data that was updated.

                + * + * + + * @return null|string + */ + public function getCatalogData(); + /** * @param ?string $change */ @@ -75,4 +88,9 @@ public function setNextValue(?ReferenceCollection $nextValue): void; * @param ?Reference $category */ public function setCategory(?Reference $category): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; } diff --git a/lib/commercetools-history/src/Models/Change/AddToCategoryChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddToCategoryChangeBuilder.php index 55897c5e7de..9ebb74b9ce6 100644 --- a/lib/commercetools-history/src/Models/Change/AddToCategoryChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/AddToCategoryChangeBuilder.php @@ -47,6 +47,12 @@ final class AddToCategoryChangeBuilder implements Builder */ private $category; + /** + + * @var ?string + */ + private $catalogData; + /** * @return null|string @@ -89,6 +95,21 @@ public function getCategory() return $this->category instanceof ReferenceBuilder ? $this->category->build() : $this->category; } + /** + *

                Product data that was updated.

                + * + * + + * @return null|string + */ + public function getCatalogData() + { + return $this->catalogData; + } + /** * @param ?string $change * @return $this @@ -133,6 +154,17 @@ public function withCategory(?Reference $category) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + /** * @deprecated use withCategory() instead * @return $this @@ -150,7 +182,8 @@ public function build(): AddToCategoryChange $this->change, $this->previousValue, $this->nextValue, - $this->category instanceof ReferenceBuilder ? $this->category->build() : $this->category + $this->category instanceof ReferenceBuilder ? $this->category->build() : $this->category, + $this->catalogData ); } diff --git a/lib/commercetools-history/src/Models/Change/AddToCategoryChangeModel.php b/lib/commercetools-history/src/Models/Change/AddToCategoryChangeModel.php index 9c7e8307fb8..f42cdf6a39d 100644 --- a/lib/commercetools-history/src/Models/Change/AddToCategoryChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddToCategoryChangeModel.php @@ -54,6 +54,12 @@ final class AddToCategoryChangeModel extends JsonObjectModel implements AddToCat */ protected $category; + /** + * + * @var ?string + */ + protected $catalogData; + /** * @psalm-suppress MissingParamType @@ -63,12 +69,14 @@ public function __construct( ?ReferenceCollection $previousValue = null, ?ReferenceCollection $nextValue = null, ?Reference $category = null, + ?string $catalogData = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->category = $category; + $this->catalogData = $catalogData; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -162,13 +170,37 @@ public function getCategory() if (is_null($data)) { return null; } - - $this->category = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->category = $className::of($data); } return $this->category; } + /** + *

                Product data that was updated.

                + * + * + * + * @return null|string + */ + public function getCatalogData() + { + if (is_null($this->catalogData)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CATALOG_DATA); + if (is_null($data)) { + return null; + } + $this->catalogData = (string) $data; + } + + return $this->catalogData; + } + /** * @param ?string $change @@ -202,6 +234,14 @@ public function setCategory(?Reference $category): void $this->category = $category; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + } diff --git a/lib/commercetools-history/src/Models/Change/AddVariantChange.php b/lib/commercetools-history/src/Models/Change/AddVariantChange.php index dd3053544bc..eea5643b98a 100644 --- a/lib/commercetools-history/src/Models/Change/AddVariantChange.php +++ b/lib/commercetools-history/src/Models/Change/AddVariantChange.php @@ -48,6 +48,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                Product data that was updated.

                *
                  *
                • staged, if the staged ProductCatalogData was updated.
                • *
                • current, if the current ProductCatalogData was updated.
                • diff --git a/lib/commercetools-history/src/Models/Change/AddVariantChangeBuilder.php b/lib/commercetools-history/src/Models/Change/AddVariantChangeBuilder.php index bab80c89c43..a9f28561187 100644 --- a/lib/commercetools-history/src/Models/Change/AddVariantChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/AddVariantChangeBuilder.php @@ -78,6 +78,7 @@ public function getNextValue() } /** + *

                  Product data that was updated.

                  *
                    *
                  • staged, if the staged ProductCatalogData was updated.
                  • *
                  • current, if the current ProductCatalogData was updated.
                  • diff --git a/lib/commercetools-history/src/Models/Change/AddVariantChangeModel.php b/lib/commercetools-history/src/Models/Change/AddVariantChangeModel.php index cec08ab495e..118b5b0dfd7 100644 --- a/lib/commercetools-history/src/Models/Change/AddVariantChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/AddVariantChangeModel.php @@ -150,6 +150,7 @@ public function getNextValue() } /** + *

                    Product data that was updated.

                    *
                      *
                    • staged, if the staged ProductCatalogData was updated.
                    • *
                    • current, if the current ProductCatalogData was updated.
                    • diff --git a/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChange.php b/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChange.php new file mode 100644 index 00000000000..8b5815dee01 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChange.php @@ -0,0 +1,62 @@ +Value before the change.

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

                      Value after the change.

                      + * + + * @return null|string + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void; + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChangeBuilder.php new file mode 100644 index 00000000000..cb4447ad30f --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChangeBuilder.php @@ -0,0 +1,119 @@ + + */ +final class ChangeApprovalRuleModeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $previousValue; + + /** + + * @var ?string + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                      Value before the change.

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

                      Value after the change.

                      + * + + * @return null|string + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $previousValue + * @return $this + */ + public function withPreviousValue(?string $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?string $nextValue + * @return $this + */ + public function withNextValue(?string $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): ChangeApprovalRuleModeChange + { + return new ChangeApprovalRuleModeChangeModel( + $this->change, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): ChangeApprovalRuleModeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChangeCollection.php b/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChangeCollection.php new file mode 100644 index 00000000000..e55f68b4742 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ChangeApprovalRuleModeChange current() + * @method ChangeApprovalRuleModeChange end() + * @method ChangeApprovalRuleModeChange at($offset) + */ +class ChangeApprovalRuleModeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ChangeApprovalRuleModeChange $value + * @psalm-param ChangeApprovalRuleModeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ChangeApprovalRuleModeChangeCollection + */ + public function add($value) + { + if (!$value instanceof ChangeApprovalRuleModeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ChangeApprovalRuleModeChange + */ + protected function mapper() + { + return function (?int $index): ?ChangeApprovalRuleModeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ChangeApprovalRuleModeChange $data */ + $data = ChangeApprovalRuleModeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChangeModel.php new file mode 100644 index 00000000000..c20ef8dd197 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeApprovalRuleModeChangeModel.php @@ -0,0 +1,167 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                      Value before the change.

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

                      Value after the change.

                      + * + * + * @return null|string + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (string) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeAssetNameChange.php b/lib/commercetools-history/src/Models/Change/ChangeAssetNameChange.php index 8d1d17f29f0..0367035d2c9 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeAssetNameChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangeAssetNameChange.php @@ -19,6 +19,8 @@ interface ChangeAssetNameChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_ASSET = 'asset'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -56,6 +58,27 @@ public function getNextValue(); */ public function getAsset(); + /** + *

                      Product data that was updated.

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

                      Identifier of the updated Product Variant.

                      + *

                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                      + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -75,4 +98,14 @@ public function setNextValue(?LocalizedString $nextValue): void; * @param ?AssetChangeValue $asset */ public function setAsset(?AssetChangeValue $asset): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/ChangeAssetNameChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeAssetNameChangeBuilder.php index 6980d06d89b..613f461a7b4 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeAssetNameChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangeAssetNameChangeBuilder.php @@ -48,6 +48,18 @@ final class ChangeAssetNameChangeBuilder implements Builder */ private $asset; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -90,6 +102,33 @@ public function getAsset() return $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset; } + /** + *

                      Product data that was updated.

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

                      Identifier of the updated Product Variant.

                      + *

                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                      + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -134,6 +173,28 @@ public function withAsset(?AssetChangeValue $asset) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -173,7 +234,9 @@ public function build(): ChangeAssetNameChange $this->change, $this->previousValue instanceof LocalizedStringBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue, - $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset + $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/ChangeAssetNameChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeAssetNameChangeModel.php index 573b039c0f0..40f1bdbbed6 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeAssetNameChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeAssetNameChangeModel.php @@ -55,6 +55,18 @@ final class ChangeAssetNameChangeModel extends JsonObjectModel implements Change */ protected $asset; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -64,12 +76,16 @@ public function __construct( ?LocalizedString $previousValue = null, ?LocalizedString $nextValue = null, ?AssetChangeValue $asset = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->asset = $asset; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -172,6 +188,51 @@ public function getAsset() return $this->asset; } + /** + *

                      Product data that was updated.

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

                      Identifier of the updated Product Variant.

                      + *

                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                      + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -205,6 +266,22 @@ public function setAsset(?AssetChangeValue $asset): void $this->asset = $asset; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChange.php b/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChange.php index fa377becb19..e50648da729 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChange.php @@ -17,6 +17,8 @@ interface ChangeAssetOrderChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -46,6 +48,27 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                      Product data that was updated.

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

                      Identifier of the updated Product Variant.

                      + *

                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                      + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -60,4 +83,14 @@ public function setPreviousValue(?LocalizedStringCollection $previousValue): voi * @param ?LocalizedStringCollection $nextValue */ public function setNextValue(?LocalizedStringCollection $nextValue): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChangeBuilder.php index 7d5cd9afab6..594e9067956 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChangeBuilder.php @@ -39,6 +39,18 @@ final class ChangeAssetOrderChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -70,6 +82,33 @@ public function getNextValue() return $this->nextValue; } + /** + *

                      Product data that was updated.

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

                      Identifier of the updated Product Variant.

                      + *

                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                      + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -103,13 +142,37 @@ public function withNextValue(?LocalizedStringCollection $nextValue) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + public function build(): ChangeAssetOrderChange { return new ChangeAssetOrderChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChangeModel.php index 51ce7c65906..a56163bb4ea 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeAssetOrderChangeModel.php @@ -46,6 +46,18 @@ final class ChangeAssetOrderChangeModel extends JsonObjectModel implements Chang */ protected $nextValue; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -54,11 +66,15 @@ public function __construct( ?string $change = null, ?LocalizedStringCollection $previousValue = null, ?LocalizedStringCollection $nextValue = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -138,6 +154,51 @@ public function getNextValue() return $this->nextValue; } + /** + *

                      Product data that was updated.

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

                      Identifier of the updated Product Variant.

                      + *

                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                      + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -163,6 +224,22 @@ public function setNextValue(?LocalizedStringCollection $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChange.php b/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChange.php index 6192cc08fa0..d916753a823 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChange.php @@ -17,6 +17,8 @@ interface ChangeCartDiscountsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -46,6 +48,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                      Elements added to the array.

                      + * + + * @return null|ReferenceCollection + */ + public function getAddedItems(); + + /** + *

                      Elements removed from the array.

                      + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -60,4 +78,14 @@ public function setPreviousValue(?ReferenceCollection $previousValue): void; * @param ?ReferenceCollection $nextValue */ public function setNextValue(?ReferenceCollection $nextValue): void; + + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void; + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChangeBuilder.php index 72046222d0c..2c84a1d0df8 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChangeBuilder.php @@ -39,6 +39,18 @@ final class ChangeCartDiscountsChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?ReferenceCollection + */ + private $addedItems; + + /** + + * @var ?ReferenceCollection + */ + private $removedItems; + /** * @return null|string @@ -70,6 +82,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                      Elements added to the array.

                      + * + + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                      Elements removed from the array.

                      + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -103,13 +137,37 @@ public function withNextValue(?ReferenceCollection $nextValue) return $this; } + /** + * @param ?ReferenceCollection $addedItems + * @return $this + */ + public function withAddedItems(?ReferenceCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?ReferenceCollection $removedItems + * @return $this + */ + public function withRemovedItems(?ReferenceCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): ChangeCartDiscountsChange { return new ChangeCartDiscountsChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChangeModel.php index ddeb09b8376..c6a8dd4c19c 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeCartDiscountsChangeModel.php @@ -46,6 +46,18 @@ final class ChangeCartDiscountsChangeModel extends JsonObjectModel implements Ch */ protected $nextValue; + /** + * + * @var ?ReferenceCollection + */ + protected $addedItems; + + /** + * + * @var ?ReferenceCollection + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -54,11 +66,15 @@ public function __construct( ?string $change = null, ?ReferenceCollection $previousValue = null, ?ReferenceCollection $nextValue = null, + ?ReferenceCollection $addedItems = null, + ?ReferenceCollection $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -138,6 +154,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                      Elements added to the array.

                      + * + * + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = ReferenceCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                      Elements removed from the array.

                      + * + * + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = ReferenceCollection::fromArray($data); + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -163,6 +219,22 @@ public function setNextValue(?ReferenceCollection $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/ChangeCustomerChange.php b/lib/commercetools-history/src/Models/Change/ChangeCustomerChange.php new file mode 100644 index 00000000000..ce5f24cd219 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeCustomerChange.php @@ -0,0 +1,63 @@ +Value before the change.

                      + * + + * @return null|Reference + */ + public function getPreviousValue(); + + /** + *

                      Value after the change.

                      + * + + * @return null|Reference + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?Reference $previousValue + */ + public function setPreviousValue(?Reference $previousValue): void; + + /** + * @param ?Reference $nextValue + */ + public function setNextValue(?Reference $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeCustomerChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeCustomerChangeBuilder.php new file mode 100644 index 00000000000..802a6c6e191 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeCustomerChangeBuilder.php @@ -0,0 +1,142 @@ + + */ +final class ChangeCustomerChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|Reference|ReferenceBuilder + */ + private $previousValue; + + /** + + * @var null|Reference|ReferenceBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                      Value before the change.

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

                      Value after the change.

                      + * + + * @return null|Reference + */ + public function getNextValue() + { + return $this->nextValue instanceof ReferenceBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?Reference $previousValue + * @return $this + */ + public function withPreviousValue(?Reference $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?Reference $nextValue + * @return $this + */ + public function withNextValue(?Reference $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?ReferenceBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?ReferenceBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): ChangeCustomerChange + { + return new ChangeCustomerChangeModel( + $this->change, + $this->previousValue instanceof ReferenceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof ReferenceBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): ChangeCustomerChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeCustomerChangeCollection.php b/lib/commercetools-history/src/Models/Change/ChangeCustomerChangeCollection.php new file mode 100644 index 00000000000..f6956a0a4c4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeCustomerChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ChangeCustomerChange current() + * @method ChangeCustomerChange end() + * @method ChangeCustomerChange at($offset) + */ +class ChangeCustomerChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ChangeCustomerChange $value + * @psalm-param ChangeCustomerChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ChangeCustomerChangeCollection + */ + public function add($value) + { + if (!$value instanceof ChangeCustomerChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ChangeCustomerChange + */ + protected function mapper() + { + return function (?int $index): ?ChangeCustomerChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ChangeCustomerChange $data */ + $data = ChangeCustomerChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeCustomerChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeCustomerChangeModel.php new file mode 100644 index 00000000000..c84b059bb5e --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeCustomerChangeModel.php @@ -0,0 +1,171 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                      Value before the change.

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

                      Value after the change.

                      + * + * + * @return null|Reference + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?Reference $previousValue + */ + public function setPreviousValue(?Reference $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?Reference $nextValue + */ + public function setNextValue(?Reference $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChange.php b/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChange.php index 2d6705e935e..dfb0068c94d 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChange.php @@ -18,6 +18,7 @@ interface ChangeEnumValueLabelChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_FIELD_NAME = 'fieldName'; public const FIELD_VALUE_KEY = 'valueKey'; + public const FIELD_ATTRIBUTE_NAME = 'attributeName'; /** @@ -63,6 +64,14 @@ public function getFieldName(); */ public function getValueKey(); + /** + *

                      Name of the updated AttributeDefinition.

                      + * + + * @return null|string + */ + public function getAttributeName(); + /** * @param ?string $change */ @@ -87,4 +96,9 @@ public function setFieldName(?string $fieldName): void; * @param ?string $valueKey */ public function setValueKey(?string $valueKey): void; + + /** + * @param ?string $attributeName + */ + public function setAttributeName(?string $attributeName): void; } diff --git a/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChangeBuilder.php index abdac3fce3d..e84b7205382 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChangeBuilder.php @@ -50,6 +50,12 @@ final class ChangeEnumValueLabelChangeBuilder implements Builder */ private $valueKey; + /** + + * @var ?string + */ + private $attributeName; + /** * @return null|string @@ -103,6 +109,17 @@ public function getValueKey() return $this->valueKey; } + /** + *

                      Name of the updated AttributeDefinition.

                      + * + + * @return null|string + */ + public function getAttributeName() + { + return $this->attributeName; + } + /** * @param ?string $change * @return $this @@ -158,6 +175,17 @@ public function withValueKey(?string $valueKey) return $this; } + /** + * @param ?string $attributeName + * @return $this + */ + public function withAttributeName(?string $attributeName) + { + $this->attributeName = $attributeName; + + return $this; + } + public function build(): ChangeEnumValueLabelChange { @@ -166,7 +194,8 @@ public function build(): ChangeEnumValueLabelChange $this->previousValue, $this->nextValue, $this->fieldName, - $this->valueKey + $this->valueKey, + $this->attributeName ); } diff --git a/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChangeModel.php index 65a49968f9a..93e2e40371a 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeEnumValueLabelChangeModel.php @@ -57,6 +57,12 @@ final class ChangeEnumValueLabelChangeModel extends JsonObjectModel implements C */ protected $valueKey; + /** + * + * @var ?string + */ + protected $attributeName; + /** * @psalm-suppress MissingParamType @@ -67,6 +73,7 @@ public function __construct( ?string $nextValue = null, ?string $fieldName = null, ?string $valueKey = null, + ?string $attributeName = null, ?string $type = null ) { $this->change = $change; @@ -74,6 +81,7 @@ public function __construct( $this->nextValue = $nextValue; $this->fieldName = $fieldName; $this->valueKey = $valueKey; + $this->attributeName = $attributeName; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -193,6 +201,26 @@ public function getValueKey() return $this->valueKey; } + /** + *

                      Name of the updated AttributeDefinition.

                      + * + * + * @return null|string + */ + public function getAttributeName() + { + if (is_null($this->attributeName)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ATTRIBUTE_NAME); + if (is_null($data)) { + return null; + } + $this->attributeName = (string) $data; + } + + return $this->attributeName; + } + /** * @param ?string $change @@ -234,6 +262,14 @@ public function setValueKey(?string $valueKey): void $this->valueKey = $valueKey; } + /** + * @param ?string $attributeName + */ + public function setAttributeName(?string $attributeName): void + { + $this->attributeName = $attributeName; + } + } diff --git a/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChange.php b/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChange.php index 15c7d63782f..71b1c9d5504 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\ChangeValue\EnumValueCollection; +use Commercetools\History\Models\Common\CustomFieldEnumValueCollection; interface ChangeEnumValueOrderChange extends Change { @@ -18,6 +18,7 @@ interface ChangeEnumValueOrderChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_FIELD_NAME = 'fieldName'; + public const FIELD_ATTRIBUTE_NAME = 'attributeName'; /** @@ -35,7 +36,7 @@ public function getChange(); *

                      Value before the change.

                      * - * @return null|EnumValueCollection + * @return null|CustomFieldEnumValueCollection */ public function getPreviousValue(); @@ -43,7 +44,7 @@ public function getPreviousValue(); *

                      Value after the change.

                      * - * @return null|EnumValueCollection + * @return null|CustomFieldEnumValueCollection */ public function getNextValue(); @@ -55,23 +56,36 @@ public function getNextValue(); */ public function getFieldName(); + /** + *

                      Name of the updated AttributeDefinition.

                      + * + + * @return null|string + */ + public function getAttributeName(); + /** * @param ?string $change */ public function setChange(?string $change): void; /** - * @param ?EnumValueCollection $previousValue + * @param ?CustomFieldEnumValueCollection $previousValue */ - public function setPreviousValue(?EnumValueCollection $previousValue): void; + public function setPreviousValue(?CustomFieldEnumValueCollection $previousValue): void; /** - * @param ?EnumValueCollection $nextValue + * @param ?CustomFieldEnumValueCollection $nextValue */ - public function setNextValue(?EnumValueCollection $nextValue): void; + public function setNextValue(?CustomFieldEnumValueCollection $nextValue): void; /** * @param ?string $fieldName */ public function setFieldName(?string $fieldName): void; + + /** + * @param ?string $attributeName + */ + public function setAttributeName(?string $attributeName): void; } diff --git a/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChangeBuilder.php index 4201c883259..532d935a824 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChangeBuilder.php @@ -14,7 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\EnumValueCollection; +use Commercetools\History\Models\Common\CustomFieldEnumValueCollection; /** * @implements Builder @@ -29,13 +29,13 @@ final class ChangeEnumValueOrderChangeBuilder implements Builder /** - * @var ?EnumValueCollection + * @var ?CustomFieldEnumValueCollection */ private $previousValue; /** - * @var ?EnumValueCollection + * @var ?CustomFieldEnumValueCollection */ private $nextValue; @@ -45,6 +45,12 @@ final class ChangeEnumValueOrderChangeBuilder implements Builder */ private $fieldName; + /** + + * @var ?string + */ + private $attributeName; + /** * @return null|string @@ -58,7 +64,7 @@ public function getChange() *

                      Value before the change.

                      * - * @return null|EnumValueCollection + * @return null|CustomFieldEnumValueCollection */ public function getPreviousValue() { @@ -69,7 +75,7 @@ public function getPreviousValue() *

                      Value after the change.

                      * - * @return null|EnumValueCollection + * @return null|CustomFieldEnumValueCollection */ public function getNextValue() { @@ -87,6 +93,17 @@ public function getFieldName() return $this->fieldName; } + /** + *

                      Name of the updated AttributeDefinition.

                      + * + + * @return null|string + */ + public function getAttributeName() + { + return $this->attributeName; + } + /** * @param ?string $change * @return $this @@ -99,10 +116,10 @@ public function withChange(?string $change) } /** - * @param ?EnumValueCollection $previousValue + * @param ?CustomFieldEnumValueCollection $previousValue * @return $this */ - public function withPreviousValue(?EnumValueCollection $previousValue) + public function withPreviousValue(?CustomFieldEnumValueCollection $previousValue) { $this->previousValue = $previousValue; @@ -110,10 +127,10 @@ public function withPreviousValue(?EnumValueCollection $previousValue) } /** - * @param ?EnumValueCollection $nextValue + * @param ?CustomFieldEnumValueCollection $nextValue * @return $this */ - public function withNextValue(?EnumValueCollection $nextValue) + public function withNextValue(?CustomFieldEnumValueCollection $nextValue) { $this->nextValue = $nextValue; @@ -131,6 +148,17 @@ public function withFieldName(?string $fieldName) return $this; } + /** + * @param ?string $attributeName + * @return $this + */ + public function withAttributeName(?string $attributeName) + { + $this->attributeName = $attributeName; + + return $this; + } + public function build(): ChangeEnumValueOrderChange { @@ -138,7 +166,8 @@ public function build(): ChangeEnumValueOrderChange $this->change, $this->previousValue, $this->nextValue, - $this->fieldName + $this->fieldName, + $this->attributeName ); } diff --git a/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChangeModel.php index 14433460c15..de3b736db65 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeEnumValueOrderChangeModel.php @@ -13,7 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\EnumValueCollection; +use Commercetools\History\Models\Common\CustomFieldEnumValueCollection; /** * @internal @@ -36,13 +36,13 @@ final class ChangeEnumValueOrderChangeModel extends JsonObjectModel implements C /** * - * @var ?EnumValueCollection + * @var ?CustomFieldEnumValueCollection */ protected $previousValue; /** * - * @var ?EnumValueCollection + * @var ?CustomFieldEnumValueCollection */ protected $nextValue; @@ -52,21 +52,29 @@ final class ChangeEnumValueOrderChangeModel extends JsonObjectModel implements C */ protected $fieldName; + /** + * + * @var ?string + */ + protected $attributeName; + /** * @psalm-suppress MissingParamType */ public function __construct( ?string $change = null, - ?EnumValueCollection $previousValue = null, - ?EnumValueCollection $nextValue = null, + ?CustomFieldEnumValueCollection $previousValue = null, + ?CustomFieldEnumValueCollection $nextValue = null, ?string $fieldName = null, + ?string $attributeName = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->fieldName = $fieldName; + $this->attributeName = $attributeName; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -110,7 +118,7 @@ public function getChange() *

                      Value before the change.

                      * * - * @return null|EnumValueCollection + * @return null|CustomFieldEnumValueCollection */ public function getPreviousValue() { @@ -120,7 +128,7 @@ public function getPreviousValue() if (is_null($data)) { return null; } - $this->previousValue = EnumValueCollection::fromArray($data); + $this->previousValue = CustomFieldEnumValueCollection::fromArray($data); } return $this->previousValue; @@ -130,7 +138,7 @@ public function getPreviousValue() *

                      Value after the change.

                      * * - * @return null|EnumValueCollection + * @return null|CustomFieldEnumValueCollection */ public function getNextValue() { @@ -140,7 +148,7 @@ public function getNextValue() if (is_null($data)) { return null; } - $this->nextValue = EnumValueCollection::fromArray($data); + $this->nextValue = CustomFieldEnumValueCollection::fromArray($data); } return $this->nextValue; @@ -166,6 +174,26 @@ public function getFieldName() return $this->fieldName; } + /** + *

                      Name of the updated AttributeDefinition.

                      + * + * + * @return null|string + */ + public function getAttributeName() + { + if (is_null($this->attributeName)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ATTRIBUTE_NAME); + if (is_null($data)) { + return null; + } + $this->attributeName = (string) $data; + } + + return $this->attributeName; + } + /** * @param ?string $change @@ -176,17 +204,17 @@ public function setChange(?string $change): void } /** - * @param ?EnumValueCollection $previousValue + * @param ?CustomFieldEnumValueCollection $previousValue */ - public function setPreviousValue(?EnumValueCollection $previousValue): void + public function setPreviousValue(?CustomFieldEnumValueCollection $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?EnumValueCollection $nextValue + * @param ?CustomFieldEnumValueCollection $nextValue */ - public function setNextValue(?EnumValueCollection $nextValue): void + public function setNextValue(?CustomFieldEnumValueCollection $nextValue): void { $this->nextValue = $nextValue; } @@ -199,6 +227,14 @@ public function setFieldName(?string $fieldName): void $this->fieldName = $fieldName; } + /** + * @param ?string $attributeName + */ + public function setAttributeName(?string $attributeName): void + { + $this->attributeName = $attributeName; + } + } diff --git a/lib/commercetools-history/src/Models/Change/ChangeGroupsChange.php b/lib/commercetools-history/src/Models/Change/ChangeGroupsChange.php index b1202edae8b..694431573a4 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeGroupsChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangeGroupsChange.php @@ -16,6 +16,8 @@ interface ChangeGroupsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -45,6 +47,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                      Elements added to the array.

                      + * + + * @return null|array + */ + public function getAddedItems(); + + /** + *

                      Elements removed from the array.

                      + * + + * @return null|array + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -59,4 +77,14 @@ public function setPreviousValue(?array $previousValue): void; * @param ?array $nextValue */ public function setNextValue(?array $nextValue): void; + + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void; + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/ChangeGroupsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeGroupsChangeBuilder.php index 9a4e7a1abb3..45e4d7e4417 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeGroupsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangeGroupsChangeBuilder.php @@ -38,6 +38,18 @@ final class ChangeGroupsChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?array + */ + private $addedItems; + + /** + + * @var ?array + */ + private $removedItems; + /** * @return null|string @@ -69,6 +81,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                      Elements added to the array.

                      + * + + * @return null|array + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                      Elements removed from the array.

                      + * + + * @return null|array + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -102,13 +136,37 @@ public function withNextValue(?array $nextValue) return $this; } + /** + * @param ?array $addedItems + * @return $this + */ + public function withAddedItems(?array $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?array $removedItems + * @return $this + */ + public function withRemovedItems(?array $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): ChangeGroupsChange { return new ChangeGroupsChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/ChangeGroupsChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeGroupsChangeModel.php index 54b0f3bae26..efb1bfdcaa7 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeGroupsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeGroupsChangeModel.php @@ -45,6 +45,18 @@ final class ChangeGroupsChangeModel extends JsonObjectModel implements ChangeGro */ protected $nextValue; + /** + * + * @var ?array + */ + protected $addedItems; + + /** + * + * @var ?array + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -53,11 +65,15 @@ public function __construct( ?string $change = null, ?array $previousValue = null, ?array $nextValue = null, + ?array $addedItems = null, + ?array $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -137,6 +153,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                      Elements added to the array.

                      + * + * + * @return null|array + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = $data; + } + + return $this->addedItems; + } + + /** + *

                      Elements removed from the array.

                      + * + * + * @return null|array + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = $data; + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -162,6 +218,22 @@ public function setNextValue(?array $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChange.php b/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChange.php new file mode 100644 index 00000000000..b37340ee3bb --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChange.php @@ -0,0 +1,62 @@ +Value before the change.

                      + * + + * @return null|bool + */ + public function getPreviousValue(); + + /** + *

                      Value after the change.

                      + * + + * @return null|bool + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?bool $previousValue + */ + public function setPreviousValue(?bool $previousValue): void; + + /** + * @param ?bool $nextValue + */ + public function setNextValue(?bool $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChangeBuilder.php new file mode 100644 index 00000000000..9c656880639 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChangeBuilder.php @@ -0,0 +1,119 @@ + + */ +final class ChangeIncludedInStatisticsChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?bool + */ + private $previousValue; + + /** + + * @var ?bool + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                      Value before the change.

                      + * + + * @return null|bool + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                      Value after the change.

                      + * + + * @return null|bool + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?bool $previousValue + * @return $this + */ + public function withPreviousValue(?bool $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?bool $nextValue + * @return $this + */ + public function withNextValue(?bool $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): ChangeIncludedInStatisticsChange + { + return new ChangeIncludedInStatisticsChangeModel( + $this->change, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): ChangeIncludedInStatisticsChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChangeCollection.php b/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChangeCollection.php new file mode 100644 index 00000000000..5102aba1052 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ChangeIncludedInStatisticsChange current() + * @method ChangeIncludedInStatisticsChange end() + * @method ChangeIncludedInStatisticsChange at($offset) + */ +class ChangeIncludedInStatisticsChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ChangeIncludedInStatisticsChange $value + * @psalm-param ChangeIncludedInStatisticsChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ChangeIncludedInStatisticsChangeCollection + */ + public function add($value) + { + if (!$value instanceof ChangeIncludedInStatisticsChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ChangeIncludedInStatisticsChange + */ + protected function mapper() + { + return function (?int $index): ?ChangeIncludedInStatisticsChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ChangeIncludedInStatisticsChange $data */ + $data = ChangeIncludedInStatisticsChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChangeModel.php new file mode 100644 index 00000000000..ae1d1abc566 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeIncludedInStatisticsChangeModel.php @@ -0,0 +1,167 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                      Value before the change.

                      + * + * + * @return null|bool + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = (bool) $data; + } + + return $this->previousValue; + } + + /** + *

                      Value after the change.

                      + * + * + * @return null|bool + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (bool) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?bool $previousValue + */ + public function setPreviousValue(?bool $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?bool $nextValue + */ + public function setNextValue(?bool $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChange.php b/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChange.php new file mode 100644 index 00000000000..19d53199f75 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChange.php @@ -0,0 +1,62 @@ +Value before the change.

                      + * + + * @return null|int + */ + public function getPreviousValue(); + + /** + *

                      Value after the change.

                      + * + + * @return null|int + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?int $previousValue + */ + public function setPreviousValue(?int $previousValue): void; + + /** + * @param ?int $nextValue + */ + public function setNextValue(?int $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChangeBuilder.php new file mode 100644 index 00000000000..f4b3869652c --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChangeBuilder.php @@ -0,0 +1,119 @@ + + */ +final class ChangeLastVariantIdChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?int + */ + private $previousValue; + + /** + + * @var ?int + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                      Value before the change.

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

                      Value after the change.

                      + * + + * @return null|int + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?int $previousValue + * @return $this + */ + public function withPreviousValue(?int $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?int $nextValue + * @return $this + */ + public function withNextValue(?int $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): ChangeLastVariantIdChange + { + return new ChangeLastVariantIdChangeModel( + $this->change, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): ChangeLastVariantIdChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChangeCollection.php b/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChangeCollection.php new file mode 100644 index 00000000000..c25927f7af3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ChangeLastVariantIdChange current() + * @method ChangeLastVariantIdChange end() + * @method ChangeLastVariantIdChange at($offset) + */ +class ChangeLastVariantIdChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ChangeLastVariantIdChange $value + * @psalm-param ChangeLastVariantIdChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ChangeLastVariantIdChangeCollection + */ + public function add($value) + { + if (!$value instanceof ChangeLastVariantIdChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ChangeLastVariantIdChange + */ + protected function mapper() + { + return function (?int $index): ?ChangeLastVariantIdChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ChangeLastVariantIdChange $data */ + $data = ChangeLastVariantIdChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChangeModel.php new file mode 100644 index 00000000000..1375fad69f6 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLastVariantIdChangeModel.php @@ -0,0 +1,167 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                      Value before the change.

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

                      Value after the change.

                      + * + * + * @return null|int + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (int) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?int $previousValue + */ + public function setPreviousValue(?int $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?int $nextValue + */ + public function setNextValue(?int $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChange.php b/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChange.php new file mode 100644 index 00000000000..1a69a40c59c --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChange.php @@ -0,0 +1,78 @@ +Holds information about the updated Shopping List Line Item.

                      + * + + * @return null|ShoppingListLineItemValue + */ + public function getLineItem(); + + /** + *

                      Value before the change.

                      + * + + * @return null|LocalizedString + */ + public function getPreviousValue(); + + /** + *

                      Value after the change.

                      + * + + * @return null|LocalizedString + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?ShoppingListLineItemValue $lineItem + */ + public function setLineItem(?ShoppingListLineItemValue $lineItem): void; + + /** + * @param ?LocalizedString $previousValue + */ + public function setPreviousValue(?LocalizedString $previousValue): void; + + /** + * @param ?LocalizedString $nextValue + */ + public function setNextValue(?LocalizedString $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChangeBuilder.php new file mode 100644 index 00000000000..d9c0450e89d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChangeBuilder.php @@ -0,0 +1,184 @@ + + */ +final class ChangeLineItemNameChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|ShoppingListLineItemValue|ShoppingListLineItemValueBuilder + */ + private $lineItem; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $previousValue; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                      Holds information about the updated Shopping List Line Item.

                      + * + + * @return null|ShoppingListLineItemValue + */ + public function getLineItem() + { + return $this->lineItem instanceof ShoppingListLineItemValueBuilder ? $this->lineItem->build() : $this->lineItem; + } + + /** + *

                      Value before the change.

                      + * + + * @return null|LocalizedString + */ + public function getPreviousValue() + { + return $this->previousValue instanceof LocalizedStringBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                      Value after the change.

                      + * + + * @return null|LocalizedString + */ + public function getNextValue() + { + return $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?ShoppingListLineItemValue $lineItem + * @return $this + */ + public function withLineItem(?ShoppingListLineItemValue $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @param ?LocalizedString $previousValue + * @return $this + */ + public function withPreviousValue(?LocalizedString $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?LocalizedString $nextValue + * @return $this + */ + public function withNextValue(?LocalizedString $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withLineItem() instead + * @return $this + */ + public function withLineItemBuilder(?ShoppingListLineItemValueBuilder $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?LocalizedStringBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?LocalizedStringBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): ChangeLineItemNameChange + { + return new ChangeLineItemNameChangeModel( + $this->change, + $this->lineItem instanceof ShoppingListLineItemValueBuilder ? $this->lineItem->build() : $this->lineItem, + $this->previousValue instanceof LocalizedStringBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): ChangeLineItemNameChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChangeCollection.php b/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChangeCollection.php new file mode 100644 index 00000000000..1ceff8214a8 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ChangeLineItemNameChange current() + * @method ChangeLineItemNameChange end() + * @method ChangeLineItemNameChange at($offset) + */ +class ChangeLineItemNameChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ChangeLineItemNameChange $value + * @psalm-param ChangeLineItemNameChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ChangeLineItemNameChangeCollection + */ + public function add($value) + { + if (!$value instanceof ChangeLineItemNameChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ChangeLineItemNameChange + */ + protected function mapper() + { + return function (?int $index): ?ChangeLineItemNameChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ChangeLineItemNameChange $data */ + $data = ChangeLineItemNameChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChangeModel.php new file mode 100644 index 00000000000..c22848d65c0 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLineItemNameChangeModel.php @@ -0,0 +1,210 @@ +change = $change; + $this->lineItem = $lineItem; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                      Holds information about the updated Shopping List Line Item.

                      + * + * + * @return null|ShoppingListLineItemValue + */ + 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 = ShoppingListLineItemValueModel::of($data); + } + + return $this->lineItem; + } + + /** + *

                      Value before the change.

                      + * + * + * @return null|LocalizedString + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = LocalizedStringModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                      Value after the change.

                      + * + * + * @return null|LocalizedString + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = LocalizedStringModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?ShoppingListLineItemValue $lineItem + */ + public function setLineItem(?ShoppingListLineItemValue $lineItem): void + { + $this->lineItem = $lineItem; + } + + /** + * @param ?LocalizedString $previousValue + */ + public function setPreviousValue(?LocalizedString $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?LocalizedString $nextValue + */ + public function setNextValue(?LocalizedString $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChange.php b/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChange.php new file mode 100644 index 00000000000..f2d042c11f0 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChange.php @@ -0,0 +1,77 @@ +Holds information about the updated Shopping List Line Item.

                      + * + + * @return null|ShoppingListLineItemValue + */ + public function getLineItem(); + + /** + *

                      Value before the change.

                      + * + + * @return null|bool + */ + public function getPreviousValue(); + + /** + *

                      Value after the change.

                      + * + + * @return null|bool + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?ShoppingListLineItemValue $lineItem + */ + public function setLineItem(?ShoppingListLineItemValue $lineItem): void; + + /** + * @param ?bool $previousValue + */ + public function setPreviousValue(?bool $previousValue): void; + + /** + * @param ?bool $nextValue + */ + public function setNextValue(?bool $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChangeBuilder.php new file mode 100644 index 00000000000..db8ca80dce3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChangeBuilder.php @@ -0,0 +1,160 @@ + + */ +final class ChangeLineItemPublishedChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|ShoppingListLineItemValue|ShoppingListLineItemValueBuilder + */ + private $lineItem; + + /** + + * @var ?bool + */ + private $previousValue; + + /** + + * @var ?bool + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                      Holds information about the updated Shopping List Line Item.

                      + * + + * @return null|ShoppingListLineItemValue + */ + public function getLineItem() + { + return $this->lineItem instanceof ShoppingListLineItemValueBuilder ? $this->lineItem->build() : $this->lineItem; + } + + /** + *

                      Value before the change.

                      + * + + * @return null|bool + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                      Value after the change.

                      + * + + * @return null|bool + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?ShoppingListLineItemValue $lineItem + * @return $this + */ + public function withLineItem(?ShoppingListLineItemValue $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @param ?bool $previousValue + * @return $this + */ + public function withPreviousValue(?bool $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?bool $nextValue + * @return $this + */ + public function withNextValue(?bool $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withLineItem() instead + * @return $this + */ + public function withLineItemBuilder(?ShoppingListLineItemValueBuilder $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + public function build(): ChangeLineItemPublishedChange + { + return new ChangeLineItemPublishedChangeModel( + $this->change, + $this->lineItem instanceof ShoppingListLineItemValueBuilder ? $this->lineItem->build() : $this->lineItem, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): ChangeLineItemPublishedChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChangeCollection.php b/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChangeCollection.php new file mode 100644 index 00000000000..4653d043d8c --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ChangeLineItemPublishedChange current() + * @method ChangeLineItemPublishedChange end() + * @method ChangeLineItemPublishedChange at($offset) + */ +class ChangeLineItemPublishedChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ChangeLineItemPublishedChange $value + * @psalm-param ChangeLineItemPublishedChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ChangeLineItemPublishedChangeCollection + */ + public function add($value) + { + if (!$value instanceof ChangeLineItemPublishedChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ChangeLineItemPublishedChange + */ + protected function mapper() + { + return function (?int $index): ?ChangeLineItemPublishedChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ChangeLineItemPublishedChange $data */ + $data = ChangeLineItemPublishedChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChangeModel.php new file mode 100644 index 00000000000..59440287250 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeLineItemPublishedChangeModel.php @@ -0,0 +1,206 @@ +change = $change; + $this->lineItem = $lineItem; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                      Holds information about the updated Shopping List Line Item.

                      + * + * + * @return null|ShoppingListLineItemValue + */ + 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 = ShoppingListLineItemValueModel::of($data); + } + + return $this->lineItem; + } + + /** + *

                      Value before the change.

                      + * + * + * @return null|bool + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = (bool) $data; + } + + return $this->previousValue; + } + + /** + *

                      Value after the change.

                      + * + * + * @return null|bool + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (bool) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?ShoppingListLineItemValue $lineItem + */ + public function setLineItem(?ShoppingListLineItemValue $lineItem): void + { + $this->lineItem = $lineItem; + } + + /** + * @param ?bool $previousValue + */ + public function setPreviousValue(?bool $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?bool $nextValue + */ + public function setNextValue(?bool $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChange.php b/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChange.php index c8a830dbfab..b4c146bcdad 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\ChangeValue\LocalizedEnumValueCollection; +use Commercetools\History\Models\Common\AttributeLocalizedEnumValueCollection; interface ChangeLocalizedEnumValueOrderChange extends Change { @@ -36,7 +36,7 @@ public function getChange(); *

                      Value before the change.

                      * - * @return null|LocalizedEnumValueCollection + * @return null|AttributeLocalizedEnumValueCollection */ public function getPreviousValue(); @@ -44,7 +44,7 @@ public function getPreviousValue(); *

                      Value after the change.

                      * - * @return null|LocalizedEnumValueCollection + * @return null|AttributeLocalizedEnumValueCollection */ public function getNextValue(); @@ -70,14 +70,14 @@ public function getAttributeName(); public function setChange(?string $change): void; /** - * @param ?LocalizedEnumValueCollection $previousValue + * @param ?AttributeLocalizedEnumValueCollection $previousValue */ - public function setPreviousValue(?LocalizedEnumValueCollection $previousValue): void; + public function setPreviousValue(?AttributeLocalizedEnumValueCollection $previousValue): void; /** - * @param ?LocalizedEnumValueCollection $nextValue + * @param ?AttributeLocalizedEnumValueCollection $nextValue */ - public function setNextValue(?LocalizedEnumValueCollection $nextValue): void; + public function setNextValue(?AttributeLocalizedEnumValueCollection $nextValue): void; /** * @param ?string $fieldName diff --git a/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChangeBuilder.php index 113b54d49f4..d94a977e3eb 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChangeBuilder.php @@ -14,7 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\LocalizedEnumValueCollection; +use Commercetools\History\Models\Common\AttributeLocalizedEnumValueCollection; /** * @implements Builder @@ -29,13 +29,13 @@ final class ChangeLocalizedEnumValueOrderChangeBuilder implements Builder /** - * @var ?LocalizedEnumValueCollection + * @var ?AttributeLocalizedEnumValueCollection */ private $previousValue; /** - * @var ?LocalizedEnumValueCollection + * @var ?AttributeLocalizedEnumValueCollection */ private $nextValue; @@ -64,7 +64,7 @@ public function getChange() *

                      Value before the change.

                      * - * @return null|LocalizedEnumValueCollection + * @return null|AttributeLocalizedEnumValueCollection */ public function getPreviousValue() { @@ -75,7 +75,7 @@ public function getPreviousValue() *

                      Value after the change.

                      * - * @return null|LocalizedEnumValueCollection + * @return null|AttributeLocalizedEnumValueCollection */ public function getNextValue() { @@ -116,10 +116,10 @@ public function withChange(?string $change) } /** - * @param ?LocalizedEnumValueCollection $previousValue + * @param ?AttributeLocalizedEnumValueCollection $previousValue * @return $this */ - public function withPreviousValue(?LocalizedEnumValueCollection $previousValue) + public function withPreviousValue(?AttributeLocalizedEnumValueCollection $previousValue) { $this->previousValue = $previousValue; @@ -127,10 +127,10 @@ public function withPreviousValue(?LocalizedEnumValueCollection $previousValue) } /** - * @param ?LocalizedEnumValueCollection $nextValue + * @param ?AttributeLocalizedEnumValueCollection $nextValue * @return $this */ - public function withNextValue(?LocalizedEnumValueCollection $nextValue) + public function withNextValue(?AttributeLocalizedEnumValueCollection $nextValue) { $this->nextValue = $nextValue; diff --git a/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChangeModel.php index 4f179684520..e1a3c485086 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeLocalizedEnumValueOrderChangeModel.php @@ -13,7 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\LocalizedEnumValueCollection; +use Commercetools\History\Models\Common\AttributeLocalizedEnumValueCollection; /** * @internal @@ -36,13 +36,13 @@ final class ChangeLocalizedEnumValueOrderChangeModel extends JsonObjectModel imp /** * - * @var ?LocalizedEnumValueCollection + * @var ?AttributeLocalizedEnumValueCollection */ protected $previousValue; /** * - * @var ?LocalizedEnumValueCollection + * @var ?AttributeLocalizedEnumValueCollection */ protected $nextValue; @@ -64,8 +64,8 @@ final class ChangeLocalizedEnumValueOrderChangeModel extends JsonObjectModel imp */ public function __construct( ?string $change = null, - ?LocalizedEnumValueCollection $previousValue = null, - ?LocalizedEnumValueCollection $nextValue = null, + ?AttributeLocalizedEnumValueCollection $previousValue = null, + ?AttributeLocalizedEnumValueCollection $nextValue = null, ?string $fieldName = null, ?string $attributeName = null, ?string $type = null @@ -118,7 +118,7 @@ public function getChange() *

                      Value before the change.

                      * * - * @return null|LocalizedEnumValueCollection + * @return null|AttributeLocalizedEnumValueCollection */ public function getPreviousValue() { @@ -128,7 +128,7 @@ public function getPreviousValue() if (is_null($data)) { return null; } - $this->previousValue = LocalizedEnumValueCollection::fromArray($data); + $this->previousValue = AttributeLocalizedEnumValueCollection::fromArray($data); } return $this->previousValue; @@ -138,7 +138,7 @@ public function getPreviousValue() *

                      Value after the change.

                      * * - * @return null|LocalizedEnumValueCollection + * @return null|AttributeLocalizedEnumValueCollection */ public function getNextValue() { @@ -148,7 +148,7 @@ public function getNextValue() if (is_null($data)) { return null; } - $this->nextValue = LocalizedEnumValueCollection::fromArray($data); + $this->nextValue = AttributeLocalizedEnumValueCollection::fromArray($data); } return $this->nextValue; @@ -204,17 +204,17 @@ public function setChange(?string $change): void } /** - * @param ?LocalizedEnumValueCollection $previousValue + * @param ?AttributeLocalizedEnumValueCollection $previousValue */ - public function setPreviousValue(?LocalizedEnumValueCollection $previousValue): void + public function setPreviousValue(?AttributeLocalizedEnumValueCollection $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?LocalizedEnumValueCollection $nextValue + * @param ?AttributeLocalizedEnumValueCollection $nextValue */ - public function setNextValue(?LocalizedEnumValueCollection $nextValue): void + public function setNextValue(?AttributeLocalizedEnumValueCollection $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChange.php b/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChange.php index 34b5723ebb1..e1dfcf26ab3 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChange.php @@ -48,6 +48,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                      Product data that was updated.

                      *
                        *
                      • staged, if the staged ProductCatalogData was updated.
                      • *
                      • current, if the current ProductCatalogData was updated.
                      • diff --git a/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChangeBuilder.php index a97d02bae5d..515e37288a8 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChangeBuilder.php @@ -78,6 +78,7 @@ public function getNextValue() } /** + *

                        Product data that was updated.

                        *
                          *
                        • staged, if the staged ProductCatalogData was updated.
                        • *
                        • current, if the current ProductCatalogData was updated.
                        • diff --git a/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChangeModel.php index 313b55818ac..5d885bd6d09 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeMasterVariantChangeModel.php @@ -150,6 +150,7 @@ public function getNextValue() } /** + *

                          Product data that was updated.

                          *
                            *
                          • staged, if the staged ProductCatalogData was updated.
                          • *
                          • current, if the current ProductCatalogData was updated.
                          • diff --git a/lib/commercetools-history/src/Models/Change/ChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeModel.php index c6b818ae60a..82f3e2f3fa7 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeModel.php @@ -65,6 +65,7 @@ final class ChangeModel extends JsonObjectModel implements Change 'AddPropertyChange' => AddPropertyChangeModel::class, 'AddReturnInfoChange' => AddReturnInfoChangeModel::class, 'AddShippingAddressIdChange' => AddShippingAddressIdChangeModel::class, + 'AddShippingChange' => AddShippingChangeModel::class, 'AddShoppingListLineItemChange' => AddShoppingListLineItemChangeModel::class, 'AddStateRolesChange' => AddStateRolesChangeModel::class, 'AddTaxRateChange' => AddTaxRateChangeModel::class, @@ -75,6 +76,7 @@ final class ChangeModel extends JsonObjectModel implements Change 'ChangeAddressChange' => ChangeAddressChangeModel::class, 'ChangeAmountAuthorizedChange' => ChangeAmountAuthorizedChangeModel::class, 'ChangeAmountPlannedChange' => ChangeAmountPlannedChangeModel::class, + 'ChangeApprovalRuleModeChange' => ChangeApprovalRuleModeChangeModel::class, 'ChangeAssetNameChange' => ChangeAssetNameChangeModel::class, 'ChangeAssetOrderChange' => ChangeAssetOrderChangeModel::class, 'ChangeAssociateChange' => ChangeAssociateChangeModel::class, @@ -85,12 +87,14 @@ final class ChangeModel extends JsonObjectModel implements Change 'ChangeCartDiscountsChange' => ChangeCartDiscountsChangeModel::class, 'ChangeCartPredicateChange' => ChangeCartPredicateChangeModel::class, 'ChangeCustomLineItemQuantityChange' => ChangeCustomLineItemQuantityChangeModel::class, + 'ChangeCustomerChange' => ChangeCustomerChangeModel::class, 'ChangeDescriptionChange' => ChangeDescriptionChangeModel::class, 'ChangeEmailChange' => ChangeEmailChangeModel::class, 'ChangeEnumValueLabelChange' => ChangeEnumValueLabelChangeModel::class, 'ChangeEnumValueOrderChange' => ChangeEnumValueOrderChangeModel::class, 'ChangeFieldDefinitionOrderChange' => ChangeFieldDefinitionOrderChangeModel::class, 'ChangeGroupsChange' => ChangeGroupsChangeModel::class, + 'ChangeIncludedInStatisticsChange' => ChangeIncludedInStatisticsChangeModel::class, 'ChangeInheritedAssociateChange' => ChangeInheritedAssociateChangeModel::class, 'ChangeInitialChange' => ChangeInitialChangeModel::class, 'ChangeInputHintChange' => ChangeInputHintChangeModel::class, @@ -98,6 +102,9 @@ final class ChangeModel extends JsonObjectModel implements Change 'ChangeIsSearchableChange' => ChangeIsSearchableChangeModel::class, 'ChangeKeyChange' => ChangeKeyChangeModel::class, 'ChangeLabelChange' => ChangeLabelChangeModel::class, + 'ChangeLastVariantIdChange' => ChangeLastVariantIdChangeModel::class, + 'ChangeLineItemNameChange' => ChangeLineItemNameChangeModel::class, + 'ChangeLineItemPublishedChange' => ChangeLineItemPublishedChangeModel::class, 'ChangeLineItemQuantityChange' => ChangeLineItemQuantityChangeModel::class, 'ChangeLocalizedDescriptionChange' => ChangeLocalizedDescriptionChangeModel::class, 'ChangeLocalizedEnumValueLabelChange' => ChangeLocalizedEnumValueLabelChangeModel::class, @@ -114,6 +121,7 @@ final class ChangeModel extends JsonObjectModel implements Change 'ChangePlainEnumValueOrderChange' => ChangePlainEnumValueOrderChangeModel::class, 'ChangePredicateChange' => ChangePredicateChangeModel::class, 'ChangePriceChange' => ChangePriceChangeModel::class, + 'ChangePriceRoundingModeChange' => ChangePriceRoundingModeChangeModel::class, 'ChangeProductSelectionActiveChange' => ChangeProductSelectionActiveChangeModel::class, 'ChangeQuantityChange' => ChangeQuantityChangeModel::class, 'ChangeQuoteRequestStateChange' => ChangeQuoteRequestStateChangeModel::class, @@ -136,10 +144,12 @@ final class ChangeModel extends JsonObjectModel implements Change 'ChangeTextLineItemNameChange' => ChangeTextLineItemNameChangeModel::class, 'ChangeTextLineItemQuantityChange' => ChangeTextLineItemQuantityChangeModel::class, 'ChangeTextLineItemsOrderChange' => ChangeTextLineItemsOrderChangeModel::class, + 'ChangeTopLevelUnitChange' => ChangeTopLevelUnitChangeModel::class, 'ChangeTransactionInteractionIdChange' => ChangeTransactionInteractionIdChangeModel::class, 'ChangeTransactionStateChange' => ChangeTransactionStateChangeModel::class, 'ChangeTransactionTimestampChange' => ChangeTransactionTimestampChangeModel::class, 'ChangeValueChange' => ChangeValueChangeModel::class, + 'ExcludeProductChange' => ExcludeProductChangeModel::class, 'MoveImageToPositionChange' => MoveImageToPositionChangeModel::class, 'PublishChange' => PublishChangeModel::class, 'RemoveAddressChange' => RemoveAddressChangeModel::class, @@ -167,15 +177,20 @@ final class ChangeModel extends JsonObjectModel implements Change 'RemoveProductSelectionChange' => RemoveProductSelectionChangeModel::class, 'RemovePropertyChange' => RemovePropertyChangeModel::class, 'RemoveShippingAddressIdChange' => RemoveShippingAddressIdChangeModel::class, + 'RemoveShippingChange' => RemoveShippingChangeModel::class, 'RemoveShoppingListLineItemChange' => RemoveShoppingListLineItemChangeModel::class, 'RemoveStateRolesChange' => RemoveStateRolesChangeModel::class, 'RemoveTaxRateChange' => RemoveTaxRateChangeModel::class, 'RemoveTextLineItemChange' => RemoveTextLineItemChangeModel::class, 'RemoveVariantChange' => RemoveVariantChangeModel::class, + 'ReplaceTaxRateChange' => ReplaceTaxRateChangeModel::class, 'RequestQuoteRenegotiationChange' => RequestQuoteRenegotiationChangeModel::class, + 'RevertStagedChangesChange' => RevertStagedChangesChangeModel::class, + 'RevertStagedVariantChangesChange' => RevertStagedVariantChangesChangeModel::class, 'SetAddressChange' => SetAddressChangeModel::class, 'SetAddressCustomFieldChange' => SetAddressCustomFieldChangeModel::class, 'SetAddressCustomTypeChange' => SetAddressCustomTypeChangeModel::class, + 'SetAncestorsChange' => SetAncestorsChangeModel::class, 'SetAnonymousIdChange' => SetAnonymousIdChangeModel::class, 'SetApplicationVersionChange' => SetApplicationVersionChangeModel::class, 'SetAssetCustomFieldChange' => SetAssetCustomFieldChangeModel::class, @@ -184,10 +199,14 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetAssetKeyChange' => SetAssetKeyChangeModel::class, 'SetAssetSourcesChange' => SetAssetSourcesChangeModel::class, 'SetAssetTagsChange' => SetAssetTagsChangeModel::class, + 'SetAssociatesChange' => SetAssociatesChangeModel::class, 'SetAttributeChange' => SetAttributeChangeModel::class, 'SetAuthenticationModeChange' => SetAuthenticationModeChangeModel::class, 'SetAuthorNameChange' => SetAuthorNameChangeModel::class, 'SetBillingAddressChange' => SetBillingAddressChangeModel::class, + 'SetBillingAddressCustomFieldChange' => SetBillingAddressCustomFieldChangeModel::class, + 'SetBillingAddressCustomTypeChange' => SetBillingAddressCustomTypeChangeModel::class, + 'SetBusinessUnitChange' => SetBusinessUnitChangeModel::class, 'SetCartPredicateChange' => SetCartPredicateChangeModel::class, 'SetCategoryOrderHintChange' => SetCategoryOrderHintChangeModel::class, 'SetChannelRolesChange' => SetChannelRolesChangeModel::class, @@ -198,6 +217,8 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetCustomFieldChange' => SetCustomFieldChangeModel::class, 'SetCustomLineItemCustomFieldChange' => SetCustomLineItemCustomFieldChangeModel::class, 'SetCustomLineItemCustomTypeChange' => SetCustomLineItemCustomTypeChangeModel::class, + 'SetCustomLineItemDiscountedPriceChange' => SetCustomLineItemDiscountedPriceChangeModel::class, + 'SetCustomLineItemDiscountedPricePerQuantityChange' => SetCustomLineItemDiscountedPricePerQuantityChangeModel::class, 'SetCustomLineItemMoneyChange' => SetCustomLineItemMoneyChangeModel::class, 'SetCustomLineItemShippingDetailsChange' => SetCustomLineItemShippingDetailsChangeModel::class, 'SetCustomLineItemTaxAmountChange' => SetCustomLineItemTaxAmountChangeModel::class, @@ -209,6 +230,7 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetCustomTypeChange' => SetCustomTypeChangeModel::class, 'SetCustomerChange' => SetCustomerChangeModel::class, 'SetCustomerEmailChange' => SetCustomerEmailChangeModel::class, + 'SetCustomerGroupAssignmentsChange' => SetCustomerGroupAssignmentsChangeModel::class, 'SetCustomerGroupChange' => SetCustomerGroupChangeModel::class, 'SetCustomerIdChange' => SetCustomerIdChangeModel::class, 'SetCustomerNumberChange' => SetCustomerNumberChangeModel::class, @@ -217,8 +239,13 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetDefaultShippingAddressChange' => SetDefaultShippingAddressChangeModel::class, 'SetDeleteDaysAfterLastModificationChange' => SetDeleteDaysAfterLastModificationChangeModel::class, 'SetDeliveryAddressChange' => SetDeliveryAddressChangeModel::class, + 'SetDeliveryAddressCustomFieldChange' => SetDeliveryAddressCustomFieldChangeModel::class, + 'SetDeliveryAddressCustomTypeChange' => SetDeliveryAddressCustomTypeChangeModel::class, + 'SetDeliveryCustomFieldChange' => SetDeliveryCustomFieldChangeModel::class, + 'SetDeliveryCustomTypeChange' => SetDeliveryCustomTypeChangeModel::class, 'SetDeliveryItemsChange' => SetDeliveryItemsChangeModel::class, 'SetDescriptionChange' => SetDescriptionChangeModel::class, + 'SetDiscountOnTotalPriceChange' => SetDiscountOnTotalPriceChangeModel::class, 'SetDiscountedPriceChange' => SetDiscountedPriceChangeModel::class, 'SetDistributionChannelsChange' => SetDistributionChannelsChangeModel::class, 'SetExpectedDeliveryChange' => SetExpectedDeliveryChangeModel::class, @@ -226,9 +253,13 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetFirstNameChange' => SetFirstNameChangeModel::class, 'SetGeoLocationChange' => SetGeoLocationChangeModel::class, 'SetImageLabelChange' => SetImageLabelChangeModel::class, + 'SetInheritedAssociatesChange' => SetInheritedAssociatesChangeModel::class, + 'SetInheritedStoresChange' => SetInheritedStoresChangeModel::class, 'SetInputTipChange' => SetInputTipChangeModel::class, 'SetInterfaceIdChange' => SetInterfaceIdChangeModel::class, 'SetIsValidChange' => SetIsValidChangeModel::class, + 'SetItemShippingAddressCustomFieldChange' => SetItemShippingAddressCustomFieldChangeModel::class, + 'SetItemShippingAddressCustomTypeChange' => SetItemShippingAddressCustomTypeChangeModel::class, 'SetKeyChange' => SetKeyChangeModel::class, 'SetLanguagesChange' => SetLanguagesChangeModel::class, 'SetLastNameChange' => SetLastNameChangeModel::class, @@ -249,6 +280,7 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetLocalizedNameChange' => SetLocalizedNameChangeModel::class, 'SetMaxApplicationsChange' => SetMaxApplicationsChangeModel::class, 'SetMaxApplicationsPerCustomerChange' => SetMaxApplicationsPerCustomerChangeModel::class, + 'SetMaxCartQuantityChange' => SetMaxCartQuantityChangeModel::class, 'SetMetaDescriptionChange' => SetMetaDescriptionChangeModel::class, 'SetMetaKeywordsChange' => SetMetaKeywordsChangeModel::class, 'SetMetaTitleChange' => SetMetaTitleChangeModel::class, @@ -256,6 +288,7 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetMethodInfoMethodChange' => SetMethodInfoMethodChangeModel::class, 'SetMethodInfoNameChange' => SetMethodInfoNameChangeModel::class, 'SetMiddleNameChange' => SetMiddleNameChangeModel::class, + 'SetMinCartQuantityChange' => SetMinCartQuantityChangeModel::class, 'SetNameChange' => SetNameChangeModel::class, 'SetOrderLineItemCustomFieldChange' => SetOrderLineItemCustomFieldChangeModel::class, 'SetOrderLineItemCustomTypeChange' => SetOrderLineItemCustomTypeChangeModel::class, @@ -263,11 +296,17 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetOrderTaxedPriceChange' => SetOrderTaxedPriceChangeModel::class, 'SetOrderTotalPriceChange' => SetOrderTotalPriceChangeModel::class, 'SetOrderTotalTaxChange' => SetOrderTotalTaxChangeModel::class, + 'SetParcelCustomFieldChange' => SetParcelCustomFieldChangeModel::class, + 'SetParcelCustomTypeChange' => SetParcelCustomTypeChangeModel::class, 'SetParcelItemsChange' => SetParcelItemsChangeModel::class, 'SetParcelMeasurementsChange' => SetParcelMeasurementsChangeModel::class, 'SetParcelTrackingDataChange' => SetParcelTrackingDataChangeModel::class, + 'SetPasswordChange' => SetPasswordChangeModel::class, 'SetPermissionsChange' => SetPermissionsChangeModel::class, + 'SetPriceKeyChange' => SetPriceKeyChangeModel::class, + 'SetPriceModeChange' => SetPriceModeChangeModel::class, 'SetPricesChange' => SetPricesChangeModel::class, + 'SetProductAttributeChange' => SetProductAttributeChangeModel::class, 'SetProductCountChange' => SetProductCountChangeModel::class, 'SetProductPriceCustomFieldChange' => SetProductPriceCustomFieldChangeModel::class, 'SetProductPriceCustomTypeChange' => SetProductPriceCustomTypeChangeModel::class, @@ -278,12 +317,21 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetRatingChange' => SetRatingChangeModel::class, 'SetReservationsChange' => SetReservationsChangeModel::class, 'SetRestockableInDaysChange' => SetRestockableInDaysChangeModel::class, + 'SetReturnInfoChange' => SetReturnInfoChangeModel::class, + 'SetReturnItemCustomLineItemCustomFieldChange' => SetReturnItemCustomLineItemCustomFieldChangeModel::class, + 'SetReturnItemCustomLineItemCustomTypeChange' => SetReturnItemCustomLineItemCustomTypeChangeModel::class, + 'SetReturnItemLineItemCustomFieldChange' => SetReturnItemLineItemCustomFieldChangeModel::class, + 'SetReturnItemLineItemCustomTypeChange' => SetReturnItemLineItemCustomTypeChangeModel::class, 'SetReturnPaymentStateChange' => SetReturnPaymentStateChangeModel::class, 'SetReturnShipmentStateChange' => SetReturnShipmentStateChangeModel::class, 'SetSalutationChange' => SetSalutationChangeModel::class, 'SetSearchKeywordsChange' => SetSearchKeywordsChangeModel::class, 'SetSellerCommentChange' => SetSellerCommentChangeModel::class, 'SetShippingAddressChange' => SetShippingAddressChangeModel::class, + 'SetShippingAddressCustomFieldChange' => SetShippingAddressCustomFieldChangeModel::class, + 'SetShippingAddressCustomTypeChange' => SetShippingAddressCustomTypeChangeModel::class, + 'SetShippingCustomFieldChange' => SetShippingCustomFieldChangeModel::class, + 'SetShippingCustomTypeChange' => SetShippingCustomTypeChangeModel::class, 'SetShippingInfoPriceChange' => SetShippingInfoPriceChangeModel::class, 'SetShippingInfoTaxedPriceChange' => SetShippingInfoTaxedPriceChangeModel::class, 'SetShippingMethodChange' => SetShippingMethodChangeModel::class, @@ -310,13 +358,17 @@ final class ChangeModel extends JsonObjectModel implements Change 'SetTextLineItemCustomTypeChange' => SetTextLineItemCustomTypeChangeModel::class, 'SetTextLineItemDescriptionChange' => SetTextLineItemDescriptionChangeModel::class, 'SetTitleChange' => SetTitleChangeModel::class, + 'SetTransactionCustomFieldChange' => SetTransactionCustomFieldChangeModel::class, + 'SetTransactionCustomTypeChange' => SetTransactionCustomTypeChangeModel::class, 'SetTransitionsChange' => SetTransitionsChangeModel::class, + 'SetUnitTypeChange' => SetUnitTypeChangeModel::class, 'SetValidFromAndUntilChange' => SetValidFromAndUntilChangeModel::class, 'SetValidFromChange' => SetValidFromChangeModel::class, 'SetValidToChange' => SetValidToChangeModel::class, 'SetValidUntilChange' => SetValidUntilChangeModel::class, 'SetValueChange' => SetValueChangeModel::class, 'SetVariantAvailabilityChange' => SetVariantAvailabilityChangeModel::class, + 'SetVariantExclusionChange' => SetVariantExclusionChangeModel::class, 'SetVariantSelectionChange' => SetVariantSelectionChangeModel::class, 'SetVatIdChange' => SetVatIdChangeModel::class, 'TransitionCustomLineItemStateChange' => TransitionCustomLineItemStateChangeModel::class, @@ -324,6 +376,7 @@ final class ChangeModel extends JsonObjectModel implements Change 'TransitionStateChange' => TransitionStateChangeModel::class, 'UnknownChange' => UnknownChangeModel::class, 'UnpublishChange' => UnpublishChangeModel::class, + 'UpdateItemShippingAddressChange' => UpdateItemShippingAddressChangeModel::class, 'UpdateSyncInfoChange' => UpdateSyncInfoChangeModel::class, 'VerifyEmailChange' => VerifyEmailChangeModel::class, ]; diff --git a/lib/commercetools-history/src/Models/Change/ChangeParentChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeParentChangeModel.php index 23d35d63be9..cfbd205e7ad 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeParentChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeParentChangeModel.php @@ -113,8 +113,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -134,8 +134,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/ChangeParentUnitChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeParentUnitChangeModel.php index 178d669f344..c94e08979bb 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeParentUnitChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeParentUnitChangeModel.php @@ -113,8 +113,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = KeyReferenceModel::of($data); + $className = KeyReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -134,8 +134,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = KeyReferenceModel::of($data); + $className = KeyReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChange.php b/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChange.php index 3df4a56cb8c..f9aba37ec52 100644 --- a/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\ChangeValue\EnumValueCollection; +use Commercetools\History\Models\Common\AttributePlainEnumValueCollection; interface ChangePlainEnumValueOrderChange extends Change { @@ -35,7 +35,7 @@ public function getChange(); *

                            Value before the change.

                            * - * @return null|EnumValueCollection + * @return null|AttributePlainEnumValueCollection */ public function getPreviousValue(); @@ -43,7 +43,7 @@ public function getPreviousValue(); *

                            Value after the change.

                            * - * @return null|EnumValueCollection + * @return null|AttributePlainEnumValueCollection */ public function getNextValue(); @@ -61,14 +61,14 @@ public function getAttributeName(); public function setChange(?string $change): void; /** - * @param ?EnumValueCollection $previousValue + * @param ?AttributePlainEnumValueCollection $previousValue */ - public function setPreviousValue(?EnumValueCollection $previousValue): void; + public function setPreviousValue(?AttributePlainEnumValueCollection $previousValue): void; /** - * @param ?EnumValueCollection $nextValue + * @param ?AttributePlainEnumValueCollection $nextValue */ - public function setNextValue(?EnumValueCollection $nextValue): void; + public function setNextValue(?AttributePlainEnumValueCollection $nextValue): void; /** * @param ?string $attributeName diff --git a/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChangeBuilder.php index 927cd4bd555..4db0d7b3b85 100644 --- a/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChangeBuilder.php @@ -14,7 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\EnumValueCollection; +use Commercetools\History\Models\Common\AttributePlainEnumValueCollection; /** * @implements Builder @@ -29,13 +29,13 @@ final class ChangePlainEnumValueOrderChangeBuilder implements Builder /** - * @var ?EnumValueCollection + * @var ?AttributePlainEnumValueCollection */ private $previousValue; /** - * @var ?EnumValueCollection + * @var ?AttributePlainEnumValueCollection */ private $nextValue; @@ -58,7 +58,7 @@ public function getChange() *

                            Value before the change.

                            * - * @return null|EnumValueCollection + * @return null|AttributePlainEnumValueCollection */ public function getPreviousValue() { @@ -69,7 +69,7 @@ public function getPreviousValue() *

                            Value after the change.

                            * - * @return null|EnumValueCollection + * @return null|AttributePlainEnumValueCollection */ public function getNextValue() { @@ -99,10 +99,10 @@ public function withChange(?string $change) } /** - * @param ?EnumValueCollection $previousValue + * @param ?AttributePlainEnumValueCollection $previousValue * @return $this */ - public function withPreviousValue(?EnumValueCollection $previousValue) + public function withPreviousValue(?AttributePlainEnumValueCollection $previousValue) { $this->previousValue = $previousValue; @@ -110,10 +110,10 @@ public function withPreviousValue(?EnumValueCollection $previousValue) } /** - * @param ?EnumValueCollection $nextValue + * @param ?AttributePlainEnumValueCollection $nextValue * @return $this */ - public function withNextValue(?EnumValueCollection $nextValue) + public function withNextValue(?AttributePlainEnumValueCollection $nextValue) { $this->nextValue = $nextValue; diff --git a/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChangeModel.php index 350de4ac9bd..b156dc7f628 100644 --- a/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangePlainEnumValueOrderChangeModel.php @@ -13,7 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\EnumValueCollection; +use Commercetools\History\Models\Common\AttributePlainEnumValueCollection; /** * @internal @@ -36,13 +36,13 @@ final class ChangePlainEnumValueOrderChangeModel extends JsonObjectModel impleme /** * - * @var ?EnumValueCollection + * @var ?AttributePlainEnumValueCollection */ protected $previousValue; /** * - * @var ?EnumValueCollection + * @var ?AttributePlainEnumValueCollection */ protected $nextValue; @@ -58,8 +58,8 @@ final class ChangePlainEnumValueOrderChangeModel extends JsonObjectModel impleme */ public function __construct( ?string $change = null, - ?EnumValueCollection $previousValue = null, - ?EnumValueCollection $nextValue = null, + ?AttributePlainEnumValueCollection $previousValue = null, + ?AttributePlainEnumValueCollection $nextValue = null, ?string $attributeName = null, ?string $type = null ) { @@ -110,7 +110,7 @@ public function getChange() *

                            Value before the change.

                            * * - * @return null|EnumValueCollection + * @return null|AttributePlainEnumValueCollection */ public function getPreviousValue() { @@ -120,7 +120,7 @@ public function getPreviousValue() if (is_null($data)) { return null; } - $this->previousValue = EnumValueCollection::fromArray($data); + $this->previousValue = AttributePlainEnumValueCollection::fromArray($data); } return $this->previousValue; @@ -130,7 +130,7 @@ public function getPreviousValue() *

                            Value after the change.

                            * * - * @return null|EnumValueCollection + * @return null|AttributePlainEnumValueCollection */ public function getNextValue() { @@ -140,7 +140,7 @@ public function getNextValue() if (is_null($data)) { return null; } - $this->nextValue = EnumValueCollection::fromArray($data); + $this->nextValue = AttributePlainEnumValueCollection::fromArray($data); } return $this->nextValue; @@ -176,17 +176,17 @@ public function setChange(?string $change): void } /** - * @param ?EnumValueCollection $previousValue + * @param ?AttributePlainEnumValueCollection $previousValue */ - public function setPreviousValue(?EnumValueCollection $previousValue): void + public function setPreviousValue(?AttributePlainEnumValueCollection $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?EnumValueCollection $nextValue + * @param ?AttributePlainEnumValueCollection $nextValue */ - public function setNextValue(?EnumValueCollection $nextValue): void + public function setNextValue(?AttributePlainEnumValueCollection $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/ChangePriceChange.php b/lib/commercetools-history/src/Models/Change/ChangePriceChange.php index 30119f5272b..bb586aad801 100644 --- a/lib/commercetools-history/src/Models/Change/ChangePriceChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangePriceChange.php @@ -19,6 +19,7 @@ interface ChangePriceChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; public const FIELD_PRICE_ID = 'priceId'; + public const FIELD_VARIANT = 'variant'; /** @@ -49,6 +50,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                            Product data that was updated.

                            *
                              *
                            • staged, if the staged ProductCatalogData was updated.
                            • *
                            • current, if the current ProductCatalogData was updated.
                            • @@ -67,6 +69,15 @@ public function getCatalogData(); */ public function getPriceId(); + /** + *

                              Identifier of the updated Product Variant.

                              + *

                              This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                              + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -91,4 +102,9 @@ public function setCatalogData(?string $catalogData): void; * @param ?string $priceId */ public function setPriceId(?string $priceId): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/ChangePriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangePriceChangeBuilder.php index 3c564997615..d387f290fe7 100644 --- a/lib/commercetools-history/src/Models/Change/ChangePriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangePriceChangeBuilder.php @@ -52,6 +52,12 @@ final class ChangePriceChangeBuilder implements Builder */ private $priceId; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -84,6 +90,7 @@ public function getNextValue() } /** + *

                              Product data that was updated.

                              *
                                *
                              • staged, if the staged ProductCatalogData was updated.
                              • *
                              • current, if the current ProductCatalogData was updated.
                              • @@ -108,6 +115,18 @@ public function getPriceId() return $this->priceId; } + /** + *

                                Identifier of the updated Product Variant.

                                + *

                                This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -163,6 +182,17 @@ public function withPriceId(?string $priceId) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -192,7 +222,8 @@ public function build(): ChangePriceChange $this->previousValue instanceof PriceBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof PriceBuilder ? $this->nextValue->build() : $this->nextValue, $this->catalogData, - $this->priceId + $this->priceId, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/ChangePriceChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangePriceChangeModel.php index 0d10bf681bf..fda164ccbe5 100644 --- a/lib/commercetools-history/src/Models/Change/ChangePriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangePriceChangeModel.php @@ -59,6 +59,12 @@ final class ChangePriceChangeModel extends JsonObjectModel implements ChangePric */ protected $priceId; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -69,6 +75,7 @@ public function __construct( ?Price $nextValue = null, ?string $catalogData = null, ?string $priceId = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; @@ -76,6 +83,7 @@ public function __construct( $this->nextValue = $nextValue; $this->catalogData = $catalogData; $this->priceId = $priceId; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -158,6 +166,7 @@ public function getNextValue() } /** + *

                                Product data that was updated.

                                *
                                  *
                                • staged, if the staged ProductCatalogData was updated.
                                • *
                                • current, if the current ProductCatalogData was updated.
                                • @@ -200,6 +209,27 @@ public function getPriceId() return $this->priceId; } + /** + *

                                  Identifier of the updated Product Variant.

                                  + *

                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                  + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -241,6 +271,14 @@ public function setPriceId(?string $priceId): void $this->priceId = $priceId; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChange.php b/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChange.php new file mode 100644 index 00000000000..542f5d69e04 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChange.php @@ -0,0 +1,62 @@ +Value before the change.

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

                                  Value after the change.

                                  + * + + * @return null|string + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void; + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChangeBuilder.php new file mode 100644 index 00000000000..d1d4f0827e5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChangeBuilder.php @@ -0,0 +1,119 @@ + + */ +final class ChangePriceRoundingModeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $previousValue; + + /** + + * @var ?string + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                  Value before the change.

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

                                  Value after the change.

                                  + * + + * @return null|string + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $previousValue + * @return $this + */ + public function withPreviousValue(?string $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?string $nextValue + * @return $this + */ + public function withNextValue(?string $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): ChangePriceRoundingModeChange + { + return new ChangePriceRoundingModeChangeModel( + $this->change, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): ChangePriceRoundingModeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChangeCollection.php b/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChangeCollection.php new file mode 100644 index 00000000000..9d498250474 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ChangePriceRoundingModeChange current() + * @method ChangePriceRoundingModeChange end() + * @method ChangePriceRoundingModeChange at($offset) + */ +class ChangePriceRoundingModeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ChangePriceRoundingModeChange $value + * @psalm-param ChangePriceRoundingModeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ChangePriceRoundingModeChangeCollection + */ + public function add($value) + { + if (!$value instanceof ChangePriceRoundingModeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ChangePriceRoundingModeChange + */ + protected function mapper() + { + return function (?int $index): ?ChangePriceRoundingModeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ChangePriceRoundingModeChange $data */ + $data = ChangePriceRoundingModeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChangeModel.php new file mode 100644 index 00000000000..96bf2082461 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangePriceRoundingModeChangeModel.php @@ -0,0 +1,167 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                  Value before the change.

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

                                  Value after the change.

                                  + * + * + * @return null|string + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (string) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeProductSelectionActiveChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeProductSelectionActiveChangeModel.php index 413100efc03..d7dabdac16c 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeProductSelectionActiveChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeProductSelectionActiveChangeModel.php @@ -121,8 +121,8 @@ public function getProductSelection() if (is_null($data)) { return null; } - - $this->productSelection = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->productSelection = $className::of($data); } return $this->productSelection; diff --git a/lib/commercetools-history/src/Models/Change/ChangeSlugChange.php b/lib/commercetools-history/src/Models/Change/ChangeSlugChange.php index 0e1a4f0e75b..ef750ce32b3 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeSlugChange.php +++ b/lib/commercetools-history/src/Models/Change/ChangeSlugChange.php @@ -17,6 +17,7 @@ interface ChangeSlugChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_CATALOG_DATA = 'catalogData'; /** @@ -46,6 +47,18 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                  Product data that was updated.

                                  + * + * + + * @return null|string + */ + public function getCatalogData(); + /** * @param ?string $change */ @@ -60,4 +73,9 @@ public function setPreviousValue(?LocalizedString $previousValue): void; * @param ?LocalizedString $nextValue */ public function setNextValue(?LocalizedString $nextValue): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; } diff --git a/lib/commercetools-history/src/Models/Change/ChangeSlugChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeSlugChangeBuilder.php index 48e2a7b90b5..e855ecb656c 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeSlugChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/ChangeSlugChangeBuilder.php @@ -40,6 +40,12 @@ final class ChangeSlugChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?string + */ + private $catalogData; + /** * @return null|string @@ -71,6 +77,21 @@ public function getNextValue() return $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue; } + /** + *

                                  Product data that was updated.

                                  + * + * + + * @return null|string + */ + public function getCatalogData() + { + return $this->catalogData; + } + /** * @param ?string $change * @return $this @@ -104,6 +125,17 @@ public function withNextValue(?LocalizedString $nextValue) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -131,7 +163,8 @@ public function build(): ChangeSlugChange return new ChangeSlugChangeModel( $this->change, $this->previousValue instanceof LocalizedStringBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue + $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue, + $this->catalogData ); } diff --git a/lib/commercetools-history/src/Models/Change/ChangeSlugChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeSlugChangeModel.php index d4c67a01e5f..acee83cb781 100644 --- a/lib/commercetools-history/src/Models/Change/ChangeSlugChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/ChangeSlugChangeModel.php @@ -47,6 +47,12 @@ final class ChangeSlugChangeModel extends JsonObjectModel implements ChangeSlugC */ protected $nextValue; + /** + * + * @var ?string + */ + protected $catalogData; + /** * @psalm-suppress MissingParamType @@ -55,11 +61,13 @@ public function __construct( ?string $change = null, ?LocalizedString $previousValue = null, ?LocalizedString $nextValue = null, + ?string $catalogData = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->catalogData = $catalogData; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -141,6 +149,30 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                  Product data that was updated.

                                  + * + * + * + * @return null|string + */ + public function getCatalogData() + { + if (is_null($this->catalogData)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CATALOG_DATA); + if (is_null($data)) { + return null; + } + $this->catalogData = (string) $data; + } + + return $this->catalogData; + } + /** * @param ?string $change @@ -166,6 +198,14 @@ public function setNextValue(?LocalizedString $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + } diff --git a/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChange.php b/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChange.php new file mode 100644 index 00000000000..1a8ee38ee85 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChange.php @@ -0,0 +1,63 @@ +Value before the change.

                                  + * + + * @return null|KeyReference + */ + public function getPreviousValue(); + + /** + *

                                  Value after the change.

                                  + * + + * @return null|KeyReference + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?KeyReference $previousValue + */ + public function setPreviousValue(?KeyReference $previousValue): void; + + /** + * @param ?KeyReference $nextValue + */ + public function setNextValue(?KeyReference $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChangeBuilder.php new file mode 100644 index 00000000000..c543b12cfe9 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChangeBuilder.php @@ -0,0 +1,142 @@ + + */ +final class ChangeTopLevelUnitChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|KeyReference|KeyReferenceBuilder + */ + private $previousValue; + + /** + + * @var null|KeyReference|KeyReferenceBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                  Value before the change.

                                  + * + + * @return null|KeyReference + */ + public function getPreviousValue() + { + return $this->previousValue instanceof KeyReferenceBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                  Value after the change.

                                  + * + + * @return null|KeyReference + */ + public function getNextValue() + { + return $this->nextValue instanceof KeyReferenceBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?KeyReference $previousValue + * @return $this + */ + public function withPreviousValue(?KeyReference $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?KeyReference $nextValue + * @return $this + */ + public function withNextValue(?KeyReference $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?KeyReferenceBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?KeyReferenceBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): ChangeTopLevelUnitChange + { + return new ChangeTopLevelUnitChangeModel( + $this->change, + $this->previousValue instanceof KeyReferenceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof KeyReferenceBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): ChangeTopLevelUnitChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChangeCollection.php b/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChangeCollection.php new file mode 100644 index 00000000000..49401824252 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ChangeTopLevelUnitChange current() + * @method ChangeTopLevelUnitChange end() + * @method ChangeTopLevelUnitChange at($offset) + */ +class ChangeTopLevelUnitChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ChangeTopLevelUnitChange $value + * @psalm-param ChangeTopLevelUnitChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ChangeTopLevelUnitChangeCollection + */ + public function add($value) + { + if (!$value instanceof ChangeTopLevelUnitChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ChangeTopLevelUnitChange + */ + protected function mapper() + { + return function (?int $index): ?ChangeTopLevelUnitChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ChangeTopLevelUnitChange $data */ + $data = ChangeTopLevelUnitChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChangeModel.php b/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChangeModel.php new file mode 100644 index 00000000000..18f15ab75f6 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ChangeTopLevelUnitChangeModel.php @@ -0,0 +1,171 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                  Value before the change.

                                  + * + * + * @return null|KeyReference + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $className = KeyReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); + } + + return $this->previousValue; + } + + /** + *

                                  Value after the change.

                                  + * + * + * @return null|KeyReference + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $className = KeyReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?KeyReference $previousValue + */ + public function setPreviousValue(?KeyReference $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?KeyReference $nextValue + */ + public function setNextValue(?KeyReference $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/ExcludeProductChange.php b/lib/commercetools-history/src/Models/Change/ExcludeProductChange.php new file mode 100644 index 00000000000..4835683e033 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ExcludeProductChange.php @@ -0,0 +1,64 @@ +Only Product Variants with the explicitly listed SKUs are part of a Product Selection with IndividualExclusion ProductSelectionMode.

                                  + * + + * @return null|ProductVariantExclusion + */ + public function getVariantExclusion(); + + /** + *

                                  Value after the change.

                                  + * + + * @return null|Reference + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?ProductVariantExclusion $variantExclusion + */ + public function setVariantExclusion(?ProductVariantExclusion $variantExclusion): void; + + /** + * @param ?Reference $nextValue + */ + public function setNextValue(?Reference $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ExcludeProductChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ExcludeProductChangeBuilder.php new file mode 100644 index 00000000000..30f11a22034 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ExcludeProductChangeBuilder.php @@ -0,0 +1,144 @@ + + */ +final class ExcludeProductChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|ProductVariantExclusion|ProductVariantExclusionBuilder + */ + private $variantExclusion; + + /** + + * @var null|Reference|ReferenceBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                  Only Product Variants with the explicitly listed SKUs are part of a Product Selection with IndividualExclusion ProductSelectionMode.

                                  + * + + * @return null|ProductVariantExclusion + */ + public function getVariantExclusion() + { + return $this->variantExclusion instanceof ProductVariantExclusionBuilder ? $this->variantExclusion->build() : $this->variantExclusion; + } + + /** + *

                                  Value after the change.

                                  + * + + * @return null|Reference + */ + public function getNextValue() + { + return $this->nextValue instanceof ReferenceBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?ProductVariantExclusion $variantExclusion + * @return $this + */ + public function withVariantExclusion(?ProductVariantExclusion $variantExclusion) + { + $this->variantExclusion = $variantExclusion; + + return $this; + } + + /** + * @param ?Reference $nextValue + * @return $this + */ + public function withNextValue(?Reference $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withVariantExclusion() instead + * @return $this + */ + public function withVariantExclusionBuilder(?ProductVariantExclusionBuilder $variantExclusion) + { + $this->variantExclusion = $variantExclusion; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?ReferenceBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): ExcludeProductChange + { + return new ExcludeProductChangeModel( + $this->change, + $this->variantExclusion instanceof ProductVariantExclusionBuilder ? $this->variantExclusion->build() : $this->variantExclusion, + $this->nextValue instanceof ReferenceBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): ExcludeProductChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ExcludeProductChangeCollection.php b/lib/commercetools-history/src/Models/Change/ExcludeProductChangeCollection.php new file mode 100644 index 00000000000..02867e105e9 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ExcludeProductChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ExcludeProductChange current() + * @method ExcludeProductChange end() + * @method ExcludeProductChange at($offset) + */ +class ExcludeProductChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ExcludeProductChange $value + * @psalm-param ExcludeProductChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ExcludeProductChangeCollection + */ + public function add($value) + { + if (!$value instanceof ExcludeProductChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ExcludeProductChange + */ + protected function mapper() + { + return function (?int $index): ?ExcludeProductChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ExcludeProductChange $data */ + $data = ExcludeProductChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ExcludeProductChangeModel.php b/lib/commercetools-history/src/Models/Change/ExcludeProductChangeModel.php new file mode 100644 index 00000000000..7da0c82d36b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ExcludeProductChangeModel.php @@ -0,0 +1,173 @@ +change = $change; + $this->variantExclusion = $variantExclusion; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                  Only Product Variants with the explicitly listed SKUs are part of a Product Selection with IndividualExclusion ProductSelectionMode.

                                  + * + * + * @return null|ProductVariantExclusion + */ + public function getVariantExclusion() + { + if (is_null($this->variantExclusion)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_VARIANT_EXCLUSION); + if (is_null($data)) { + return null; + } + + $this->variantExclusion = ProductVariantExclusionModel::of($data); + } + + return $this->variantExclusion; + } + + /** + *

                                  Value after the change.

                                  + * + * + * @return null|Reference + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?ProductVariantExclusion $variantExclusion + */ + public function setVariantExclusion(?ProductVariantExclusion $variantExclusion): void + { + $this->variantExclusion = $variantExclusion; + } + + /** + * @param ?Reference $nextValue + */ + public function setNextValue(?Reference $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/MoveImageToPositionChange.php b/lib/commercetools-history/src/Models/Change/MoveImageToPositionChange.php index 97d5db2013c..76def2b7773 100644 --- a/lib/commercetools-history/src/Models/Change/MoveImageToPositionChange.php +++ b/lib/commercetools-history/src/Models/Change/MoveImageToPositionChange.php @@ -18,6 +18,7 @@ interface MoveImageToPositionChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -48,6 +49,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                  Product data that was updated.

                                  *
                                    *
                                  • staged, if the staged ProductCatalogData was updated.
                                  • *
                                  • current, if the current ProductCatalogData was updated.
                                  • @@ -58,6 +60,15 @@ public function getNextValue(); */ public function getCatalogData(); + /** + *

                                    Identifier of the updated Product Variant.

                                    + *

                                    This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                    + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -77,4 +88,9 @@ public function setNextValue(?ImageCollection $nextValue): void; * @param ?string $catalogData */ public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/MoveImageToPositionChangeBuilder.php b/lib/commercetools-history/src/Models/Change/MoveImageToPositionChangeBuilder.php index 5617211b0d6..d4a2f7098a5 100644 --- a/lib/commercetools-history/src/Models/Change/MoveImageToPositionChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/MoveImageToPositionChangeBuilder.php @@ -45,6 +45,12 @@ final class MoveImageToPositionChangeBuilder implements Builder */ private $catalogData; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -77,6 +83,7 @@ public function getNextValue() } /** + *

                                    Product data that was updated.

                                    *
                                      *
                                    • staged, if the staged ProductCatalogData was updated.
                                    • *
                                    • current, if the current ProductCatalogData was updated.
                                    • @@ -90,6 +97,18 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                      Identifier of the updated Product Variant.

                                      + *

                                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                      + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -134,6 +153,17 @@ public function withCatalogData(?string $catalogData) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + public function build(): MoveImageToPositionChange { @@ -141,7 +171,8 @@ public function build(): MoveImageToPositionChange $this->change, $this->previousValue, $this->nextValue, - $this->catalogData + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/MoveImageToPositionChangeModel.php b/lib/commercetools-history/src/Models/Change/MoveImageToPositionChangeModel.php index 6aa980528cd..cd28e3482e4 100644 --- a/lib/commercetools-history/src/Models/Change/MoveImageToPositionChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/MoveImageToPositionChangeModel.php @@ -52,6 +52,12 @@ final class MoveImageToPositionChangeModel extends JsonObjectModel implements Mo */ protected $catalogData; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -61,12 +67,14 @@ public function __construct( ?ImageCollection $previousValue = null, ?ImageCollection $nextValue = null, ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -147,6 +155,7 @@ public function getNextValue() } /** + *

                                      Product data that was updated.

                                      *
                                        *
                                      • staged, if the staged ProductCatalogData was updated.
                                      • *
                                      • current, if the current ProductCatalogData was updated.
                                      • @@ -169,6 +178,27 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                        Identifier of the updated Product Variant.

                                        + *

                                        This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                        + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -202,6 +232,14 @@ public function setCatalogData(?string $catalogData): void $this->catalogData = $catalogData; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/RemoveAssetChange.php b/lib/commercetools-history/src/Models/Change/RemoveAssetChange.php index 504b5100dd7..72794236a8f 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveAssetChange.php +++ b/lib/commercetools-history/src/Models/Change/RemoveAssetChange.php @@ -16,6 +16,8 @@ interface RemoveAssetChange extends Change { public const FIELD_PREVIOUS_VALUE = 'previousValue'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -37,6 +39,27 @@ public function getType(); */ public function getPreviousValue(); + /** + *

                                        Product data that was updated.

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

                                        Identifier of the updated Product Variant.

                                        + *

                                        This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                        + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -46,4 +69,14 @@ public function setChange(?string $change): void; * @param ?Asset $previousValue */ public function setPreviousValue(?Asset $previousValue): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/RemoveAssetChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemoveAssetChangeBuilder.php index 0342b714909..2af5fa27975 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveAssetChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/RemoveAssetChangeBuilder.php @@ -34,6 +34,18 @@ final class RemoveAssetChangeBuilder implements Builder */ private $previousValue; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -54,6 +66,33 @@ public function getPreviousValue() return $this->previousValue instanceof AssetBuilder ? $this->previousValue->build() : $this->previousValue; } + /** + *

                                        Product data that was updated.

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

                                        Identifier of the updated Product Variant.

                                        + *

                                        This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                        + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -76,6 +115,28 @@ public function withPreviousValue(?Asset $previousValue) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -91,7 +152,9 @@ public function build(): RemoveAssetChange { return new RemoveAssetChangeModel( $this->change, - $this->previousValue instanceof AssetBuilder ? $this->previousValue->build() : $this->previousValue + $this->previousValue instanceof AssetBuilder ? $this->previousValue->build() : $this->previousValue, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/RemoveAssetChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveAssetChangeModel.php index fadc84b0a2f..f0e7d0389fd 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveAssetChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemoveAssetChangeModel.php @@ -41,6 +41,18 @@ final class RemoveAssetChangeModel extends JsonObjectModel implements RemoveAsse */ protected $previousValue; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -48,10 +60,14 @@ final class RemoveAssetChangeModel extends JsonObjectModel implements RemoveAsse public function __construct( ?string $change = null, ?Asset $previousValue = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -112,6 +128,51 @@ public function getPreviousValue() return $this->previousValue; } + /** + *

                                        Product data that was updated.

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

                                        Identifier of the updated Product Variant.

                                        + *

                                        This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                        + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -129,6 +190,22 @@ public function setPreviousValue(?Asset $previousValue): void $this->previousValue = $previousValue; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChange.php b/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChange.php index 0f210444240..1f840f12965 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChange.php +++ b/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\Common\Delivery; +use Commercetools\History\Models\ChangeValue\DeliveryChangeValue; interface RemoveDeliveryItemsChange extends Change { @@ -33,7 +33,7 @@ public function getChange(); *

                                        Value before the change.

                                        * - * @return null|Delivery + * @return null|DeliveryChangeValue */ public function getPreviousValue(); @@ -43,7 +43,7 @@ public function getPreviousValue(); public function setChange(?string $change): void; /** - * @param ?Delivery $previousValue + * @param ?DeliveryChangeValue $previousValue */ - public function setPreviousValue(?Delivery $previousValue): void; + public function setPreviousValue(?DeliveryChangeValue $previousValue): void; } diff --git a/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChangeBuilder.php index 64d64d8f8a3..efb6e67be27 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\Delivery; -use Commercetools\History\Models\Common\DeliveryBuilder; +use Commercetools\History\Models\ChangeValue\DeliveryChangeValue; +use Commercetools\History\Models\ChangeValue\DeliveryChangeValueBuilder; /** * @implements Builder @@ -30,7 +30,7 @@ final class RemoveDeliveryItemsChangeBuilder implements Builder /** - * @var null|Delivery|DeliveryBuilder + * @var null|DeliveryChangeValue|DeliveryChangeValueBuilder */ private $previousValue; @@ -47,11 +47,11 @@ public function getChange() *

                                        Value before the change.

                                        * - * @return null|Delivery + * @return null|DeliveryChangeValue */ public function getPreviousValue() { - return $this->previousValue instanceof DeliveryBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof DeliveryChangeValueBuilder ? $this->previousValue->build() : $this->previousValue; } /** @@ -66,10 +66,10 @@ public function withChange(?string $change) } /** - * @param ?Delivery $previousValue + * @param ?DeliveryChangeValue $previousValue * @return $this */ - public function withPreviousValue(?Delivery $previousValue) + public function withPreviousValue(?DeliveryChangeValue $previousValue) { $this->previousValue = $previousValue; @@ -80,7 +80,7 @@ public function withPreviousValue(?Delivery $previousValue) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?DeliveryBuilder $previousValue) + public function withPreviousValueBuilder(?DeliveryChangeValueBuilder $previousValue) { $this->previousValue = $previousValue; @@ -91,7 +91,7 @@ public function build(): RemoveDeliveryItemsChange { return new RemoveDeliveryItemsChangeModel( $this->change, - $this->previousValue instanceof DeliveryBuilder ? $this->previousValue->build() : $this->previousValue + $this->previousValue instanceof DeliveryChangeValueBuilder ? $this->previousValue->build() : $this->previousValue ); } diff --git a/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChangeModel.php index 697499bf96c..a684d8ffa2a 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemoveDeliveryItemsChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\Delivery; -use Commercetools\History\Models\Common\DeliveryModel; +use Commercetools\History\Models\ChangeValue\DeliveryChangeValue; +use Commercetools\History\Models\ChangeValue\DeliveryChangeValueModel; /** * @internal @@ -37,7 +37,7 @@ final class RemoveDeliveryItemsChangeModel extends JsonObjectModel implements Re /** * - * @var ?Delivery + * @var ?DeliveryChangeValue */ protected $previousValue; @@ -47,7 +47,7 @@ final class RemoveDeliveryItemsChangeModel extends JsonObjectModel implements Re */ public function __construct( ?string $change = null, - ?Delivery $previousValue = null, + ?DeliveryChangeValue $previousValue = null, ?string $type = null ) { $this->change = $change; @@ -95,7 +95,7 @@ public function getChange() *

                                        Value before the change.

                                        * * - * @return null|Delivery + * @return null|DeliveryChangeValue */ public function getPreviousValue() { @@ -106,7 +106,7 @@ public function getPreviousValue() return null; } - $this->previousValue = DeliveryModel::of($data); + $this->previousValue = DeliveryChangeValueModel::of($data); } return $this->previousValue; @@ -122,9 +122,9 @@ public function setChange(?string $change): void } /** - * @param ?Delivery $previousValue + * @param ?DeliveryChangeValue $previousValue */ - public function setPreviousValue(?Delivery $previousValue): void + public function setPreviousValue(?DeliveryChangeValue $previousValue): void { $this->previousValue = $previousValue; } diff --git a/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChange.php b/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChange.php index 88f1e5178b7..f6b1d774fa7 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChange.php +++ b/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\ChangeValue\EnumValue; +use Commercetools\History\Models\Common\AttributePlainEnumValue; interface RemoveEnumValuesChange extends Change { @@ -34,7 +34,7 @@ public function getChange(); *

                                        Value before the change.

                                        * - * @return null|EnumValue + * @return null|AttributePlainEnumValue */ public function getPreviousValue(); @@ -52,9 +52,9 @@ public function getAttributeName(); public function setChange(?string $change): void; /** - * @param ?EnumValue $previousValue + * @param ?AttributePlainEnumValue $previousValue */ - public function setPreviousValue(?EnumValue $previousValue): void; + public function setPreviousValue(?AttributePlainEnumValue $previousValue): void; /** * @param ?string $attributeName diff --git a/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChangeBuilder.php index c8052f2231d..14abddab4d5 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\EnumValue; -use Commercetools\History\Models\ChangeValue\EnumValueBuilder; +use Commercetools\History\Models\Common\AttributePlainEnumValue; +use Commercetools\History\Models\Common\AttributePlainEnumValueBuilder; /** * @implements Builder @@ -30,7 +30,7 @@ final class RemoveEnumValuesChangeBuilder implements Builder /** - * @var null|EnumValue|EnumValueBuilder + * @var null|AttributePlainEnumValue|AttributePlainEnumValueBuilder */ private $previousValue; @@ -53,11 +53,11 @@ public function getChange() *

                                        Value before the change.

                                        * - * @return null|EnumValue + * @return null|AttributePlainEnumValue */ public function getPreviousValue() { - return $this->previousValue instanceof EnumValueBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof AttributePlainEnumValueBuilder ? $this->previousValue->build() : $this->previousValue; } /** @@ -83,10 +83,10 @@ public function withChange(?string $change) } /** - * @param ?EnumValue $previousValue + * @param ?AttributePlainEnumValue $previousValue * @return $this */ - public function withPreviousValue(?EnumValue $previousValue) + public function withPreviousValue(?AttributePlainEnumValue $previousValue) { $this->previousValue = $previousValue; @@ -108,7 +108,7 @@ public function withAttributeName(?string $attributeName) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?EnumValueBuilder $previousValue) + public function withPreviousValueBuilder(?AttributePlainEnumValueBuilder $previousValue) { $this->previousValue = $previousValue; @@ -119,7 +119,7 @@ public function build(): RemoveEnumValuesChange { return new RemoveEnumValuesChangeModel( $this->change, - $this->previousValue instanceof EnumValueBuilder ? $this->previousValue->build() : $this->previousValue, + $this->previousValue instanceof AttributePlainEnumValueBuilder ? $this->previousValue->build() : $this->previousValue, $this->attributeName ); } diff --git a/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChangeModel.php index 513f96f1088..ef60c4eb080 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemoveEnumValuesChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\EnumValue; -use Commercetools\History\Models\ChangeValue\EnumValueModel; +use Commercetools\History\Models\Common\AttributePlainEnumValue; +use Commercetools\History\Models\Common\AttributePlainEnumValueModel; /** * @internal @@ -37,7 +37,7 @@ final class RemoveEnumValuesChangeModel extends JsonObjectModel implements Remov /** * - * @var ?EnumValue + * @var ?AttributePlainEnumValue */ protected $previousValue; @@ -53,7 +53,7 @@ final class RemoveEnumValuesChangeModel extends JsonObjectModel implements Remov */ public function __construct( ?string $change = null, - ?EnumValue $previousValue = null, + ?AttributePlainEnumValue $previousValue = null, ?string $attributeName = null, ?string $type = null ) { @@ -103,7 +103,7 @@ public function getChange() *

                                        Value before the change.

                                        * * - * @return null|EnumValue + * @return null|AttributePlainEnumValue */ public function getPreviousValue() { @@ -114,7 +114,7 @@ public function getPreviousValue() return null; } - $this->previousValue = EnumValueModel::of($data); + $this->previousValue = AttributePlainEnumValueModel::of($data); } return $this->previousValue; @@ -150,9 +150,9 @@ public function setChange(?string $change): void } /** - * @param ?EnumValue $previousValue + * @param ?AttributePlainEnumValue $previousValue */ - public function setPreviousValue(?EnumValue $previousValue): void + public function setPreviousValue(?AttributePlainEnumValue $previousValue): void { $this->previousValue = $previousValue; } diff --git a/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChange.php b/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChange.php index 23ce2964067..bbb3de9ea43 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChange.php +++ b/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChange.php @@ -19,6 +19,7 @@ interface RemoveFromCategoryChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATEGORY = 'category'; + public const FIELD_CATALOG_DATA = 'catalogData'; /** @@ -56,6 +57,18 @@ public function getNextValue(); */ public function getCategory(); + /** + *

                                        Product data that was updated.

                                        + * + * + + * @return null|string + */ + public function getCatalogData(); + /** * @param ?string $change */ @@ -75,4 +88,9 @@ public function setNextValue(?ReferenceCollection $nextValue): void; * @param ?Reference $category */ public function setCategory(?Reference $category): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; } diff --git a/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChangeBuilder.php index 2cbe201c280..f4330d3bed8 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChangeBuilder.php @@ -47,6 +47,12 @@ final class RemoveFromCategoryChangeBuilder implements Builder */ private $category; + /** + + * @var ?string + */ + private $catalogData; + /** * @return null|string @@ -89,6 +95,21 @@ public function getCategory() return $this->category instanceof ReferenceBuilder ? $this->category->build() : $this->category; } + /** + *

                                        Product data that was updated.

                                        + * + * + + * @return null|string + */ + public function getCatalogData() + { + return $this->catalogData; + } + /** * @param ?string $change * @return $this @@ -133,6 +154,17 @@ public function withCategory(?Reference $category) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + /** * @deprecated use withCategory() instead * @return $this @@ -150,7 +182,8 @@ public function build(): RemoveFromCategoryChange $this->change, $this->previousValue, $this->nextValue, - $this->category instanceof ReferenceBuilder ? $this->category->build() : $this->category + $this->category instanceof ReferenceBuilder ? $this->category->build() : $this->category, + $this->catalogData ); } diff --git a/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChangeModel.php index b79c83f28f3..4061c0a6edb 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemoveFromCategoryChangeModel.php @@ -54,6 +54,12 @@ final class RemoveFromCategoryChangeModel extends JsonObjectModel implements Rem */ protected $category; + /** + * + * @var ?string + */ + protected $catalogData; + /** * @psalm-suppress MissingParamType @@ -63,12 +69,14 @@ public function __construct( ?ReferenceCollection $previousValue = null, ?ReferenceCollection $nextValue = null, ?Reference $category = null, + ?string $catalogData = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->category = $category; + $this->catalogData = $catalogData; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -162,13 +170,37 @@ public function getCategory() if (is_null($data)) { return null; } - - $this->category = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->category = $className::of($data); } return $this->category; } + /** + *

                                        Product data that was updated.

                                        + * + * + * + * @return null|string + */ + public function getCatalogData() + { + if (is_null($this->catalogData)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CATALOG_DATA); + if (is_null($data)) { + return null; + } + $this->catalogData = (string) $data; + } + + return $this->catalogData; + } + /** * @param ?string $change @@ -202,6 +234,14 @@ public function setCategory(?Reference $category): void $this->category = $category; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + } diff --git a/lib/commercetools-history/src/Models/Change/RemoveImageChange.php b/lib/commercetools-history/src/Models/Change/RemoveImageChange.php index 83a0b27f804..6e836c66f39 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveImageChange.php +++ b/lib/commercetools-history/src/Models/Change/RemoveImageChange.php @@ -18,6 +18,7 @@ interface RemoveImageChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -48,6 +49,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                        Product data that was updated.

                                        *
                                          *
                                        • staged, if the staged ProductCatalogData was updated.
                                        • *
                                        • current, if the current ProductCatalogData was updated.
                                        • @@ -58,6 +60,15 @@ public function getNextValue(); */ public function getCatalogData(); + /** + *

                                          Identifier of the updated Product Variant.

                                          + *

                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                          + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -77,4 +88,9 @@ public function setNextValue(?ImageCollection $nextValue): void; * @param ?string $catalogData */ public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/RemoveImageChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemoveImageChangeBuilder.php index c9d56d762fc..9920c123fc1 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveImageChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/RemoveImageChangeBuilder.php @@ -45,6 +45,12 @@ final class RemoveImageChangeBuilder implements Builder */ private $catalogData; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -77,6 +83,7 @@ public function getNextValue() } /** + *

                                          Product data that was updated.

                                          *
                                            *
                                          • staged, if the staged ProductCatalogData was updated.
                                          • *
                                          • current, if the current ProductCatalogData was updated.
                                          • @@ -90,6 +97,18 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                            Identifier of the updated Product Variant.

                                            + *

                                            This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                            + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -134,6 +153,17 @@ public function withCatalogData(?string $catalogData) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + public function build(): RemoveImageChange { @@ -141,7 +171,8 @@ public function build(): RemoveImageChange $this->change, $this->previousValue, $this->nextValue, - $this->catalogData + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/RemoveImageChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveImageChangeModel.php index b77a0ad16a7..ea3c8901558 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveImageChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemoveImageChangeModel.php @@ -52,6 +52,12 @@ final class RemoveImageChangeModel extends JsonObjectModel implements RemoveImag */ protected $catalogData; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -61,12 +67,14 @@ public function __construct( ?ImageCollection $previousValue = null, ?ImageCollection $nextValue = null, ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -147,6 +155,7 @@ public function getNextValue() } /** + *

                                            Product data that was updated.

                                            *
                                              *
                                            • staged, if the staged ProductCatalogData was updated.
                                            • *
                                            • current, if the current ProductCatalogData was updated.
                                            • @@ -169,6 +178,27 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                              Identifier of the updated Product Variant.

                                              + *

                                              This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                              + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -202,6 +232,14 @@ public function setCatalogData(?string $catalogData): void $this->catalogData = $catalogData; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChange.php b/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChange.php index 653c3453842..2bc65bffe86 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChange.php +++ b/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\ChangeValue\LocalizedEnumValue; +use Commercetools\History\Models\Common\AttributeLocalizedEnumValue; interface RemoveLocalizedEnumValuesChange extends Change { @@ -34,7 +34,7 @@ public function getChange(); *

                                              Value before the change.

                                              * - * @return null|LocalizedEnumValue + * @return null|AttributeLocalizedEnumValue */ public function getPreviousValue(); @@ -52,9 +52,9 @@ public function getAttributeName(); public function setChange(?string $change): void; /** - * @param ?LocalizedEnumValue $previousValue + * @param ?AttributeLocalizedEnumValue $previousValue */ - public function setPreviousValue(?LocalizedEnumValue $previousValue): void; + public function setPreviousValue(?AttributeLocalizedEnumValue $previousValue): void; /** * @param ?string $attributeName diff --git a/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChangeBuilder.php index 9c12e71e3b4..efa16fd1e7c 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\LocalizedEnumValue; -use Commercetools\History\Models\ChangeValue\LocalizedEnumValueBuilder; +use Commercetools\History\Models\Common\AttributeLocalizedEnumValue; +use Commercetools\History\Models\Common\AttributeLocalizedEnumValueBuilder; /** * @implements Builder @@ -30,7 +30,7 @@ final class RemoveLocalizedEnumValuesChangeBuilder implements Builder /** - * @var null|LocalizedEnumValue|LocalizedEnumValueBuilder + * @var null|AttributeLocalizedEnumValue|AttributeLocalizedEnumValueBuilder */ private $previousValue; @@ -53,11 +53,11 @@ public function getChange() *

                                              Value before the change.

                                              * - * @return null|LocalizedEnumValue + * @return null|AttributeLocalizedEnumValue */ public function getPreviousValue() { - return $this->previousValue instanceof LocalizedEnumValueBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof AttributeLocalizedEnumValueBuilder ? $this->previousValue->build() : $this->previousValue; } /** @@ -83,10 +83,10 @@ public function withChange(?string $change) } /** - * @param ?LocalizedEnumValue $previousValue + * @param ?AttributeLocalizedEnumValue $previousValue * @return $this */ - public function withPreviousValue(?LocalizedEnumValue $previousValue) + public function withPreviousValue(?AttributeLocalizedEnumValue $previousValue) { $this->previousValue = $previousValue; @@ -108,7 +108,7 @@ public function withAttributeName(?string $attributeName) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?LocalizedEnumValueBuilder $previousValue) + public function withPreviousValueBuilder(?AttributeLocalizedEnumValueBuilder $previousValue) { $this->previousValue = $previousValue; @@ -119,7 +119,7 @@ public function build(): RemoveLocalizedEnumValuesChange { return new RemoveLocalizedEnumValuesChangeModel( $this->change, - $this->previousValue instanceof LocalizedEnumValueBuilder ? $this->previousValue->build() : $this->previousValue, + $this->previousValue instanceof AttributeLocalizedEnumValueBuilder ? $this->previousValue->build() : $this->previousValue, $this->attributeName ); } diff --git a/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChangeModel.php index de05bdff91d..c6148238062 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemoveLocalizedEnumValuesChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\LocalizedEnumValue; -use Commercetools\History\Models\ChangeValue\LocalizedEnumValueModel; +use Commercetools\History\Models\Common\AttributeLocalizedEnumValue; +use Commercetools\History\Models\Common\AttributeLocalizedEnumValueModel; /** * @internal @@ -37,7 +37,7 @@ final class RemoveLocalizedEnumValuesChangeModel extends JsonObjectModel impleme /** * - * @var ?LocalizedEnumValue + * @var ?AttributeLocalizedEnumValue */ protected $previousValue; @@ -53,7 +53,7 @@ final class RemoveLocalizedEnumValuesChangeModel extends JsonObjectModel impleme */ public function __construct( ?string $change = null, - ?LocalizedEnumValue $previousValue = null, + ?AttributeLocalizedEnumValue $previousValue = null, ?string $attributeName = null, ?string $type = null ) { @@ -103,7 +103,7 @@ public function getChange() *

                                              Value before the change.

                                              * * - * @return null|LocalizedEnumValue + * @return null|AttributeLocalizedEnumValue */ public function getPreviousValue() { @@ -114,7 +114,7 @@ public function getPreviousValue() return null; } - $this->previousValue = LocalizedEnumValueModel::of($data); + $this->previousValue = AttributeLocalizedEnumValueModel::of($data); } return $this->previousValue; @@ -150,9 +150,9 @@ public function setChange(?string $change): void } /** - * @param ?LocalizedEnumValue $previousValue + * @param ?AttributeLocalizedEnumValue $previousValue */ - public function setPreviousValue(?LocalizedEnumValue $previousValue): void + public function setPreviousValue(?AttributeLocalizedEnumValue $previousValue): void { $this->previousValue = $previousValue; } diff --git a/lib/commercetools-history/src/Models/Change/RemovePriceChange.php b/lib/commercetools-history/src/Models/Change/RemovePriceChange.php index 883cfa05a4b..025b6023d80 100644 --- a/lib/commercetools-history/src/Models/Change/RemovePriceChange.php +++ b/lib/commercetools-history/src/Models/Change/RemovePriceChange.php @@ -19,6 +19,7 @@ interface RemovePriceChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; public const FIELD_PRICE_ID = 'priceId'; + public const FIELD_VARIANT = 'variant'; /** @@ -49,6 +50,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                              Product data that was updated.

                                              *
                                                *
                                              • staged, if the staged ProductCatalogData was updated.
                                              • *
                                              • current, if the current ProductCatalogData was updated.
                                              • @@ -67,6 +69,15 @@ public function getCatalogData(); */ public function getPriceId(); + /** + *

                                                Identifier of the updated Product Variant.

                                                + *

                                                This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -91,4 +102,9 @@ public function setCatalogData(?string $catalogData): void; * @param ?string $priceId */ public function setPriceId(?string $priceId): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/RemovePriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemovePriceChangeBuilder.php index 6754778291a..0b36d607527 100644 --- a/lib/commercetools-history/src/Models/Change/RemovePriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/RemovePriceChangeBuilder.php @@ -52,6 +52,12 @@ final class RemovePriceChangeBuilder implements Builder */ private $priceId; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -84,6 +90,7 @@ public function getNextValue() } /** + *

                                                Product data that was updated.

                                                *
                                                  *
                                                • staged, if the staged ProductCatalogData was updated.
                                                • *
                                                • current, if the current ProductCatalogData was updated.
                                                • @@ -108,6 +115,18 @@ public function getPriceId() return $this->priceId; } + /** + *

                                                  Identifier of the updated Product Variant.

                                                  + *

                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                  + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -163,6 +182,17 @@ public function withPriceId(?string $priceId) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -192,7 +222,8 @@ public function build(): RemovePriceChange $this->previousValue instanceof PriceBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof PriceBuilder ? $this->nextValue->build() : $this->nextValue, $this->catalogData, - $this->priceId + $this->priceId, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/RemovePriceChangeModel.php b/lib/commercetools-history/src/Models/Change/RemovePriceChangeModel.php index 4248271793f..9335d93a8bb 100644 --- a/lib/commercetools-history/src/Models/Change/RemovePriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemovePriceChangeModel.php @@ -59,6 +59,12 @@ final class RemovePriceChangeModel extends JsonObjectModel implements RemovePric */ protected $priceId; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -69,6 +75,7 @@ public function __construct( ?Price $nextValue = null, ?string $catalogData = null, ?string $priceId = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; @@ -76,6 +83,7 @@ public function __construct( $this->nextValue = $nextValue; $this->catalogData = $catalogData; $this->priceId = $priceId; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -158,6 +166,7 @@ public function getNextValue() } /** + *

                                                  Product data that was updated.

                                                  *
                                                    *
                                                  • staged, if the staged ProductCatalogData was updated.
                                                  • *
                                                  • current, if the current ProductCatalogData was updated.
                                                  • @@ -200,6 +209,27 @@ public function getPriceId() return $this->priceId; } + /** + *

                                                    Identifier of the updated Product Variant.

                                                    + *

                                                    This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                    + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -241,6 +271,14 @@ public function setPriceId(?string $priceId): void $this->priceId = $priceId; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/RemoveProductChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveProductChangeModel.php index c2fa6455d53..6f450795fc0 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveProductChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemoveProductChangeModel.php @@ -105,8 +105,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; diff --git a/lib/commercetools-history/src/Models/Change/RemoveShippingChange.php b/lib/commercetools-history/src/Models/Change/RemoveShippingChange.php new file mode 100644 index 00000000000..5ac9bf061c4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RemoveShippingChange.php @@ -0,0 +1,49 @@ +Value before the change.

                                                    + * + + * @return null|Shipping + */ + public function getPreviousValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?Shipping $previousValue + */ + public function setPreviousValue(?Shipping $previousValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/RemoveShippingChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemoveShippingChangeBuilder.php new file mode 100644 index 00000000000..d91ab305961 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RemoveShippingChangeBuilder.php @@ -0,0 +1,102 @@ + + */ +final class RemoveShippingChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|Shipping|ShippingBuilder + */ + private $previousValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                    Value before the change.

                                                    + * + + * @return null|Shipping + */ + public function getPreviousValue() + { + return $this->previousValue instanceof ShippingBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?Shipping $previousValue + * @return $this + */ + public function withPreviousValue(?Shipping $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?ShippingBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + public function build(): RemoveShippingChange + { + return new RemoveShippingChangeModel( + $this->change, + $this->previousValue instanceof ShippingBuilder ? $this->previousValue->build() : $this->previousValue + ); + } + + public static function of(): RemoveShippingChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/RemoveShippingChangeCollection.php b/lib/commercetools-history/src/Models/Change/RemoveShippingChangeCollection.php new file mode 100644 index 00000000000..062222333dc --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RemoveShippingChangeCollection.php @@ -0,0 +1,56 @@ + + * @method RemoveShippingChange current() + * @method RemoveShippingChange end() + * @method RemoveShippingChange at($offset) + */ +class RemoveShippingChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert RemoveShippingChange $value + * @psalm-param RemoveShippingChange|stdClass $value + * @throws InvalidArgumentException + * + * @return RemoveShippingChangeCollection + */ + public function add($value) + { + if (!$value instanceof RemoveShippingChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RemoveShippingChange + */ + protected function mapper() + { + return function (?int $index): ?RemoveShippingChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RemoveShippingChange $data */ + $data = RemoveShippingChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/RemoveShippingChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveShippingChangeModel.php new file mode 100644 index 00000000000..32f21e58cd6 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RemoveShippingChangeModel.php @@ -0,0 +1,134 @@ +change = $change; + $this->previousValue = $previousValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                    Value before the change.

                                                    + * + * + * @return null|Shipping + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = ShippingModel::of($data); + } + + return $this->previousValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?Shipping $previousValue + */ + public function setPreviousValue(?Shipping $previousValue): void + { + $this->previousValue = $previousValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChange.php b/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChange.php index 245392b9b7a..884c405b7b6 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChange.php +++ b/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\Common\LineItem; +use Commercetools\History\Models\Common\ShoppingListLineItem; interface RemoveShoppingListLineItemChange extends Change { @@ -34,7 +34,7 @@ public function getChange(); *

                                                    Value before the change.

                                                    * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getPreviousValue(); @@ -42,7 +42,7 @@ public function getPreviousValue(); *

                                                    Value after the change.

                                                    * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getNextValue(); @@ -52,12 +52,12 @@ public function getNextValue(); public function setChange(?string $change): void; /** - * @param ?LineItem $previousValue + * @param ?ShoppingListLineItem $previousValue */ - public function setPreviousValue(?LineItem $previousValue): void; + public function setPreviousValue(?ShoppingListLineItem $previousValue): void; /** - * @param ?LineItem $nextValue + * @param ?ShoppingListLineItem $nextValue */ - public function setNextValue(?LineItem $nextValue): void; + public function setNextValue(?ShoppingListLineItem $nextValue): void; } diff --git a/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChangeBuilder.php index 17a5871614a..8fb01389888 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\LineItem; -use Commercetools\History\Models\Common\LineItemBuilder; +use Commercetools\History\Models\Common\ShoppingListLineItem; +use Commercetools\History\Models\Common\ShoppingListLineItemBuilder; /** * @implements Builder @@ -30,13 +30,13 @@ final class RemoveShoppingListLineItemChangeBuilder implements Builder /** - * @var null|LineItem|LineItemBuilder + * @var null|ShoppingListLineItem|ShoppingListLineItemBuilder */ private $previousValue; /** - * @var null|LineItem|LineItemBuilder + * @var null|ShoppingListLineItem|ShoppingListLineItemBuilder */ private $nextValue; @@ -53,22 +53,22 @@ public function getChange() *

                                                    Value before the change.

                                                    * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getPreviousValue() { - return $this->previousValue instanceof LineItemBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof ShoppingListLineItemBuilder ? $this->previousValue->build() : $this->previousValue; } /** *

                                                    Value after the change.

                                                    * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getNextValue() { - return $this->nextValue instanceof LineItemBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof ShoppingListLineItemBuilder ? $this->nextValue->build() : $this->nextValue; } /** @@ -83,10 +83,10 @@ public function withChange(?string $change) } /** - * @param ?LineItem $previousValue + * @param ?ShoppingListLineItem $previousValue * @return $this */ - public function withPreviousValue(?LineItem $previousValue) + public function withPreviousValue(?ShoppingListLineItem $previousValue) { $this->previousValue = $previousValue; @@ -94,10 +94,10 @@ public function withPreviousValue(?LineItem $previousValue) } /** - * @param ?LineItem $nextValue + * @param ?ShoppingListLineItem $nextValue * @return $this */ - public function withNextValue(?LineItem $nextValue) + public function withNextValue(?ShoppingListLineItem $nextValue) { $this->nextValue = $nextValue; @@ -108,7 +108,7 @@ public function withNextValue(?LineItem $nextValue) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?LineItemBuilder $previousValue) + public function withPreviousValueBuilder(?ShoppingListLineItemBuilder $previousValue) { $this->previousValue = $previousValue; @@ -119,7 +119,7 @@ public function withPreviousValueBuilder(?LineItemBuilder $previousValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?LineItemBuilder $nextValue) + public function withNextValueBuilder(?ShoppingListLineItemBuilder $nextValue) { $this->nextValue = $nextValue; @@ -130,8 +130,8 @@ public function build(): RemoveShoppingListLineItemChange { return new RemoveShoppingListLineItemChangeModel( $this->change, - $this->previousValue instanceof LineItemBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof LineItemBuilder ? $this->nextValue->build() : $this->nextValue + $this->previousValue instanceof ShoppingListLineItemBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof ShoppingListLineItemBuilder ? $this->nextValue->build() : $this->nextValue ); } diff --git a/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChangeModel.php index edaef550083..c445d2e526e 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemoveShoppingListLineItemChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\LineItem; -use Commercetools\History\Models\Common\LineItemModel; +use Commercetools\History\Models\Common\ShoppingListLineItem; +use Commercetools\History\Models\Common\ShoppingListLineItemModel; /** * @internal @@ -37,13 +37,13 @@ final class RemoveShoppingListLineItemChangeModel extends JsonObjectModel implem /** * - * @var ?LineItem + * @var ?ShoppingListLineItem */ protected $previousValue; /** * - * @var ?LineItem + * @var ?ShoppingListLineItem */ protected $nextValue; @@ -53,8 +53,8 @@ final class RemoveShoppingListLineItemChangeModel extends JsonObjectModel implem */ public function __construct( ?string $change = null, - ?LineItem $previousValue = null, - ?LineItem $nextValue = null, + ?ShoppingListLineItem $previousValue = null, + ?ShoppingListLineItem $nextValue = null, ?string $type = null ) { $this->change = $change; @@ -103,7 +103,7 @@ public function getChange() *

                                                    Value before the change.

                                                    * * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getPreviousValue() { @@ -114,7 +114,7 @@ public function getPreviousValue() return null; } - $this->previousValue = LineItemModel::of($data); + $this->previousValue = ShoppingListLineItemModel::of($data); } return $this->previousValue; @@ -124,7 +124,7 @@ public function getPreviousValue() *

                                                    Value after the change.

                                                    * * - * @return null|LineItem + * @return null|ShoppingListLineItem */ public function getNextValue() { @@ -135,7 +135,7 @@ public function getNextValue() return null; } - $this->nextValue = LineItemModel::of($data); + $this->nextValue = ShoppingListLineItemModel::of($data); } return $this->nextValue; @@ -151,17 +151,17 @@ public function setChange(?string $change): void } /** - * @param ?LineItem $previousValue + * @param ?ShoppingListLineItem $previousValue */ - public function setPreviousValue(?LineItem $previousValue): void + public function setPreviousValue(?ShoppingListLineItem $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?LineItem $nextValue + * @param ?ShoppingListLineItem $nextValue */ - public function setNextValue(?LineItem $nextValue): void + public function setNextValue(?ShoppingListLineItem $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/RemoveVariantChange.php b/lib/commercetools-history/src/Models/Change/RemoveVariantChange.php index f1d594ffbc2..513210af80f 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveVariantChange.php +++ b/lib/commercetools-history/src/Models/Change/RemoveVariantChange.php @@ -48,6 +48,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                    Product data that was updated.

                                                    *
                                                      *
                                                    • staged, if the staged ProductCatalogData was updated.
                                                    • *
                                                    • current, if the current ProductCatalogData was updated.
                                                    • diff --git a/lib/commercetools-history/src/Models/Change/RemoveVariantChangeBuilder.php b/lib/commercetools-history/src/Models/Change/RemoveVariantChangeBuilder.php index b5ec244ce0f..d06a8c74360 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveVariantChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/RemoveVariantChangeBuilder.php @@ -78,6 +78,7 @@ public function getNextValue() } /** + *

                                                      Product data that was updated.

                                                      *
                                                        *
                                                      • staged, if the staged ProductCatalogData was updated.
                                                      • *
                                                      • current, if the current ProductCatalogData was updated.
                                                      • diff --git a/lib/commercetools-history/src/Models/Change/RemoveVariantChangeModel.php b/lib/commercetools-history/src/Models/Change/RemoveVariantChangeModel.php index f564820bdb1..1fc980ad68d 100644 --- a/lib/commercetools-history/src/Models/Change/RemoveVariantChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/RemoveVariantChangeModel.php @@ -150,6 +150,7 @@ public function getNextValue() } /** + *

                                                        Product data that was updated.

                                                        *
                                                          *
                                                        • staged, if the staged ProductCatalogData was updated.
                                                        • *
                                                        • current, if the current ProductCatalogData was updated.
                                                        • diff --git a/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChange.php b/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChange.php new file mode 100644 index 00000000000..16d356bfff4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChange.php @@ -0,0 +1,63 @@ +Value before the change.

                                                          + * + + * @return null|TaxRate + */ + public function getPreviousValue(); + + /** + *

                                                          Value after the change.

                                                          + * + + * @return null|TaxRate + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?TaxRate $previousValue + */ + public function setPreviousValue(?TaxRate $previousValue): void; + + /** + * @param ?TaxRate $nextValue + */ + public function setNextValue(?TaxRate $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChangeBuilder.php b/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChangeBuilder.php new file mode 100644 index 00000000000..da70ad3a7c8 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChangeBuilder.php @@ -0,0 +1,142 @@ + + */ +final class ReplaceTaxRateChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|TaxRate|TaxRateBuilder + */ + private $previousValue; + + /** + + * @var null|TaxRate|TaxRateBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                          Value before the change.

                                                          + * + + * @return null|TaxRate + */ + public function getPreviousValue() + { + return $this->previousValue instanceof TaxRateBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                          Value after the change.

                                                          + * + + * @return null|TaxRate + */ + public function getNextValue() + { + return $this->nextValue instanceof TaxRateBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?TaxRate $previousValue + * @return $this + */ + public function withPreviousValue(?TaxRate $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?TaxRate $nextValue + * @return $this + */ + public function withNextValue(?TaxRate $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?TaxRateBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?TaxRateBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): ReplaceTaxRateChange + { + return new ReplaceTaxRateChangeModel( + $this->change, + $this->previousValue instanceof TaxRateBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof TaxRateBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): ReplaceTaxRateChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChangeCollection.php b/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChangeCollection.php new file mode 100644 index 00000000000..35299da4b40 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChangeCollection.php @@ -0,0 +1,56 @@ + + * @method ReplaceTaxRateChange current() + * @method ReplaceTaxRateChange end() + * @method ReplaceTaxRateChange at($offset) + */ +class ReplaceTaxRateChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert ReplaceTaxRateChange $value + * @psalm-param ReplaceTaxRateChange|stdClass $value + * @throws InvalidArgumentException + * + * @return ReplaceTaxRateChangeCollection + */ + public function add($value) + { + if (!$value instanceof ReplaceTaxRateChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ReplaceTaxRateChange + */ + protected function mapper() + { + return function (?int $index): ?ReplaceTaxRateChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ReplaceTaxRateChange $data */ + $data = ReplaceTaxRateChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChangeModel.php b/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChangeModel.php new file mode 100644 index 00000000000..721ea7498ea --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/ReplaceTaxRateChangeModel.php @@ -0,0 +1,171 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                          Value before the change.

                                                          + * + * + * @return null|TaxRate + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = TaxRateModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                          Value after the change.

                                                          + * + * + * @return null|TaxRate + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = TaxRateModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?TaxRate $previousValue + */ + public function setPreviousValue(?TaxRate $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?TaxRate $nextValue + */ + public function setNextValue(?TaxRate $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/RevertStagedChangesChange.php b/lib/commercetools-history/src/Models/Change/RevertStagedChangesChange.php new file mode 100644 index 00000000000..9d0f5795596 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RevertStagedChangesChange.php @@ -0,0 +1,34 @@ + + */ +final class RevertStagedChangesChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + + public function build(): RevertStagedChangesChange + { + return new RevertStagedChangesChangeModel( + $this->change + ); + } + + public static function of(): RevertStagedChangesChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/RevertStagedChangesChangeCollection.php b/lib/commercetools-history/src/Models/Change/RevertStagedChangesChangeCollection.php new file mode 100644 index 00000000000..b511faffaaa --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RevertStagedChangesChangeCollection.php @@ -0,0 +1,56 @@ + + * @method RevertStagedChangesChange current() + * @method RevertStagedChangesChange end() + * @method RevertStagedChangesChange at($offset) + */ +class RevertStagedChangesChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert RevertStagedChangesChange $value + * @psalm-param RevertStagedChangesChange|stdClass $value + * @throws InvalidArgumentException + * + * @return RevertStagedChangesChangeCollection + */ + public function add($value) + { + if (!$value instanceof RevertStagedChangesChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RevertStagedChangesChange + */ + protected function mapper() + { + return function (?int $index): ?RevertStagedChangesChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RevertStagedChangesChange $data */ + $data = RevertStagedChangesChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/RevertStagedChangesChangeModel.php b/lib/commercetools-history/src/Models/Change/RevertStagedChangesChangeModel.php new file mode 100644 index 00000000000..9ccbbe243ad --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RevertStagedChangesChangeModel.php @@ -0,0 +1,95 @@ +change = $change; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/RevertStagedVariantChangesChange.php b/lib/commercetools-history/src/Models/Change/RevertStagedVariantChangesChange.php new file mode 100644 index 00000000000..d5c39856508 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RevertStagedVariantChangesChange.php @@ -0,0 +1,34 @@ + + */ +final class RevertStagedVariantChangesChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + + public function build(): RevertStagedVariantChangesChange + { + return new RevertStagedVariantChangesChangeModel( + $this->change + ); + } + + public static function of(): RevertStagedVariantChangesChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/RevertStagedVariantChangesChangeCollection.php b/lib/commercetools-history/src/Models/Change/RevertStagedVariantChangesChangeCollection.php new file mode 100644 index 00000000000..71f90f978c6 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RevertStagedVariantChangesChangeCollection.php @@ -0,0 +1,56 @@ + + * @method RevertStagedVariantChangesChange current() + * @method RevertStagedVariantChangesChange end() + * @method RevertStagedVariantChangesChange at($offset) + */ +class RevertStagedVariantChangesChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert RevertStagedVariantChangesChange $value + * @psalm-param RevertStagedVariantChangesChange|stdClass $value + * @throws InvalidArgumentException + * + * @return RevertStagedVariantChangesChangeCollection + */ + public function add($value) + { + if (!$value instanceof RevertStagedVariantChangesChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RevertStagedVariantChangesChange + */ + protected function mapper() + { + return function (?int $index): ?RevertStagedVariantChangesChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RevertStagedVariantChangesChange $data */ + $data = RevertStagedVariantChangesChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/RevertStagedVariantChangesChangeModel.php b/lib/commercetools-history/src/Models/Change/RevertStagedVariantChangesChangeModel.php new file mode 100644 index 00000000000..692db65f625 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/RevertStagedVariantChangesChangeModel.php @@ -0,0 +1,95 @@ +change = $change; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetAncestorsChange.php b/lib/commercetools-history/src/Models/Change/SetAncestorsChange.php new file mode 100644 index 00000000000..9b3cbe34690 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetAncestorsChange.php @@ -0,0 +1,91 @@ +Elements added to the array.

                                                          + * + + * @return null|ReferenceCollection + */ + public function getAddedItems(); + + /** + *

                                                          Elements removed from the array.

                                                          + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems(); + + /** + *

                                                          Value before the change.

                                                          + * + + * @return null|ReferenceCollection + */ + public function getPreviousValue(); + + /** + *

                                                          Value after the change.

                                                          + * + + * @return null|ReferenceCollection + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void; + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void; + + /** + * @param ?ReferenceCollection $previousValue + */ + public function setPreviousValue(?ReferenceCollection $previousValue): void; + + /** + * @param ?ReferenceCollection $nextValue + */ + public function setNextValue(?ReferenceCollection $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetAncestorsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetAncestorsChangeBuilder.php new file mode 100644 index 00000000000..539b89fecac --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetAncestorsChangeBuilder.php @@ -0,0 +1,178 @@ + + */ +final class SetAncestorsChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?ReferenceCollection + */ + private $addedItems; + + /** + + * @var ?ReferenceCollection + */ + private $removedItems; + + /** + + * @var ?ReferenceCollection + */ + private $previousValue; + + /** + + * @var ?ReferenceCollection + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                          Elements added to the array.

                                                          + * + + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                          Elements removed from the array.

                                                          + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + + /** + *

                                                          Value before the change.

                                                          + * + + * @return null|ReferenceCollection + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                          Value after the change.

                                                          + * + + * @return null|ReferenceCollection + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?ReferenceCollection $addedItems + * @return $this + */ + public function withAddedItems(?ReferenceCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?ReferenceCollection $removedItems + * @return $this + */ + public function withRemovedItems(?ReferenceCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + + /** + * @param ?ReferenceCollection $previousValue + * @return $this + */ + public function withPreviousValue(?ReferenceCollection $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?ReferenceCollection $nextValue + * @return $this + */ + public function withNextValue(?ReferenceCollection $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetAncestorsChange + { + return new SetAncestorsChangeModel( + $this->change, + $this->addedItems, + $this->removedItems, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetAncestorsChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetAncestorsChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetAncestorsChangeCollection.php new file mode 100644 index 00000000000..9006ec411df --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetAncestorsChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetAncestorsChange current() + * @method SetAncestorsChange end() + * @method SetAncestorsChange at($offset) + */ +class SetAncestorsChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetAncestorsChange $value + * @psalm-param SetAncestorsChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetAncestorsChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetAncestorsChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetAncestorsChange + */ + protected function mapper() + { + return function (?int $index): ?SetAncestorsChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetAncestorsChange $data */ + $data = SetAncestorsChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetAncestorsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetAncestorsChangeModel.php new file mode 100644 index 00000000000..3450b405dfc --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetAncestorsChangeModel.php @@ -0,0 +1,240 @@ +change = $change; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                          Elements added to the array.

                                                          + * + * + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = ReferenceCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                          Elements removed from the array.

                                                          + * + * + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = ReferenceCollection::fromArray($data); + } + + return $this->removedItems; + } + + /** + *

                                                          Value before the change.

                                                          + * + * + * @return null|ReferenceCollection + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = ReferenceCollection::fromArray($data); + } + + return $this->previousValue; + } + + /** + *

                                                          Value after the change.

                                                          + * + * + * @return null|ReferenceCollection + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = ReferenceCollection::fromArray($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + + /** + * @param ?ReferenceCollection $previousValue + */ + public function setPreviousValue(?ReferenceCollection $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?ReferenceCollection $nextValue + */ + public function setNextValue(?ReferenceCollection $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChange.php index 850a2539f91..4c4ff84d3a3 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChange.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChange.php @@ -20,6 +20,8 @@ interface SetAssetCustomFieldChange extends Change public const FIELD_NAME = 'name'; public const FIELD_CUSTOM_TYPE_ID = 'customTypeId'; public const FIELD_ASSET = 'asset'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -73,6 +75,27 @@ public function getCustomTypeId(); */ public function getAsset(); + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -102,4 +125,14 @@ public function setCustomTypeId(?string $customTypeId): void; * @param ?AssetChangeValue $asset */ public function setAsset(?AssetChangeValue $asset): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChangeBuilder.php index 852c12de62e..75f0c0aeee2 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChangeBuilder.php @@ -58,6 +58,18 @@ final class SetAssetCustomFieldChangeBuilder implements Builder */ private $asset; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -122,6 +134,33 @@ public function getAsset() return $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -188,6 +227,28 @@ public function withAsset(?AssetChangeValue $asset) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withAsset() instead * @return $this @@ -207,7 +268,9 @@ public function build(): SetAssetCustomFieldChange $this->nextValue, $this->name, $this->customTypeId, - $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset + $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChangeModel.php index 1200b175a2d..3666fc3515c 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetCustomFieldChangeModel.php @@ -65,6 +65,18 @@ final class SetAssetCustomFieldChangeModel extends JsonObjectModel implements Se */ protected $asset; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -76,6 +88,8 @@ public function __construct( ?string $name = null, ?string $customTypeId = null, ?AssetChangeValue $asset = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; @@ -84,6 +98,8 @@ public function __construct( $this->name = $name; $this->customTypeId = $customTypeId; $this->asset = $asset; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -224,6 +240,51 @@ public function getAsset() return $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -273,6 +334,22 @@ public function setAsset(?AssetChangeValue $asset): void $this->asset = $asset; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChange.php index 84893ab16ab..345be6a10fb 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChange.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChange.php @@ -19,6 +19,8 @@ interface SetAssetCustomTypeChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_ASSET = 'asset'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -56,6 +58,27 @@ public function getNextValue(); */ public function getAsset(); + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -75,4 +98,14 @@ public function setNextValue(?CustomFields $nextValue): void; * @param ?AssetChangeValue $asset */ public function setAsset(?AssetChangeValue $asset): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChangeBuilder.php index 0aaa8847b36..a50b0a90dd9 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChangeBuilder.php @@ -48,6 +48,18 @@ final class SetAssetCustomTypeChangeBuilder implements Builder */ private $asset; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -90,6 +102,33 @@ public function getAsset() return $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -134,6 +173,28 @@ public function withAsset(?AssetChangeValue $asset) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -173,7 +234,9 @@ public function build(): SetAssetCustomTypeChange $this->change, $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue, - $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset + $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChangeModel.php index b8da7fb5cd2..b31fce90305 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetCustomTypeChangeModel.php @@ -55,6 +55,18 @@ final class SetAssetCustomTypeChangeModel extends JsonObjectModel implements Set */ protected $asset; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -64,12 +76,16 @@ public function __construct( ?CustomFields $previousValue = null, ?CustomFields $nextValue = null, ?AssetChangeValue $asset = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->asset = $asset; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -172,6 +188,51 @@ public function getAsset() return $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -205,6 +266,22 @@ public function setAsset(?AssetChangeValue $asset): void $this->asset = $asset; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChange.php b/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChange.php index d6eed6418a1..618edd7ce5a 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChange.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChange.php @@ -19,6 +19,8 @@ interface SetAssetDescriptionChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_ASSET = 'asset'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -56,6 +58,27 @@ public function getNextValue(); */ public function getAsset(); + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -75,4 +98,14 @@ public function setNextValue(?LocalizedString $nextValue): void; * @param ?AssetChangeValue $asset */ public function setAsset(?AssetChangeValue $asset): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChangeBuilder.php index ba04f8cffcf..843e3c18186 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChangeBuilder.php @@ -48,6 +48,18 @@ final class SetAssetDescriptionChangeBuilder implements Builder */ private $asset; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -90,6 +102,33 @@ public function getAsset() return $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -134,6 +173,28 @@ public function withAsset(?AssetChangeValue $asset) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -173,7 +234,9 @@ public function build(): SetAssetDescriptionChange $this->change, $this->previousValue instanceof LocalizedStringBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue, - $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset + $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChangeModel.php b/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChangeModel.php index 7927d24cada..5386cfa688c 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetDescriptionChangeModel.php @@ -55,6 +55,18 @@ final class SetAssetDescriptionChangeModel extends JsonObjectModel implements Se */ protected $asset; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -64,12 +76,16 @@ public function __construct( ?LocalizedString $previousValue = null, ?LocalizedString $nextValue = null, ?AssetChangeValue $asset = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->asset = $asset; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -172,6 +188,51 @@ public function getAsset() return $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -205,6 +266,22 @@ public function setAsset(?AssetChangeValue $asset): void $this->asset = $asset; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetKeyChange.php b/lib/commercetools-history/src/Models/Change/SetAssetKeyChange.php index 7492bfd6b9b..843201effee 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetKeyChange.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetKeyChange.php @@ -18,6 +18,8 @@ interface SetAssetKeyChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_ASSET = 'asset'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -55,6 +57,27 @@ public function getNextValue(); */ public function getAsset(); + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -74,4 +97,14 @@ public function setNextValue(?string $nextValue): void; * @param ?AssetChangeValue $asset */ public function setAsset(?AssetChangeValue $asset): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetKeyChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetAssetKeyChangeBuilder.php index 69f2e9f8b99..58d96f8ba68 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetKeyChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetKeyChangeBuilder.php @@ -46,6 +46,18 @@ final class SetAssetKeyChangeBuilder implements Builder */ private $asset; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -88,6 +100,33 @@ public function getAsset() return $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -132,6 +171,28 @@ public function withAsset(?AssetChangeValue $asset) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withAsset() instead * @return $this @@ -149,7 +210,9 @@ public function build(): SetAssetKeyChange $this->change, $this->previousValue, $this->nextValue, - $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset + $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetKeyChangeModel.php b/lib/commercetools-history/src/Models/Change/SetAssetKeyChangeModel.php index 61640662562..aaba7baa153 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetKeyChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetKeyChangeModel.php @@ -53,6 +53,18 @@ final class SetAssetKeyChangeModel extends JsonObjectModel implements SetAssetKe */ protected $asset; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -62,12 +74,16 @@ public function __construct( ?string $previousValue = null, ?string $nextValue = null, ?AssetChangeValue $asset = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->asset = $asset; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -168,6 +184,51 @@ public function getAsset() return $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -201,6 +262,22 @@ public function setAsset(?AssetChangeValue $asset): void $this->asset = $asset; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetSourcesChange.php b/lib/commercetools-history/src/Models/Change/SetAssetSourcesChange.php index d210f33b137..7b83beba516 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetSourcesChange.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetSourcesChange.php @@ -19,6 +19,8 @@ interface SetAssetSourcesChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_ASSET = 'asset'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -56,6 +58,27 @@ public function getNextValue(); */ public function getAsset(); + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -75,4 +98,14 @@ public function setNextValue(?AssetSourceCollection $nextValue): void; * @param ?AssetChangeValue $asset */ public function setAsset(?AssetChangeValue $asset): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetSourcesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetAssetSourcesChangeBuilder.php index 691080f65f8..183df800147 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetSourcesChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetSourcesChangeBuilder.php @@ -47,6 +47,18 @@ final class SetAssetSourcesChangeBuilder implements Builder */ private $asset; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -89,6 +101,33 @@ public function getAsset() return $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -133,6 +172,28 @@ public function withAsset(?AssetChangeValue $asset) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withAsset() instead * @return $this @@ -150,7 +211,9 @@ public function build(): SetAssetSourcesChange $this->change, $this->previousValue, $this->nextValue, - $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset + $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetSourcesChangeModel.php b/lib/commercetools-history/src/Models/Change/SetAssetSourcesChangeModel.php index f8e6c8f6d2b..c2f7f178b15 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetSourcesChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetSourcesChangeModel.php @@ -54,6 +54,18 @@ final class SetAssetSourcesChangeModel extends JsonObjectModel implements SetAss */ protected $asset; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -63,12 +75,16 @@ public function __construct( ?AssetSourceCollection $previousValue = null, ?AssetSourceCollection $nextValue = null, ?AssetChangeValue $asset = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->asset = $asset; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -169,6 +185,51 @@ public function getAsset() return $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -202,6 +263,22 @@ public function setAsset(?AssetChangeValue $asset): void $this->asset = $asset; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetTagsChange.php b/lib/commercetools-history/src/Models/Change/SetAssetTagsChange.php index 52c76e148e0..975a971a1cd 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetTagsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetTagsChange.php @@ -18,6 +18,8 @@ interface SetAssetTagsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_ASSET = 'asset'; + public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -55,6 +57,27 @@ public function getNextValue(); */ public function getAsset(); + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -74,4 +97,14 @@ public function setNextValue(?array $nextValue): void; * @param ?AssetChangeValue $asset */ public function setAsset(?AssetChangeValue $asset): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetTagsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetAssetTagsChangeBuilder.php index f722230798b..a64f9cdada5 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetTagsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetTagsChangeBuilder.php @@ -46,6 +46,18 @@ final class SetAssetTagsChangeBuilder implements Builder */ private $asset; + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -88,6 +100,33 @@ public function getAsset() return $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -132,6 +171,28 @@ public function withAsset(?AssetChangeValue $asset) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withAsset() instead * @return $this @@ -149,7 +210,9 @@ public function build(): SetAssetTagsChange $this->change, $this->previousValue, $this->nextValue, - $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset + $this->asset instanceof AssetChangeValueBuilder ? $this->asset->build() : $this->asset, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetAssetTagsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetAssetTagsChangeModel.php index 5c24a2b1330..5a1b3adc359 100644 --- a/lib/commercetools-history/src/Models/Change/SetAssetTagsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetAssetTagsChangeModel.php @@ -53,6 +53,18 @@ final class SetAssetTagsChangeModel extends JsonObjectModel implements SetAssetT */ protected $asset; + /** + * + * @var ?string + */ + protected $catalogData; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -62,12 +74,16 @@ public function __construct( ?array $previousValue = null, ?array $nextValue = null, ?AssetChangeValue $asset = null, + ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->asset = $asset; + $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -168,6 +184,51 @@ public function getAsset() return $this->asset; } + /** + *

                                                          Product data that was updated.

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

                                                          Identifier of the updated Product Variant.

                                                          + *

                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                          + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -201,6 +262,22 @@ public function setAsset(?AssetChangeValue $asset): void $this->asset = $asset; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetAssociatesChange.php b/lib/commercetools-history/src/Models/Change/SetAssociatesChange.php new file mode 100644 index 00000000000..26c0e02c156 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetAssociatesChange.php @@ -0,0 +1,91 @@ +Elements added to the array.

                                                          + * + + * @return null|AssociateCollection + */ + public function getAddedItems(); + + /** + *

                                                          Elements removed from the array.

                                                          + * + + * @return null|AssociateCollection + */ + public function getRemovedItems(); + + /** + *

                                                          Value before the change.

                                                          + * + + * @return null|AssociateCollection + */ + public function getPreviousValue(); + + /** + *

                                                          Value after the change.

                                                          + * + + * @return null|AssociateCollection + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?AssociateCollection $addedItems + */ + public function setAddedItems(?AssociateCollection $addedItems): void; + + /** + * @param ?AssociateCollection $removedItems + */ + public function setRemovedItems(?AssociateCollection $removedItems): void; + + /** + * @param ?AssociateCollection $previousValue + */ + public function setPreviousValue(?AssociateCollection $previousValue): void; + + /** + * @param ?AssociateCollection $nextValue + */ + public function setNextValue(?AssociateCollection $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetAssociatesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetAssociatesChangeBuilder.php new file mode 100644 index 00000000000..c6f0cc71f30 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetAssociatesChangeBuilder.php @@ -0,0 +1,178 @@ + + */ +final class SetAssociatesChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?AssociateCollection + */ + private $addedItems; + + /** + + * @var ?AssociateCollection + */ + private $removedItems; + + /** + + * @var ?AssociateCollection + */ + private $previousValue; + + /** + + * @var ?AssociateCollection + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                          Elements added to the array.

                                                          + * + + * @return null|AssociateCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                          Elements removed from the array.

                                                          + * + + * @return null|AssociateCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + + /** + *

                                                          Value before the change.

                                                          + * + + * @return null|AssociateCollection + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                          Value after the change.

                                                          + * + + * @return null|AssociateCollection + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?AssociateCollection $addedItems + * @return $this + */ + public function withAddedItems(?AssociateCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?AssociateCollection $removedItems + * @return $this + */ + public function withRemovedItems(?AssociateCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + + /** + * @param ?AssociateCollection $previousValue + * @return $this + */ + public function withPreviousValue(?AssociateCollection $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?AssociateCollection $nextValue + * @return $this + */ + public function withNextValue(?AssociateCollection $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetAssociatesChange + { + return new SetAssociatesChangeModel( + $this->change, + $this->addedItems, + $this->removedItems, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetAssociatesChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetAssociatesChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetAssociatesChangeCollection.php new file mode 100644 index 00000000000..a8fb44c6dfb --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetAssociatesChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetAssociatesChange current() + * @method SetAssociatesChange end() + * @method SetAssociatesChange at($offset) + */ +class SetAssociatesChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetAssociatesChange $value + * @psalm-param SetAssociatesChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetAssociatesChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetAssociatesChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetAssociatesChange + */ + protected function mapper() + { + return function (?int $index): ?SetAssociatesChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetAssociatesChange $data */ + $data = SetAssociatesChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetAssociatesChangeModel.php b/lib/commercetools-history/src/Models/Change/SetAssociatesChangeModel.php new file mode 100644 index 00000000000..42b2285db99 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetAssociatesChangeModel.php @@ -0,0 +1,240 @@ +change = $change; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                          Elements added to the array.

                                                          + * + * + * @return null|AssociateCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = AssociateCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                          Elements removed from the array.

                                                          + * + * + * @return null|AssociateCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = AssociateCollection::fromArray($data); + } + + return $this->removedItems; + } + + /** + *

                                                          Value before the change.

                                                          + * + * + * @return null|AssociateCollection + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = AssociateCollection::fromArray($data); + } + + return $this->previousValue; + } + + /** + *

                                                          Value after the change.

                                                          + * + * + * @return null|AssociateCollection + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = AssociateCollection::fromArray($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?AssociateCollection $addedItems + */ + public function setAddedItems(?AssociateCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?AssociateCollection $removedItems + */ + public function setRemovedItems(?AssociateCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + + /** + * @param ?AssociateCollection $previousValue + */ + public function setPreviousValue(?AssociateCollection $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?AssociateCollection $nextValue + */ + public function setNextValue(?AssociateCollection $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetAttributeChange.php b/lib/commercetools-history/src/Models/Change/SetAttributeChange.php index 81ca0db2acb..384a426431b 100644 --- a/lib/commercetools-history/src/Models/Change/SetAttributeChange.php +++ b/lib/commercetools-history/src/Models/Change/SetAttributeChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\ChangeValue\AttributeValue; +use Commercetools\History\Models\Common\Attribute; interface SetAttributeChange extends Change { @@ -18,6 +18,7 @@ interface SetAttributeChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -35,7 +36,7 @@ public function getChange(); *

                                                          Value before the change.

                                                          * - * @return null|AttributeValue + * @return null|Attribute */ public function getPreviousValue(); @@ -43,11 +44,12 @@ public function getPreviousValue(); *

                                                          Value after the change.

                                                          * - * @return null|AttributeValue + * @return null|Attribute */ public function getNextValue(); /** + *

                                                          Product data that was updated.

                                                          *
                                                            *
                                                          • staged, if the staged ProductCatalogData was updated.
                                                          • *
                                                          • current, if the current ProductCatalogData was updated.
                                                          • @@ -58,23 +60,37 @@ public function getNextValue(); */ public function getCatalogData(); + /** + *

                                                            Identifier of the updated Product Variant.

                                                            + *

                                                            This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                            + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ public function setChange(?string $change): void; /** - * @param ?AttributeValue $previousValue + * @param ?Attribute $previousValue */ - public function setPreviousValue(?AttributeValue $previousValue): void; + public function setPreviousValue(?Attribute $previousValue): void; /** - * @param ?AttributeValue $nextValue + * @param ?Attribute $nextValue */ - public function setNextValue(?AttributeValue $nextValue): void; + public function setNextValue(?Attribute $nextValue): void; /** * @param ?string $catalogData */ public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetAttributeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetAttributeChangeBuilder.php index 22293f49f11..dffc7745989 100644 --- a/lib/commercetools-history/src/Models/Change/SetAttributeChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetAttributeChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\AttributeValue; -use Commercetools\History\Models\ChangeValue\AttributeValueBuilder; +use Commercetools\History\Models\Common\Attribute; +use Commercetools\History\Models\Common\AttributeBuilder; /** * @implements Builder @@ -30,13 +30,13 @@ final class SetAttributeChangeBuilder implements Builder /** - * @var null|AttributeValue|AttributeValueBuilder + * @var null|Attribute|AttributeBuilder */ private $previousValue; /** - * @var null|AttributeValue|AttributeValueBuilder + * @var null|Attribute|AttributeBuilder */ private $nextValue; @@ -46,6 +46,12 @@ final class SetAttributeChangeBuilder implements Builder */ private $catalogData; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -59,25 +65,26 @@ public function getChange() *

                                                            Value before the change.

                                                            * - * @return null|AttributeValue + * @return null|Attribute */ public function getPreviousValue() { - return $this->previousValue instanceof AttributeValueBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof AttributeBuilder ? $this->previousValue->build() : $this->previousValue; } /** *

                                                            Value after the change.

                                                            * - * @return null|AttributeValue + * @return null|Attribute */ public function getNextValue() { - return $this->nextValue instanceof AttributeValueBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof AttributeBuilder ? $this->nextValue->build() : $this->nextValue; } /** + *

                                                            Product data that was updated.

                                                            *
                                                              *
                                                            • staged, if the staged ProductCatalogData was updated.
                                                            • *
                                                            • current, if the current ProductCatalogData was updated.
                                                            • @@ -91,6 +98,18 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                              Identifier of the updated Product Variant.

                                                              + *

                                                              This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                              + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -103,10 +122,10 @@ public function withChange(?string $change) } /** - * @param ?AttributeValue $previousValue + * @param ?Attribute $previousValue * @return $this */ - public function withPreviousValue(?AttributeValue $previousValue) + public function withPreviousValue(?Attribute $previousValue) { $this->previousValue = $previousValue; @@ -114,10 +133,10 @@ public function withPreviousValue(?AttributeValue $previousValue) } /** - * @param ?AttributeValue $nextValue + * @param ?Attribute $nextValue * @return $this */ - public function withNextValue(?AttributeValue $nextValue) + public function withNextValue(?Attribute $nextValue) { $this->nextValue = $nextValue; @@ -135,11 +154,22 @@ public function withCatalogData(?string $catalogData) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?AttributeValueBuilder $previousValue) + public function withPreviousValueBuilder(?AttributeBuilder $previousValue) { $this->previousValue = $previousValue; @@ -150,7 +180,7 @@ public function withPreviousValueBuilder(?AttributeValueBuilder $previousValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?AttributeValueBuilder $nextValue) + public function withNextValueBuilder(?AttributeBuilder $nextValue) { $this->nextValue = $nextValue; @@ -161,9 +191,10 @@ public function build(): SetAttributeChange { return new SetAttributeChangeModel( $this->change, - $this->previousValue instanceof AttributeValueBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof AttributeValueBuilder ? $this->nextValue->build() : $this->nextValue, - $this->catalogData + $this->previousValue instanceof AttributeBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof AttributeBuilder ? $this->nextValue->build() : $this->nextValue, + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetAttributeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetAttributeChangeModel.php index 4f501d6bc95..06e343620e1 100644 --- a/lib/commercetools-history/src/Models/Change/SetAttributeChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetAttributeChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\ChangeValue\AttributeValue; -use Commercetools\History\Models\ChangeValue\AttributeValueModel; +use Commercetools\History\Models\Common\Attribute; +use Commercetools\History\Models\Common\AttributeModel; /** * @internal @@ -37,13 +37,13 @@ final class SetAttributeChangeModel extends JsonObjectModel implements SetAttrib /** * - * @var ?AttributeValue + * @var ?Attribute */ protected $previousValue; /** * - * @var ?AttributeValue + * @var ?Attribute */ protected $nextValue; @@ -53,21 +53,29 @@ final class SetAttributeChangeModel extends JsonObjectModel implements SetAttrib */ protected $catalogData; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType */ public function __construct( ?string $change = null, - ?AttributeValue $previousValue = null, - ?AttributeValue $nextValue = null, + ?Attribute $previousValue = null, + ?Attribute $nextValue = null, ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -111,7 +119,7 @@ public function getChange() *

                                                              Value before the change.

                                                              * * - * @return null|AttributeValue + * @return null|Attribute */ public function getPreviousValue() { @@ -122,7 +130,7 @@ public function getPreviousValue() return null; } - $this->previousValue = AttributeValueModel::of($data); + $this->previousValue = AttributeModel::of($data); } return $this->previousValue; @@ -132,7 +140,7 @@ public function getPreviousValue() *

                                                              Value after the change.

                                                              * * - * @return null|AttributeValue + * @return null|Attribute */ public function getNextValue() { @@ -143,13 +151,14 @@ public function getNextValue() return null; } - $this->nextValue = AttributeValueModel::of($data); + $this->nextValue = AttributeModel::of($data); } return $this->nextValue; } /** + *

                                                              Product data that was updated.

                                                              *
                                                                *
                                                              • staged, if the staged ProductCatalogData was updated.
                                                              • *
                                                              • current, if the current ProductCatalogData was updated.
                                                              • @@ -172,6 +181,27 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                Identifier of the updated Product Variant.

                                                                + *

                                                                This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -182,17 +212,17 @@ public function setChange(?string $change): void } /** - * @param ?AttributeValue $previousValue + * @param ?Attribute $previousValue */ - public function setPreviousValue(?AttributeValue $previousValue): void + public function setPreviousValue(?Attribute $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?AttributeValue $nextValue + * @param ?Attribute $nextValue */ - public function setNextValue(?AttributeValue $nextValue): void + public function setNextValue(?Attribute $nextValue): void { $this->nextValue = $nextValue; } @@ -205,6 +235,14 @@ public function setCatalogData(?string $catalogData): void $this->catalogData = $catalogData; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChange.php new file mode 100644 index 00000000000..305b1badf68 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChange.php @@ -0,0 +1,90 @@ +Name of the Custom Field.

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

                                                                id of the referenced Type.

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

                                                                Value before the change.

                                                                + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                Value after the change.

                                                                + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..33805ba8696 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChangeBuilder.php @@ -0,0 +1,177 @@ + + */ +final class SetBillingAddressCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                Name of the Custom Field.

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

                                                                id of the referenced Type.

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

                                                                Value before the change.

                                                                + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                Value after the change.

                                                                + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetBillingAddressCustomFieldChange + { + return new SetBillingAddressCustomFieldChangeModel( + $this->change, + $this->name, + $this->customTypeId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetBillingAddressCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChangeCollection.php new file mode 100644 index 00000000000..a5d039149ad --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetBillingAddressCustomFieldChange current() + * @method SetBillingAddressCustomFieldChange end() + * @method SetBillingAddressCustomFieldChange at($offset) + */ +class SetBillingAddressCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetBillingAddressCustomFieldChange $value + * @psalm-param SetBillingAddressCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetBillingAddressCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetBillingAddressCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetBillingAddressCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetBillingAddressCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetBillingAddressCustomFieldChange $data */ + $data = SetBillingAddressCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChangeModel.php new file mode 100644 index 00000000000..2264018d536 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomFieldChangeModel.php @@ -0,0 +1,239 @@ +change = $change; + $this->name = $name; + $this->customTypeId = $customTypeId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                Name of the Custom Field.

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

                                                                id of the referenced Type.

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

                                                                Value before the change.

                                                                + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                Value after the change.

                                                                + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChange.php new file mode 100644 index 00000000000..be160d0aa22 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChange.php @@ -0,0 +1,63 @@ +Value before the change.

                                                                + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                Value after the change.

                                                                + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..37f5cae50dd --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChangeBuilder.php @@ -0,0 +1,142 @@ + + */ +final class SetBillingAddressCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                Value before the change.

                                                                + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                Value after the change.

                                                                + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetBillingAddressCustomTypeChange + { + return new SetBillingAddressCustomTypeChangeModel( + $this->change, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetBillingAddressCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChangeCollection.php new file mode 100644 index 00000000000..92c2ca6282b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetBillingAddressCustomTypeChange current() + * @method SetBillingAddressCustomTypeChange end() + * @method SetBillingAddressCustomTypeChange at($offset) + */ +class SetBillingAddressCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetBillingAddressCustomTypeChange $value + * @psalm-param SetBillingAddressCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetBillingAddressCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetBillingAddressCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetBillingAddressCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetBillingAddressCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetBillingAddressCustomTypeChange $data */ + $data = SetBillingAddressCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChangeModel.php new file mode 100644 index 00000000000..836d9c8d1fe --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBillingAddressCustomTypeChangeModel.php @@ -0,0 +1,171 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                Value before the change.

                                                                + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                Value after the change.

                                                                + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetBusinessUnitChange.php b/lib/commercetools-history/src/Models/Change/SetBusinessUnitChange.php new file mode 100644 index 00000000000..896f1ee21ad --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBusinessUnitChange.php @@ -0,0 +1,63 @@ +Value before the change.

                                                                + * + + * @return null|KeyReference + */ + public function getPreviousValue(); + + /** + *

                                                                Value after the change.

                                                                + * + + * @return null|KeyReference + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?KeyReference $previousValue + */ + public function setPreviousValue(?KeyReference $previousValue): void; + + /** + * @param ?KeyReference $nextValue + */ + public function setNextValue(?KeyReference $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetBusinessUnitChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetBusinessUnitChangeBuilder.php new file mode 100644 index 00000000000..9e39a0b16b4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBusinessUnitChangeBuilder.php @@ -0,0 +1,142 @@ + + */ +final class SetBusinessUnitChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|KeyReference|KeyReferenceBuilder + */ + private $previousValue; + + /** + + * @var null|KeyReference|KeyReferenceBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                Value before the change.

                                                                + * + + * @return null|KeyReference + */ + public function getPreviousValue() + { + return $this->previousValue instanceof KeyReferenceBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                Value after the change.

                                                                + * + + * @return null|KeyReference + */ + public function getNextValue() + { + return $this->nextValue instanceof KeyReferenceBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?KeyReference $previousValue + * @return $this + */ + public function withPreviousValue(?KeyReference $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?KeyReference $nextValue + * @return $this + */ + public function withNextValue(?KeyReference $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?KeyReferenceBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?KeyReferenceBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetBusinessUnitChange + { + return new SetBusinessUnitChangeModel( + $this->change, + $this->previousValue instanceof KeyReferenceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof KeyReferenceBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetBusinessUnitChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetBusinessUnitChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetBusinessUnitChangeCollection.php new file mode 100644 index 00000000000..254b0a2e160 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBusinessUnitChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetBusinessUnitChange current() + * @method SetBusinessUnitChange end() + * @method SetBusinessUnitChange at($offset) + */ +class SetBusinessUnitChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetBusinessUnitChange $value + * @psalm-param SetBusinessUnitChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetBusinessUnitChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetBusinessUnitChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetBusinessUnitChange + */ + protected function mapper() + { + return function (?int $index): ?SetBusinessUnitChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetBusinessUnitChange $data */ + $data = SetBusinessUnitChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetBusinessUnitChangeModel.php b/lib/commercetools-history/src/Models/Change/SetBusinessUnitChangeModel.php new file mode 100644 index 00000000000..6a365978b64 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetBusinessUnitChangeModel.php @@ -0,0 +1,171 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                Value before the change.

                                                                + * + * + * @return null|KeyReference + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $className = KeyReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                Value after the change.

                                                                + * + * + * @return null|KeyReference + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $className = KeyReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?KeyReference $previousValue + */ + public function setPreviousValue(?KeyReference $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?KeyReference $nextValue + */ + public function setNextValue(?KeyReference $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChange.php b/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChange.php index 150576b67da..fda01f540ef 100644 --- a/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChange.php +++ b/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChange.php @@ -49,6 +49,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                                Product data that was updated.

                                                                *
                                                                  *
                                                                • staged, if the staged ProductCatalogData was updated.
                                                                • *
                                                                • current, if the current ProductCatalogData was updated.
                                                                • diff --git a/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChangeBuilder.php index 16df8ab2757..53c80e66c55 100644 --- a/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChangeBuilder.php @@ -84,6 +84,7 @@ public function getNextValue() } /** + *

                                                                  Product data that was updated.

                                                                  *
                                                                    *
                                                                  • staged, if the staged ProductCatalogData was updated.
                                                                  • *
                                                                  • current, if the current ProductCatalogData was updated.
                                                                  • diff --git a/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChangeModel.php index 61030bcb3b1..c4258ea1a19 100644 --- a/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetCategoryOrderHintChangeModel.php @@ -158,6 +158,7 @@ public function getNextValue() } /** + *

                                                                    Product data that was updated.

                                                                    *
                                                                      *
                                                                    • staged, if the staged ProductCatalogData was updated.
                                                                    • *
                                                                    • current, if the current ProductCatalogData was updated.
                                                                    • diff --git a/lib/commercetools-history/src/Models/Change/SetChannelRolesChange.php b/lib/commercetools-history/src/Models/Change/SetChannelRolesChange.php index 1755c5518e9..0cb9f06ac04 100644 --- a/lib/commercetools-history/src/Models/Change/SetChannelRolesChange.php +++ b/lib/commercetools-history/src/Models/Change/SetChannelRolesChange.php @@ -16,6 +16,8 @@ interface SetChannelRolesChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -45,6 +47,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                      Elements added to the array.

                                                                      + * + + * @return null|array + */ + public function getAddedItems(); + + /** + *

                                                                      Elements removed from the array.

                                                                      + * + + * @return null|array + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -59,4 +77,14 @@ public function setPreviousValue(?array $previousValue): void; * @param ?array $nextValue */ public function setNextValue(?array $nextValue): void; + + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void; + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetChannelRolesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetChannelRolesChangeBuilder.php index ea4a6fcc062..fa3cb026420 100644 --- a/lib/commercetools-history/src/Models/Change/SetChannelRolesChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetChannelRolesChangeBuilder.php @@ -38,6 +38,18 @@ final class SetChannelRolesChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?array + */ + private $addedItems; + + /** + + * @var ?array + */ + private $removedItems; + /** * @return null|string @@ -69,6 +81,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                      Elements added to the array.

                                                                      + * + + * @return null|array + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                      Elements removed from the array.

                                                                      + * + + * @return null|array + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -102,13 +136,37 @@ public function withNextValue(?array $nextValue) return $this; } + /** + * @param ?array $addedItems + * @return $this + */ + public function withAddedItems(?array $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?array $removedItems + * @return $this + */ + public function withRemovedItems(?array $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetChannelRolesChange { return new SetChannelRolesChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetChannelRolesChangeModel.php b/lib/commercetools-history/src/Models/Change/SetChannelRolesChangeModel.php index a612232fdd1..c0747a537fc 100644 --- a/lib/commercetools-history/src/Models/Change/SetChannelRolesChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetChannelRolesChangeModel.php @@ -45,6 +45,18 @@ final class SetChannelRolesChangeModel extends JsonObjectModel implements SetCha */ protected $nextValue; + /** + * + * @var ?array + */ + protected $addedItems; + + /** + * + * @var ?array + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -53,11 +65,15 @@ public function __construct( ?string $change = null, ?array $previousValue = null, ?array $nextValue = null, + ?array $addedItems = null, + ?array $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -137,6 +153,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                      Elements added to the array.

                                                                      + * + * + * @return null|array + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = $data; + } + + return $this->addedItems; + } + + /** + *

                                                                      Elements removed from the array.

                                                                      + * + * + * @return null|array + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = $data; + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -162,6 +218,22 @@ public function setNextValue(?array $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetCountriesChange.php b/lib/commercetools-history/src/Models/Change/SetCountriesChange.php index ab4ae0dc1e1..f68ba876621 100644 --- a/lib/commercetools-history/src/Models/Change/SetCountriesChange.php +++ b/lib/commercetools-history/src/Models/Change/SetCountriesChange.php @@ -17,6 +17,8 @@ interface SetCountriesChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -46,6 +48,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                      Elements added to the array.

                                                                      + * + + * @return null|StoreCountryCollection + */ + public function getAddedItems(); + + /** + *

                                                                      Elements removed from the array.

                                                                      + * + + * @return null|StoreCountryCollection + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -60,4 +78,14 @@ public function setPreviousValue(?StoreCountryCollection $previousValue): void; * @param ?StoreCountryCollection $nextValue */ public function setNextValue(?StoreCountryCollection $nextValue): void; + + /** + * @param ?StoreCountryCollection $addedItems + */ + public function setAddedItems(?StoreCountryCollection $addedItems): void; + + /** + * @param ?StoreCountryCollection $removedItems + */ + public function setRemovedItems(?StoreCountryCollection $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetCountriesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetCountriesChangeBuilder.php index 91b639c649d..8cd19c37847 100644 --- a/lib/commercetools-history/src/Models/Change/SetCountriesChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetCountriesChangeBuilder.php @@ -39,6 +39,18 @@ final class SetCountriesChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?StoreCountryCollection + */ + private $addedItems; + + /** + + * @var ?StoreCountryCollection + */ + private $removedItems; + /** * @return null|string @@ -70,6 +82,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                      Elements added to the array.

                                                                      + * + + * @return null|StoreCountryCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                      Elements removed from the array.

                                                                      + * + + * @return null|StoreCountryCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -103,13 +137,37 @@ public function withNextValue(?StoreCountryCollection $nextValue) return $this; } + /** + * @param ?StoreCountryCollection $addedItems + * @return $this + */ + public function withAddedItems(?StoreCountryCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?StoreCountryCollection $removedItems + * @return $this + */ + public function withRemovedItems(?StoreCountryCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetCountriesChange { return new SetCountriesChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetCountriesChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCountriesChangeModel.php index 79b045e9e04..b9b5cc41d78 100644 --- a/lib/commercetools-history/src/Models/Change/SetCountriesChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetCountriesChangeModel.php @@ -46,6 +46,18 @@ final class SetCountriesChangeModel extends JsonObjectModel implements SetCountr */ protected $nextValue; + /** + * + * @var ?StoreCountryCollection + */ + protected $addedItems; + + /** + * + * @var ?StoreCountryCollection + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -54,11 +66,15 @@ public function __construct( ?string $change = null, ?StoreCountryCollection $previousValue = null, ?StoreCountryCollection $nextValue = null, + ?StoreCountryCollection $addedItems = null, + ?StoreCountryCollection $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -138,6 +154,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                      Elements added to the array.

                                                                      + * + * + * @return null|StoreCountryCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = StoreCountryCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                      Elements removed from the array.

                                                                      + * + * + * @return null|StoreCountryCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = StoreCountryCollection::fromArray($data); + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -163,6 +219,22 @@ public function setNextValue(?StoreCountryCollection $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?StoreCountryCollection $addedItems + */ + public function setAddedItems(?StoreCountryCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?StoreCountryCollection $removedItems + */ + public function setRemovedItems(?StoreCountryCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChange.php index 57a3caed3cf..64ccf22d5ff 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChange.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChange.php @@ -20,6 +20,7 @@ interface SetCustomLineItemCustomFieldChange extends Change public const FIELD_NAME = 'name'; public const FIELD_CUSTOM_LINE_ITEM = 'customLineItem'; public const FIELD_CUSTOM_LINE_ITEM_ID = 'customLineItemId'; + public const FIELD_CUSTOM_TYPE_ID = 'customTypeId'; /** @@ -73,6 +74,14 @@ public function getCustomLineItem(); */ public function getCustomLineItemId(); + /** + *

                                                                      id of the referenced Type.

                                                                      + * + + * @return null|string + */ + public function getCustomTypeId(); + /** * @param ?string $change */ @@ -102,4 +111,9 @@ public function setCustomLineItem(?LocalizedString $customLineItem): void; * @param ?string $customLineItemId */ public function setCustomLineItemId(?string $customLineItemId): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChangeBuilder.php index 8efa52262de..5243214208d 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChangeBuilder.php @@ -58,6 +58,12 @@ final class SetCustomLineItemCustomFieldChangeBuilder implements Builder */ private $customLineItemId; + /** + + * @var ?string + */ + private $customTypeId; + /** * @return null|string @@ -122,6 +128,17 @@ public function getCustomLineItemId() return $this->customLineItemId; } + /** + *

                                                                      id of the referenced Type.

                                                                      + * + + * @return null|string + */ + public function getCustomTypeId() + { + return $this->customTypeId; + } + /** * @param ?string $change * @return $this @@ -188,6 +205,17 @@ public function withCustomLineItemId(?string $customLineItemId) return $this; } + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + /** * @deprecated use withCustomLineItem() instead * @return $this @@ -207,7 +235,8 @@ public function build(): SetCustomLineItemCustomFieldChange $this->nextValue, $this->name, $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem, - $this->customLineItemId + $this->customLineItemId, + $this->customTypeId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChangeModel.php index d0d248c7d8d..b95e3977547 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemCustomFieldChangeModel.php @@ -65,6 +65,12 @@ final class SetCustomLineItemCustomFieldChangeModel extends JsonObjectModel impl */ protected $customLineItemId; + /** + * + * @var ?string + */ + protected $customTypeId; + /** * @psalm-suppress MissingParamType @@ -76,6 +82,7 @@ public function __construct( ?string $name = null, ?LocalizedString $customLineItem = null, ?string $customLineItemId = null, + ?string $customTypeId = null, ?string $type = null ) { $this->change = $change; @@ -84,6 +91,7 @@ public function __construct( $this->name = $name; $this->customLineItem = $customLineItem; $this->customLineItemId = $customLineItemId; + $this->customTypeId = $customTypeId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -224,6 +232,26 @@ public function getCustomLineItemId() return $this->customLineItemId; } + /** + *

                                                                      id of the referenced Type.

                                                                      + * + * + * @return null|string + */ + public function getCustomTypeId() + { + if (is_null($this->customTypeId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CUSTOM_TYPE_ID); + if (is_null($data)) { + return null; + } + $this->customTypeId = (string) $data; + } + + return $this->customTypeId; + } + /** * @param ?string $change @@ -273,6 +301,14 @@ public function setCustomLineItemId(?string $customLineItemId): void $this->customLineItemId = $customLineItemId; } + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChange.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChange.php new file mode 100644 index 00000000000..4ff3d2e4cb8 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChange.php @@ -0,0 +1,92 @@ +Name of the updated CustomLineItem.

                                                                      + * + + * @return null|LocalizedString + */ + public function getCustomLineItem(); + + /** + *

                                                                      id of the updated CustomLineItem.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|DiscountedLineItemPrice + */ + public function getPreviousValue(); + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|DiscountedLineItemPrice + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void; + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void; + + /** + * @param ?DiscountedLineItemPrice $previousValue + */ + public function setPreviousValue(?DiscountedLineItemPrice $previousValue): void; + + /** + * @param ?DiscountedLineItemPrice $nextValue + */ + public function setNextValue(?DiscountedLineItemPrice $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChangeBuilder.php new file mode 100644 index 00000000000..245e788dffe --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChangeBuilder.php @@ -0,0 +1,213 @@ + + */ +final class SetCustomLineItemDiscountedPriceChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $customLineItem; + + /** + + * @var ?string + */ + private $customLineItemId; + + /** + + * @var null|DiscountedLineItemPrice|DiscountedLineItemPriceBuilder + */ + private $previousValue; + + /** + + * @var null|DiscountedLineItemPrice|DiscountedLineItemPriceBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                      Name of the updated CustomLineItem.

                                                                      + * + + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + return $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem; + } + + /** + *

                                                                      id of the updated CustomLineItem.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|DiscountedLineItemPrice + */ + public function getPreviousValue() + { + return $this->previousValue instanceof DiscountedLineItemPriceBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|DiscountedLineItemPrice + */ + public function getNextValue() + { + return $this->nextValue instanceof DiscountedLineItemPriceBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?LocalizedString $customLineItem + * @return $this + */ + public function withCustomLineItem(?LocalizedString $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + + /** + * @param ?string $customLineItemId + * @return $this + */ + public function withCustomLineItemId(?string $customLineItemId) + { + $this->customLineItemId = $customLineItemId; + + return $this; + } + + /** + * @param ?DiscountedLineItemPrice $previousValue + * @return $this + */ + public function withPreviousValue(?DiscountedLineItemPrice $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?DiscountedLineItemPrice $nextValue + * @return $this + */ + public function withNextValue(?DiscountedLineItemPrice $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withCustomLineItem() instead + * @return $this + */ + public function withCustomLineItemBuilder(?LocalizedStringBuilder $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?DiscountedLineItemPriceBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?DiscountedLineItemPriceBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetCustomLineItemDiscountedPriceChange + { + return new SetCustomLineItemDiscountedPriceChangeModel( + $this->change, + $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem, + $this->customLineItemId, + $this->previousValue instanceof DiscountedLineItemPriceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof DiscountedLineItemPriceBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetCustomLineItemDiscountedPriceChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChangeCollection.php new file mode 100644 index 00000000000..66ad7b73dbb --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetCustomLineItemDiscountedPriceChange current() + * @method SetCustomLineItemDiscountedPriceChange end() + * @method SetCustomLineItemDiscountedPriceChange at($offset) + */ +class SetCustomLineItemDiscountedPriceChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetCustomLineItemDiscountedPriceChange $value + * @psalm-param SetCustomLineItemDiscountedPriceChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetCustomLineItemDiscountedPriceChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetCustomLineItemDiscountedPriceChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetCustomLineItemDiscountedPriceChange + */ + protected function mapper() + { + return function (?int $index): ?SetCustomLineItemDiscountedPriceChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetCustomLineItemDiscountedPriceChange $data */ + $data = SetCustomLineItemDiscountedPriceChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChangeModel.php new file mode 100644 index 00000000000..e37b3e7816a --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPriceChangeModel.php @@ -0,0 +1,246 @@ +change = $change; + $this->customLineItem = $customLineItem; + $this->customLineItemId = $customLineItemId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                      Name of the updated CustomLineItem.

                                                                      + * + * + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + if (is_null($this->customLineItem)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM_LINE_ITEM); + if (is_null($data)) { + return null; + } + + $this->customLineItem = LocalizedStringModel::of($data); + } + + return $this->customLineItem; + } + + /** + *

                                                                      id of the updated CustomLineItem.

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

                                                                      Value before the change.

                                                                      + * + * + * @return null|DiscountedLineItemPrice + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = DiscountedLineItemPriceModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + * + * @return null|DiscountedLineItemPrice + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = DiscountedLineItemPriceModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void + { + $this->customLineItem = $customLineItem; + } + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void + { + $this->customLineItemId = $customLineItemId; + } + + /** + * @param ?DiscountedLineItemPrice $previousValue + */ + public function setPreviousValue(?DiscountedLineItemPrice $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?DiscountedLineItemPrice $nextValue + */ + public function setNextValue(?DiscountedLineItemPrice $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChange.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChange.php new file mode 100644 index 00000000000..3376aae7ec6 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChange.php @@ -0,0 +1,92 @@ +Name of the updated CustomLineItem.

                                                                      + * + + * @return null|LocalizedString + */ + public function getCustomLineItem(); + + /** + *

                                                                      id of the updated CustomLineItem.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|DiscountedLineItemPriceForQuantity + */ + public function getPreviousValue(); + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|DiscountedLineItemPriceForQuantity + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void; + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void; + + /** + * @param ?DiscountedLineItemPriceForQuantity $previousValue + */ + public function setPreviousValue(?DiscountedLineItemPriceForQuantity $previousValue): void; + + /** + * @param ?DiscountedLineItemPriceForQuantity $nextValue + */ + public function setNextValue(?DiscountedLineItemPriceForQuantity $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChangeBuilder.php new file mode 100644 index 00000000000..daa39a4b857 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChangeBuilder.php @@ -0,0 +1,213 @@ + + */ +final class SetCustomLineItemDiscountedPricePerQuantityChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $customLineItem; + + /** + + * @var ?string + */ + private $customLineItemId; + + /** + + * @var null|DiscountedLineItemPriceForQuantity|DiscountedLineItemPriceForQuantityBuilder + */ + private $previousValue; + + /** + + * @var null|DiscountedLineItemPriceForQuantity|DiscountedLineItemPriceForQuantityBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                      Name of the updated CustomLineItem.

                                                                      + * + + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + return $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem; + } + + /** + *

                                                                      id of the updated CustomLineItem.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|DiscountedLineItemPriceForQuantity + */ + public function getPreviousValue() + { + return $this->previousValue instanceof DiscountedLineItemPriceForQuantityBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|DiscountedLineItemPriceForQuantity + */ + public function getNextValue() + { + return $this->nextValue instanceof DiscountedLineItemPriceForQuantityBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?LocalizedString $customLineItem + * @return $this + */ + public function withCustomLineItem(?LocalizedString $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + + /** + * @param ?string $customLineItemId + * @return $this + */ + public function withCustomLineItemId(?string $customLineItemId) + { + $this->customLineItemId = $customLineItemId; + + return $this; + } + + /** + * @param ?DiscountedLineItemPriceForQuantity $previousValue + * @return $this + */ + public function withPreviousValue(?DiscountedLineItemPriceForQuantity $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?DiscountedLineItemPriceForQuantity $nextValue + * @return $this + */ + public function withNextValue(?DiscountedLineItemPriceForQuantity $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withCustomLineItem() instead + * @return $this + */ + public function withCustomLineItemBuilder(?LocalizedStringBuilder $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?DiscountedLineItemPriceForQuantityBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?DiscountedLineItemPriceForQuantityBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetCustomLineItemDiscountedPricePerQuantityChange + { + return new SetCustomLineItemDiscountedPricePerQuantityChangeModel( + $this->change, + $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem, + $this->customLineItemId, + $this->previousValue instanceof DiscountedLineItemPriceForQuantityBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof DiscountedLineItemPriceForQuantityBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetCustomLineItemDiscountedPricePerQuantityChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChangeCollection.php new file mode 100644 index 00000000000..2ad7cdffd8b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetCustomLineItemDiscountedPricePerQuantityChange current() + * @method SetCustomLineItemDiscountedPricePerQuantityChange end() + * @method SetCustomLineItemDiscountedPricePerQuantityChange at($offset) + */ +class SetCustomLineItemDiscountedPricePerQuantityChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetCustomLineItemDiscountedPricePerQuantityChange $value + * @psalm-param SetCustomLineItemDiscountedPricePerQuantityChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetCustomLineItemDiscountedPricePerQuantityChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetCustomLineItemDiscountedPricePerQuantityChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetCustomLineItemDiscountedPricePerQuantityChange + */ + protected function mapper() + { + return function (?int $index): ?SetCustomLineItemDiscountedPricePerQuantityChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetCustomLineItemDiscountedPricePerQuantityChange $data */ + $data = SetCustomLineItemDiscountedPricePerQuantityChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChangeModel.php new file mode 100644 index 00000000000..2ac814aed7e --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemDiscountedPricePerQuantityChangeModel.php @@ -0,0 +1,246 @@ +change = $change; + $this->customLineItem = $customLineItem; + $this->customLineItemId = $customLineItemId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                      Name of the updated CustomLineItem.

                                                                      + * + * + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + if (is_null($this->customLineItem)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM_LINE_ITEM); + if (is_null($data)) { + return null; + } + + $this->customLineItem = LocalizedStringModel::of($data); + } + + return $this->customLineItem; + } + + /** + *

                                                                      id of the updated CustomLineItem.

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

                                                                      Value before the change.

                                                                      + * + * + * @return null|DiscountedLineItemPriceForQuantity + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = DiscountedLineItemPriceForQuantityModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + * + * @return null|DiscountedLineItemPriceForQuantity + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = DiscountedLineItemPriceForQuantityModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void + { + $this->customLineItem = $customLineItem; + } + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void + { + $this->customLineItemId = $customLineItemId; + } + + /** + * @param ?DiscountedLineItemPriceForQuantity $previousValue + */ + public function setPreviousValue(?DiscountedLineItemPriceForQuantity $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?DiscountedLineItemPriceForQuantity $nextValue + */ + public function setNextValue(?DiscountedLineItemPriceForQuantity $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChange.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChange.php index f9165fbe761..08080f524be 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChange.php @@ -11,6 +11,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\History\Models\Common\ItemShippingDetails; +use Commercetools\History\Models\Common\LocalizedString; interface SetCustomLineItemShippingDetailsChange extends Change { @@ -18,6 +19,7 @@ interface SetCustomLineItemShippingDetailsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CUSTOM_LINE_ITEM_ID = 'customLineItemId'; + public const FIELD_CUSTOM_LINE_ITEM = 'customLineItem'; /** @@ -55,6 +57,14 @@ public function getNextValue(); */ public function getCustomLineItemId(); + /** + *

                                                                      Name of the updated CustomLineItem.

                                                                      + * + + * @return null|LocalizedString + */ + public function getCustomLineItem(); + /** * @param ?string $change */ @@ -74,4 +84,9 @@ public function setNextValue(?ItemShippingDetails $nextValue): void; * @param ?string $customLineItemId */ public function setCustomLineItemId(?string $customLineItemId): void; + + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChangeBuilder.php index a0566f9662c..5d681c3dc45 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChangeBuilder.php @@ -16,6 +16,8 @@ use stdClass; use Commercetools\History\Models\Common\ItemShippingDetails; use Commercetools\History\Models\Common\ItemShippingDetailsBuilder; +use Commercetools\History\Models\Common\LocalizedString; +use Commercetools\History\Models\Common\LocalizedStringBuilder; /** * @implements Builder @@ -46,6 +48,12 @@ final class SetCustomLineItemShippingDetailsChangeBuilder implements Builder */ private $customLineItemId; + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $customLineItem; + /** * @return null|string @@ -88,6 +96,17 @@ public function getCustomLineItemId() return $this->customLineItemId; } + /** + *

                                                                      Name of the updated CustomLineItem.

                                                                      + * + + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + return $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem; + } + /** * @param ?string $change * @return $this @@ -132,6 +151,17 @@ public function withCustomLineItemId(?string $customLineItemId) return $this; } + /** + * @param ?LocalizedString $customLineItem + * @return $this + */ + public function withCustomLineItem(?LocalizedString $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -154,13 +184,25 @@ public function withNextValueBuilder(?ItemShippingDetailsBuilder $nextValue) return $this; } + /** + * @deprecated use withCustomLineItem() instead + * @return $this + */ + public function withCustomLineItemBuilder(?LocalizedStringBuilder $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + public function build(): SetCustomLineItemShippingDetailsChange { return new SetCustomLineItemShippingDetailsChangeModel( $this->change, $this->previousValue instanceof ItemShippingDetailsBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof ItemShippingDetailsBuilder ? $this->nextValue->build() : $this->nextValue, - $this->customLineItemId + $this->customLineItemId, + $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem ); } diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChangeModel.php index afedd0e9068..9a31ee18b1d 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemShippingDetailsChangeModel.php @@ -15,6 +15,8 @@ use stdClass; use Commercetools\History\Models\Common\ItemShippingDetails; use Commercetools\History\Models\Common\ItemShippingDetailsModel; +use Commercetools\History\Models\Common\LocalizedString; +use Commercetools\History\Models\Common\LocalizedStringModel; /** * @internal @@ -53,6 +55,12 @@ final class SetCustomLineItemShippingDetailsChangeModel extends JsonObjectModel */ protected $customLineItemId; + /** + * + * @var ?LocalizedString + */ + protected $customLineItem; + /** * @psalm-suppress MissingParamType @@ -62,12 +70,14 @@ public function __construct( ?ItemShippingDetails $previousValue = null, ?ItemShippingDetails $nextValue = null, ?string $customLineItemId = null, + ?LocalizedString $customLineItem = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->customLineItemId = $customLineItemId; + $this->customLineItem = $customLineItem; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -169,6 +179,27 @@ public function getCustomLineItemId() return $this->customLineItemId; } + /** + *

                                                                      Name of the updated CustomLineItem.

                                                                      + * + * + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + if (is_null($this->customLineItem)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM_LINE_ITEM); + if (is_null($data)) { + return null; + } + + $this->customLineItem = LocalizedStringModel::of($data); + } + + return $this->customLineItem; + } + /** * @param ?string $change @@ -202,6 +233,14 @@ public function setCustomLineItemId(?string $customLineItemId): void $this->customLineItemId = $customLineItemId; } + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void + { + $this->customLineItem = $customLineItem; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxCategoryChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxCategoryChangeModel.php index e692b49f62f..1e8768340bd 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxCategoryChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxCategoryChangeModel.php @@ -131,8 +131,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -152,8 +152,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChange.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChange.php index 7df059fa0f1..21c1231db5e 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChange.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChange.php @@ -11,7 +11,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\History\Models\Common\LocalizedString; -use Commercetools\History\Models\Common\Money; +use Commercetools\History\Models\Common\TaxedItemPrice; interface SetCustomLineItemTaxedPriceChange extends Change { @@ -37,7 +37,7 @@ public function getChange(); *

                                                                      Value before the change.

                                                                      * - * @return null|Money + * @return null|TaxedItemPrice */ public function getPreviousValue(); @@ -45,7 +45,7 @@ public function getPreviousValue(); *

                                                                      Value after the change.

                                                                      * - * @return null|Money + * @return null|TaxedItemPrice */ public function getNextValue(); @@ -71,14 +71,14 @@ public function getCustomLineItemId(); public function setChange(?string $change): void; /** - * @param ?Money $previousValue + * @param ?TaxedItemPrice $previousValue */ - public function setPreviousValue(?Money $previousValue): void; + public function setPreviousValue(?TaxedItemPrice $previousValue): void; /** - * @param ?Money $nextValue + * @param ?TaxedItemPrice $nextValue */ - public function setNextValue(?Money $nextValue): void; + public function setNextValue(?TaxedItemPrice $nextValue): void; /** * @param ?LocalizedString $customLineItem diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChangeBuilder.php index 2d0d0f18911..1d4c60c953b 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChangeBuilder.php @@ -16,8 +16,8 @@ use stdClass; use Commercetools\History\Models\Common\LocalizedString; use Commercetools\History\Models\Common\LocalizedStringBuilder; -use Commercetools\History\Models\Common\Money; -use Commercetools\History\Models\Common\MoneyBuilder; +use Commercetools\History\Models\Common\TaxedItemPrice; +use Commercetools\History\Models\Common\TaxedItemPriceBuilder; /** * @implements Builder @@ -32,13 +32,13 @@ final class SetCustomLineItemTaxedPriceChangeBuilder implements Builder /** - * @var null|Money|MoneyBuilder + * @var null|TaxedItemPrice|TaxedItemPriceBuilder */ private $previousValue; /** - * @var null|Money|MoneyBuilder + * @var null|TaxedItemPrice|TaxedItemPriceBuilder */ private $nextValue; @@ -67,22 +67,22 @@ public function getChange() *

                                                                      Value before the change.

                                                                      * - * @return null|Money + * @return null|TaxedItemPrice */ public function getPreviousValue() { - return $this->previousValue instanceof MoneyBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof TaxedItemPriceBuilder ? $this->previousValue->build() : $this->previousValue; } /** *

                                                                      Value after the change.

                                                                      * - * @return null|Money + * @return null|TaxedItemPrice */ public function getNextValue() { - return $this->nextValue instanceof MoneyBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof TaxedItemPriceBuilder ? $this->nextValue->build() : $this->nextValue; } /** @@ -119,10 +119,10 @@ public function withChange(?string $change) } /** - * @param ?Money $previousValue + * @param ?TaxedItemPrice $previousValue * @return $this */ - public function withPreviousValue(?Money $previousValue) + public function withPreviousValue(?TaxedItemPrice $previousValue) { $this->previousValue = $previousValue; @@ -130,10 +130,10 @@ public function withPreviousValue(?Money $previousValue) } /** - * @param ?Money $nextValue + * @param ?TaxedItemPrice $nextValue * @return $this */ - public function withNextValue(?Money $nextValue) + public function withNextValue(?TaxedItemPrice $nextValue) { $this->nextValue = $nextValue; @@ -166,7 +166,7 @@ public function withCustomLineItemId(?string $customLineItemId) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?MoneyBuilder $previousValue) + public function withPreviousValueBuilder(?TaxedItemPriceBuilder $previousValue) { $this->previousValue = $previousValue; @@ -177,7 +177,7 @@ public function withPreviousValueBuilder(?MoneyBuilder $previousValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?MoneyBuilder $nextValue) + public function withNextValueBuilder(?TaxedItemPriceBuilder $nextValue) { $this->nextValue = $nextValue; @@ -199,8 +199,8 @@ public function build(): SetCustomLineItemTaxedPriceChange { return new SetCustomLineItemTaxedPriceChangeModel( $this->change, - $this->previousValue instanceof MoneyBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof MoneyBuilder ? $this->nextValue->build() : $this->nextValue, + $this->previousValue instanceof TaxedItemPriceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof TaxedItemPriceBuilder ? $this->nextValue->build() : $this->nextValue, $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem, $this->customLineItemId ); diff --git a/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChangeModel.php index f9715a7fb1b..afd69e5e92e 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomLineItemTaxedPriceChangeModel.php @@ -15,8 +15,8 @@ use stdClass; use Commercetools\History\Models\Common\LocalizedString; use Commercetools\History\Models\Common\LocalizedStringModel; -use Commercetools\History\Models\Common\Money; -use Commercetools\History\Models\Common\MoneyModel; +use Commercetools\History\Models\Common\TaxedItemPrice; +use Commercetools\History\Models\Common\TaxedItemPriceModel; /** * @internal @@ -39,13 +39,13 @@ final class SetCustomLineItemTaxedPriceChangeModel extends JsonObjectModel imple /** * - * @var ?Money + * @var ?TaxedItemPrice */ protected $previousValue; /** * - * @var ?Money + * @var ?TaxedItemPrice */ protected $nextValue; @@ -67,8 +67,8 @@ final class SetCustomLineItemTaxedPriceChangeModel extends JsonObjectModel imple */ public function __construct( ?string $change = null, - ?Money $previousValue = null, - ?Money $nextValue = null, + ?TaxedItemPrice $previousValue = null, + ?TaxedItemPrice $nextValue = null, ?LocalizedString $customLineItem = null, ?string $customLineItemId = null, ?string $type = null @@ -121,7 +121,7 @@ public function getChange() *

                                                                      Value before the change.

                                                                      * * - * @return null|Money + * @return null|TaxedItemPrice */ public function getPreviousValue() { @@ -132,7 +132,7 @@ public function getPreviousValue() return null; } - $this->previousValue = MoneyModel::of($data); + $this->previousValue = TaxedItemPriceModel::of($data); } return $this->previousValue; @@ -142,7 +142,7 @@ public function getPreviousValue() *

                                                                      Value after the change.

                                                                      * * - * @return null|Money + * @return null|TaxedItemPrice */ public function getNextValue() { @@ -153,7 +153,7 @@ public function getNextValue() return null; } - $this->nextValue = MoneyModel::of($data); + $this->nextValue = TaxedItemPriceModel::of($data); } return $this->nextValue; @@ -210,17 +210,17 @@ public function setChange(?string $change): void } /** - * @param ?Money $previousValue + * @param ?TaxedItemPrice $previousValue */ - public function setPreviousValue(?Money $previousValue): void + public function setPreviousValue(?TaxedItemPrice $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?Money $nextValue + * @param ?TaxedItemPrice $nextValue */ - public function setNextValue(?Money $nextValue): void + public function setNextValue(?TaxedItemPrice $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/SetCustomerChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCustomerChangeModel.php index 0a73e3a161f..587d575f90b 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomerChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomerChangeModel.php @@ -113,8 +113,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -134,8 +134,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChange.php b/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChange.php new file mode 100644 index 00000000000..6e0ae0c4ed5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChange.php @@ -0,0 +1,91 @@ +Elements added to the array.

                                                                      + * + + * @return null|CustomerGroupAssignmentCollection + */ + public function getAddedItems(); + + /** + *

                                                                      Elements removed from the array.

                                                                      + * + + * @return null|CustomerGroupAssignmentCollection + */ + public function getRemovedItems(); + + /** + *

                                                                      Value before the change.

                                                                      + * + + * @return null|CustomerGroupAssignmentCollection + */ + public function getPreviousValue(); + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|CustomerGroupAssignmentCollection + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?CustomerGroupAssignmentCollection $addedItems + */ + public function setAddedItems(?CustomerGroupAssignmentCollection $addedItems): void; + + /** + * @param ?CustomerGroupAssignmentCollection $removedItems + */ + public function setRemovedItems(?CustomerGroupAssignmentCollection $removedItems): void; + + /** + * @param ?CustomerGroupAssignmentCollection $previousValue + */ + public function setPreviousValue(?CustomerGroupAssignmentCollection $previousValue): void; + + /** + * @param ?CustomerGroupAssignmentCollection $nextValue + */ + public function setNextValue(?CustomerGroupAssignmentCollection $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChangeBuilder.php new file mode 100644 index 00000000000..a804ed953f1 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChangeBuilder.php @@ -0,0 +1,178 @@ + + */ +final class SetCustomerGroupAssignmentsChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?CustomerGroupAssignmentCollection + */ + private $addedItems; + + /** + + * @var ?CustomerGroupAssignmentCollection + */ + private $removedItems; + + /** + + * @var ?CustomerGroupAssignmentCollection + */ + private $previousValue; + + /** + + * @var ?CustomerGroupAssignmentCollection + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                      Elements added to the array.

                                                                      + * + + * @return null|CustomerGroupAssignmentCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                      Elements removed from the array.

                                                                      + * + + * @return null|CustomerGroupAssignmentCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + + /** + *

                                                                      Value before the change.

                                                                      + * + + * @return null|CustomerGroupAssignmentCollection + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|CustomerGroupAssignmentCollection + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?CustomerGroupAssignmentCollection $addedItems + * @return $this + */ + public function withAddedItems(?CustomerGroupAssignmentCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?CustomerGroupAssignmentCollection $removedItems + * @return $this + */ + public function withRemovedItems(?CustomerGroupAssignmentCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + + /** + * @param ?CustomerGroupAssignmentCollection $previousValue + * @return $this + */ + public function withPreviousValue(?CustomerGroupAssignmentCollection $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomerGroupAssignmentCollection $nextValue + * @return $this + */ + public function withNextValue(?CustomerGroupAssignmentCollection $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetCustomerGroupAssignmentsChange + { + return new SetCustomerGroupAssignmentsChangeModel( + $this->change, + $this->addedItems, + $this->removedItems, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetCustomerGroupAssignmentsChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChangeCollection.php new file mode 100644 index 00000000000..a1cd1acfb86 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetCustomerGroupAssignmentsChange current() + * @method SetCustomerGroupAssignmentsChange end() + * @method SetCustomerGroupAssignmentsChange at($offset) + */ +class SetCustomerGroupAssignmentsChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetCustomerGroupAssignmentsChange $value + * @psalm-param SetCustomerGroupAssignmentsChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetCustomerGroupAssignmentsChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetCustomerGroupAssignmentsChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetCustomerGroupAssignmentsChange + */ + protected function mapper() + { + return function (?int $index): ?SetCustomerGroupAssignmentsChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetCustomerGroupAssignmentsChange $data */ + $data = SetCustomerGroupAssignmentsChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChangeModel.php new file mode 100644 index 00000000000..5ccfcbf20ea --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetCustomerGroupAssignmentsChangeModel.php @@ -0,0 +1,240 @@ +change = $change; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                      Elements added to the array.

                                                                      + * + * + * @return null|CustomerGroupAssignmentCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = CustomerGroupAssignmentCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                      Elements removed from the array.

                                                                      + * + * + * @return null|CustomerGroupAssignmentCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = CustomerGroupAssignmentCollection::fromArray($data); + } + + return $this->removedItems; + } + + /** + *

                                                                      Value before the change.

                                                                      + * + * + * @return null|CustomerGroupAssignmentCollection + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = CustomerGroupAssignmentCollection::fromArray($data); + } + + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + * + * @return null|CustomerGroupAssignmentCollection + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = CustomerGroupAssignmentCollection::fromArray($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?CustomerGroupAssignmentCollection $addedItems + */ + public function setAddedItems(?CustomerGroupAssignmentCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?CustomerGroupAssignmentCollection $removedItems + */ + public function setRemovedItems(?CustomerGroupAssignmentCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + + /** + * @param ?CustomerGroupAssignmentCollection $previousValue + */ + public function setPreviousValue(?CustomerGroupAssignmentCollection $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomerGroupAssignmentCollection $nextValue + */ + public function setNextValue(?CustomerGroupAssignmentCollection $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetCustomerGroupChangeModel.php b/lib/commercetools-history/src/Models/Change/SetCustomerGroupChangeModel.php index a5da1c0d7d8..40bf5ddc52a 100644 --- a/lib/commercetools-history/src/Models/Change/SetCustomerGroupChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetCustomerGroupChangeModel.php @@ -113,8 +113,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -134,8 +134,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChange.php new file mode 100644 index 00000000000..15bdb4c4949 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChange.php @@ -0,0 +1,118 @@ +id of the updated Delivery.

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

                                                                      id of the updated Address.

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

                                                                      Name of the Custom Field.

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

                                                                      id of the referenced Type.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $deliveryId + */ + public function setDeliveryId(?string $deliveryId): void; + + /** + * @param ?string $addressId + */ + public function setAddressId(?string $addressId): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..fa88aebd574 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChangeBuilder.php @@ -0,0 +1,235 @@ + + */ +final class SetDeliveryAddressCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $deliveryId; + + /** + + * @var ?string + */ + private $addressId; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                      id of the updated Delivery.

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

                                                                      id of the updated Address.

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

                                                                      Name of the Custom Field.

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

                                                                      id of the referenced Type.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $deliveryId + * @return $this + */ + public function withDeliveryId(?string $deliveryId) + { + $this->deliveryId = $deliveryId; + + return $this; + } + + /** + * @param ?string $addressId + * @return $this + */ + public function withAddressId(?string $addressId) + { + $this->addressId = $addressId; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetDeliveryAddressCustomFieldChange + { + return new SetDeliveryAddressCustomFieldChangeModel( + $this->change, + $this->deliveryId, + $this->addressId, + $this->name, + $this->customTypeId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetDeliveryAddressCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChangeCollection.php new file mode 100644 index 00000000000..6485c402d3e --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetDeliveryAddressCustomFieldChange current() + * @method SetDeliveryAddressCustomFieldChange end() + * @method SetDeliveryAddressCustomFieldChange at($offset) + */ +class SetDeliveryAddressCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetDeliveryAddressCustomFieldChange $value + * @psalm-param SetDeliveryAddressCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetDeliveryAddressCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetDeliveryAddressCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetDeliveryAddressCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetDeliveryAddressCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetDeliveryAddressCustomFieldChange $data */ + $data = SetDeliveryAddressCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChangeModel.php new file mode 100644 index 00000000000..129f175144c --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomFieldChangeModel.php @@ -0,0 +1,311 @@ +change = $change; + $this->deliveryId = $deliveryId; + $this->addressId = $addressId; + $this->name = $name; + $this->customTypeId = $customTypeId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                      id of the updated Delivery.

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

                                                                      id of the updated Address.

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

                                                                      Name of the Custom Field.

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

                                                                      id of the referenced Type.

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

                                                                      Value before the change.

                                                                      + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $deliveryId + */ + public function setDeliveryId(?string $deliveryId): void + { + $this->deliveryId = $deliveryId; + } + + /** + * @param ?string $addressId + */ + public function setAddressId(?string $addressId): void + { + $this->addressId = $addressId; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChange.php new file mode 100644 index 00000000000..f791efc2e2b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChange.php @@ -0,0 +1,91 @@ +id of the updated Delivery.

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

                                                                      id of the updated Address.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $deliveryId + */ + public function setDeliveryId(?string $deliveryId): void; + + /** + * @param ?string $addressId + */ + public function setAddressId(?string $addressId): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..417afa8d4e5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChangeBuilder.php @@ -0,0 +1,200 @@ + + */ +final class SetDeliveryAddressCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $deliveryId; + + /** + + * @var ?string + */ + private $addressId; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                      id of the updated Delivery.

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

                                                                      id of the updated Address.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $deliveryId + * @return $this + */ + public function withDeliveryId(?string $deliveryId) + { + $this->deliveryId = $deliveryId; + + return $this; + } + + /** + * @param ?string $addressId + * @return $this + */ + public function withAddressId(?string $addressId) + { + $this->addressId = $addressId; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetDeliveryAddressCustomTypeChange + { + return new SetDeliveryAddressCustomTypeChangeModel( + $this->change, + $this->deliveryId, + $this->addressId, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetDeliveryAddressCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChangeCollection.php new file mode 100644 index 00000000000..f6b9d51cfb4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetDeliveryAddressCustomTypeChange current() + * @method SetDeliveryAddressCustomTypeChange end() + * @method SetDeliveryAddressCustomTypeChange at($offset) + */ +class SetDeliveryAddressCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetDeliveryAddressCustomTypeChange $value + * @psalm-param SetDeliveryAddressCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetDeliveryAddressCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetDeliveryAddressCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetDeliveryAddressCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetDeliveryAddressCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetDeliveryAddressCustomTypeChange $data */ + $data = SetDeliveryAddressCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChangeModel.php new file mode 100644 index 00000000000..9a8038779f9 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryAddressCustomTypeChangeModel.php @@ -0,0 +1,243 @@ +change = $change; + $this->deliveryId = $deliveryId; + $this->addressId = $addressId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                      id of the updated Delivery.

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

                                                                      id of the updated Address.

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

                                                                      Value before the change.

                                                                      + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $deliveryId + */ + public function setDeliveryId(?string $deliveryId): void + { + $this->deliveryId = $deliveryId; + } + + /** + * @param ?string $addressId + */ + public function setAddressId(?string $addressId): void + { + $this->addressId = $addressId; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChange.php new file mode 100644 index 00000000000..bbe2886cc0e --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChange.php @@ -0,0 +1,104 @@ +id of the updated Delivery.

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

                                                                      Name of the Custom Field.

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

                                                                      id of the referenced Type.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $deliveryId + */ + public function setDeliveryId(?string $deliveryId): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..4ad9799370a --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChangeBuilder.php @@ -0,0 +1,206 @@ + + */ +final class SetDeliveryCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $deliveryId; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                      id of the updated Delivery.

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

                                                                      Name of the Custom Field.

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

                                                                      id of the referenced Type.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $deliveryId + * @return $this + */ + public function withDeliveryId(?string $deliveryId) + { + $this->deliveryId = $deliveryId; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetDeliveryCustomFieldChange + { + return new SetDeliveryCustomFieldChangeModel( + $this->change, + $this->deliveryId, + $this->name, + $this->customTypeId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetDeliveryCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChangeCollection.php new file mode 100644 index 00000000000..017a6e27e06 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetDeliveryCustomFieldChange current() + * @method SetDeliveryCustomFieldChange end() + * @method SetDeliveryCustomFieldChange at($offset) + */ +class SetDeliveryCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetDeliveryCustomFieldChange $value + * @psalm-param SetDeliveryCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetDeliveryCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetDeliveryCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetDeliveryCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetDeliveryCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetDeliveryCustomFieldChange $data */ + $data = SetDeliveryCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChangeModel.php new file mode 100644 index 00000000000..e688ec70ed6 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomFieldChangeModel.php @@ -0,0 +1,275 @@ +change = $change; + $this->deliveryId = $deliveryId; + $this->name = $name; + $this->customTypeId = $customTypeId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                      id of the updated Delivery.

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

                                                                      Name of the Custom Field.

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

                                                                      id of the referenced Type.

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

                                                                      Value before the change.

                                                                      + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $deliveryId + */ + public function setDeliveryId(?string $deliveryId): void + { + $this->deliveryId = $deliveryId; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChange.php new file mode 100644 index 00000000000..9aabb610150 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChange.php @@ -0,0 +1,77 @@ +id of the updated Delivery.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $deliveryId + */ + public function setDeliveryId(?string $deliveryId): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..e9db2fcb42d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChangeBuilder.php @@ -0,0 +1,171 @@ + + */ +final class SetDeliveryCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $deliveryId; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                      id of the updated Delivery.

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

                                                                      Value before the change.

                                                                      + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $deliveryId + * @return $this + */ + public function withDeliveryId(?string $deliveryId) + { + $this->deliveryId = $deliveryId; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetDeliveryCustomTypeChange + { + return new SetDeliveryCustomTypeChangeModel( + $this->change, + $this->deliveryId, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetDeliveryCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChangeCollection.php new file mode 100644 index 00000000000..097e4f4dcc0 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetDeliveryCustomTypeChange current() + * @method SetDeliveryCustomTypeChange end() + * @method SetDeliveryCustomTypeChange at($offset) + */ +class SetDeliveryCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetDeliveryCustomTypeChange $value + * @psalm-param SetDeliveryCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetDeliveryCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetDeliveryCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetDeliveryCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetDeliveryCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetDeliveryCustomTypeChange $data */ + $data = SetDeliveryCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChangeModel.php new file mode 100644 index 00000000000..b7247537104 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDeliveryCustomTypeChangeModel.php @@ -0,0 +1,207 @@ +change = $change; + $this->deliveryId = $deliveryId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                      id of the updated Delivery.

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

                                                                      Value before the change.

                                                                      + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $deliveryId + */ + public function setDeliveryId(?string $deliveryId): void + { + $this->deliveryId = $deliveryId; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChange.php b/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChange.php new file mode 100644 index 00000000000..cb96926ca74 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChange.php @@ -0,0 +1,63 @@ +Value before the change.

                                                                      + * + + * @return null|DiscountOnTotalPrice + */ + public function getPreviousValue(); + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|DiscountOnTotalPrice + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?DiscountOnTotalPrice $previousValue + */ + public function setPreviousValue(?DiscountOnTotalPrice $previousValue): void; + + /** + * @param ?DiscountOnTotalPrice $nextValue + */ + public function setNextValue(?DiscountOnTotalPrice $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChangeBuilder.php new file mode 100644 index 00000000000..198590e412f --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChangeBuilder.php @@ -0,0 +1,142 @@ + + */ +final class SetDiscountOnTotalPriceChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|DiscountOnTotalPrice|DiscountOnTotalPriceBuilder + */ + private $previousValue; + + /** + + * @var null|DiscountOnTotalPrice|DiscountOnTotalPriceBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                      Value before the change.

                                                                      + * + + * @return null|DiscountOnTotalPrice + */ + public function getPreviousValue() + { + return $this->previousValue instanceof DiscountOnTotalPriceBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + + * @return null|DiscountOnTotalPrice + */ + public function getNextValue() + { + return $this->nextValue instanceof DiscountOnTotalPriceBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?DiscountOnTotalPrice $previousValue + * @return $this + */ + public function withPreviousValue(?DiscountOnTotalPrice $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?DiscountOnTotalPrice $nextValue + * @return $this + */ + public function withNextValue(?DiscountOnTotalPrice $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?DiscountOnTotalPriceBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?DiscountOnTotalPriceBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetDiscountOnTotalPriceChange + { + return new SetDiscountOnTotalPriceChangeModel( + $this->change, + $this->previousValue instanceof DiscountOnTotalPriceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof DiscountOnTotalPriceBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetDiscountOnTotalPriceChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChangeCollection.php new file mode 100644 index 00000000000..f0d575fc047 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetDiscountOnTotalPriceChange current() + * @method SetDiscountOnTotalPriceChange end() + * @method SetDiscountOnTotalPriceChange at($offset) + */ +class SetDiscountOnTotalPriceChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetDiscountOnTotalPriceChange $value + * @psalm-param SetDiscountOnTotalPriceChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetDiscountOnTotalPriceChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetDiscountOnTotalPriceChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetDiscountOnTotalPriceChange + */ + protected function mapper() + { + return function (?int $index): ?SetDiscountOnTotalPriceChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetDiscountOnTotalPriceChange $data */ + $data = SetDiscountOnTotalPriceChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChangeModel.php new file mode 100644 index 00000000000..13b427495cc --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetDiscountOnTotalPriceChangeModel.php @@ -0,0 +1,171 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                      Value before the change.

                                                                      + * + * + * @return null|DiscountOnTotalPrice + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = DiscountOnTotalPriceModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                      Value after the change.

                                                                      + * + * + * @return null|DiscountOnTotalPrice + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = DiscountOnTotalPriceModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?DiscountOnTotalPrice $previousValue + */ + public function setPreviousValue(?DiscountOnTotalPrice $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?DiscountOnTotalPrice $nextValue + */ + public function setNextValue(?DiscountOnTotalPrice $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChange.php b/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChange.php index 7b0629c5c61..50a3267fd9c 100644 --- a/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChange.php +++ b/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChange.php @@ -10,6 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use Commercetools\History\Models\Common\DiscountedPrice; use Commercetools\History\Models\Common\Price; interface SetDiscountedPriceChange extends Change @@ -20,6 +21,7 @@ interface SetDiscountedPriceChange extends Change public const FIELD_CATALOG_DATA = 'catalogData'; public const FIELD_VARIANT = 'variant'; public const FIELD_PRICE_ID = 'priceId'; + public const FIELD_PRICE = 'price'; /** @@ -37,7 +39,7 @@ public function getChange(); *

                                                                      Value before the change.

                                                                      * - * @return null|Price + * @return null|DiscountedPrice */ public function getPreviousValue(); @@ -45,11 +47,12 @@ public function getPreviousValue(); *

                                                                      Value after the change.

                                                                      * - * @return null|Price + * @return null|DiscountedPrice */ public function getNextValue(); /** + *

                                                                      Product data that was updated.

                                                                      *
                                                                        *
                                                                      • staged, if the staged ProductCatalogData was updated.
                                                                      • *
                                                                      • current, if the current ProductCatalogData was updated.
                                                                      • @@ -61,7 +64,8 @@ public function getNextValue(); public function getCatalogData(); /** - *

                                                                        sku or key of the updated ProductVariant.

                                                                        + *

                                                                        Identifier of the updated Product Variant.

                                                                        + *

                                                                        This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                        * * @return null|string @@ -76,20 +80,28 @@ public function getVariant(); */ public function getPriceId(); + /** + *

                                                                        Embedded Price of the ProductVariant.

                                                                        + * + + * @return null|Price + */ + public function getPrice(); + /** * @param ?string $change */ public function setChange(?string $change): void; /** - * @param ?Price $previousValue + * @param ?DiscountedPrice $previousValue */ - public function setPreviousValue(?Price $previousValue): void; + public function setPreviousValue(?DiscountedPrice $previousValue): void; /** - * @param ?Price $nextValue + * @param ?DiscountedPrice $nextValue */ - public function setNextValue(?Price $nextValue): void; + public function setNextValue(?DiscountedPrice $nextValue): void; /** * @param ?string $catalogData @@ -105,4 +117,9 @@ public function setVariant(?string $variant): void; * @param ?string $priceId */ public function setPriceId(?string $priceId): void; + + /** + * @param ?Price $price + */ + public function setPrice(?Price $price): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChangeBuilder.php index aafab57dae1..0ed7b54f024 100644 --- a/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChangeBuilder.php @@ -14,6 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use Commercetools\History\Models\Common\DiscountedPrice; +use Commercetools\History\Models\Common\DiscountedPriceBuilder; use Commercetools\History\Models\Common\Price; use Commercetools\History\Models\Common\PriceBuilder; @@ -30,13 +32,13 @@ final class SetDiscountedPriceChangeBuilder implements Builder /** - * @var null|Price|PriceBuilder + * @var null|DiscountedPrice|DiscountedPriceBuilder */ private $previousValue; /** - * @var null|Price|PriceBuilder + * @var null|DiscountedPrice|DiscountedPriceBuilder */ private $nextValue; @@ -58,6 +60,12 @@ final class SetDiscountedPriceChangeBuilder implements Builder */ private $priceId; + /** + + * @var null|Price|PriceBuilder + */ + private $price; + /** * @return null|string @@ -71,25 +79,26 @@ public function getChange() *

                                                                        Value before the change.

                                                                        * - * @return null|Price + * @return null|DiscountedPrice */ public function getPreviousValue() { - return $this->previousValue instanceof PriceBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof DiscountedPriceBuilder ? $this->previousValue->build() : $this->previousValue; } /** *

                                                                        Value after the change.

                                                                        * - * @return null|Price + * @return null|DiscountedPrice */ public function getNextValue() { - return $this->nextValue instanceof PriceBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof DiscountedPriceBuilder ? $this->nextValue->build() : $this->nextValue; } /** + *

                                                                        Product data that was updated.

                                                                        *
                                                                          *
                                                                        • staged, if the staged ProductCatalogData was updated.
                                                                        • *
                                                                        • current, if the current ProductCatalogData was updated.
                                                                        • @@ -104,7 +113,8 @@ public function getCatalogData() } /** - *

                                                                          sku or key of the updated ProductVariant.

                                                                          + *

                                                                          Identifier of the updated Product Variant.

                                                                          + *

                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                          * * @return null|string @@ -125,6 +135,17 @@ public function getPriceId() return $this->priceId; } + /** + *

                                                                          Embedded Price of the ProductVariant.

                                                                          + * + + * @return null|Price + */ + public function getPrice() + { + return $this->price instanceof PriceBuilder ? $this->price->build() : $this->price; + } + /** * @param ?string $change * @return $this @@ -137,10 +158,10 @@ public function withChange(?string $change) } /** - * @param ?Price $previousValue + * @param ?DiscountedPrice $previousValue * @return $this */ - public function withPreviousValue(?Price $previousValue) + public function withPreviousValue(?DiscountedPrice $previousValue) { $this->previousValue = $previousValue; @@ -148,10 +169,10 @@ public function withPreviousValue(?Price $previousValue) } /** - * @param ?Price $nextValue + * @param ?DiscountedPrice $nextValue * @return $this */ - public function withNextValue(?Price $nextValue) + public function withNextValue(?DiscountedPrice $nextValue) { $this->nextValue = $nextValue; @@ -191,11 +212,22 @@ public function withPriceId(?string $priceId) return $this; } + /** + * @param ?Price $price + * @return $this + */ + public function withPrice(?Price $price) + { + $this->price = $price; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?PriceBuilder $previousValue) + public function withPreviousValueBuilder(?DiscountedPriceBuilder $previousValue) { $this->previousValue = $previousValue; @@ -206,22 +238,34 @@ public function withPreviousValueBuilder(?PriceBuilder $previousValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?PriceBuilder $nextValue) + public function withNextValueBuilder(?DiscountedPriceBuilder $nextValue) { $this->nextValue = $nextValue; return $this; } + /** + * @deprecated use withPrice() instead + * @return $this + */ + public function withPriceBuilder(?PriceBuilder $price) + { + $this->price = $price; + + return $this; + } + public function build(): SetDiscountedPriceChange { return new SetDiscountedPriceChangeModel( $this->change, - $this->previousValue instanceof PriceBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof PriceBuilder ? $this->nextValue->build() : $this->nextValue, + $this->previousValue instanceof DiscountedPriceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof DiscountedPriceBuilder ? $this->nextValue->build() : $this->nextValue, $this->catalogData, $this->variant, - $this->priceId + $this->priceId, + $this->price instanceof PriceBuilder ? $this->price->build() : $this->price ); } diff --git a/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChangeModel.php index 4222142df9e..1aa6d49aeb5 100644 --- a/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetDiscountedPriceChangeModel.php @@ -13,6 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use Commercetools\History\Models\Common\DiscountedPrice; +use Commercetools\History\Models\Common\DiscountedPriceModel; use Commercetools\History\Models\Common\Price; use Commercetools\History\Models\Common\PriceModel; @@ -37,13 +39,13 @@ final class SetDiscountedPriceChangeModel extends JsonObjectModel implements Set /** * - * @var ?Price + * @var ?DiscountedPrice */ protected $previousValue; /** * - * @var ?Price + * @var ?DiscountedPrice */ protected $nextValue; @@ -65,17 +67,24 @@ final class SetDiscountedPriceChangeModel extends JsonObjectModel implements Set */ protected $priceId; + /** + * + * @var ?Price + */ + protected $price; + /** * @psalm-suppress MissingParamType */ public function __construct( ?string $change = null, - ?Price $previousValue = null, - ?Price $nextValue = null, + ?DiscountedPrice $previousValue = null, + ?DiscountedPrice $nextValue = null, ?string $catalogData = null, ?string $variant = null, ?string $priceId = null, + ?Price $price = null, ?string $type = null ) { $this->change = $change; @@ -84,6 +93,7 @@ public function __construct( $this->catalogData = $catalogData; $this->variant = $variant; $this->priceId = $priceId; + $this->price = $price; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -127,7 +137,7 @@ public function getChange() *

                                                                          Value before the change.

                                                                          * * - * @return null|Price + * @return null|DiscountedPrice */ public function getPreviousValue() { @@ -138,7 +148,7 @@ public function getPreviousValue() return null; } - $this->previousValue = PriceModel::of($data); + $this->previousValue = DiscountedPriceModel::of($data); } return $this->previousValue; @@ -148,7 +158,7 @@ public function getPreviousValue() *

                                                                          Value after the change.

                                                                          * * - * @return null|Price + * @return null|DiscountedPrice */ public function getNextValue() { @@ -159,13 +169,14 @@ public function getNextValue() return null; } - $this->nextValue = PriceModel::of($data); + $this->nextValue = DiscountedPriceModel::of($data); } return $this->nextValue; } /** + *

                                                                          Product data that was updated.

                                                                          *
                                                                            *
                                                                          • staged, if the staged ProductCatalogData was updated.
                                                                          • *
                                                                          • current, if the current ProductCatalogData was updated.
                                                                          • @@ -189,7 +200,8 @@ public function getCatalogData() } /** - *

                                                                            sku or key of the updated ProductVariant.

                                                                            + *

                                                                            Identifier of the updated Product Variant.

                                                                            + *

                                                                            This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                            * * * @return null|string @@ -228,6 +240,27 @@ public function getPriceId() return $this->priceId; } + /** + *

                                                                            Embedded Price of the ProductVariant.

                                                                            + * + * + * @return null|Price + */ + public function getPrice() + { + if (is_null($this->price)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PRICE); + if (is_null($data)) { + return null; + } + + $this->price = PriceModel::of($data); + } + + return $this->price; + } + /** * @param ?string $change @@ -238,17 +271,17 @@ public function setChange(?string $change): void } /** - * @param ?Price $previousValue + * @param ?DiscountedPrice $previousValue */ - public function setPreviousValue(?Price $previousValue): void + public function setPreviousValue(?DiscountedPrice $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?Price $nextValue + * @param ?DiscountedPrice $nextValue */ - public function setNextValue(?Price $nextValue): void + public function setNextValue(?DiscountedPrice $nextValue): void { $this->nextValue = $nextValue; } @@ -277,6 +310,14 @@ public function setPriceId(?string $priceId): void $this->priceId = $priceId; } + /** + * @param ?Price $price + */ + public function setPrice(?Price $price): void + { + $this->price = $price; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChange.php b/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChange.php index b1880c871c1..fd66d6197ee 100644 --- a/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChange.php @@ -17,6 +17,8 @@ interface SetDistributionChannelsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -46,6 +48,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                            Elements added to the array.

                                                                            + * + + * @return null|ReferenceCollection + */ + public function getAddedItems(); + + /** + *

                                                                            Elements removed from the array.

                                                                            + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -60,4 +78,14 @@ public function setPreviousValue(?ReferenceCollection $previousValue): void; * @param ?ReferenceCollection $nextValue */ public function setNextValue(?ReferenceCollection $nextValue): void; + + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void; + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChangeBuilder.php index 6a26dda87ea..9bbf9e505b7 100644 --- a/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChangeBuilder.php @@ -39,6 +39,18 @@ final class SetDistributionChannelsChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?ReferenceCollection + */ + private $addedItems; + + /** + + * @var ?ReferenceCollection + */ + private $removedItems; + /** * @return null|string @@ -70,6 +82,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                            Elements added to the array.

                                                                            + * + + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                            Elements removed from the array.

                                                                            + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -103,13 +137,37 @@ public function withNextValue(?ReferenceCollection $nextValue) return $this; } + /** + * @param ?ReferenceCollection $addedItems + * @return $this + */ + public function withAddedItems(?ReferenceCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?ReferenceCollection $removedItems + * @return $this + */ + public function withRemovedItems(?ReferenceCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetDistributionChannelsChange { return new SetDistributionChannelsChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChangeModel.php index 3ef4044d1ce..d3752805544 100644 --- a/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetDistributionChannelsChangeModel.php @@ -46,6 +46,18 @@ final class SetDistributionChannelsChangeModel extends JsonObjectModel implement */ protected $nextValue; + /** + * + * @var ?ReferenceCollection + */ + protected $addedItems; + + /** + * + * @var ?ReferenceCollection + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -54,11 +66,15 @@ public function __construct( ?string $change = null, ?ReferenceCollection $previousValue = null, ?ReferenceCollection $nextValue = null, + ?ReferenceCollection $addedItems = null, + ?ReferenceCollection $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -138,6 +154,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                            Elements added to the array.

                                                                            + * + * + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = ReferenceCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                            Elements removed from the array.

                                                                            + * + * + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = ReferenceCollection::fromArray($data); + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -163,6 +219,22 @@ public function setNextValue(?ReferenceCollection $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetImageLabelChange.php b/lib/commercetools-history/src/Models/Change/SetImageLabelChange.php index 86a77248ccd..733086f0ffa 100644 --- a/lib/commercetools-history/src/Models/Change/SetImageLabelChange.php +++ b/lib/commercetools-history/src/Models/Change/SetImageLabelChange.php @@ -18,6 +18,7 @@ interface SetImageLabelChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -48,6 +49,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                                            Product data that was updated.

                                                                            *
                                                                              *
                                                                            • staged, if the staged ProductCatalogData was updated.
                                                                            • *
                                                                            • current, if the current ProductCatalogData was updated.
                                                                            • @@ -58,6 +60,15 @@ public function getNextValue(); */ public function getCatalogData(); + /** + *

                                                                              Identifier of the updated Product Variant.

                                                                              + *

                                                                              This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                              + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -77,4 +88,9 @@ public function setNextValue(?Image $nextValue): void; * @param ?string $catalogData */ public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetImageLabelChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetImageLabelChangeBuilder.php index 68766ecb886..33870599487 100644 --- a/lib/commercetools-history/src/Models/Change/SetImageLabelChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetImageLabelChangeBuilder.php @@ -46,6 +46,12 @@ final class SetImageLabelChangeBuilder implements Builder */ private $catalogData; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -78,6 +84,7 @@ public function getNextValue() } /** + *

                                                                              Product data that was updated.

                                                                              *
                                                                                *
                                                                              • staged, if the staged ProductCatalogData was updated.
                                                                              • *
                                                                              • current, if the current ProductCatalogData was updated.
                                                                              • @@ -91,6 +98,18 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                Identifier of the updated Product Variant.

                                                                                + *

                                                                                This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -135,6 +154,17 @@ public function withCatalogData(?string $catalogData) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -163,7 +193,8 @@ public function build(): SetImageLabelChange $this->change, $this->previousValue instanceof ImageBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof ImageBuilder ? $this->nextValue->build() : $this->nextValue, - $this->catalogData + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetImageLabelChangeModel.php b/lib/commercetools-history/src/Models/Change/SetImageLabelChangeModel.php index 0402433377c..624ae8da1b7 100644 --- a/lib/commercetools-history/src/Models/Change/SetImageLabelChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetImageLabelChangeModel.php @@ -53,6 +53,12 @@ final class SetImageLabelChangeModel extends JsonObjectModel implements SetImage */ protected $catalogData; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -62,12 +68,14 @@ public function __construct( ?Image $previousValue = null, ?Image $nextValue = null, ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -150,6 +158,7 @@ public function getNextValue() } /** + *

                                                                                Product data that was updated.

                                                                                *
                                                                                  *
                                                                                • staged, if the staged ProductCatalogData was updated.
                                                                                • *
                                                                                • current, if the current ProductCatalogData was updated.
                                                                                • @@ -172,6 +181,27 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -205,6 +235,14 @@ public function setCatalogData(?string $catalogData): void $this->catalogData = $catalogData; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChange.php b/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChange.php new file mode 100644 index 00000000000..9a5e0406421 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChange.php @@ -0,0 +1,91 @@ +Elements added to the array.

                                                                                  + * + + * @return null|InheritedAssociateCollection + */ + public function getAddedItems(); + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + + * @return null|InheritedAssociateCollection + */ + public function getRemovedItems(); + + /** + *

                                                                                  Value before the change.

                                                                                  + * + + * @return null|InheritedAssociateCollection + */ + public function getPreviousValue(); + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|InheritedAssociateCollection + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?InheritedAssociateCollection $addedItems + */ + public function setAddedItems(?InheritedAssociateCollection $addedItems): void; + + /** + * @param ?InheritedAssociateCollection $removedItems + */ + public function setRemovedItems(?InheritedAssociateCollection $removedItems): void; + + /** + * @param ?InheritedAssociateCollection $previousValue + */ + public function setPreviousValue(?InheritedAssociateCollection $previousValue): void; + + /** + * @param ?InheritedAssociateCollection $nextValue + */ + public function setNextValue(?InheritedAssociateCollection $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChangeBuilder.php new file mode 100644 index 00000000000..fc5172f8599 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChangeBuilder.php @@ -0,0 +1,178 @@ + + */ +final class SetInheritedAssociatesChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?InheritedAssociateCollection + */ + private $addedItems; + + /** + + * @var ?InheritedAssociateCollection + */ + private $removedItems; + + /** + + * @var ?InheritedAssociateCollection + */ + private $previousValue; + + /** + + * @var ?InheritedAssociateCollection + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + + * @return null|InheritedAssociateCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + + * @return null|InheritedAssociateCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + + /** + *

                                                                                  Value before the change.

                                                                                  + * + + * @return null|InheritedAssociateCollection + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|InheritedAssociateCollection + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?InheritedAssociateCollection $addedItems + * @return $this + */ + public function withAddedItems(?InheritedAssociateCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?InheritedAssociateCollection $removedItems + * @return $this + */ + public function withRemovedItems(?InheritedAssociateCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + + /** + * @param ?InheritedAssociateCollection $previousValue + * @return $this + */ + public function withPreviousValue(?InheritedAssociateCollection $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?InheritedAssociateCollection $nextValue + * @return $this + */ + public function withNextValue(?InheritedAssociateCollection $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetInheritedAssociatesChange + { + return new SetInheritedAssociatesChangeModel( + $this->change, + $this->addedItems, + $this->removedItems, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetInheritedAssociatesChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChangeCollection.php new file mode 100644 index 00000000000..428ae5aeb85 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetInheritedAssociatesChange current() + * @method SetInheritedAssociatesChange end() + * @method SetInheritedAssociatesChange at($offset) + */ +class SetInheritedAssociatesChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetInheritedAssociatesChange $value + * @psalm-param SetInheritedAssociatesChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetInheritedAssociatesChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetInheritedAssociatesChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetInheritedAssociatesChange + */ + protected function mapper() + { + return function (?int $index): ?SetInheritedAssociatesChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetInheritedAssociatesChange $data */ + $data = SetInheritedAssociatesChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChangeModel.php b/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChangeModel.php new file mode 100644 index 00000000000..bef51eb6aec --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetInheritedAssociatesChangeModel.php @@ -0,0 +1,240 @@ +change = $change; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + * + * @return null|InheritedAssociateCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = InheritedAssociateCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + * + * @return null|InheritedAssociateCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = InheritedAssociateCollection::fromArray($data); + } + + return $this->removedItems; + } + + /** + *

                                                                                  Value before the change.

                                                                                  + * + * + * @return null|InheritedAssociateCollection + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = InheritedAssociateCollection::fromArray($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|InheritedAssociateCollection + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = InheritedAssociateCollection::fromArray($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?InheritedAssociateCollection $addedItems + */ + public function setAddedItems(?InheritedAssociateCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?InheritedAssociateCollection $removedItems + */ + public function setRemovedItems(?InheritedAssociateCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + + /** + * @param ?InheritedAssociateCollection $previousValue + */ + public function setPreviousValue(?InheritedAssociateCollection $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?InheritedAssociateCollection $nextValue + */ + public function setNextValue(?InheritedAssociateCollection $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetInheritedStoresChange.php b/lib/commercetools-history/src/Models/Change/SetInheritedStoresChange.php new file mode 100644 index 00000000000..e1a6dc22728 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetInheritedStoresChange.php @@ -0,0 +1,91 @@ +Elements added to the array.

                                                                                  + * + + * @return null|KeyReferenceCollection + */ + public function getAddedItems(); + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + + * @return null|KeyReferenceCollection + */ + public function getRemovedItems(); + + /** + *

                                                                                  Value before the change.

                                                                                  + * + + * @return null|KeyReferenceCollection + */ + public function getPreviousValue(); + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|KeyReferenceCollection + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?KeyReferenceCollection $addedItems + */ + public function setAddedItems(?KeyReferenceCollection $addedItems): void; + + /** + * @param ?KeyReferenceCollection $removedItems + */ + public function setRemovedItems(?KeyReferenceCollection $removedItems): void; + + /** + * @param ?KeyReferenceCollection $previousValue + */ + public function setPreviousValue(?KeyReferenceCollection $previousValue): void; + + /** + * @param ?KeyReferenceCollection $nextValue + */ + public function setNextValue(?KeyReferenceCollection $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetInheritedStoresChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetInheritedStoresChangeBuilder.php new file mode 100644 index 00000000000..ef62f7718d3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetInheritedStoresChangeBuilder.php @@ -0,0 +1,178 @@ + + */ +final class SetInheritedStoresChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?KeyReferenceCollection + */ + private $addedItems; + + /** + + * @var ?KeyReferenceCollection + */ + private $removedItems; + + /** + + * @var ?KeyReferenceCollection + */ + private $previousValue; + + /** + + * @var ?KeyReferenceCollection + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + + * @return null|KeyReferenceCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + + * @return null|KeyReferenceCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + + /** + *

                                                                                  Value before the change.

                                                                                  + * + + * @return null|KeyReferenceCollection + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|KeyReferenceCollection + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?KeyReferenceCollection $addedItems + * @return $this + */ + public function withAddedItems(?KeyReferenceCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?KeyReferenceCollection $removedItems + * @return $this + */ + public function withRemovedItems(?KeyReferenceCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + + /** + * @param ?KeyReferenceCollection $previousValue + * @return $this + */ + public function withPreviousValue(?KeyReferenceCollection $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?KeyReferenceCollection $nextValue + * @return $this + */ + public function withNextValue(?KeyReferenceCollection $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetInheritedStoresChange + { + return new SetInheritedStoresChangeModel( + $this->change, + $this->addedItems, + $this->removedItems, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetInheritedStoresChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetInheritedStoresChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetInheritedStoresChangeCollection.php new file mode 100644 index 00000000000..1baf49bac84 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetInheritedStoresChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetInheritedStoresChange current() + * @method SetInheritedStoresChange end() + * @method SetInheritedStoresChange at($offset) + */ +class SetInheritedStoresChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetInheritedStoresChange $value + * @psalm-param SetInheritedStoresChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetInheritedStoresChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetInheritedStoresChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetInheritedStoresChange + */ + protected function mapper() + { + return function (?int $index): ?SetInheritedStoresChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetInheritedStoresChange $data */ + $data = SetInheritedStoresChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetInheritedStoresChangeModel.php b/lib/commercetools-history/src/Models/Change/SetInheritedStoresChangeModel.php new file mode 100644 index 00000000000..6cd98f3101f --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetInheritedStoresChangeModel.php @@ -0,0 +1,240 @@ +change = $change; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + * + * @return null|KeyReferenceCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = KeyReferenceCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + * + * @return null|KeyReferenceCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = KeyReferenceCollection::fromArray($data); + } + + return $this->removedItems; + } + + /** + *

                                                                                  Value before the change.

                                                                                  + * + * + * @return null|KeyReferenceCollection + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = KeyReferenceCollection::fromArray($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|KeyReferenceCollection + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = KeyReferenceCollection::fromArray($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?KeyReferenceCollection $addedItems + */ + public function setAddedItems(?KeyReferenceCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?KeyReferenceCollection $removedItems + */ + public function setRemovedItems(?KeyReferenceCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + + /** + * @param ?KeyReferenceCollection $previousValue + */ + public function setPreviousValue(?KeyReferenceCollection $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?KeyReferenceCollection $nextValue + */ + public function setNextValue(?KeyReferenceCollection $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChange.php new file mode 100644 index 00000000000..67e0e14a989 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChange.php @@ -0,0 +1,104 @@ +id of the updated Address.

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

                                                                                  Name of the Custom Field.

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

                                                                                  id of the referenced Type.

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

                                                                                  Value before the change.

                                                                                  + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $addressId + */ + public function setAddressId(?string $addressId): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..e515bda26f7 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChangeBuilder.php @@ -0,0 +1,206 @@ + + */ +final class SetItemShippingAddressCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $addressId; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  id of the updated Address.

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

                                                                                  Name of the Custom Field.

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

                                                                                  id of the referenced Type.

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

                                                                                  Value before the change.

                                                                                  + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $addressId + * @return $this + */ + public function withAddressId(?string $addressId) + { + $this->addressId = $addressId; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetItemShippingAddressCustomFieldChange + { + return new SetItemShippingAddressCustomFieldChangeModel( + $this->change, + $this->addressId, + $this->name, + $this->customTypeId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetItemShippingAddressCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChangeCollection.php new file mode 100644 index 00000000000..07fdadaa325 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetItemShippingAddressCustomFieldChange current() + * @method SetItemShippingAddressCustomFieldChange end() + * @method SetItemShippingAddressCustomFieldChange at($offset) + */ +class SetItemShippingAddressCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetItemShippingAddressCustomFieldChange $value + * @psalm-param SetItemShippingAddressCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetItemShippingAddressCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetItemShippingAddressCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetItemShippingAddressCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetItemShippingAddressCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetItemShippingAddressCustomFieldChange $data */ + $data = SetItemShippingAddressCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChangeModel.php new file mode 100644 index 00000000000..978958db02d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomFieldChangeModel.php @@ -0,0 +1,275 @@ +change = $change; + $this->addressId = $addressId; + $this->name = $name; + $this->customTypeId = $customTypeId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  id of the updated Address.

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

                                                                                  Name of the Custom Field.

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

                                                                                  id of the referenced Type.

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

                                                                                  Value before the change.

                                                                                  + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $addressId + */ + public function setAddressId(?string $addressId): void + { + $this->addressId = $addressId; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChange.php new file mode 100644 index 00000000000..a899d00c778 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChange.php @@ -0,0 +1,77 @@ +id of the updated Address.

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

                                                                                  Value before the change.

                                                                                  + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $addressId + */ + public function setAddressId(?string $addressId): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..6e3af7ecc85 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChangeBuilder.php @@ -0,0 +1,171 @@ + + */ +final class SetItemShippingAddressCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $addressId; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  id of the updated Address.

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

                                                                                  Value before the change.

                                                                                  + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $addressId + * @return $this + */ + public function withAddressId(?string $addressId) + { + $this->addressId = $addressId; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetItemShippingAddressCustomTypeChange + { + return new SetItemShippingAddressCustomTypeChangeModel( + $this->change, + $this->addressId, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetItemShippingAddressCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChangeCollection.php new file mode 100644 index 00000000000..9b448362ebf --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetItemShippingAddressCustomTypeChange current() + * @method SetItemShippingAddressCustomTypeChange end() + * @method SetItemShippingAddressCustomTypeChange at($offset) + */ +class SetItemShippingAddressCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetItemShippingAddressCustomTypeChange $value + * @psalm-param SetItemShippingAddressCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetItemShippingAddressCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetItemShippingAddressCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetItemShippingAddressCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetItemShippingAddressCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetItemShippingAddressCustomTypeChange $data */ + $data = SetItemShippingAddressCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChangeModel.php new file mode 100644 index 00000000000..bf18d7d2efd --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetItemShippingAddressCustomTypeChangeModel.php @@ -0,0 +1,207 @@ +change = $change; + $this->addressId = $addressId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  id of the updated Address.

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

                                                                                  Value before the change.

                                                                                  + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $addressId + */ + public function setAddressId(?string $addressId): void + { + $this->addressId = $addressId; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetLanguagesChange.php b/lib/commercetools-history/src/Models/Change/SetLanguagesChange.php index d4f3581c9c1..d66290d148e 100644 --- a/lib/commercetools-history/src/Models/Change/SetLanguagesChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLanguagesChange.php @@ -16,6 +16,8 @@ interface SetLanguagesChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -45,6 +47,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + + * @return null|array + */ + public function getAddedItems(); + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + + * @return null|array + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -59,4 +77,14 @@ public function setPreviousValue(?array $previousValue): void; * @param ?array $nextValue */ public function setNextValue(?array $nextValue): void; + + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void; + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLanguagesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLanguagesChangeBuilder.php index 84392836147..ce570d34b14 100644 --- a/lib/commercetools-history/src/Models/Change/SetLanguagesChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLanguagesChangeBuilder.php @@ -38,6 +38,18 @@ final class SetLanguagesChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?array + */ + private $addedItems; + + /** + + * @var ?array + */ + private $removedItems; + /** * @return null|string @@ -69,6 +81,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + + * @return null|array + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + + * @return null|array + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -102,13 +136,37 @@ public function withNextValue(?array $nextValue) return $this; } + /** + * @param ?array $addedItems + * @return $this + */ + public function withAddedItems(?array $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?array $removedItems + * @return $this + */ + public function withRemovedItems(?array $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetLanguagesChange { return new SetLanguagesChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLanguagesChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLanguagesChangeModel.php index c876cb317d8..61f993c5720 100644 --- a/lib/commercetools-history/src/Models/Change/SetLanguagesChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLanguagesChangeModel.php @@ -45,6 +45,18 @@ final class SetLanguagesChangeModel extends JsonObjectModel implements SetLangua */ protected $nextValue; + /** + * + * @var ?array + */ + protected $addedItems; + + /** + * + * @var ?array + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -53,11 +65,15 @@ public function __construct( ?string $change = null, ?array $previousValue = null, ?array $nextValue = null, + ?array $addedItems = null, + ?array $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -137,6 +153,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + * + * @return null|array + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = $data; + } + + return $this->addedItems; + } + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + * + * @return null|array + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = $data; + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -162,6 +218,22 @@ public function setNextValue(?array $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChange.php index d05cbe86a97..baa303b577a 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChange.php @@ -20,6 +20,7 @@ interface SetLineItemDiscountedPriceChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_LINE_ITEM = 'lineItem'; public const FIELD_VARIANT = 'variant'; + public const FIELD_LINE_ITEM_ID = 'lineItemId'; /** @@ -58,13 +59,22 @@ public function getNextValue(); public function getLineItem(); /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId(); + /** * @param ?string $change */ @@ -89,4 +99,9 @@ public function setLineItem(?LocalizedString $lineItem): void; * @param ?string $variant */ public function setVariant(?string $variant): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChangeBuilder.php index 0cda98e9fe0..62f81b556bf 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChangeBuilder.php @@ -54,6 +54,12 @@ final class SetLineItemDiscountedPriceChangeBuilder implements Builder */ private $variant; + /** + + * @var ?string + */ + private $lineItemId; + /** * @return null|string @@ -97,7 +103,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string @@ -107,6 +114,17 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId() + { + return $this->lineItemId; + } + /** * @param ?string $change * @return $this @@ -162,6 +180,17 @@ public function withVariant(?string $variant) return $this; } + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -202,7 +231,8 @@ public function build(): SetLineItemDiscountedPriceChange $this->previousValue instanceof DiscountedLineItemPriceBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof DiscountedLineItemPriceBuilder ? $this->nextValue->build() : $this->nextValue, $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, - $this->variant + $this->variant, + $this->lineItemId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChangeModel.php index c11e77a1b87..bf699db7bec 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPriceChangeModel.php @@ -61,6 +61,12 @@ final class SetLineItemDiscountedPriceChangeModel extends JsonObjectModel implem */ protected $variant; + /** + * + * @var ?string + */ + protected $lineItemId; + /** * @psalm-suppress MissingParamType @@ -71,6 +77,7 @@ public function __construct( ?DiscountedLineItemPrice $nextValue = null, ?LocalizedString $lineItem = null, ?string $variant = null, + ?string $lineItemId = null, ?string $type = null ) { $this->change = $change; @@ -78,6 +85,7 @@ public function __construct( $this->nextValue = $nextValue; $this->lineItem = $lineItem; $this->variant = $variant; + $this->lineItemId = $lineItemId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -181,7 +189,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * * @return null|string @@ -200,6 +209,26 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + * + * @return null|string + */ + public function getLineItemId() + { + if (is_null($this->lineItemId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LINE_ITEM_ID); + if (is_null($data)) { + return null; + } + $this->lineItemId = (string) $data; + } + + return $this->lineItemId; + } + /** * @param ?string $change @@ -241,6 +270,14 @@ public function setVariant(?string $variant): void $this->variant = $variant; } + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChange.php index 3ff24af76c6..a145983ebdc 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChange.php @@ -20,6 +20,7 @@ interface SetLineItemDiscountedPricePerQuantityChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_LINE_ITEM = 'lineItem'; public const FIELD_VARIANT = 'variant'; + public const FIELD_LINE_ITEM_ID = 'lineItemId'; /** @@ -58,13 +59,22 @@ public function getNextValue(); public function getLineItem(); /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId(); + /** * @param ?string $change */ @@ -89,4 +99,9 @@ public function setLineItem(?LocalizedString $lineItem): void; * @param ?string $variant */ public function setVariant(?string $variant): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChangeBuilder.php index 5b7f257598c..6d3d92f9581 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChangeBuilder.php @@ -54,6 +54,12 @@ final class SetLineItemDiscountedPricePerQuantityChangeBuilder implements Builde */ private $variant; + /** + + * @var ?string + */ + private $lineItemId; + /** * @return null|string @@ -97,7 +103,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string @@ -107,6 +114,17 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId() + { + return $this->lineItemId; + } + /** * @param ?string $change * @return $this @@ -162,6 +180,17 @@ public function withVariant(?string $variant) return $this; } + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -202,7 +231,8 @@ public function build(): SetLineItemDiscountedPricePerQuantityChange $this->previousValue instanceof DiscountedLineItemPriceForQuantityBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof DiscountedLineItemPriceForQuantityBuilder ? $this->nextValue->build() : $this->nextValue, $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, - $this->variant + $this->variant, + $this->lineItemId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChangeModel.php index 83c03a2266f..e096e5aa75b 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemDiscountedPricePerQuantityChangeModel.php @@ -61,6 +61,12 @@ final class SetLineItemDiscountedPricePerQuantityChangeModel extends JsonObjectM */ protected $variant; + /** + * + * @var ?string + */ + protected $lineItemId; + /** * @psalm-suppress MissingParamType @@ -71,6 +77,7 @@ public function __construct( ?DiscountedLineItemPriceForQuantity $nextValue = null, ?LocalizedString $lineItem = null, ?string $variant = null, + ?string $lineItemId = null, ?string $type = null ) { $this->change = $change; @@ -78,6 +85,7 @@ public function __construct( $this->nextValue = $nextValue; $this->lineItem = $lineItem; $this->variant = $variant; + $this->lineItemId = $lineItemId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -181,7 +189,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * * @return null|string @@ -200,6 +209,26 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + * + * @return null|string + */ + public function getLineItemId() + { + if (is_null($this->lineItemId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LINE_ITEM_ID); + if (is_null($data)) { + return null; + } + $this->lineItemId = (string) $data; + } + + return $this->lineItemId; + } + /** * @param ?string $change @@ -241,6 +270,14 @@ public function setVariant(?string $variant): void $this->variant = $variant; } + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChange.php index b10aaaa7a13..6b5d5809c1e 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChange.php @@ -58,7 +58,8 @@ public function getNextValue(); public function getLineItem(); /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChangeBuilder.php index 980f454bd39..2d7233c1905 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChangeBuilder.php @@ -97,7 +97,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChangeModel.php index 812ecec2f80..020ee3b5410 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemDistributionChannelChangeModel.php @@ -131,8 +131,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -152,8 +152,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; @@ -181,7 +181,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * * @return null|string diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemPriceChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemPriceChange.php index 691cdcc9fc8..c95e5ff249e 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemPriceChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemPriceChange.php @@ -19,6 +19,7 @@ interface SetLineItemPriceChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_LINE_ITEM = 'lineItem'; + public const FIELD_LINE_ITEM_ID = 'lineItemId'; /** @@ -56,6 +57,14 @@ public function getNextValue(); */ public function getLineItem(); + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId(); + /** * @param ?string $change */ @@ -75,4 +84,9 @@ public function setNextValue(?Price $nextValue): void; * @param ?LocalizedString $lineItem */ public function setLineItem(?LocalizedString $lineItem): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemPriceChangeBuilder.php index 4591dad46f7..8d897aa797f 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemPriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemPriceChangeBuilder.php @@ -48,6 +48,12 @@ final class SetLineItemPriceChangeBuilder implements Builder */ private $lineItem; + /** + + * @var ?string + */ + private $lineItemId; + /** * @return null|string @@ -90,6 +96,17 @@ public function getLineItem() return $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId() + { + return $this->lineItemId; + } + /** * @param ?string $change * @return $this @@ -134,6 +151,17 @@ public function withLineItem(?LocalizedString $lineItem) return $this; } + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -173,7 +201,8 @@ public function build(): SetLineItemPriceChange $this->change, $this->previousValue instanceof PriceBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof PriceBuilder ? $this->nextValue->build() : $this->nextValue, - $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem + $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, + $this->lineItemId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemPriceChangeModel.php index 4dfc1fd0c33..d0dc73029fb 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemPriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemPriceChangeModel.php @@ -55,6 +55,12 @@ final class SetLineItemPriceChangeModel extends JsonObjectModel implements SetLi */ protected $lineItem; + /** + * + * @var ?string + */ + protected $lineItemId; + /** * @psalm-suppress MissingParamType @@ -64,12 +70,14 @@ public function __construct( ?Price $previousValue = null, ?Price $nextValue = null, ?LocalizedString $lineItem = null, + ?string $lineItemId = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->lineItem = $lineItem; + $this->lineItemId = $lineItemId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -172,6 +180,26 @@ public function getLineItem() return $this->lineItem; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + * + * @return null|string + */ + public function getLineItemId() + { + if (is_null($this->lineItemId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LINE_ITEM_ID); + if (is_null($data)) { + return null; + } + $this->lineItemId = (string) $data; + } + + return $this->lineItemId; + } + /** * @param ?string $change @@ -205,6 +233,14 @@ public function setLineItem(?LocalizedString $lineItem): void $this->lineItem = $lineItem; } + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChange.php index b685be3d057..645a8528e27 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChange.php @@ -66,7 +66,8 @@ public function getLineItem(); public function getLineItemId(); /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChangeBuilder.php index 56c13b8aafd..d64a5566bf3 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChangeBuilder.php @@ -112,7 +112,8 @@ public function getLineItemId() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChangeModel.php index 39d42048fad..0e55f1ddd3d 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemProductKeyChangeModel.php @@ -205,7 +205,8 @@ public function getLineItemId() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * * @return null|string diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChange.php index 6b6a816403b..7144feed4b0 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChange.php @@ -19,6 +19,7 @@ interface SetLineItemProductSlugChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_LINE_ITEM = 'lineItem'; public const FIELD_VARIANT = 'variant'; + public const FIELD_LINE_ITEM_ID = 'lineItemId'; /** @@ -57,13 +58,22 @@ public function getNextValue(); public function getLineItem(); /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId(); + /** * @param ?string $change */ @@ -88,4 +98,9 @@ public function setLineItem(?LocalizedString $lineItem): void; * @param ?string $variant */ public function setVariant(?string $variant): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChangeBuilder.php index 4449ba678fd..63b2f0170ce 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChangeBuilder.php @@ -52,6 +52,12 @@ final class SetLineItemProductSlugChangeBuilder implements Builder */ private $variant; + /** + + * @var ?string + */ + private $lineItemId; + /** * @return null|string @@ -95,7 +101,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string @@ -105,6 +112,17 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId() + { + return $this->lineItemId; + } + /** * @param ?string $change * @return $this @@ -160,6 +178,17 @@ public function withVariant(?string $variant) return $this; } + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -200,7 +229,8 @@ public function build(): SetLineItemProductSlugChange $this->previousValue instanceof LocalizedStringBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue, $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, - $this->variant + $this->variant, + $this->lineItemId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChangeModel.php index 8a3bf815729..c5028883532 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemProductSlugChangeModel.php @@ -59,6 +59,12 @@ final class SetLineItemProductSlugChangeModel extends JsonObjectModel implements */ protected $variant; + /** + * + * @var ?string + */ + protected $lineItemId; + /** * @psalm-suppress MissingParamType @@ -69,6 +75,7 @@ public function __construct( ?LocalizedString $nextValue = null, ?LocalizedString $lineItem = null, ?string $variant = null, + ?string $lineItemId = null, ?string $type = null ) { $this->change = $change; @@ -76,6 +83,7 @@ public function __construct( $this->nextValue = $nextValue; $this->lineItem = $lineItem; $this->variant = $variant; + $this->lineItemId = $lineItemId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -179,7 +187,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the updated ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * * @return null|string @@ -198,6 +207,26 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + * + * @return null|string + */ + public function getLineItemId() + { + if (is_null($this->lineItemId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LINE_ITEM_ID); + if (is_null($data)) { + return null; + } + $this->lineItemId = (string) $data; + } + + return $this->lineItemId; + } + /** * @param ?string $change @@ -239,6 +268,14 @@ public function setVariant(?string $variant): void $this->variant = $variant; } + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChange.php index 03c33f93139..83f05aff475 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChange.php @@ -11,6 +11,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\History\Models\Common\ItemShippingDetails; +use Commercetools\History\Models\Common\LocalizedString; interface SetLineItemShippingDetailsChange extends Change { @@ -18,6 +19,8 @@ interface SetLineItemShippingDetailsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_LINE_ITEM_ID = 'lineItemId'; + public const FIELD_LINE_ITEM = 'lineItem'; + public const FIELD_VARIANT = 'variant'; /** @@ -55,6 +58,23 @@ public function getNextValue(); */ public function getLineItemId(); + /** + *

                                                                                  Name of the Product the updated Line Item is based on.

                                                                                  + * + + * @return null|LocalizedString + */ + public function getLineItem(); + + /** + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -74,4 +94,14 @@ public function setNextValue(?ItemShippingDetails $nextValue): void; * @param ?string $lineItemId */ public function setLineItemId(?string $lineItemId): void; + + /** + * @param ?LocalizedString $lineItem + */ + public function setLineItem(?LocalizedString $lineItem): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChangeBuilder.php index 7a413ee90b2..25645e62868 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChangeBuilder.php @@ -16,6 +16,8 @@ use stdClass; use Commercetools\History\Models\Common\ItemShippingDetails; use Commercetools\History\Models\Common\ItemShippingDetailsBuilder; +use Commercetools\History\Models\Common\LocalizedString; +use Commercetools\History\Models\Common\LocalizedStringBuilder; /** * @implements Builder @@ -46,6 +48,18 @@ final class SetLineItemShippingDetailsChangeBuilder implements Builder */ private $lineItemId; + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $lineItem; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -88,6 +102,29 @@ public function getLineItemId() return $this->lineItemId; } + /** + *

                                                                                  Name of the Product the updated Line Item is based on.

                                                                                  + * + + * @return null|LocalizedString + */ + public function getLineItem() + { + return $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem; + } + + /** + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -132,6 +169,28 @@ public function withLineItemId(?string $lineItemId) return $this; } + /** + * @param ?LocalizedString $lineItem + * @return $this + */ + public function withLineItem(?LocalizedString $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -154,13 +213,26 @@ public function withNextValueBuilder(?ItemShippingDetailsBuilder $nextValue) return $this; } + /** + * @deprecated use withLineItem() instead + * @return $this + */ + public function withLineItemBuilder(?LocalizedStringBuilder $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + public function build(): SetLineItemShippingDetailsChange { return new SetLineItemShippingDetailsChangeModel( $this->change, $this->previousValue instanceof ItemShippingDetailsBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof ItemShippingDetailsBuilder ? $this->nextValue->build() : $this->nextValue, - $this->lineItemId + $this->lineItemId, + $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChangeModel.php index b0dbfc76399..5f616abc7bd 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemShippingDetailsChangeModel.php @@ -15,6 +15,8 @@ use stdClass; use Commercetools\History\Models\Common\ItemShippingDetails; use Commercetools\History\Models\Common\ItemShippingDetailsModel; +use Commercetools\History\Models\Common\LocalizedString; +use Commercetools\History\Models\Common\LocalizedStringModel; /** * @internal @@ -53,6 +55,18 @@ final class SetLineItemShippingDetailsChangeModel extends JsonObjectModel implem */ protected $lineItemId; + /** + * + * @var ?LocalizedString + */ + protected $lineItem; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -62,12 +76,16 @@ public function __construct( ?ItemShippingDetails $previousValue = null, ?ItemShippingDetails $nextValue = null, ?string $lineItemId = null, + ?LocalizedString $lineItem = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->lineItemId = $lineItemId; + $this->lineItem = $lineItem; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -169,6 +187,48 @@ public function getLineItemId() return $this->lineItemId; } + /** + *

                                                                                  Name of the Product the updated Line Item is based on.

                                                                                  + * + * + * @return null|LocalizedString + */ + 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 = LocalizedStringModel::of($data); + } + + return $this->lineItem; + } + + /** + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -202,6 +262,22 @@ public function setLineItemId(?string $lineItemId): void $this->lineItemId = $lineItemId; } + /** + * @param ?LocalizedString $lineItem + */ + public function setLineItem(?LocalizedString $lineItem): void + { + $this->lineItem = $lineItem; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChange.php index ba21048a68a..660251c8c17 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChange.php @@ -21,6 +21,7 @@ interface SetLineItemTaxAmountChange extends Change public const FIELD_LINE_ITEM = 'lineItem'; public const FIELD_VARIANT = 'variant'; public const FIELD_TAX_MODE = 'taxMode'; + public const FIELD_LINE_ITEM_ID = 'lineItemId'; /** @@ -59,7 +60,8 @@ public function getNextValue(); public function getLineItem(); /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string @@ -74,6 +76,14 @@ public function getVariant(); */ public function getTaxMode(); + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId(); + /** * @param ?string $change */ @@ -103,4 +113,9 @@ public function setVariant(?string $variant): void; * @param ?string $taxMode */ public function setTaxMode(?string $taxMode): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChangeBuilder.php index ce0cd7eb45d..ae4c52c0660 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChangeBuilder.php @@ -60,6 +60,12 @@ final class SetLineItemTaxAmountChangeBuilder implements Builder */ private $taxMode; + /** + + * @var ?string + */ + private $lineItemId; + /** * @return null|string @@ -103,7 +109,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string @@ -124,6 +131,17 @@ public function getTaxMode() return $this->taxMode; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId() + { + return $this->lineItemId; + } + /** * @param ?string $change * @return $this @@ -190,6 +208,17 @@ public function withTaxMode(?string $taxMode) return $this; } + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -231,7 +260,8 @@ public function build(): SetLineItemTaxAmountChange $this->nextValue instanceof TaxRateBuilder ? $this->nextValue->build() : $this->nextValue, $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, $this->variant, - $this->taxMode + $this->taxMode, + $this->lineItemId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChangeModel.php index 8d47734a1bf..3661c2d4bf3 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTaxAmountChangeModel.php @@ -67,6 +67,12 @@ final class SetLineItemTaxAmountChangeModel extends JsonObjectModel implements S */ protected $taxMode; + /** + * + * @var ?string + */ + protected $lineItemId; + /** * @psalm-suppress MissingParamType @@ -78,6 +84,7 @@ public function __construct( ?LocalizedString $lineItem = null, ?string $variant = null, ?string $taxMode = null, + ?string $lineItemId = null, ?string $type = null ) { $this->change = $change; @@ -86,6 +93,7 @@ public function __construct( $this->lineItem = $lineItem; $this->variant = $variant; $this->taxMode = $taxMode; + $this->lineItemId = $lineItemId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -189,7 +197,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * * @return null|string @@ -228,6 +237,26 @@ public function getTaxMode() return $this->taxMode; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + * + * @return null|string + */ + public function getLineItemId() + { + if (is_null($this->lineItemId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LINE_ITEM_ID); + if (is_null($data)) { + return null; + } + $this->lineItemId = (string) $data; + } + + return $this->lineItemId; + } + /** * @param ?string $change @@ -277,6 +306,14 @@ public function setTaxMode(?string $taxMode): void $this->taxMode = $taxMode; } + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChange.php index 8de58d1c501..26c67fe66e5 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChange.php @@ -21,6 +21,7 @@ interface SetLineItemTaxRateChange extends Change public const FIELD_LINE_ITEM = 'lineItem'; public const FIELD_VARIANT = 'variant'; public const FIELD_TAX_MODE = 'taxMode'; + public const FIELD_LINE_ITEM_ID = 'lineItemId'; /** @@ -59,7 +60,8 @@ public function getNextValue(); public function getLineItem(); /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string @@ -74,6 +76,14 @@ public function getVariant(); */ public function getTaxMode(); + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId(); + /** * @param ?string $change */ @@ -103,4 +113,9 @@ public function setVariant(?string $variant): void; * @param ?string $taxMode */ public function setTaxMode(?string $taxMode): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChangeBuilder.php index 25f3d4c2aa4..6032707b6e2 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChangeBuilder.php @@ -60,6 +60,12 @@ final class SetLineItemTaxRateChangeBuilder implements Builder */ private $taxMode; + /** + + * @var ?string + */ + private $lineItemId; + /** * @return null|string @@ -103,7 +109,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string @@ -124,6 +131,17 @@ public function getTaxMode() return $this->taxMode; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId() + { + return $this->lineItemId; + } + /** * @param ?string $change * @return $this @@ -190,6 +208,17 @@ public function withTaxMode(?string $taxMode) return $this; } + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -231,7 +260,8 @@ public function build(): SetLineItemTaxRateChange $this->nextValue instanceof TaxRateBuilder ? $this->nextValue->build() : $this->nextValue, $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, $this->variant, - $this->taxMode + $this->taxMode, + $this->lineItemId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChangeModel.php index b8e3ecfd3b4..266010bf190 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTaxRateChangeModel.php @@ -67,6 +67,12 @@ final class SetLineItemTaxRateChangeModel extends JsonObjectModel implements Set */ protected $taxMode; + /** + * + * @var ?string + */ + protected $lineItemId; + /** * @psalm-suppress MissingParamType @@ -78,6 +84,7 @@ public function __construct( ?LocalizedString $lineItem = null, ?string $variant = null, ?string $taxMode = null, + ?string $lineItemId = null, ?string $type = null ) { $this->change = $change; @@ -86,6 +93,7 @@ public function __construct( $this->lineItem = $lineItem; $this->variant = $variant; $this->taxMode = $taxMode; + $this->lineItemId = $lineItemId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -189,7 +197,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * * @return null|string @@ -228,6 +237,26 @@ public function getTaxMode() return $this->taxMode; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + * + * @return null|string + */ + public function getLineItemId() + { + if (is_null($this->lineItemId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LINE_ITEM_ID); + if (is_null($data)) { + return null; + } + $this->lineItemId = (string) $data; + } + + return $this->lineItemId; + } + /** * @param ?string $change @@ -277,6 +306,14 @@ public function setTaxMode(?string $taxMode): void $this->taxMode = $taxMode; } + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChange.php index 83443195ce1..ab0139a3292 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChange.php @@ -20,6 +20,7 @@ interface SetLineItemTaxedPriceChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_LINE_ITEM = 'lineItem'; public const FIELD_LINE_ITEM_ID = 'lineItemId'; + public const FIELD_VARIANT = 'variant'; /** @@ -65,6 +66,15 @@ public function getLineItem(); */ public function getLineItemId(); + /** + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -89,4 +99,9 @@ public function setLineItem(?LocalizedString $lineItem): void; * @param ?string $lineItemId */ public function setLineItemId(?string $lineItemId): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChangeBuilder.php index f310d80cf2c..47b8581c15e 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChangeBuilder.php @@ -54,6 +54,12 @@ final class SetLineItemTaxedPriceChangeBuilder implements Builder */ private $lineItemId; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -107,6 +113,18 @@ public function getLineItemId() return $this->lineItemId; } + /** + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -162,6 +180,17 @@ public function withLineItemId(?string $lineItemId) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -202,7 +231,8 @@ public function build(): SetLineItemTaxedPriceChange $this->previousValue instanceof TaxedItemPriceBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof TaxedItemPriceBuilder ? $this->nextValue->build() : $this->nextValue, $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, - $this->lineItemId + $this->lineItemId, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChangeModel.php index 94b661cb512..541d09859f4 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTaxedPriceChangeModel.php @@ -61,6 +61,12 @@ final class SetLineItemTaxedPriceChangeModel extends JsonObjectModel implements */ protected $lineItemId; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -71,6 +77,7 @@ public function __construct( ?TaxedItemPrice $nextValue = null, ?LocalizedString $lineItem = null, ?string $lineItemId = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; @@ -78,6 +85,7 @@ public function __construct( $this->nextValue = $nextValue; $this->lineItem = $lineItem; $this->lineItemId = $lineItemId; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -200,6 +208,27 @@ public function getLineItemId() return $this->lineItemId; } + /** + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -241,6 +270,14 @@ public function setLineItemId(?string $lineItemId): void $this->lineItemId = $lineItemId; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChange.php b/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChange.php index 12e55352969..8f8102f45c5 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChange.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChange.php @@ -19,6 +19,8 @@ interface SetLineItemTotalPriceChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_LINE_ITEM = 'lineItem'; + public const FIELD_LINE_ITEM_ID = 'lineItemId'; + public const FIELD_VARIANT = 'variant'; /** @@ -56,6 +58,23 @@ public function getNextValue(); */ public function getLineItem(); + /** + *

                                                                                  id of the updated LineItem.

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

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -75,4 +94,14 @@ public function setNextValue(?Money $nextValue): void; * @param ?LocalizedString $lineItem */ public function setLineItem(?LocalizedString $lineItem): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChangeBuilder.php index 353d05d2eba..d57919c1a6a 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChangeBuilder.php @@ -48,6 +48,18 @@ final class SetLineItemTotalPriceChangeBuilder implements Builder */ private $lineItem; + /** + + * @var ?string + */ + private $lineItemId; + + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -90,6 +102,29 @@ public function getLineItem() return $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem; } + /** + *

                                                                                  id of the updated LineItem.

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

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -134,6 +169,28 @@ public function withLineItem(?LocalizedString $lineItem) return $this; } + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -173,7 +230,9 @@ public function build(): SetLineItemTotalPriceChange $this->change, $this->previousValue instanceof MoneyBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof MoneyBuilder ? $this->nextValue->build() : $this->nextValue, - $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem + $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, + $this->lineItemId, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChangeModel.php index 9a71eda1e3a..c8fda6d1803 100644 --- a/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetLineItemTotalPriceChangeModel.php @@ -55,6 +55,18 @@ final class SetLineItemTotalPriceChangeModel extends JsonObjectModel implements */ protected $lineItem; + /** + * + * @var ?string + */ + protected $lineItemId; + + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -64,12 +76,16 @@ public function __construct( ?Money $previousValue = null, ?Money $nextValue = null, ?LocalizedString $lineItem = null, + ?string $lineItemId = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->lineItem = $lineItem; + $this->lineItemId = $lineItemId; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -172,6 +188,47 @@ public function getLineItem() return $this->lineItem; } + /** + *

                                                                                  id of the updated LineItem.

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

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -205,6 +262,22 @@ public function setLineItem(?LocalizedString $lineItem): void $this->lineItem = $lineItem; } + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChange.php b/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChange.php new file mode 100644 index 00000000000..cd2ef23d36a --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChange.php @@ -0,0 +1,62 @@ +Value before the change.

                                                                                  + * + + * @return null|int + */ + public function getPreviousValue(); + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|int + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?int $previousValue + */ + public function setPreviousValue(?int $previousValue): void; + + /** + * @param ?int $nextValue + */ + public function setNextValue(?int $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChangeBuilder.php new file mode 100644 index 00000000000..880f96a82d9 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChangeBuilder.php @@ -0,0 +1,119 @@ + + */ +final class SetMaxCartQuantityChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?int + */ + private $previousValue; + + /** + + * @var ?int + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + + * @return null|int + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?int $previousValue + * @return $this + */ + public function withPreviousValue(?int $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?int $nextValue + * @return $this + */ + public function withNextValue(?int $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetMaxCartQuantityChange + { + return new SetMaxCartQuantityChangeModel( + $this->change, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetMaxCartQuantityChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChangeCollection.php new file mode 100644 index 00000000000..7f7bb43a31b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetMaxCartQuantityChange current() + * @method SetMaxCartQuantityChange end() + * @method SetMaxCartQuantityChange at($offset) + */ +class SetMaxCartQuantityChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetMaxCartQuantityChange $value + * @psalm-param SetMaxCartQuantityChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetMaxCartQuantityChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetMaxCartQuantityChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetMaxCartQuantityChange + */ + protected function mapper() + { + return function (?int $index): ?SetMaxCartQuantityChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetMaxCartQuantityChange $data */ + $data = SetMaxCartQuantityChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChangeModel.php b/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChangeModel.php new file mode 100644 index 00000000000..140881d908c --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetMaxCartQuantityChangeModel.php @@ -0,0 +1,167 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|int + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (int) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?int $previousValue + */ + public function setPreviousValue(?int $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?int $nextValue + */ + public function setNextValue(?int $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChange.php b/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChange.php index 5807eeef5f5..02d0fa8d04b 100644 --- a/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChange.php +++ b/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChange.php @@ -17,6 +17,7 @@ interface SetMetaDescriptionChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_CATALOG_DATA = 'catalogData'; /** @@ -46,6 +47,18 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                  Product data that was updated.

                                                                                  + * + * + + * @return null|string + */ + public function getCatalogData(); + /** * @param ?string $change */ @@ -60,4 +73,9 @@ public function setPreviousValue(?LocalizedString $previousValue): void; * @param ?LocalizedString $nextValue */ public function setNextValue(?LocalizedString $nextValue): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChangeBuilder.php index 3742b7c0f52..c410d81a222 100644 --- a/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChangeBuilder.php @@ -40,6 +40,12 @@ final class SetMetaDescriptionChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?string + */ + private $catalogData; + /** * @return null|string @@ -71,6 +77,21 @@ public function getNextValue() return $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue; } + /** + *

                                                                                  Product data that was updated.

                                                                                  + * + * + + * @return null|string + */ + public function getCatalogData() + { + return $this->catalogData; + } + /** * @param ?string $change * @return $this @@ -104,6 +125,17 @@ public function withNextValue(?LocalizedString $nextValue) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -131,7 +163,8 @@ public function build(): SetMetaDescriptionChange return new SetMetaDescriptionChangeModel( $this->change, $this->previousValue instanceof LocalizedStringBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue + $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue, + $this->catalogData ); } diff --git a/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChangeModel.php b/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChangeModel.php index 61791c373af..442d66c4bc1 100644 --- a/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetMetaDescriptionChangeModel.php @@ -47,6 +47,12 @@ final class SetMetaDescriptionChangeModel extends JsonObjectModel implements Set */ protected $nextValue; + /** + * + * @var ?string + */ + protected $catalogData; + /** * @psalm-suppress MissingParamType @@ -55,11 +61,13 @@ public function __construct( ?string $change = null, ?LocalizedString $previousValue = null, ?LocalizedString $nextValue = null, + ?string $catalogData = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->catalogData = $catalogData; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -141,6 +149,30 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                  Product data that was updated.

                                                                                  + * + * + * + * @return null|string + */ + public function getCatalogData() + { + if (is_null($this->catalogData)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CATALOG_DATA); + if (is_null($data)) { + return null; + } + $this->catalogData = (string) $data; + } + + return $this->catalogData; + } + /** * @param ?string $change @@ -166,6 +198,14 @@ public function setNextValue(?LocalizedString $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChange.php b/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChange.php index 64c1715cd5a..da3916d18ae 100644 --- a/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChange.php @@ -17,6 +17,7 @@ interface SetMetaKeywordsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_CATALOG_DATA = 'catalogData'; /** @@ -46,6 +47,18 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                  Product data that was updated.

                                                                                  + * + * + + * @return null|string + */ + public function getCatalogData(); + /** * @param ?string $change */ @@ -60,4 +73,9 @@ public function setPreviousValue(?LocalizedString $previousValue): void; * @param ?LocalizedString $nextValue */ public function setNextValue(?LocalizedString $nextValue): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChangeBuilder.php index 4202f6e290b..0ed999aa04b 100644 --- a/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChangeBuilder.php @@ -40,6 +40,12 @@ final class SetMetaKeywordsChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?string + */ + private $catalogData; + /** * @return null|string @@ -71,6 +77,21 @@ public function getNextValue() return $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue; } + /** + *

                                                                                  Product data that was updated.

                                                                                  + * + * + + * @return null|string + */ + public function getCatalogData() + { + return $this->catalogData; + } + /** * @param ?string $change * @return $this @@ -104,6 +125,17 @@ public function withNextValue(?LocalizedString $nextValue) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -131,7 +163,8 @@ public function build(): SetMetaKeywordsChange return new SetMetaKeywordsChangeModel( $this->change, $this->previousValue instanceof LocalizedStringBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue + $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue, + $this->catalogData ); } diff --git a/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChangeModel.php index 6813717a396..7cc23444154 100644 --- a/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetMetaKeywordsChangeModel.php @@ -47,6 +47,12 @@ final class SetMetaKeywordsChangeModel extends JsonObjectModel implements SetMet */ protected $nextValue; + /** + * + * @var ?string + */ + protected $catalogData; + /** * @psalm-suppress MissingParamType @@ -55,11 +61,13 @@ public function __construct( ?string $change = null, ?LocalizedString $previousValue = null, ?LocalizedString $nextValue = null, + ?string $catalogData = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->catalogData = $catalogData; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -141,6 +149,30 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                  Product data that was updated.

                                                                                  + * + * + * + * @return null|string + */ + public function getCatalogData() + { + if (is_null($this->catalogData)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CATALOG_DATA); + if (is_null($data)) { + return null; + } + $this->catalogData = (string) $data; + } + + return $this->catalogData; + } + /** * @param ?string $change @@ -166,6 +198,14 @@ public function setNextValue(?LocalizedString $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetMetaTitleChange.php b/lib/commercetools-history/src/Models/Change/SetMetaTitleChange.php index 8bbe264046d..0f8951265dc 100644 --- a/lib/commercetools-history/src/Models/Change/SetMetaTitleChange.php +++ b/lib/commercetools-history/src/Models/Change/SetMetaTitleChange.php @@ -17,6 +17,7 @@ interface SetMetaTitleChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_CATALOG_DATA = 'catalogData'; /** @@ -46,6 +47,18 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                  Product data that was updated.

                                                                                  + * + * + + * @return null|string + */ + public function getCatalogData(); + /** * @param ?string $change */ @@ -60,4 +73,9 @@ public function setPreviousValue(?LocalizedString $previousValue): void; * @param ?LocalizedString $nextValue */ public function setNextValue(?LocalizedString $nextValue): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetMetaTitleChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetMetaTitleChangeBuilder.php index a25fc51b10b..4e38ace61a9 100644 --- a/lib/commercetools-history/src/Models/Change/SetMetaTitleChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetMetaTitleChangeBuilder.php @@ -40,6 +40,12 @@ final class SetMetaTitleChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?string + */ + private $catalogData; + /** * @return null|string @@ -71,6 +77,21 @@ public function getNextValue() return $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue; } + /** + *

                                                                                  Product data that was updated.

                                                                                  + * + * + + * @return null|string + */ + public function getCatalogData() + { + return $this->catalogData; + } + /** * @param ?string $change * @return $this @@ -104,6 +125,17 @@ public function withNextValue(?LocalizedString $nextValue) return $this; } + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -131,7 +163,8 @@ public function build(): SetMetaTitleChange return new SetMetaTitleChangeModel( $this->change, $this->previousValue instanceof LocalizedStringBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue + $this->nextValue instanceof LocalizedStringBuilder ? $this->nextValue->build() : $this->nextValue, + $this->catalogData ); } diff --git a/lib/commercetools-history/src/Models/Change/SetMetaTitleChangeModel.php b/lib/commercetools-history/src/Models/Change/SetMetaTitleChangeModel.php index dc59d14ec6c..dcdb1e5628d 100644 --- a/lib/commercetools-history/src/Models/Change/SetMetaTitleChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetMetaTitleChangeModel.php @@ -47,6 +47,12 @@ final class SetMetaTitleChangeModel extends JsonObjectModel implements SetMetaTi */ protected $nextValue; + /** + * + * @var ?string + */ + protected $catalogData; + /** * @psalm-suppress MissingParamType @@ -55,11 +61,13 @@ public function __construct( ?string $change = null, ?LocalizedString $previousValue = null, ?LocalizedString $nextValue = null, + ?string $catalogData = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->catalogData = $catalogData; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -141,6 +149,30 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                  Product data that was updated.

                                                                                  + * + * + * + * @return null|string + */ + public function getCatalogData() + { + if (is_null($this->catalogData)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CATALOG_DATA); + if (is_null($data)) { + return null; + } + $this->catalogData = (string) $data; + } + + return $this->catalogData; + } + /** * @param ?string $change @@ -166,6 +198,14 @@ public function setNextValue(?LocalizedString $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChange.php b/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChange.php new file mode 100644 index 00000000000..daaa35f5fdb --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChange.php @@ -0,0 +1,62 @@ +Value before the change.

                                                                                  + * + + * @return null|int + */ + public function getPreviousValue(); + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|int + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?int $previousValue + */ + public function setPreviousValue(?int $previousValue): void; + + /** + * @param ?int $nextValue + */ + public function setNextValue(?int $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChangeBuilder.php new file mode 100644 index 00000000000..e2eb572161f --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChangeBuilder.php @@ -0,0 +1,119 @@ + + */ +final class SetMinCartQuantityChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?int + */ + private $previousValue; + + /** + + * @var ?int + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + + * @return null|int + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?int $previousValue + * @return $this + */ + public function withPreviousValue(?int $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?int $nextValue + * @return $this + */ + public function withNextValue(?int $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetMinCartQuantityChange + { + return new SetMinCartQuantityChangeModel( + $this->change, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetMinCartQuantityChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChangeCollection.php new file mode 100644 index 00000000000..b283a44cc59 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetMinCartQuantityChange current() + * @method SetMinCartQuantityChange end() + * @method SetMinCartQuantityChange at($offset) + */ +class SetMinCartQuantityChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetMinCartQuantityChange $value + * @psalm-param SetMinCartQuantityChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetMinCartQuantityChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetMinCartQuantityChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetMinCartQuantityChange + */ + protected function mapper() + { + return function (?int $index): ?SetMinCartQuantityChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetMinCartQuantityChange $data */ + $data = SetMinCartQuantityChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChangeModel.php b/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChangeModel.php new file mode 100644 index 00000000000..adcbba89135 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetMinCartQuantityChangeModel.php @@ -0,0 +1,167 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|int + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (int) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?int $previousValue + */ + public function setPreviousValue(?int $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?int $nextValue + */ + public function setNextValue(?int $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChange.php index 90c25938281..1b182ec4571 100644 --- a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChange.php +++ b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChange.php @@ -21,6 +21,7 @@ interface SetOrderLineItemCustomFieldChange extends Change public const FIELD_NAME = 'name'; public const FIELD_LINE_ITEM = 'lineItem'; public const FIELD_VARIANT = 'variant'; + public const FIELD_LINE_ITEM_ID = 'lineItemId'; /** @@ -75,13 +76,22 @@ public function getName(); public function getLineItem(); /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId(); + /** * @param ?string $change */ @@ -116,4 +126,9 @@ public function setLineItem(?LocalizedString $lineItem): void; * @param ?string $variant */ public function setVariant(?string $variant): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChangeBuilder.php index 612532fcfa5..e9b0b560dd0 100644 --- a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChangeBuilder.php @@ -64,6 +64,12 @@ final class SetOrderLineItemCustomFieldChangeBuilder implements Builder */ private $variant; + /** + + * @var ?string + */ + private $lineItemId; + /** * @return null|string @@ -129,7 +135,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string @@ -139,6 +146,17 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId() + { + return $this->lineItemId; + } + /** * @param ?string $change * @return $this @@ -216,6 +234,17 @@ public function withVariant(?string $variant) return $this; } + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + /** * @deprecated use withLineItem() instead * @return $this @@ -236,7 +265,8 @@ public function build(): SetOrderLineItemCustomFieldChange $this->customTypeId, $this->name, $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, - $this->variant + $this->variant, + $this->lineItemId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChangeModel.php index 7fb1c737405..a5f25b0176d 100644 --- a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomFieldChangeModel.php @@ -71,6 +71,12 @@ final class SetOrderLineItemCustomFieldChangeModel extends JsonObjectModel imple */ protected $variant; + /** + * + * @var ?string + */ + protected $lineItemId; + /** * @psalm-suppress MissingParamType @@ -83,6 +89,7 @@ public function __construct( ?string $name = null, ?LocalizedString $lineItem = null, ?string $variant = null, + ?string $lineItemId = null, ?string $type = null ) { $this->change = $change; @@ -92,6 +99,7 @@ public function __construct( $this->name = $name; $this->lineItem = $lineItem; $this->variant = $variant; + $this->lineItemId = $lineItemId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -233,7 +241,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * * @return null|string @@ -252,6 +261,26 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + * + * @return null|string + */ + public function getLineItemId() + { + if (is_null($this->lineItemId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LINE_ITEM_ID); + if (is_null($data)) { + return null; + } + $this->lineItemId = (string) $data; + } + + return $this->lineItemId; + } + /** * @param ?string $change @@ -309,6 +338,14 @@ public function setVariant(?string $variant): void $this->variant = $variant; } + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChange.php index 63fe4003446..fd11914ef3a 100644 --- a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChange.php +++ b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChange.php @@ -20,6 +20,7 @@ interface SetOrderLineItemCustomTypeChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_LINE_ITEM = 'lineItem'; public const FIELD_VARIANT = 'variant'; + public const FIELD_LINE_ITEM_ID = 'lineItemId'; /** @@ -58,13 +59,22 @@ public function getNextValue(); public function getLineItem(); /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId(); + /** * @param ?string $change */ @@ -89,4 +99,9 @@ public function setLineItem(?LocalizedString $lineItem): void; * @param ?string $variant */ public function setVariant(?string $variant): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChangeBuilder.php index fbcee75f553..171d5b80d38 100644 --- a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChangeBuilder.php @@ -54,6 +54,12 @@ final class SetOrderLineItemCustomTypeChangeBuilder implements Builder */ private $variant; + /** + + * @var ?string + */ + private $lineItemId; + /** * @return null|string @@ -97,7 +103,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * @return null|string @@ -107,6 +114,17 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + + * @return null|string + */ + public function getLineItemId() + { + return $this->lineItemId; + } + /** * @param ?string $change * @return $this @@ -162,6 +180,17 @@ public function withVariant(?string $variant) return $this; } + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -202,7 +231,8 @@ public function build(): SetOrderLineItemCustomTypeChange $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue, $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, - $this->variant + $this->variant, + $this->lineItemId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChangeModel.php index bc84281494c..434834c4594 100644 --- a/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetOrderLineItemCustomTypeChangeModel.php @@ -61,6 +61,12 @@ final class SetOrderLineItemCustomTypeChangeModel extends JsonObjectModel implem */ protected $variant; + /** + * + * @var ?string + */ + protected $lineItemId; + /** * @psalm-suppress MissingParamType @@ -71,6 +77,7 @@ public function __construct( ?CustomFields $nextValue = null, ?LocalizedString $lineItem = null, ?string $variant = null, + ?string $lineItemId = null, ?string $type = null ) { $this->change = $change; @@ -78,6 +85,7 @@ public function __construct( $this->nextValue = $nextValue; $this->lineItem = $lineItem; $this->variant = $variant; + $this->lineItemId = $lineItemId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -181,7 +189,8 @@ public function getLineItem() } /** - *

                                                                                  sku or key of the ProductVariant.

                                                                                  + *

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                  * * * @return null|string @@ -200,6 +209,26 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                  id of the updated LineItem.

                                                                                  + * + * + * @return null|string + */ + public function getLineItemId() + { + if (is_null($this->lineItemId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LINE_ITEM_ID); + if (is_null($data)) { + return null; + } + $this->lineItemId = (string) $data; + } + + return $this->lineItemId; + } + /** * @param ?string $change @@ -241,6 +270,14 @@ public function setVariant(?string $variant): void $this->variant = $variant; } + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChange.php b/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChange.php index d8c02a4f6ca..52e5206a333 100644 --- a/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChange.php +++ b/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\Common\TaxedItemPrice; +use Commercetools\History\Models\Common\TaxedPrice; interface SetOrderTaxedPriceChange extends Change { @@ -35,7 +35,7 @@ public function getChange(); *

                                                                                  Value before the change.

                                                                                  * - * @return null|TaxedItemPrice + * @return null|TaxedPrice */ public function getPreviousValue(); @@ -43,11 +43,13 @@ public function getPreviousValue(); *

                                                                                  Value after the change.

                                                                                  * - * @return null|TaxedItemPrice + * @return null|TaxedPrice */ public function getNextValue(); /** + *

                                                                                  Indicates how taxes are set on the Cart.

                                                                                  + * * @return null|string */ @@ -59,14 +61,14 @@ public function getTaxMode(); public function setChange(?string $change): void; /** - * @param ?TaxedItemPrice $previousValue + * @param ?TaxedPrice $previousValue */ - public function setPreviousValue(?TaxedItemPrice $previousValue): void; + public function setPreviousValue(?TaxedPrice $previousValue): void; /** - * @param ?TaxedItemPrice $nextValue + * @param ?TaxedPrice $nextValue */ - public function setNextValue(?TaxedItemPrice $nextValue): void; + public function setNextValue(?TaxedPrice $nextValue): void; /** * @param ?string $taxMode diff --git a/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChangeBuilder.php index f285df6289e..3f3c860ad13 100644 --- a/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\TaxedItemPrice; -use Commercetools\History\Models\Common\TaxedItemPriceBuilder; +use Commercetools\History\Models\Common\TaxedPrice; +use Commercetools\History\Models\Common\TaxedPriceBuilder; /** * @implements Builder @@ -30,13 +30,13 @@ final class SetOrderTaxedPriceChangeBuilder implements Builder /** - * @var null|TaxedItemPrice|TaxedItemPriceBuilder + * @var null|TaxedPrice|TaxedPriceBuilder */ private $previousValue; /** - * @var null|TaxedItemPrice|TaxedItemPriceBuilder + * @var null|TaxedPrice|TaxedPriceBuilder */ private $nextValue; @@ -59,25 +59,27 @@ public function getChange() *

                                                                                  Value before the change.

                                                                                  * - * @return null|TaxedItemPrice + * @return null|TaxedPrice */ public function getPreviousValue() { - return $this->previousValue instanceof TaxedItemPriceBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof TaxedPriceBuilder ? $this->previousValue->build() : $this->previousValue; } /** *

                                                                                  Value after the change.

                                                                                  * - * @return null|TaxedItemPrice + * @return null|TaxedPrice */ public function getNextValue() { - return $this->nextValue instanceof TaxedItemPriceBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof TaxedPriceBuilder ? $this->nextValue->build() : $this->nextValue; } /** + *

                                                                                  Indicates how taxes are set on the Cart.

                                                                                  + * * @return null|string */ @@ -98,10 +100,10 @@ public function withChange(?string $change) } /** - * @param ?TaxedItemPrice $previousValue + * @param ?TaxedPrice $previousValue * @return $this */ - public function withPreviousValue(?TaxedItemPrice $previousValue) + public function withPreviousValue(?TaxedPrice $previousValue) { $this->previousValue = $previousValue; @@ -109,10 +111,10 @@ public function withPreviousValue(?TaxedItemPrice $previousValue) } /** - * @param ?TaxedItemPrice $nextValue + * @param ?TaxedPrice $nextValue * @return $this */ - public function withNextValue(?TaxedItemPrice $nextValue) + public function withNextValue(?TaxedPrice $nextValue) { $this->nextValue = $nextValue; @@ -134,7 +136,7 @@ public function withTaxMode(?string $taxMode) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?TaxedItemPriceBuilder $previousValue) + public function withPreviousValueBuilder(?TaxedPriceBuilder $previousValue) { $this->previousValue = $previousValue; @@ -145,7 +147,7 @@ public function withPreviousValueBuilder(?TaxedItemPriceBuilder $previousValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?TaxedItemPriceBuilder $nextValue) + public function withNextValueBuilder(?TaxedPriceBuilder $nextValue) { $this->nextValue = $nextValue; @@ -156,8 +158,8 @@ public function build(): SetOrderTaxedPriceChange { return new SetOrderTaxedPriceChangeModel( $this->change, - $this->previousValue instanceof TaxedItemPriceBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof TaxedItemPriceBuilder ? $this->nextValue->build() : $this->nextValue, + $this->previousValue instanceof TaxedPriceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof TaxedPriceBuilder ? $this->nextValue->build() : $this->nextValue, $this->taxMode ); } diff --git a/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChangeModel.php index fa59cf46406..c08c83f0b05 100644 --- a/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetOrderTaxedPriceChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\TaxedItemPrice; -use Commercetools\History\Models\Common\TaxedItemPriceModel; +use Commercetools\History\Models\Common\TaxedPrice; +use Commercetools\History\Models\Common\TaxedPriceModel; /** * @internal @@ -37,13 +37,13 @@ final class SetOrderTaxedPriceChangeModel extends JsonObjectModel implements Set /** * - * @var ?TaxedItemPrice + * @var ?TaxedPrice */ protected $previousValue; /** * - * @var ?TaxedItemPrice + * @var ?TaxedPrice */ protected $nextValue; @@ -59,8 +59,8 @@ final class SetOrderTaxedPriceChangeModel extends JsonObjectModel implements Set */ public function __construct( ?string $change = null, - ?TaxedItemPrice $previousValue = null, - ?TaxedItemPrice $nextValue = null, + ?TaxedPrice $previousValue = null, + ?TaxedPrice $nextValue = null, ?string $taxMode = null, ?string $type = null ) { @@ -111,7 +111,7 @@ public function getChange() *

                                                                                  Value before the change.

                                                                                  * * - * @return null|TaxedItemPrice + * @return null|TaxedPrice */ public function getPreviousValue() { @@ -122,7 +122,7 @@ public function getPreviousValue() return null; } - $this->previousValue = TaxedItemPriceModel::of($data); + $this->previousValue = TaxedPriceModel::of($data); } return $this->previousValue; @@ -132,7 +132,7 @@ public function getPreviousValue() *

                                                                                  Value after the change.

                                                                                  * * - * @return null|TaxedItemPrice + * @return null|TaxedPrice */ public function getNextValue() { @@ -143,13 +143,15 @@ public function getNextValue() return null; } - $this->nextValue = TaxedItemPriceModel::of($data); + $this->nextValue = TaxedPriceModel::of($data); } return $this->nextValue; } /** + *

                                                                                  Indicates how taxes are set on the Cart.

                                                                                  + * * * @return null|string */ @@ -177,17 +179,17 @@ public function setChange(?string $change): void } /** - * @param ?TaxedItemPrice $previousValue + * @param ?TaxedPrice $previousValue */ - public function setPreviousValue(?TaxedItemPrice $previousValue): void + public function setPreviousValue(?TaxedPrice $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?TaxedItemPrice $nextValue + * @param ?TaxedPrice $nextValue */ - public function setNextValue(?TaxedItemPrice $nextValue): void + public function setNextValue(?TaxedPrice $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChange.php new file mode 100644 index 00000000000..596766fb426 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChange.php @@ -0,0 +1,105 @@ +Information about the updated Parcel.

                                                                                  + * + + * @return null|ParcelChangeValue + */ + public function getParcel(); + + /** + *

                                                                                  id of the referenced Type.

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

                                                                                  Name of the Custom Field.

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

                                                                                  Value before the change.

                                                                                  + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?ParcelChangeValue $parcel + */ + public function setParcel(?ParcelChangeValue $parcel): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..5036f6c3dfa --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChangeBuilder.php @@ -0,0 +1,218 @@ + + */ +final class SetParcelCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|ParcelChangeValue|ParcelChangeValueBuilder + */ + private $parcel; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  Information about the updated Parcel.

                                                                                  + * + + * @return null|ParcelChangeValue + */ + public function getParcel() + { + return $this->parcel instanceof ParcelChangeValueBuilder ? $this->parcel->build() : $this->parcel; + } + + /** + *

                                                                                  id of the referenced Type.

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

                                                                                  Name of the Custom Field.

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

                                                                                  Value before the change.

                                                                                  + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?ParcelChangeValue $parcel + * @return $this + */ + public function withParcel(?ParcelChangeValue $parcel) + { + $this->parcel = $parcel; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withParcel() instead + * @return $this + */ + public function withParcelBuilder(?ParcelChangeValueBuilder $parcel) + { + $this->parcel = $parcel; + + return $this; + } + + public function build(): SetParcelCustomFieldChange + { + return new SetParcelCustomFieldChangeModel( + $this->change, + $this->parcel instanceof ParcelChangeValueBuilder ? $this->parcel->build() : $this->parcel, + $this->customTypeId, + $this->name, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetParcelCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChangeCollection.php new file mode 100644 index 00000000000..ef25d74371b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetParcelCustomFieldChange current() + * @method SetParcelCustomFieldChange end() + * @method SetParcelCustomFieldChange at($offset) + */ +class SetParcelCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetParcelCustomFieldChange $value + * @psalm-param SetParcelCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetParcelCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetParcelCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetParcelCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetParcelCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetParcelCustomFieldChange $data */ + $data = SetParcelCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChangeModel.php new file mode 100644 index 00000000000..65684b4ce3a --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetParcelCustomFieldChangeModel.php @@ -0,0 +1,278 @@ +change = $change; + $this->parcel = $parcel; + $this->customTypeId = $customTypeId; + $this->name = $name; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  Information about the updated Parcel.

                                                                                  + * + * + * @return null|ParcelChangeValue + */ + public function getParcel() + { + if (is_null($this->parcel)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PARCEL); + if (is_null($data)) { + return null; + } + + $this->parcel = ParcelChangeValueModel::of($data); + } + + return $this->parcel; + } + + /** + *

                                                                                  id of the referenced Type.

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

                                                                                  Name of the Custom Field.

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

                                                                                  Value before the change.

                                                                                  + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?ParcelChangeValue $parcel + */ + public function setParcel(?ParcelChangeValue $parcel): void + { + $this->parcel = $parcel; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChange.php new file mode 100644 index 00000000000..af1ae7ed8b9 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChange.php @@ -0,0 +1,78 @@ +Information about the updated Parcel.

                                                                                  + * + + * @return null|ParcelChangeValue + */ + public function getParcel(); + + /** + *

                                                                                  Value before the change.

                                                                                  + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?ParcelChangeValue $parcel + */ + public function setParcel(?ParcelChangeValue $parcel): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..50651e582f4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChangeBuilder.php @@ -0,0 +1,184 @@ + + */ +final class SetParcelCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|ParcelChangeValue|ParcelChangeValueBuilder + */ + private $parcel; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  Information about the updated Parcel.

                                                                                  + * + + * @return null|ParcelChangeValue + */ + public function getParcel() + { + return $this->parcel instanceof ParcelChangeValueBuilder ? $this->parcel->build() : $this->parcel; + } + + /** + *

                                                                                  Value before the change.

                                                                                  + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?ParcelChangeValue $parcel + * @return $this + */ + public function withParcel(?ParcelChangeValue $parcel) + { + $this->parcel = $parcel; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withParcel() instead + * @return $this + */ + public function withParcelBuilder(?ParcelChangeValueBuilder $parcel) + { + $this->parcel = $parcel; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetParcelCustomTypeChange + { + return new SetParcelCustomTypeChangeModel( + $this->change, + $this->parcel instanceof ParcelChangeValueBuilder ? $this->parcel->build() : $this->parcel, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetParcelCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChangeCollection.php new file mode 100644 index 00000000000..db61100eded --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetParcelCustomTypeChange current() + * @method SetParcelCustomTypeChange end() + * @method SetParcelCustomTypeChange at($offset) + */ +class SetParcelCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetParcelCustomTypeChange $value + * @psalm-param SetParcelCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetParcelCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetParcelCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetParcelCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetParcelCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetParcelCustomTypeChange $data */ + $data = SetParcelCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChangeModel.php new file mode 100644 index 00000000000..0b0074d6fe0 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetParcelCustomTypeChangeModel.php @@ -0,0 +1,210 @@ +change = $change; + $this->parcel = $parcel; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  Information about the updated Parcel.

                                                                                  + * + * + * @return null|ParcelChangeValue + */ + public function getParcel() + { + if (is_null($this->parcel)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PARCEL); + if (is_null($data)) { + return null; + } + + $this->parcel = ParcelChangeValueModel::of($data); + } + + return $this->parcel; + } + + /** + *

                                                                                  Value before the change.

                                                                                  + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?ParcelChangeValue $parcel + */ + public function setParcel(?ParcelChangeValue $parcel): void + { + $this->parcel = $parcel; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetPasswordChange.php b/lib/commercetools-history/src/Models/Change/SetPasswordChange.php new file mode 100644 index 00000000000..eff7b429831 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPasswordChange.php @@ -0,0 +1,34 @@ + + */ +final class SetPasswordChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + + public function build(): SetPasswordChange + { + return new SetPasswordChangeModel( + $this->change + ); + } + + public static function of(): SetPasswordChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetPasswordChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetPasswordChangeCollection.php new file mode 100644 index 00000000000..6cab0361462 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPasswordChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetPasswordChange current() + * @method SetPasswordChange end() + * @method SetPasswordChange at($offset) + */ +class SetPasswordChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetPasswordChange $value + * @psalm-param SetPasswordChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetPasswordChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetPasswordChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetPasswordChange + */ + protected function mapper() + { + return function (?int $index): ?SetPasswordChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetPasswordChange $data */ + $data = SetPasswordChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetPasswordChangeModel.php b/lib/commercetools-history/src/Models/Change/SetPasswordChangeModel.php new file mode 100644 index 00000000000..643be451f92 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPasswordChangeModel.php @@ -0,0 +1,95 @@ +change = $change; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetPermissionsChange.php b/lib/commercetools-history/src/Models/Change/SetPermissionsChange.php index 3d9b8062e07..07f6b28e1e4 100644 --- a/lib/commercetools-history/src/Models/Change/SetPermissionsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetPermissionsChange.php @@ -16,6 +16,8 @@ interface SetPermissionsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -45,6 +47,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + + * @return null|array + */ + public function getAddedItems(); + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + + * @return null|array + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -59,4 +77,14 @@ public function setPreviousValue(?array $previousValue): void; * @param ?array $nextValue */ public function setNextValue(?array $nextValue): void; + + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void; + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetPermissionsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetPermissionsChangeBuilder.php index bbf98bcec9a..fe4c75f7bc1 100644 --- a/lib/commercetools-history/src/Models/Change/SetPermissionsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetPermissionsChangeBuilder.php @@ -38,6 +38,18 @@ final class SetPermissionsChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?array + */ + private $addedItems; + + /** + + * @var ?array + */ + private $removedItems; + /** * @return null|string @@ -69,6 +81,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + + * @return null|array + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + + * @return null|array + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -102,13 +136,37 @@ public function withNextValue(?array $nextValue) return $this; } + /** + * @param ?array $addedItems + * @return $this + */ + public function withAddedItems(?array $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?array $removedItems + * @return $this + */ + public function withRemovedItems(?array $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetPermissionsChange { return new SetPermissionsChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetPermissionsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetPermissionsChangeModel.php index 43d5a71f3c5..2c758b1dc49 100644 --- a/lib/commercetools-history/src/Models/Change/SetPermissionsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetPermissionsChangeModel.php @@ -45,6 +45,18 @@ final class SetPermissionsChangeModel extends JsonObjectModel implements SetPerm */ protected $nextValue; + /** + * + * @var ?array + */ + protected $addedItems; + + /** + * + * @var ?array + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -53,11 +65,15 @@ public function __construct( ?string $change = null, ?array $previousValue = null, ?array $nextValue = null, + ?array $addedItems = null, + ?array $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -137,6 +153,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                  Elements added to the array.

                                                                                  + * + * + * @return null|array + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = $data; + } + + return $this->addedItems; + } + + /** + *

                                                                                  Elements removed from the array.

                                                                                  + * + * + * @return null|array + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = $data; + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -162,6 +218,22 @@ public function setNextValue(?array $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetPriceKeyChange.php b/lib/commercetools-history/src/Models/Change/SetPriceKeyChange.php new file mode 100644 index 00000000000..f96e9d064f1 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPriceKeyChange.php @@ -0,0 +1,109 @@ +Product data that was updated.

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

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                  id of the Embedded Price.

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

                                                                                  Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + + * @return null|string + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; + + /** + * @param ?string $priceId + */ + public function setPriceId(?string $priceId): void; + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void; + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetPriceKeyChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetPriceKeyChangeBuilder.php new file mode 100644 index 00000000000..83a41d40001 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPriceKeyChangeBuilder.php @@ -0,0 +1,211 @@ + + */ +final class SetPriceKeyChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var ?string + */ + private $variant; + + /** + + * @var ?string + */ + private $priceId; + + /** + + * @var ?string + */ + private $previousValue; + + /** + + * @var ?string + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  Product data that was updated.

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

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                  id of the Embedded Price.

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

                                                                                  Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + + * @return null|string + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + + /** + * @param ?string $priceId + * @return $this + */ + public function withPriceId(?string $priceId) + { + $this->priceId = $priceId; + + return $this; + } + + /** + * @param ?string $previousValue + * @return $this + */ + public function withPreviousValue(?string $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?string $nextValue + * @return $this + */ + public function withNextValue(?string $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetPriceKeyChange + { + return new SetPriceKeyChangeModel( + $this->change, + $this->catalogData, + $this->variant, + $this->priceId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetPriceKeyChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetPriceKeyChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetPriceKeyChangeCollection.php new file mode 100644 index 00000000000..d28ff1e0d01 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPriceKeyChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetPriceKeyChange current() + * @method SetPriceKeyChange end() + * @method SetPriceKeyChange at($offset) + */ +class SetPriceKeyChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetPriceKeyChange $value + * @psalm-param SetPriceKeyChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetPriceKeyChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetPriceKeyChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetPriceKeyChange + */ + protected function mapper() + { + return function (?int $index): ?SetPriceKeyChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetPriceKeyChange $data */ + $data = SetPriceKeyChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetPriceKeyChangeModel.php b/lib/commercetools-history/src/Models/Change/SetPriceKeyChangeModel.php new file mode 100644 index 00000000000..4302603ac60 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPriceKeyChangeModel.php @@ -0,0 +1,280 @@ +change = $change; + $this->catalogData = $catalogData; + $this->variant = $variant; + $this->priceId = $priceId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  Product data that was updated.

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

                                                                                  Identifier of the updated Product Variant.

                                                                                  + *

                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                  id of the Embedded Price.

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

                                                                                  Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|string + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (string) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + + /** + * @param ?string $priceId + */ + public function setPriceId(?string $priceId): void + { + $this->priceId = $priceId; + } + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetPriceModeChange.php b/lib/commercetools-history/src/Models/Change/SetPriceModeChange.php new file mode 100644 index 00000000000..47e8b447d3f --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPriceModeChange.php @@ -0,0 +1,62 @@ +Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + + * @return null|string + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void; + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetPriceModeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetPriceModeChangeBuilder.php new file mode 100644 index 00000000000..9891df42335 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPriceModeChangeBuilder.php @@ -0,0 +1,119 @@ + + */ +final class SetPriceModeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $previousValue; + + /** + + * @var ?string + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                  Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + + * @return null|string + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $previousValue + * @return $this + */ + public function withPreviousValue(?string $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?string $nextValue + * @return $this + */ + public function withNextValue(?string $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetPriceModeChange + { + return new SetPriceModeChangeModel( + $this->change, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetPriceModeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetPriceModeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetPriceModeChangeCollection.php new file mode 100644 index 00000000000..6b83743d9ca --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPriceModeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetPriceModeChange current() + * @method SetPriceModeChange end() + * @method SetPriceModeChange at($offset) + */ +class SetPriceModeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetPriceModeChange $value + * @psalm-param SetPriceModeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetPriceModeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetPriceModeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetPriceModeChange + */ + protected function mapper() + { + return function (?int $index): ?SetPriceModeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetPriceModeChange $data */ + $data = SetPriceModeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetPriceModeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetPriceModeChangeModel.php new file mode 100644 index 00000000000..5df65d57ce7 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetPriceModeChangeModel.php @@ -0,0 +1,167 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                  Value before the change.

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

                                                                                  Value after the change.

                                                                                  + * + * + * @return null|string + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (string) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetPricesChange.php b/lib/commercetools-history/src/Models/Change/SetPricesChange.php index 09baecbc842..609dc77a486 100644 --- a/lib/commercetools-history/src/Models/Change/SetPricesChange.php +++ b/lib/commercetools-history/src/Models/Change/SetPricesChange.php @@ -19,6 +19,8 @@ interface SetPricesChange extends Change public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; public const FIELD_VARIANT = 'variant'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -49,6 +51,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                                                  Product data that was updated.

                                                                                  *
                                                                                    *
                                                                                  • staged, if the staged ProductCatalogData was updated.
                                                                                  • *
                                                                                  • current, if the current ProductCatalogData was updated.
                                                                                  • @@ -60,13 +63,30 @@ public function getNextValue(); public function getCatalogData(); /** - *

                                                                                    sku or key of the ProductVariant.

                                                                                    + *

                                                                                    Identifier of the updated Product Variant.

                                                                                    + *

                                                                                    This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                    Elements added to the array.

                                                                                    + * + + * @return null|PriceCollection + */ + public function getAddedItems(); + + /** + *

                                                                                    Elements removed from the array.

                                                                                    + * + + * @return null|PriceCollection + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -91,4 +111,14 @@ public function setCatalogData(?string $catalogData): void; * @param ?string $variant */ public function setVariant(?string $variant): void; + + /** + * @param ?PriceCollection $addedItems + */ + public function setAddedItems(?PriceCollection $addedItems): void; + + /** + * @param ?PriceCollection $removedItems + */ + public function setRemovedItems(?PriceCollection $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetPricesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetPricesChangeBuilder.php index 702c6d5c9d0..f54d372e4b1 100644 --- a/lib/commercetools-history/src/Models/Change/SetPricesChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetPricesChangeBuilder.php @@ -51,6 +51,18 @@ final class SetPricesChangeBuilder implements Builder */ private $variant; + /** + + * @var ?PriceCollection + */ + private $addedItems; + + /** + + * @var ?PriceCollection + */ + private $removedItems; + /** * @return null|string @@ -83,6 +95,7 @@ public function getNextValue() } /** + *

                                                                                    Product data that was updated.

                                                                                    *
                                                                                      *
                                                                                    • staged, if the staged ProductCatalogData was updated.
                                                                                    • *
                                                                                    • current, if the current ProductCatalogData was updated.
                                                                                    • @@ -97,7 +110,8 @@ public function getCatalogData() } /** - *

                                                                                      sku or key of the ProductVariant.

                                                                                      + *

                                                                                      Identifier of the updated Product Variant.

                                                                                      + *

                                                                                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                      * * @return null|string @@ -107,6 +121,28 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                      Elements added to the array.

                                                                                      + * + + * @return null|PriceCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                      Elements removed from the array.

                                                                                      + * + + * @return null|PriceCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -162,6 +198,28 @@ public function withVariant(?string $variant) return $this; } + /** + * @param ?PriceCollection $addedItems + * @return $this + */ + public function withAddedItems(?PriceCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?PriceCollection $removedItems + * @return $this + */ + public function withRemovedItems(?PriceCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetPricesChange { @@ -170,7 +228,9 @@ public function build(): SetPricesChange $this->previousValue, $this->nextValue, $this->catalogData, - $this->variant + $this->variant, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetPricesChangeModel.php b/lib/commercetools-history/src/Models/Change/SetPricesChangeModel.php index 7e04e08f4e2..175a3222452 100644 --- a/lib/commercetools-history/src/Models/Change/SetPricesChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetPricesChangeModel.php @@ -58,6 +58,18 @@ final class SetPricesChangeModel extends JsonObjectModel implements SetPricesCha */ protected $variant; + /** + * + * @var ?PriceCollection + */ + protected $addedItems; + + /** + * + * @var ?PriceCollection + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -68,6 +80,8 @@ public function __construct( ?PriceCollection $nextValue = null, ?string $catalogData = null, ?string $variant = null, + ?PriceCollection $addedItems = null, + ?PriceCollection $removedItems = null, ?string $type = null ) { $this->change = $change; @@ -75,6 +89,8 @@ public function __construct( $this->nextValue = $nextValue; $this->catalogData = $catalogData; $this->variant = $variant; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -155,6 +171,7 @@ public function getNextValue() } /** + *

                                                                                      Product data that was updated.

                                                                                      *
                                                                                        *
                                                                                      • staged, if the staged ProductCatalogData was updated.
                                                                                      • *
                                                                                      • current, if the current ProductCatalogData was updated.
                                                                                      • @@ -178,7 +195,8 @@ public function getCatalogData() } /** - *

                                                                                        sku or key of the ProductVariant.

                                                                                        + *

                                                                                        Identifier of the updated Product Variant.

                                                                                        + *

                                                                                        This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                        * * * @return null|string @@ -197,6 +215,46 @@ public function getVariant() return $this->variant; } + /** + *

                                                                                        Elements added to the array.

                                                                                        + * + * + * @return null|PriceCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = PriceCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                                        Elements removed from the array.

                                                                                        + * + * + * @return null|PriceCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = PriceCollection::fromArray($data); + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -238,6 +296,22 @@ public function setVariant(?string $variant): void $this->variant = $variant; } + /** + * @param ?PriceCollection $addedItems + */ + public function setAddedItems(?PriceCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?PriceCollection $removedItems + */ + public function setRemovedItems(?PriceCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetProductAttributeChange.php b/lib/commercetools-history/src/Models/Change/SetProductAttributeChange.php new file mode 100644 index 00000000000..f01b655e909 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetProductAttributeChange.php @@ -0,0 +1,81 @@ +Product data that was updated.

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

                                                                                        Value before the change.

                                                                                        + * + + * @return null|Attribute + */ + public function getPreviousValue(); + + /** + *

                                                                                        Value after the change.

                                                                                        + * + + * @return null|Attribute + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void; + + /** + * @param ?Attribute $previousValue + */ + public function setPreviousValue(?Attribute $previousValue): void; + + /** + * @param ?Attribute $nextValue + */ + public function setNextValue(?Attribute $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetProductAttributeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetProductAttributeChangeBuilder.php new file mode 100644 index 00000000000..ea25f664a87 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetProductAttributeChangeBuilder.php @@ -0,0 +1,175 @@ + + */ +final class SetProductAttributeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $catalogData; + + /** + + * @var null|Attribute|AttributeBuilder + */ + private $previousValue; + + /** + + * @var null|Attribute|AttributeBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                        Product data that was updated.

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

                                                                                        Value before the change.

                                                                                        + * + + * @return null|Attribute + */ + public function getPreviousValue() + { + return $this->previousValue instanceof AttributeBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                        Value after the change.

                                                                                        + * + + * @return null|Attribute + */ + public function getNextValue() + { + return $this->nextValue instanceof AttributeBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $catalogData + * @return $this + */ + public function withCatalogData(?string $catalogData) + { + $this->catalogData = $catalogData; + + return $this; + } + + /** + * @param ?Attribute $previousValue + * @return $this + */ + public function withPreviousValue(?Attribute $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?Attribute $nextValue + * @return $this + */ + public function withNextValue(?Attribute $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?AttributeBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?AttributeBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetProductAttributeChange + { + return new SetProductAttributeChangeModel( + $this->change, + $this->catalogData, + $this->previousValue instanceof AttributeBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof AttributeBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetProductAttributeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetProductAttributeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetProductAttributeChangeCollection.php new file mode 100644 index 00000000000..7e74a0257fc --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetProductAttributeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetProductAttributeChange current() + * @method SetProductAttributeChange end() + * @method SetProductAttributeChange at($offset) + */ +class SetProductAttributeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetProductAttributeChange $value + * @psalm-param SetProductAttributeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetProductAttributeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetProductAttributeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetProductAttributeChange + */ + protected function mapper() + { + return function (?int $index): ?SetProductAttributeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetProductAttributeChange $data */ + $data = SetProductAttributeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetProductAttributeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetProductAttributeChangeModel.php new file mode 100644 index 00000000000..06d41bc6095 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetProductAttributeChangeModel.php @@ -0,0 +1,211 @@ +change = $change; + $this->catalogData = $catalogData; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                        Product data that was updated.

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

                                                                                        Value before the change.

                                                                                        + * + * + * @return null|Attribute + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = AttributeModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                        Value after the change.

                                                                                        + * + * + * @return null|Attribute + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = AttributeModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $catalogData + */ + public function setCatalogData(?string $catalogData): void + { + $this->catalogData = $catalogData; + } + + /** + * @param ?Attribute $previousValue + */ + public function setPreviousValue(?Attribute $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?Attribute $nextValue + */ + public function setNextValue(?Attribute $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChange.php index 66e2da65f22..786cfcef8ba 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChange.php +++ b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChange.php @@ -18,6 +18,10 @@ interface SetProductPriceCustomFieldChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; + public const FIELD_PRICE_ID = 'priceId'; + public const FIELD_CUSTOM_TYPE_ID = 'customTypeId'; + public const FIELD_NAME = 'name'; /** @@ -48,6 +52,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                                                        Product data that was updated.

                                                                                        *
                                                                                          *
                                                                                        • staged, if the staged ProductCatalogData was updated.
                                                                                        • *
                                                                                        • current, if the current ProductCatalogData was updated.
                                                                                        • @@ -58,6 +63,39 @@ public function getNextValue(); */ public function getCatalogData(); + /** + *

                                                                                          Identifier of the updated Product Variant.

                                                                                          + *

                                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                          id of the Embedded Price.

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

                                                                                          id of the referenced Type.

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

                                                                                          Name of the Custom Field.

                                                                                          + * + + * @return null|string + */ + public function getName(); + /** * @param ?string $change */ @@ -77,4 +115,24 @@ public function setNextValue(?CustomFields $nextValue): void; * @param ?string $catalogData */ public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; + + /** + * @param ?string $priceId + */ + public function setPriceId(?string $priceId): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChangeBuilder.php index 07691b8970a..5d02bbac7ff 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChangeBuilder.php @@ -46,6 +46,30 @@ final class SetProductPriceCustomFieldChangeBuilder implements Builder */ private $catalogData; + /** + + * @var ?string + */ + private $variant; + + /** + + * @var ?string + */ + private $priceId; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var ?string + */ + private $name; + /** * @return null|string @@ -78,6 +102,7 @@ public function getNextValue() } /** + *

                                                                                          Product data that was updated.

                                                                                          *
                                                                                            *
                                                                                          • staged, if the staged ProductCatalogData was updated.
                                                                                          • *
                                                                                          • current, if the current ProductCatalogData was updated.
                                                                                          • @@ -91,6 +116,51 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                            Identifier of the updated Product Variant.

                                                                                            + *

                                                                                            This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                            id of the Embedded Price.

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

                                                                                            id of the referenced Type.

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

                                                                                            Name of the Custom Field.

                                                                                            + * + + * @return null|string + */ + public function getName() + { + return $this->name; + } + /** * @param ?string $change * @return $this @@ -135,6 +205,50 @@ public function withCatalogData(?string $catalogData) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + + /** + * @param ?string $priceId + * @return $this + */ + public function withPriceId(?string $priceId) + { + $this->priceId = $priceId; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -163,7 +277,11 @@ public function build(): SetProductPriceCustomFieldChange $this->change, $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue, - $this->catalogData + $this->catalogData, + $this->variant, + $this->priceId, + $this->customTypeId, + $this->name ); } diff --git a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChangeModel.php index a3bdbe67431..1c36883dc99 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomFieldChangeModel.php @@ -53,6 +53,30 @@ final class SetProductPriceCustomFieldChangeModel extends JsonObjectModel implem */ protected $catalogData; + /** + * + * @var ?string + */ + protected $variant; + + /** + * + * @var ?string + */ + protected $priceId; + + /** + * + * @var ?string + */ + protected $customTypeId; + + /** + * + * @var ?string + */ + protected $name; + /** * @psalm-suppress MissingParamType @@ -62,12 +86,20 @@ public function __construct( ?CustomFields $previousValue = null, ?CustomFields $nextValue = null, ?string $catalogData = null, + ?string $variant = null, + ?string $priceId = null, + ?string $customTypeId = null, + ?string $name = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->catalogData = $catalogData; + $this->variant = $variant; + $this->priceId = $priceId; + $this->customTypeId = $customTypeId; + $this->name = $name; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -150,6 +182,7 @@ public function getNextValue() } /** + *

                                                                                            Product data that was updated.

                                                                                            *
                                                                                              *
                                                                                            • staged, if the staged ProductCatalogData was updated.
                                                                                            • *
                                                                                            • current, if the current ProductCatalogData was updated.
                                                                                            • @@ -172,6 +205,87 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                              Identifier of the updated Product Variant.

                                                                                              + *

                                                                                              This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                              id of the Embedded Price.

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

                                                                                              id of the referenced Type.

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

                                                                                              Name of the Custom Field.

                                                                                              + * + * + * @return null|string + */ + public function getName() + { + if (is_null($this->name)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NAME); + if (is_null($data)) { + return null; + } + $this->name = (string) $data; + } + + return $this->name; + } + /** * @param ?string $change @@ -205,6 +319,38 @@ public function setCatalogData(?string $catalogData): void $this->catalogData = $catalogData; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + + /** + * @param ?string $priceId + */ + public function setPriceId(?string $priceId): void + { + $this->priceId = $priceId; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChange.php index 79b30d17ee3..c6e514c254f 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChange.php +++ b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChange.php @@ -18,6 +18,8 @@ interface SetProductPriceCustomTypeChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; + public const FIELD_PRICE_ID = 'priceId'; /** @@ -48,6 +50,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                                                              Product data that was updated.

                                                                                              *
                                                                                                *
                                                                                              • staged, if the staged ProductCatalogData was updated.
                                                                                              • *
                                                                                              • current, if the current ProductCatalogData was updated.
                                                                                              • @@ -58,6 +61,23 @@ public function getNextValue(); */ public function getCatalogData(); + /** + *

                                                                                                Identifier of the updated Product Variant.

                                                                                                + *

                                                                                                This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                                id of the Embedded Price.

                                                                                                + * + + * @return null|string + */ + public function getPriceId(); + /** * @param ?string $change */ @@ -77,4 +97,14 @@ public function setNextValue(?CustomFields $nextValue): void; * @param ?string $catalogData */ public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; + + /** + * @param ?string $priceId + */ + public function setPriceId(?string $priceId): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChangeBuilder.php index 8c135027da9..7596e221e5e 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChangeBuilder.php @@ -46,6 +46,18 @@ final class SetProductPriceCustomTypeChangeBuilder implements Builder */ private $catalogData; + /** + + * @var ?string + */ + private $variant; + + /** + + * @var ?string + */ + private $priceId; + /** * @return null|string @@ -78,6 +90,7 @@ public function getNextValue() } /** + *

                                                                                                Product data that was updated.

                                                                                                *
                                                                                                  *
                                                                                                • staged, if the staged ProductCatalogData was updated.
                                                                                                • *
                                                                                                • current, if the current ProductCatalogData was updated.
                                                                                                • @@ -91,6 +104,29 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                                  Identifier of the updated Product Variant.

                                                                                                  + *

                                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                                  id of the Embedded Price.

                                                                                                  + * + + * @return null|string + */ + public function getPriceId() + { + return $this->priceId; + } + /** * @param ?string $change * @return $this @@ -135,6 +171,28 @@ public function withCatalogData(?string $catalogData) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + + /** + * @param ?string $priceId + * @return $this + */ + public function withPriceId(?string $priceId) + { + $this->priceId = $priceId; + + return $this; + } + /** * @deprecated use withPreviousValue() instead * @return $this @@ -163,7 +221,9 @@ public function build(): SetProductPriceCustomTypeChange $this->change, $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue, - $this->catalogData + $this->catalogData, + $this->variant, + $this->priceId ); } diff --git a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChangeModel.php index 5a116add751..6ce755c252d 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetProductPriceCustomTypeChangeModel.php @@ -53,6 +53,18 @@ final class SetProductPriceCustomTypeChangeModel extends JsonObjectModel impleme */ protected $catalogData; + /** + * + * @var ?string + */ + protected $variant; + + /** + * + * @var ?string + */ + protected $priceId; + /** * @psalm-suppress MissingParamType @@ -62,12 +74,16 @@ public function __construct( ?CustomFields $previousValue = null, ?CustomFields $nextValue = null, ?string $catalogData = null, + ?string $variant = null, + ?string $priceId = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->catalogData = $catalogData; + $this->variant = $variant; + $this->priceId = $priceId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -150,6 +166,7 @@ public function getNextValue() } /** + *

                                                                                                  Product data that was updated.

                                                                                                  *
                                                                                                    *
                                                                                                  • staged, if the staged ProductCatalogData was updated.
                                                                                                  • *
                                                                                                  • current, if the current ProductCatalogData was updated.
                                                                                                  • @@ -172,6 +189,47 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                                    Identifier of the updated Product Variant.

                                                                                                    + *

                                                                                                    This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                                    id of the Embedded Price.

                                                                                                    + * + * + * @return null|string + */ + public function getPriceId() + { + if (is_null($this->priceId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_PRICE_ID); + if (is_null($data)) { + return null; + } + $this->priceId = (string) $data; + } + + return $this->priceId; + } + /** * @param ?string $change @@ -205,6 +263,22 @@ public function setCatalogData(?string $catalogData): void $this->catalogData = $catalogData; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + + /** + * @param ?string $priceId + */ + public function setPriceId(?string $priceId): void + { + $this->priceId = $priceId; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetProductSelectionsChange.php b/lib/commercetools-history/src/Models/Change/SetProductSelectionsChange.php index ce08b1c74ca..66fc00e51f8 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductSelectionsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetProductSelectionsChange.php @@ -17,6 +17,8 @@ interface SetProductSelectionsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -46,6 +48,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                                    Elements added to the array.

                                                                                                    + * + + * @return null|ProductSelectionSettingCollection + */ + public function getAddedItems(); + + /** + *

                                                                                                    Elements removed from the array.

                                                                                                    + * + + * @return null|ProductSelectionSettingCollection + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -60,4 +78,14 @@ public function setPreviousValue(?ProductSelectionSettingCollection $previousVal * @param ?ProductSelectionSettingCollection $nextValue */ public function setNextValue(?ProductSelectionSettingCollection $nextValue): void; + + /** + * @param ?ProductSelectionSettingCollection $addedItems + */ + public function setAddedItems(?ProductSelectionSettingCollection $addedItems): void; + + /** + * @param ?ProductSelectionSettingCollection $removedItems + */ + public function setRemovedItems(?ProductSelectionSettingCollection $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetProductSelectionsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetProductSelectionsChangeBuilder.php index f1a47b87229..71de497a54a 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductSelectionsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetProductSelectionsChangeBuilder.php @@ -39,6 +39,18 @@ final class SetProductSelectionsChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?ProductSelectionSettingCollection + */ + private $addedItems; + + /** + + * @var ?ProductSelectionSettingCollection + */ + private $removedItems; + /** * @return null|string @@ -70,6 +82,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                    Elements added to the array.

                                                                                                    + * + + * @return null|ProductSelectionSettingCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                                    Elements removed from the array.

                                                                                                    + * + + * @return null|ProductSelectionSettingCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -103,13 +137,37 @@ public function withNextValue(?ProductSelectionSettingCollection $nextValue) return $this; } + /** + * @param ?ProductSelectionSettingCollection $addedItems + * @return $this + */ + public function withAddedItems(?ProductSelectionSettingCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?ProductSelectionSettingCollection $removedItems + * @return $this + */ + public function withRemovedItems(?ProductSelectionSettingCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetProductSelectionsChange { return new SetProductSelectionsChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetProductSelectionsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetProductSelectionsChangeModel.php index aabae360aef..1215df25c92 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductSelectionsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetProductSelectionsChangeModel.php @@ -46,6 +46,18 @@ final class SetProductSelectionsChangeModel extends JsonObjectModel implements S */ protected $nextValue; + /** + * + * @var ?ProductSelectionSettingCollection + */ + protected $addedItems; + + /** + * + * @var ?ProductSelectionSettingCollection + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -54,11 +66,15 @@ public function __construct( ?string $change = null, ?ProductSelectionSettingCollection $previousValue = null, ?ProductSelectionSettingCollection $nextValue = null, + ?ProductSelectionSettingCollection $addedItems = null, + ?ProductSelectionSettingCollection $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -138,6 +154,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                    Elements added to the array.

                                                                                                    + * + * + * @return null|ProductSelectionSettingCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = ProductSelectionSettingCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                                                    Elements removed from the array.

                                                                                                    + * + * + * @return null|ProductSelectionSettingCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = ProductSelectionSettingCollection::fromArray($data); + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -163,6 +219,22 @@ public function setNextValue(?ProductSelectionSettingCollection $nextValue): voi $this->nextValue = $nextValue; } + /** + * @param ?ProductSelectionSettingCollection $addedItems + */ + public function setAddedItems(?ProductSelectionSettingCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?ProductSelectionSettingCollection $removedItems + */ + public function setRemovedItems(?ProductSelectionSettingCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChange.php b/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChange.php index 4f8df81184b..761fc6873ea 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChange.php +++ b/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChange.php @@ -17,6 +17,7 @@ interface SetProductVariantKeyChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -47,6 +48,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                                                                    Product data that was updated.

                                                                                                    *
                                                                                                      *
                                                                                                    • staged, if the staged ProductCatalogData was updated.
                                                                                                    • *
                                                                                                    • current, if the current ProductCatalogData was updated.
                                                                                                    • @@ -57,6 +59,15 @@ public function getNextValue(); */ public function getCatalogData(); + /** + *

                                                                                                      Identifier of the updated Product Variant.

                                                                                                      + *

                                                                                                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                                      + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -76,4 +87,9 @@ public function setNextValue(?string $nextValue): void; * @param ?string $catalogData */ public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChangeBuilder.php index 798d32abd35..ef5ff33f9a6 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChangeBuilder.php @@ -44,6 +44,12 @@ final class SetProductVariantKeyChangeBuilder implements Builder */ private $catalogData; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -76,6 +82,7 @@ public function getNextValue() } /** + *

                                                                                                      Product data that was updated.

                                                                                                      *
                                                                                                        *
                                                                                                      • staged, if the staged ProductCatalogData was updated.
                                                                                                      • *
                                                                                                      • current, if the current ProductCatalogData was updated.
                                                                                                      • @@ -89,6 +96,18 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                                        Identifier of the updated Product Variant.

                                                                                                        + *

                                                                                                        This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                                        + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -133,6 +152,17 @@ public function withCatalogData(?string $catalogData) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + public function build(): SetProductVariantKeyChange { @@ -140,7 +170,8 @@ public function build(): SetProductVariantKeyChange $this->change, $this->previousValue, $this->nextValue, - $this->catalogData + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChangeModel.php b/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChangeModel.php index e8fab476fb4..517279630ae 100644 --- a/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetProductVariantKeyChangeModel.php @@ -51,6 +51,12 @@ final class SetProductVariantKeyChangeModel extends JsonObjectModel implements S */ protected $catalogData; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -60,12 +66,14 @@ public function __construct( ?string $previousValue = null, ?string $nextValue = null, ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -146,6 +154,7 @@ public function getNextValue() } /** + *

                                                                                                        Product data that was updated.

                                                                                                        *
                                                                                                          *
                                                                                                        • staged, if the staged ProductCatalogData was updated.
                                                                                                        • *
                                                                                                        • current, if the current ProductCatalogData was updated.
                                                                                                        • @@ -168,6 +177,27 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                                          Identifier of the updated Product Variant.

                                                                                                          + *

                                                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                                          + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -201,6 +231,14 @@ public function setCatalogData(?string $catalogData): void $this->catalogData = $catalogData; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetReservationsChange.php b/lib/commercetools-history/src/Models/Change/SetReservationsChange.php index 4701463792d..6c77e180ffc 100644 --- a/lib/commercetools-history/src/Models/Change/SetReservationsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetReservationsChange.php @@ -17,6 +17,8 @@ interface SetReservationsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -46,6 +48,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                                          Elements added to the array.

                                                                                                          + * + + * @return null|ReservationCollection + */ + public function getAddedItems(); + + /** + *

                                                                                                          Elements removed from the array.

                                                                                                          + * + + * @return null|ReservationCollection + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -60,4 +78,14 @@ public function setPreviousValue(?ReservationCollection $previousValue): void; * @param ?ReservationCollection $nextValue */ public function setNextValue(?ReservationCollection $nextValue): void; + + /** + * @param ?ReservationCollection $addedItems + */ + public function setAddedItems(?ReservationCollection $addedItems): void; + + /** + * @param ?ReservationCollection $removedItems + */ + public function setRemovedItems(?ReservationCollection $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetReservationsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetReservationsChangeBuilder.php index 2f010544c3f..068f8bc3765 100644 --- a/lib/commercetools-history/src/Models/Change/SetReservationsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetReservationsChangeBuilder.php @@ -39,6 +39,18 @@ final class SetReservationsChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?ReservationCollection + */ + private $addedItems; + + /** + + * @var ?ReservationCollection + */ + private $removedItems; + /** * @return null|string @@ -70,6 +82,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                          Elements added to the array.

                                                                                                          + * + + * @return null|ReservationCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                                          Elements removed from the array.

                                                                                                          + * + + * @return null|ReservationCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -103,13 +137,37 @@ public function withNextValue(?ReservationCollection $nextValue) return $this; } + /** + * @param ?ReservationCollection $addedItems + * @return $this + */ + public function withAddedItems(?ReservationCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?ReservationCollection $removedItems + * @return $this + */ + public function withRemovedItems(?ReservationCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetReservationsChange { return new SetReservationsChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetReservationsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetReservationsChangeModel.php index 79093bb9660..fdf8de6f78d 100644 --- a/lib/commercetools-history/src/Models/Change/SetReservationsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetReservationsChangeModel.php @@ -46,6 +46,18 @@ final class SetReservationsChangeModel extends JsonObjectModel implements SetRes */ protected $nextValue; + /** + * + * @var ?ReservationCollection + */ + protected $addedItems; + + /** + * + * @var ?ReservationCollection + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -54,11 +66,15 @@ public function __construct( ?string $change = null, ?ReservationCollection $previousValue = null, ?ReservationCollection $nextValue = null, + ?ReservationCollection $addedItems = null, + ?ReservationCollection $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -138,6 +154,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                          Elements added to the array.

                                                                                                          + * + * + * @return null|ReservationCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = ReservationCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                                                          Elements removed from the array.

                                                                                                          + * + * + * @return null|ReservationCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = ReservationCollection::fromArray($data); + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -163,6 +219,22 @@ public function setNextValue(?ReservationCollection $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?ReservationCollection $addedItems + */ + public function setAddedItems(?ReservationCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?ReservationCollection $removedItems + */ + public function setRemovedItems(?ReservationCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetReturnInfoChange.php b/lib/commercetools-history/src/Models/Change/SetReturnInfoChange.php new file mode 100644 index 00000000000..bfad4e2ee65 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnInfoChange.php @@ -0,0 +1,63 @@ +Value before the change.

                                                                                                          + * + + * @return null|ReturnInfo + */ + public function getPreviousValue(); + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|ReturnInfo + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?ReturnInfo $previousValue + */ + public function setPreviousValue(?ReturnInfo $previousValue): void; + + /** + * @param ?ReturnInfo $nextValue + */ + public function setNextValue(?ReturnInfo $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnInfoChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetReturnInfoChangeBuilder.php new file mode 100644 index 00000000000..82911f1f15b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnInfoChangeBuilder.php @@ -0,0 +1,142 @@ + + */ +final class SetReturnInfoChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|ReturnInfo|ReturnInfoBuilder + */ + private $previousValue; + + /** + + * @var null|ReturnInfo|ReturnInfoBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                          Value before the change.

                                                                                                          + * + + * @return null|ReturnInfo + */ + public function getPreviousValue() + { + return $this->previousValue instanceof ReturnInfoBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|ReturnInfo + */ + public function getNextValue() + { + return $this->nextValue instanceof ReturnInfoBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?ReturnInfo $previousValue + * @return $this + */ + public function withPreviousValue(?ReturnInfo $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?ReturnInfo $nextValue + * @return $this + */ + public function withNextValue(?ReturnInfo $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?ReturnInfoBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?ReturnInfoBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetReturnInfoChange + { + return new SetReturnInfoChangeModel( + $this->change, + $this->previousValue instanceof ReturnInfoBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof ReturnInfoBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetReturnInfoChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnInfoChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetReturnInfoChangeCollection.php new file mode 100644 index 00000000000..19028b65e54 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnInfoChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetReturnInfoChange current() + * @method SetReturnInfoChange end() + * @method SetReturnInfoChange at($offset) + */ +class SetReturnInfoChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetReturnInfoChange $value + * @psalm-param SetReturnInfoChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetReturnInfoChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetReturnInfoChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetReturnInfoChange + */ + protected function mapper() + { + return function (?int $index): ?SetReturnInfoChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetReturnInfoChange $data */ + $data = SetReturnInfoChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnInfoChangeModel.php b/lib/commercetools-history/src/Models/Change/SetReturnInfoChangeModel.php new file mode 100644 index 00000000000..c9c37743d7d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnInfoChangeModel.php @@ -0,0 +1,171 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                          Value before the change.

                                                                                                          + * + * + * @return null|ReturnInfo + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = ReturnInfoModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + * + * @return null|ReturnInfo + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = ReturnInfoModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?ReturnInfo $previousValue + */ + public function setPreviousValue(?ReturnInfo $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?ReturnInfo $nextValue + */ + public function setNextValue(?ReturnInfo $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChange.php new file mode 100644 index 00000000000..1ecc02310b7 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChange.php @@ -0,0 +1,119 @@ +Name of the updated CustomLineItem.

                                                                                                          + * + + * @return null|LocalizedString + */ + public function getCustomLineItem(); + + /** + *

                                                                                                          id of the updated CustomLineItem.

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

                                                                                                          Name of the Custom Field.

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

                                                                                                          id of the referenced Type.

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

                                                                                                          Value before the change.

                                                                                                          + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void; + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..62129d59d29 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChangeBuilder.php @@ -0,0 +1,247 @@ + + */ +final class SetReturnItemCustomLineItemCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $customLineItem; + + /** + + * @var ?string + */ + private $customLineItemId; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                          Name of the updated CustomLineItem.

                                                                                                          + * + + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + return $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem; + } + + /** + *

                                                                                                          id of the updated CustomLineItem.

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

                                                                                                          Name of the Custom Field.

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

                                                                                                          id of the referenced Type.

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

                                                                                                          Value before the change.

                                                                                                          + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?LocalizedString $customLineItem + * @return $this + */ + public function withCustomLineItem(?LocalizedString $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + + /** + * @param ?string $customLineItemId + * @return $this + */ + public function withCustomLineItemId(?string $customLineItemId) + { + $this->customLineItemId = $customLineItemId; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withCustomLineItem() instead + * @return $this + */ + public function withCustomLineItemBuilder(?LocalizedStringBuilder $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + + public function build(): SetReturnItemCustomLineItemCustomFieldChange + { + return new SetReturnItemCustomLineItemCustomFieldChangeModel( + $this->change, + $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem, + $this->customLineItemId, + $this->name, + $this->customTypeId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetReturnItemCustomLineItemCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChangeCollection.php new file mode 100644 index 00000000000..12af24bf7f4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetReturnItemCustomLineItemCustomFieldChange current() + * @method SetReturnItemCustomLineItemCustomFieldChange end() + * @method SetReturnItemCustomLineItemCustomFieldChange at($offset) + */ +class SetReturnItemCustomLineItemCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetReturnItemCustomLineItemCustomFieldChange $value + * @psalm-param SetReturnItemCustomLineItemCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetReturnItemCustomLineItemCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetReturnItemCustomLineItemCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetReturnItemCustomLineItemCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetReturnItemCustomLineItemCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetReturnItemCustomLineItemCustomFieldChange $data */ + $data = SetReturnItemCustomLineItemCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChangeModel.php new file mode 100644 index 00000000000..6673dafd5fb --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomFieldChangeModel.php @@ -0,0 +1,314 @@ +change = $change; + $this->customLineItem = $customLineItem; + $this->customLineItemId = $customLineItemId; + $this->name = $name; + $this->customTypeId = $customTypeId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                          Name of the updated CustomLineItem.

                                                                                                          + * + * + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + if (is_null($this->customLineItem)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM_LINE_ITEM); + if (is_null($data)) { + return null; + } + + $this->customLineItem = LocalizedStringModel::of($data); + } + + return $this->customLineItem; + } + + /** + *

                                                                                                          id of the updated CustomLineItem.

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

                                                                                                          Name of the Custom Field.

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

                                                                                                          id of the referenced Type.

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

                                                                                                          Value before the change.

                                                                                                          + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void + { + $this->customLineItem = $customLineItem; + } + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void + { + $this->customLineItemId = $customLineItemId; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChange.php new file mode 100644 index 00000000000..3abc1ccf54b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChange.php @@ -0,0 +1,92 @@ +Name of the updated CustomLineItem.

                                                                                                          + * + + * @return null|LocalizedString + */ + public function getCustomLineItem(); + + /** + *

                                                                                                          id of the updated CustomLineItem.

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

                                                                                                          Value before the change.

                                                                                                          + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void; + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..ecd1845d356 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChangeBuilder.php @@ -0,0 +1,213 @@ + + */ +final class SetReturnItemCustomLineItemCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $customLineItem; + + /** + + * @var ?string + */ + private $customLineItemId; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                          Name of the updated CustomLineItem.

                                                                                                          + * + + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + return $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem; + } + + /** + *

                                                                                                          id of the updated CustomLineItem.

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

                                                                                                          Value before the change.

                                                                                                          + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?LocalizedString $customLineItem + * @return $this + */ + public function withCustomLineItem(?LocalizedString $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + + /** + * @param ?string $customLineItemId + * @return $this + */ + public function withCustomLineItemId(?string $customLineItemId) + { + $this->customLineItemId = $customLineItemId; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withCustomLineItem() instead + * @return $this + */ + public function withCustomLineItemBuilder(?LocalizedStringBuilder $customLineItem) + { + $this->customLineItem = $customLineItem; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetReturnItemCustomLineItemCustomTypeChange + { + return new SetReturnItemCustomLineItemCustomTypeChangeModel( + $this->change, + $this->customLineItem instanceof LocalizedStringBuilder ? $this->customLineItem->build() : $this->customLineItem, + $this->customLineItemId, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetReturnItemCustomLineItemCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChangeCollection.php new file mode 100644 index 00000000000..d615b96f045 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetReturnItemCustomLineItemCustomTypeChange current() + * @method SetReturnItemCustomLineItemCustomTypeChange end() + * @method SetReturnItemCustomLineItemCustomTypeChange at($offset) + */ +class SetReturnItemCustomLineItemCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetReturnItemCustomLineItemCustomTypeChange $value + * @psalm-param SetReturnItemCustomLineItemCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetReturnItemCustomLineItemCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetReturnItemCustomLineItemCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetReturnItemCustomLineItemCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetReturnItemCustomLineItemCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetReturnItemCustomLineItemCustomTypeChange $data */ + $data = SetReturnItemCustomLineItemCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChangeModel.php new file mode 100644 index 00000000000..526179c1fa2 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemCustomLineItemCustomTypeChangeModel.php @@ -0,0 +1,246 @@ +change = $change; + $this->customLineItem = $customLineItem; + $this->customLineItemId = $customLineItemId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                          Name of the updated CustomLineItem.

                                                                                                          + * + * + * @return null|LocalizedString + */ + public function getCustomLineItem() + { + if (is_null($this->customLineItem)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM_LINE_ITEM); + if (is_null($data)) { + return null; + } + + $this->customLineItem = LocalizedStringModel::of($data); + } + + return $this->customLineItem; + } + + /** + *

                                                                                                          id of the updated CustomLineItem.

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

                                                                                                          Value before the change.

                                                                                                          + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?LocalizedString $customLineItem + */ + public function setCustomLineItem(?LocalizedString $customLineItem): void + { + $this->customLineItem = $customLineItem; + } + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void + { + $this->customLineItemId = $customLineItemId; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChange.php new file mode 100644 index 00000000000..ff3b212b0cc --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChange.php @@ -0,0 +1,134 @@ +Identifier of the updated Product Variant.

                                                                                                          + *

                                                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                                          Name of the Product the updated Line Item is based on.

                                                                                                          + * + + * @return null|LocalizedString + */ + public function getLineItem(); + + /** + *

                                                                                                          id of the updated LineItem.

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

                                                                                                          Name of the Custom Field.

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

                                                                                                          id of the referenced Type.

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

                                                                                                          Value before the change.

                                                                                                          + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; + + /** + * @param ?LocalizedString $lineItem + */ + public function setLineItem(?LocalizedString $lineItem): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..ea60a625e51 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChangeBuilder.php @@ -0,0 +1,277 @@ + + */ +final class SetReturnItemLineItemCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $variant; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $lineItem; + + /** + + * @var ?string + */ + private $lineItemId; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                          Identifier of the updated Product Variant.

                                                                                                          + *

                                                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                                          Name of the Product the updated Line Item is based on.

                                                                                                          + * + + * @return null|LocalizedString + */ + public function getLineItem() + { + return $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem; + } + + /** + *

                                                                                                          id of the updated LineItem.

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

                                                                                                          Name of the Custom Field.

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

                                                                                                          id of the referenced Type.

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

                                                                                                          Value before the change.

                                                                                                          + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + + /** + * @param ?LocalizedString $lineItem + * @return $this + */ + public function withLineItem(?LocalizedString $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withLineItem() instead + * @return $this + */ + public function withLineItemBuilder(?LocalizedStringBuilder $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + public function build(): SetReturnItemLineItemCustomFieldChange + { + return new SetReturnItemLineItemCustomFieldChangeModel( + $this->change, + $this->variant, + $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, + $this->lineItemId, + $this->name, + $this->customTypeId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetReturnItemLineItemCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChangeCollection.php new file mode 100644 index 00000000000..e02ccfb74a4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetReturnItemLineItemCustomFieldChange current() + * @method SetReturnItemLineItemCustomFieldChange end() + * @method SetReturnItemLineItemCustomFieldChange at($offset) + */ +class SetReturnItemLineItemCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetReturnItemLineItemCustomFieldChange $value + * @psalm-param SetReturnItemLineItemCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetReturnItemLineItemCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetReturnItemLineItemCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetReturnItemLineItemCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetReturnItemLineItemCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetReturnItemLineItemCustomFieldChange $data */ + $data = SetReturnItemLineItemCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChangeModel.php new file mode 100644 index 00000000000..8e303bd943d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomFieldChangeModel.php @@ -0,0 +1,351 @@ +change = $change; + $this->variant = $variant; + $this->lineItem = $lineItem; + $this->lineItemId = $lineItemId; + $this->name = $name; + $this->customTypeId = $customTypeId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                          Identifier of the updated Product Variant.

                                                                                                          + *

                                                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                                          Name of the Product the updated Line Item is based on.

                                                                                                          + * + * + * @return null|LocalizedString + */ + 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 = LocalizedStringModel::of($data); + } + + return $this->lineItem; + } + + /** + *

                                                                                                          id of the updated LineItem.

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

                                                                                                          Name of the Custom Field.

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

                                                                                                          id of the referenced Type.

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

                                                                                                          Value before the change.

                                                                                                          + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + + /** + * @param ?LocalizedString $lineItem + */ + public function setLineItem(?LocalizedString $lineItem): void + { + $this->lineItem = $lineItem; + } + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChange.php new file mode 100644 index 00000000000..008b3232ec3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChange.php @@ -0,0 +1,107 @@ +Identifier of the updated Product Variant.

                                                                                                          + *

                                                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                                          Name of the Product the updated Line Item is based on.

                                                                                                          + * + + * @return null|LocalizedString + */ + public function getLineItem(); + + /** + *

                                                                                                          id of the updated LineItem.

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

                                                                                                          Value before the change.

                                                                                                          + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; + + /** + * @param ?LocalizedString $lineItem + */ + public function setLineItem(?LocalizedString $lineItem): void; + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..1f264e17847 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChangeBuilder.php @@ -0,0 +1,243 @@ + + */ +final class SetReturnItemLineItemCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $variant; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $lineItem; + + /** + + * @var ?string + */ + private $lineItemId; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                          Identifier of the updated Product Variant.

                                                                                                          + *

                                                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                                          Name of the Product the updated Line Item is based on.

                                                                                                          + * + + * @return null|LocalizedString + */ + public function getLineItem() + { + return $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem; + } + + /** + *

                                                                                                          id of the updated LineItem.

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

                                                                                                          Value before the change.

                                                                                                          + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + + /** + * @param ?LocalizedString $lineItem + * @return $this + */ + public function withLineItem(?LocalizedString $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withLineItem() instead + * @return $this + */ + public function withLineItemBuilder(?LocalizedStringBuilder $lineItem) + { + $this->lineItem = $lineItem; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetReturnItemLineItemCustomTypeChange + { + return new SetReturnItemLineItemCustomTypeChangeModel( + $this->change, + $this->variant, + $this->lineItem instanceof LocalizedStringBuilder ? $this->lineItem->build() : $this->lineItem, + $this->lineItemId, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetReturnItemLineItemCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChangeCollection.php new file mode 100644 index 00000000000..e2fb62aacec --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetReturnItemLineItemCustomTypeChange current() + * @method SetReturnItemLineItemCustomTypeChange end() + * @method SetReturnItemLineItemCustomTypeChange at($offset) + */ +class SetReturnItemLineItemCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetReturnItemLineItemCustomTypeChange $value + * @psalm-param SetReturnItemLineItemCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetReturnItemLineItemCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetReturnItemLineItemCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetReturnItemLineItemCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetReturnItemLineItemCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetReturnItemLineItemCustomTypeChange $data */ + $data = SetReturnItemLineItemCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChangeModel.php new file mode 100644 index 00000000000..10fbeded887 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetReturnItemLineItemCustomTypeChangeModel.php @@ -0,0 +1,283 @@ +change = $change; + $this->variant = $variant; + $this->lineItem = $lineItem; + $this->lineItemId = $lineItemId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                          Identifier of the updated Product Variant.

                                                                                                          + *

                                                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

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

                                                                                                          Name of the Product the updated Line Item is based on.

                                                                                                          + * + * + * @return null|LocalizedString + */ + 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 = LocalizedStringModel::of($data); + } + + return $this->lineItem; + } + + /** + *

                                                                                                          id of the updated LineItem.

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

                                                                                                          Value before the change.

                                                                                                          + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                                          Value after the change.

                                                                                                          + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + + /** + * @param ?LocalizedString $lineItem + */ + public function setLineItem(?LocalizedString $lineItem): void + { + $this->lineItem = $lineItem; + } + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChange.php b/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChange.php index cdf5340689d..c4da097015c 100644 --- a/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChange.php @@ -48,6 +48,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                                                                          Product data that was updated.

                                                                                                          *
                                                                                                            *
                                                                                                          • staged, if the staged ProductCatalogData was updated.
                                                                                                          • *
                                                                                                          • current, if the current ProductCatalogData was updated.
                                                                                                          • diff --git a/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChangeBuilder.php index 50e8408392d..10924a3ed39 100644 --- a/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChangeBuilder.php @@ -78,6 +78,7 @@ public function getNextValue() } /** + *

                                                                                                            Product data that was updated.

                                                                                                            *
                                                                                                              *
                                                                                                            • staged, if the staged ProductCatalogData was updated.
                                                                                                            • *
                                                                                                            • current, if the current ProductCatalogData was updated.
                                                                                                            • diff --git a/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChangeModel.php index 7620294c7cc..67207e648a5 100644 --- a/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetSearchKeywordsChangeModel.php @@ -150,6 +150,7 @@ public function getNextValue() } /** + *

                                                                                                              Product data that was updated.

                                                                                                              *
                                                                                                                *
                                                                                                              • staged, if the staged ProductCatalogData was updated.
                                                                                                              • *
                                                                                                              • current, if the current ProductCatalogData was updated.
                                                                                                              • diff --git a/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChange.php new file mode 100644 index 00000000000..ecc90fb5134 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChange.php @@ -0,0 +1,90 @@ +Name of the Custom Field.

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

                                                                                                                id of the referenced Type.

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

                                                                                                                Value before the change.

                                                                                                                + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..d9d181845c7 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChangeBuilder.php @@ -0,0 +1,177 @@ + + */ +final class SetShippingAddressCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                                Name of the Custom Field.

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

                                                                                                                id of the referenced Type.

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

                                                                                                                Value before the change.

                                                                                                                + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetShippingAddressCustomFieldChange + { + return new SetShippingAddressCustomFieldChangeModel( + $this->change, + $this->name, + $this->customTypeId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetShippingAddressCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChangeCollection.php new file mode 100644 index 00000000000..8c770cbf40d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetShippingAddressCustomFieldChange current() + * @method SetShippingAddressCustomFieldChange end() + * @method SetShippingAddressCustomFieldChange at($offset) + */ +class SetShippingAddressCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetShippingAddressCustomFieldChange $value + * @psalm-param SetShippingAddressCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetShippingAddressCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetShippingAddressCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetShippingAddressCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetShippingAddressCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetShippingAddressCustomFieldChange $data */ + $data = SetShippingAddressCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChangeModel.php new file mode 100644 index 00000000000..e305d624dcf --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomFieldChangeModel.php @@ -0,0 +1,239 @@ +change = $change; + $this->name = $name; + $this->customTypeId = $customTypeId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                                Name of the Custom Field.

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

                                                                                                                id of the referenced Type.

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

                                                                                                                Value before the change.

                                                                                                                + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChange.php new file mode 100644 index 00000000000..2098fb5bcfa --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChange.php @@ -0,0 +1,63 @@ +Value before the change.

                                                                                                                + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..d058825961b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChangeBuilder.php @@ -0,0 +1,142 @@ + + */ +final class SetShippingAddressCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                                Value before the change.

                                                                                                                + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetShippingAddressCustomTypeChange + { + return new SetShippingAddressCustomTypeChangeModel( + $this->change, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetShippingAddressCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChangeCollection.php new file mode 100644 index 00000000000..adb10918457 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetShippingAddressCustomTypeChange current() + * @method SetShippingAddressCustomTypeChange end() + * @method SetShippingAddressCustomTypeChange at($offset) + */ +class SetShippingAddressCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetShippingAddressCustomTypeChange $value + * @psalm-param SetShippingAddressCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetShippingAddressCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetShippingAddressCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetShippingAddressCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetShippingAddressCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetShippingAddressCustomTypeChange $data */ + $data = SetShippingAddressCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChangeModel.php new file mode 100644 index 00000000000..05796059370 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingAddressCustomTypeChangeModel.php @@ -0,0 +1,171 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                                Value before the change.

                                                                                                                + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChange.php new file mode 100644 index 00000000000..936f667f1d1 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChange.php @@ -0,0 +1,104 @@ +shippingKey of the updated Shipping.

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

                                                                                                                Name of the Custom Field.

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

                                                                                                                id of the referenced Type.

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

                                                                                                                Value before the change.

                                                                                                                + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $shippingKey + */ + public function setShippingKey(?string $shippingKey): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..d9466ed7f24 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChangeBuilder.php @@ -0,0 +1,206 @@ + + */ +final class SetShippingCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $shippingKey; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                                shippingKey of the updated Shipping.

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

                                                                                                                Name of the Custom Field.

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

                                                                                                                id of the referenced Type.

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

                                                                                                                Value before the change.

                                                                                                                + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $shippingKey + * @return $this + */ + public function withShippingKey(?string $shippingKey) + { + $this->shippingKey = $shippingKey; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + + public function build(): SetShippingCustomFieldChange + { + return new SetShippingCustomFieldChangeModel( + $this->change, + $this->shippingKey, + $this->name, + $this->customTypeId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetShippingCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChangeCollection.php new file mode 100644 index 00000000000..d0e17365593 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetShippingCustomFieldChange current() + * @method SetShippingCustomFieldChange end() + * @method SetShippingCustomFieldChange at($offset) + */ +class SetShippingCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetShippingCustomFieldChange $value + * @psalm-param SetShippingCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetShippingCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetShippingCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetShippingCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetShippingCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetShippingCustomFieldChange $data */ + $data = SetShippingCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChangeModel.php new file mode 100644 index 00000000000..77d05632546 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingCustomFieldChangeModel.php @@ -0,0 +1,275 @@ +change = $change; + $this->shippingKey = $shippingKey; + $this->name = $name; + $this->customTypeId = $customTypeId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                                shippingKey of the updated Shipping.

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

                                                                                                                Name of the Custom Field.

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

                                                                                                                id of the referenced Type.

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

                                                                                                                Value before the change.

                                                                                                                + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $shippingKey + */ + public function setShippingKey(?string $shippingKey): void + { + $this->shippingKey = $shippingKey; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChange.php new file mode 100644 index 00000000000..d76305a2b0c --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChange.php @@ -0,0 +1,77 @@ +shippingKey of the updated Shipping.

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

                                                                                                                Value before the change.

                                                                                                                + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?string $shippingKey + */ + public function setShippingKey(?string $shippingKey): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..5c94f176603 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChangeBuilder.php @@ -0,0 +1,171 @@ + + */ +final class SetShippingCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var ?string + */ + private $shippingKey; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                                shippingKey of the updated Shipping.

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

                                                                                                                Value before the change.

                                                                                                                + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?string $shippingKey + * @return $this + */ + public function withShippingKey(?string $shippingKey) + { + $this->shippingKey = $shippingKey; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetShippingCustomTypeChange + { + return new SetShippingCustomTypeChangeModel( + $this->change, + $this->shippingKey, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetShippingCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChangeCollection.php new file mode 100644 index 00000000000..a65e262e1b8 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetShippingCustomTypeChange current() + * @method SetShippingCustomTypeChange end() + * @method SetShippingCustomTypeChange at($offset) + */ +class SetShippingCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetShippingCustomTypeChange $value + * @psalm-param SetShippingCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetShippingCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetShippingCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetShippingCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetShippingCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetShippingCustomTypeChange $data */ + $data = SetShippingCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChangeModel.php new file mode 100644 index 00000000000..29bc1e43e31 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetShippingCustomTypeChangeModel.php @@ -0,0 +1,207 @@ +change = $change; + $this->shippingKey = $shippingKey; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                                shippingKey of the updated Shipping.

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

                                                                                                                Value before the change.

                                                                                                                + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                                                Value after the change.

                                                                                                                + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?string $shippingKey + */ + public function setShippingKey(?string $shippingKey): void + { + $this->shippingKey = $shippingKey; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChange.php b/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChange.php index 7cc30c364c4..c7302cf7946 100644 --- a/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChange.php +++ b/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\Common\TaxedPrice; +use Commercetools\History\Models\Common\TaxedItemPrice; interface SetShippingInfoTaxedPriceChange extends Change { @@ -34,7 +34,7 @@ public function getChange(); *

                                                                                                                Value before the change.

                                                                                                                * - * @return null|TaxedPrice + * @return null|TaxedItemPrice */ public function getPreviousValue(); @@ -42,7 +42,7 @@ public function getPreviousValue(); *

                                                                                                                Value after the change.

                                                                                                                * - * @return null|TaxedPrice + * @return null|TaxedItemPrice */ public function getNextValue(); @@ -52,12 +52,12 @@ public function getNextValue(); public function setChange(?string $change): void; /** - * @param ?TaxedPrice $previousValue + * @param ?TaxedItemPrice $previousValue */ - public function setPreviousValue(?TaxedPrice $previousValue): void; + public function setPreviousValue(?TaxedItemPrice $previousValue): void; /** - * @param ?TaxedPrice $nextValue + * @param ?TaxedItemPrice $nextValue */ - public function setNextValue(?TaxedPrice $nextValue): void; + public function setNextValue(?TaxedItemPrice $nextValue): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChangeBuilder.php index 9618c64efb8..a58c76df440 100644 --- a/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\TaxedPrice; -use Commercetools\History\Models\Common\TaxedPriceBuilder; +use Commercetools\History\Models\Common\TaxedItemPrice; +use Commercetools\History\Models\Common\TaxedItemPriceBuilder; /** * @implements Builder @@ -30,13 +30,13 @@ final class SetShippingInfoTaxedPriceChangeBuilder implements Builder /** - * @var null|TaxedPrice|TaxedPriceBuilder + * @var null|TaxedItemPrice|TaxedItemPriceBuilder */ private $previousValue; /** - * @var null|TaxedPrice|TaxedPriceBuilder + * @var null|TaxedItemPrice|TaxedItemPriceBuilder */ private $nextValue; @@ -53,22 +53,22 @@ public function getChange() *

                                                                                                                Value before the change.

                                                                                                                * - * @return null|TaxedPrice + * @return null|TaxedItemPrice */ public function getPreviousValue() { - return $this->previousValue instanceof TaxedPriceBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof TaxedItemPriceBuilder ? $this->previousValue->build() : $this->previousValue; } /** *

                                                                                                                Value after the change.

                                                                                                                * - * @return null|TaxedPrice + * @return null|TaxedItemPrice */ public function getNextValue() { - return $this->nextValue instanceof TaxedPriceBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof TaxedItemPriceBuilder ? $this->nextValue->build() : $this->nextValue; } /** @@ -83,10 +83,10 @@ public function withChange(?string $change) } /** - * @param ?TaxedPrice $previousValue + * @param ?TaxedItemPrice $previousValue * @return $this */ - public function withPreviousValue(?TaxedPrice $previousValue) + public function withPreviousValue(?TaxedItemPrice $previousValue) { $this->previousValue = $previousValue; @@ -94,10 +94,10 @@ public function withPreviousValue(?TaxedPrice $previousValue) } /** - * @param ?TaxedPrice $nextValue + * @param ?TaxedItemPrice $nextValue * @return $this */ - public function withNextValue(?TaxedPrice $nextValue) + public function withNextValue(?TaxedItemPrice $nextValue) { $this->nextValue = $nextValue; @@ -108,7 +108,7 @@ public function withNextValue(?TaxedPrice $nextValue) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?TaxedPriceBuilder $previousValue) + public function withPreviousValueBuilder(?TaxedItemPriceBuilder $previousValue) { $this->previousValue = $previousValue; @@ -119,7 +119,7 @@ public function withPreviousValueBuilder(?TaxedPriceBuilder $previousValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?TaxedPriceBuilder $nextValue) + public function withNextValueBuilder(?TaxedItemPriceBuilder $nextValue) { $this->nextValue = $nextValue; @@ -130,8 +130,8 @@ public function build(): SetShippingInfoTaxedPriceChange { return new SetShippingInfoTaxedPriceChangeModel( $this->change, - $this->previousValue instanceof TaxedPriceBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof TaxedPriceBuilder ? $this->nextValue->build() : $this->nextValue + $this->previousValue instanceof TaxedItemPriceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof TaxedItemPriceBuilder ? $this->nextValue->build() : $this->nextValue ); } diff --git a/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChangeModel.php b/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChangeModel.php index 696a18985bd..efc720ff11f 100644 --- a/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetShippingInfoTaxedPriceChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\TaxedPrice; -use Commercetools\History\Models\Common\TaxedPriceModel; +use Commercetools\History\Models\Common\TaxedItemPrice; +use Commercetools\History\Models\Common\TaxedItemPriceModel; /** * @internal @@ -37,13 +37,13 @@ final class SetShippingInfoTaxedPriceChangeModel extends JsonObjectModel impleme /** * - * @var ?TaxedPrice + * @var ?TaxedItemPrice */ protected $previousValue; /** * - * @var ?TaxedPrice + * @var ?TaxedItemPrice */ protected $nextValue; @@ -53,8 +53,8 @@ final class SetShippingInfoTaxedPriceChangeModel extends JsonObjectModel impleme */ public function __construct( ?string $change = null, - ?TaxedPrice $previousValue = null, - ?TaxedPrice $nextValue = null, + ?TaxedItemPrice $previousValue = null, + ?TaxedItemPrice $nextValue = null, ?string $type = null ) { $this->change = $change; @@ -103,7 +103,7 @@ public function getChange() *

                                                                                                                Value before the change.

                                                                                                                * * - * @return null|TaxedPrice + * @return null|TaxedItemPrice */ public function getPreviousValue() { @@ -114,7 +114,7 @@ public function getPreviousValue() return null; } - $this->previousValue = TaxedPriceModel::of($data); + $this->previousValue = TaxedItemPriceModel::of($data); } return $this->previousValue; @@ -124,7 +124,7 @@ public function getPreviousValue() *

                                                                                                                Value after the change.

                                                                                                                * * - * @return null|TaxedPrice + * @return null|TaxedItemPrice */ public function getNextValue() { @@ -135,7 +135,7 @@ public function getNextValue() return null; } - $this->nextValue = TaxedPriceModel::of($data); + $this->nextValue = TaxedItemPriceModel::of($data); } return $this->nextValue; @@ -151,17 +151,17 @@ public function setChange(?string $change): void } /** - * @param ?TaxedPrice $previousValue + * @param ?TaxedItemPrice $previousValue */ - public function setPreviousValue(?TaxedPrice $previousValue): void + public function setPreviousValue(?TaxedItemPrice $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?TaxedPrice $nextValue + * @param ?TaxedItemPrice $nextValue */ - public function setNextValue(?TaxedPrice $nextValue): void + public function setNextValue(?TaxedItemPrice $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/SetShippingRateChange.php b/lib/commercetools-history/src/Models/Change/SetShippingRateChange.php index 57323ce072a..226e8d99137 100644 --- a/lib/commercetools-history/src/Models/Change/SetShippingRateChange.php +++ b/lib/commercetools-history/src/Models/Change/SetShippingRateChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\Common\Money; +use Commercetools\History\Models\Common\ShippingRate; interface SetShippingRateChange extends Change { @@ -34,7 +34,7 @@ public function getChange(); *

                                                                                                                Value before the change.

                                                                                                                * - * @return null|Money + * @return null|ShippingRate */ public function getPreviousValue(); @@ -42,7 +42,7 @@ public function getPreviousValue(); *

                                                                                                                Value after the change.

                                                                                                                * - * @return null|Money + * @return null|ShippingRate */ public function getNextValue(); @@ -52,12 +52,12 @@ public function getNextValue(); public function setChange(?string $change): void; /** - * @param ?Money $previousValue + * @param ?ShippingRate $previousValue */ - public function setPreviousValue(?Money $previousValue): void; + public function setPreviousValue(?ShippingRate $previousValue): void; /** - * @param ?Money $nextValue + * @param ?ShippingRate $nextValue */ - public function setNextValue(?Money $nextValue): void; + public function setNextValue(?ShippingRate $nextValue): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetShippingRateChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetShippingRateChangeBuilder.php index 3f8dc4de71b..4ab5241d597 100644 --- a/lib/commercetools-history/src/Models/Change/SetShippingRateChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetShippingRateChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\Money; -use Commercetools\History\Models\Common\MoneyBuilder; +use Commercetools\History\Models\Common\ShippingRate; +use Commercetools\History\Models\Common\ShippingRateBuilder; /** * @implements Builder @@ -30,13 +30,13 @@ final class SetShippingRateChangeBuilder implements Builder /** - * @var null|Money|MoneyBuilder + * @var null|ShippingRate|ShippingRateBuilder */ private $previousValue; /** - * @var null|Money|MoneyBuilder + * @var null|ShippingRate|ShippingRateBuilder */ private $nextValue; @@ -53,22 +53,22 @@ public function getChange() *

                                                                                                                Value before the change.

                                                                                                                * - * @return null|Money + * @return null|ShippingRate */ public function getPreviousValue() { - return $this->previousValue instanceof MoneyBuilder ? $this->previousValue->build() : $this->previousValue; + return $this->previousValue instanceof ShippingRateBuilder ? $this->previousValue->build() : $this->previousValue; } /** *

                                                                                                                Value after the change.

                                                                                                                * - * @return null|Money + * @return null|ShippingRate */ public function getNextValue() { - return $this->nextValue instanceof MoneyBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof ShippingRateBuilder ? $this->nextValue->build() : $this->nextValue; } /** @@ -83,10 +83,10 @@ public function withChange(?string $change) } /** - * @param ?Money $previousValue + * @param ?ShippingRate $previousValue * @return $this */ - public function withPreviousValue(?Money $previousValue) + public function withPreviousValue(?ShippingRate $previousValue) { $this->previousValue = $previousValue; @@ -94,10 +94,10 @@ public function withPreviousValue(?Money $previousValue) } /** - * @param ?Money $nextValue + * @param ?ShippingRate $nextValue * @return $this */ - public function withNextValue(?Money $nextValue) + public function withNextValue(?ShippingRate $nextValue) { $this->nextValue = $nextValue; @@ -108,7 +108,7 @@ public function withNextValue(?Money $nextValue) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?MoneyBuilder $previousValue) + public function withPreviousValueBuilder(?ShippingRateBuilder $previousValue) { $this->previousValue = $previousValue; @@ -119,7 +119,7 @@ public function withPreviousValueBuilder(?MoneyBuilder $previousValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?MoneyBuilder $nextValue) + public function withNextValueBuilder(?ShippingRateBuilder $nextValue) { $this->nextValue = $nextValue; @@ -130,8 +130,8 @@ public function build(): SetShippingRateChange { return new SetShippingRateChangeModel( $this->change, - $this->previousValue instanceof MoneyBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof MoneyBuilder ? $this->nextValue->build() : $this->nextValue + $this->previousValue instanceof ShippingRateBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof ShippingRateBuilder ? $this->nextValue->build() : $this->nextValue ); } diff --git a/lib/commercetools-history/src/Models/Change/SetShippingRateChangeModel.php b/lib/commercetools-history/src/Models/Change/SetShippingRateChangeModel.php index 7123ac925c4..9da15116a80 100644 --- a/lib/commercetools-history/src/Models/Change/SetShippingRateChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetShippingRateChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\Money; -use Commercetools\History\Models\Common\MoneyModel; +use Commercetools\History\Models\Common\ShippingRate; +use Commercetools\History\Models\Common\ShippingRateModel; /** * @internal @@ -37,13 +37,13 @@ final class SetShippingRateChangeModel extends JsonObjectModel implements SetShi /** * - * @var ?Money + * @var ?ShippingRate */ protected $previousValue; /** * - * @var ?Money + * @var ?ShippingRate */ protected $nextValue; @@ -53,8 +53,8 @@ final class SetShippingRateChangeModel extends JsonObjectModel implements SetShi */ public function __construct( ?string $change = null, - ?Money $previousValue = null, - ?Money $nextValue = null, + ?ShippingRate $previousValue = null, + ?ShippingRate $nextValue = null, ?string $type = null ) { $this->change = $change; @@ -103,7 +103,7 @@ public function getChange() *

                                                                                                                Value before the change.

                                                                                                                * * - * @return null|Money + * @return null|ShippingRate */ public function getPreviousValue() { @@ -114,7 +114,7 @@ public function getPreviousValue() return null; } - $this->previousValue = MoneyModel::of($data); + $this->previousValue = ShippingRateModel::of($data); } return $this->previousValue; @@ -124,7 +124,7 @@ public function getPreviousValue() *

                                                                                                                Value after the change.

                                                                                                                * * - * @return null|Money + * @return null|ShippingRate */ public function getNextValue() { @@ -135,7 +135,7 @@ public function getNextValue() return null; } - $this->nextValue = MoneyModel::of($data); + $this->nextValue = ShippingRateModel::of($data); } return $this->nextValue; @@ -151,17 +151,17 @@ public function setChange(?string $change): void } /** - * @param ?Money $previousValue + * @param ?ShippingRate $previousValue */ - public function setPreviousValue(?Money $previousValue): void + public function setPreviousValue(?ShippingRate $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?Money $nextValue + * @param ?ShippingRate $nextValue */ - public function setNextValue(?Money $nextValue): void + public function setNextValue(?ShippingRate $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/SetSkuChange.php b/lib/commercetools-history/src/Models/Change/SetSkuChange.php index 297521c75b6..f9f8f86be7e 100644 --- a/lib/commercetools-history/src/Models/Change/SetSkuChange.php +++ b/lib/commercetools-history/src/Models/Change/SetSkuChange.php @@ -17,6 +17,7 @@ interface SetSkuChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_CATALOG_DATA = 'catalogData'; + public const FIELD_VARIANT = 'variant'; /** @@ -47,6 +48,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                                                                                Product data that was updated.

                                                                                                                *
                                                                                                                  *
                                                                                                                • staged, if the staged ProductCatalogData was updated.
                                                                                                                • *
                                                                                                                • current, if the current ProductCatalogData was updated.
                                                                                                                • @@ -57,6 +59,15 @@ public function getNextValue(); */ public function getCatalogData(); + /** + *

                                                                                                                  Identifier of the updated Product Variant.

                                                                                                                  + *

                                                                                                                  This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                                                  + * + + * @return null|string + */ + public function getVariant(); + /** * @param ?string $change */ @@ -76,4 +87,9 @@ public function setNextValue(?string $nextValue): void; * @param ?string $catalogData */ public function setCatalogData(?string $catalogData): void; + + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetSkuChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetSkuChangeBuilder.php index 7d67b0c3b54..915e86f05d3 100644 --- a/lib/commercetools-history/src/Models/Change/SetSkuChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetSkuChangeBuilder.php @@ -44,6 +44,12 @@ final class SetSkuChangeBuilder implements Builder */ private $catalogData; + /** + + * @var ?string + */ + private $variant; + /** * @return null|string @@ -76,6 +82,7 @@ public function getNextValue() } /** + *

                                                                                                                  Product data that was updated.

                                                                                                                  *
                                                                                                                    *
                                                                                                                  • staged, if the staged ProductCatalogData was updated.
                                                                                                                  • *
                                                                                                                  • current, if the current ProductCatalogData was updated.
                                                                                                                  • @@ -89,6 +96,18 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                                                    Identifier of the updated Product Variant.

                                                                                                                    + *

                                                                                                                    This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                                                    + * + + * @return null|string + */ + public function getVariant() + { + return $this->variant; + } + /** * @param ?string $change * @return $this @@ -133,6 +152,17 @@ public function withCatalogData(?string $catalogData) return $this; } + /** + * @param ?string $variant + * @return $this + */ + public function withVariant(?string $variant) + { + $this->variant = $variant; + + return $this; + } + public function build(): SetSkuChange { @@ -140,7 +170,8 @@ public function build(): SetSkuChange $this->change, $this->previousValue, $this->nextValue, - $this->catalogData + $this->catalogData, + $this->variant ); } diff --git a/lib/commercetools-history/src/Models/Change/SetSkuChangeModel.php b/lib/commercetools-history/src/Models/Change/SetSkuChangeModel.php index 4c8bf871bd5..998888cac31 100644 --- a/lib/commercetools-history/src/Models/Change/SetSkuChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetSkuChangeModel.php @@ -51,6 +51,12 @@ final class SetSkuChangeModel extends JsonObjectModel implements SetSkuChange */ protected $catalogData; + /** + * + * @var ?string + */ + protected $variant; + /** * @psalm-suppress MissingParamType @@ -60,12 +66,14 @@ public function __construct( ?string $previousValue = null, ?string $nextValue = null, ?string $catalogData = null, + ?string $variant = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->catalogData = $catalogData; + $this->variant = $variant; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -146,6 +154,7 @@ public function getNextValue() } /** + *

                                                                                                                    Product data that was updated.

                                                                                                                    *
                                                                                                                      *
                                                                                                                    • staged, if the staged ProductCatalogData was updated.
                                                                                                                    • *
                                                                                                                    • current, if the current ProductCatalogData was updated.
                                                                                                                    • @@ -168,6 +177,27 @@ public function getCatalogData() return $this->catalogData; } + /** + *

                                                                                                                      Identifier of the updated Product Variant.

                                                                                                                      + *

                                                                                                                      This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                                                      + * + * + * @return null|string + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + $this->variant = (string) $data; + } + + return $this->variant; + } + /** * @param ?string $change @@ -201,6 +231,14 @@ public function setCatalogData(?string $catalogData): void $this->catalogData = $catalogData; } + /** + * @param ?string $variant + */ + public function setVariant(?string $variant): void + { + $this->variant = $variant; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetStateRolesChange.php b/lib/commercetools-history/src/Models/Change/SetStateRolesChange.php index bbd087583af..844a75c82e9 100644 --- a/lib/commercetools-history/src/Models/Change/SetStateRolesChange.php +++ b/lib/commercetools-history/src/Models/Change/SetStateRolesChange.php @@ -16,6 +16,8 @@ interface SetStateRolesChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -45,6 +47,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + + * @return null|array + */ + public function getAddedItems(); + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + + * @return null|array + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -59,4 +77,14 @@ public function setPreviousValue(?array $previousValue): void; * @param ?array $nextValue */ public function setNextValue(?array $nextValue): void; + + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void; + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetStateRolesChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetStateRolesChangeBuilder.php index 793984b72e9..8e9c458bcae 100644 --- a/lib/commercetools-history/src/Models/Change/SetStateRolesChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetStateRolesChangeBuilder.php @@ -38,6 +38,18 @@ final class SetStateRolesChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?array + */ + private $addedItems; + + /** + + * @var ?array + */ + private $removedItems; + /** * @return null|string @@ -69,6 +81,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + + * @return null|array + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + + * @return null|array + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -102,13 +136,37 @@ public function withNextValue(?array $nextValue) return $this; } + /** + * @param ?array $addedItems + * @return $this + */ + public function withAddedItems(?array $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?array $removedItems + * @return $this + */ + public function withRemovedItems(?array $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetStateRolesChange { return new SetStateRolesChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetStateRolesChangeModel.php b/lib/commercetools-history/src/Models/Change/SetStateRolesChangeModel.php index 4dc41a79c3f..7898359951a 100644 --- a/lib/commercetools-history/src/Models/Change/SetStateRolesChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetStateRolesChangeModel.php @@ -45,6 +45,18 @@ final class SetStateRolesChangeModel extends JsonObjectModel implements SetState */ protected $nextValue; + /** + * + * @var ?array + */ + protected $addedItems; + + /** + * + * @var ?array + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -53,11 +65,15 @@ public function __construct( ?string $change = null, ?array $previousValue = null, ?array $nextValue = null, + ?array $addedItems = null, + ?array $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -137,6 +153,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + * + * @return null|array + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = $data; + } + + return $this->addedItems; + } + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + * + * @return null|array + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = $data; + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -162,6 +218,22 @@ public function setNextValue(?array $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?array $addedItems + */ + public function setAddedItems(?array $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?array $removedItems + */ + public function setRemovedItems(?array $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetStoreChange.php b/lib/commercetools-history/src/Models/Change/SetStoreChange.php index 70ba66ec6f4..85d16df0bdc 100644 --- a/lib/commercetools-history/src/Models/Change/SetStoreChange.php +++ b/lib/commercetools-history/src/Models/Change/SetStoreChange.php @@ -10,7 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\Common\Reference; +use Commercetools\History\Models\Common\KeyReference; interface SetStoreChange extends Change { @@ -34,7 +34,7 @@ public function getChange(); *

                                                                                                                      Value before the change.

                                                                                                                      * - * @return null|Reference + * @return null|KeyReference */ public function getPreviousValue(); @@ -42,7 +42,7 @@ public function getPreviousValue(); *

                                                                                                                      Value after the change.

                                                                                                                      * - * @return null|Reference + * @return null|KeyReference */ public function getNextValue(); @@ -52,12 +52,12 @@ public function getNextValue(); public function setChange(?string $change): void; /** - * @param ?Reference $previousValue + * @param ?KeyReference $previousValue */ - public function setPreviousValue(?Reference $previousValue): void; + public function setPreviousValue(?KeyReference $previousValue): void; /** - * @param ?Reference $nextValue + * @param ?KeyReference $nextValue */ - public function setNextValue(?Reference $nextValue): void; + public function setNextValue(?KeyReference $nextValue): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetStoreChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetStoreChangeBuilder.php index 497aeb67117..255bcf99f9f 100644 --- a/lib/commercetools-history/src/Models/Change/SetStoreChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetStoreChangeBuilder.php @@ -14,8 +14,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\Reference; -use Commercetools\History\Models\Common\ReferenceBuilder; +use Commercetools\History\Models\Common\KeyReference; +use Commercetools\History\Models\Common\KeyReferenceBuilder; /** * @implements Builder @@ -30,13 +30,13 @@ final class SetStoreChangeBuilder implements Builder /** - * @var null|Reference|ReferenceBuilder + * @var null|KeyReference|KeyReferenceBuilder */ private $previousValue; /** - * @var null|Reference|ReferenceBuilder + * @var null|KeyReference|KeyReferenceBuilder */ private $nextValue; @@ -53,22 +53,22 @@ public function getChange() *

                                                                                                                      Value before the change.

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

                                                                                                                      Value after the change.

                                                                                                                      * - * @return null|Reference + * @return null|KeyReference */ public function getNextValue() { - return $this->nextValue instanceof ReferenceBuilder ? $this->nextValue->build() : $this->nextValue; + return $this->nextValue instanceof KeyReferenceBuilder ? $this->nextValue->build() : $this->nextValue; } /** @@ -83,10 +83,10 @@ public function withChange(?string $change) } /** - * @param ?Reference $previousValue + * @param ?KeyReference $previousValue * @return $this */ - public function withPreviousValue(?Reference $previousValue) + public function withPreviousValue(?KeyReference $previousValue) { $this->previousValue = $previousValue; @@ -94,10 +94,10 @@ public function withPreviousValue(?Reference $previousValue) } /** - * @param ?Reference $nextValue + * @param ?KeyReference $nextValue * @return $this */ - public function withNextValue(?Reference $nextValue) + public function withNextValue(?KeyReference $nextValue) { $this->nextValue = $nextValue; @@ -108,7 +108,7 @@ public function withNextValue(?Reference $nextValue) * @deprecated use withPreviousValue() instead * @return $this */ - public function withPreviousValueBuilder(?ReferenceBuilder $previousValue) + public function withPreviousValueBuilder(?KeyReferenceBuilder $previousValue) { $this->previousValue = $previousValue; @@ -119,7 +119,7 @@ public function withPreviousValueBuilder(?ReferenceBuilder $previousValue) * @deprecated use withNextValue() instead * @return $this */ - public function withNextValueBuilder(?ReferenceBuilder $nextValue) + public function withNextValueBuilder(?KeyReferenceBuilder $nextValue) { $this->nextValue = $nextValue; @@ -130,8 +130,8 @@ public function build(): SetStoreChange { return new SetStoreChangeModel( $this->change, - $this->previousValue instanceof ReferenceBuilder ? $this->previousValue->build() : $this->previousValue, - $this->nextValue instanceof ReferenceBuilder ? $this->nextValue->build() : $this->nextValue + $this->previousValue instanceof KeyReferenceBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof KeyReferenceBuilder ? $this->nextValue->build() : $this->nextValue ); } diff --git a/lib/commercetools-history/src/Models/Change/SetStoreChangeModel.php b/lib/commercetools-history/src/Models/Change/SetStoreChangeModel.php index 5e3343e5399..1bc3c5e3475 100644 --- a/lib/commercetools-history/src/Models/Change/SetStoreChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetStoreChangeModel.php @@ -13,8 +13,8 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Common\Reference; -use Commercetools\History\Models\Common\ReferenceModel; +use Commercetools\History\Models\Common\KeyReference; +use Commercetools\History\Models\Common\KeyReferenceModel; /** * @internal @@ -37,13 +37,13 @@ final class SetStoreChangeModel extends JsonObjectModel implements SetStoreChang /** * - * @var ?Reference + * @var ?KeyReference */ protected $previousValue; /** * - * @var ?Reference + * @var ?KeyReference */ protected $nextValue; @@ -53,8 +53,8 @@ final class SetStoreChangeModel extends JsonObjectModel implements SetStoreChang */ public function __construct( ?string $change = null, - ?Reference $previousValue = null, - ?Reference $nextValue = null, + ?KeyReference $previousValue = null, + ?KeyReference $nextValue = null, ?string $type = null ) { $this->change = $change; @@ -103,7 +103,7 @@ public function getChange() *

                                                                                                                      Value before the change.

                                                                                                                      * * - * @return null|Reference + * @return null|KeyReference */ public function getPreviousValue() { @@ -113,8 +113,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = KeyReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -124,7 +124,7 @@ public function getPreviousValue() *

                                                                                                                      Value after the change.

                                                                                                                      * * - * @return null|Reference + * @return null|KeyReference */ public function getNextValue() { @@ -134,8 +134,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = KeyReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; @@ -151,17 +151,17 @@ public function setChange(?string $change): void } /** - * @param ?Reference $previousValue + * @param ?KeyReference $previousValue */ - public function setPreviousValue(?Reference $previousValue): void + public function setPreviousValue(?KeyReference $previousValue): void { $this->previousValue = $previousValue; } /** - * @param ?Reference $nextValue + * @param ?KeyReference $nextValue */ - public function setNextValue(?Reference $nextValue): void + public function setNextValue(?KeyReference $nextValue): void { $this->nextValue = $nextValue; } diff --git a/lib/commercetools-history/src/Models/Change/SetStoresChange.php b/lib/commercetools-history/src/Models/Change/SetStoresChange.php index cca1d60f477..ee852682980 100644 --- a/lib/commercetools-history/src/Models/Change/SetStoresChange.php +++ b/lib/commercetools-history/src/Models/Change/SetStoresChange.php @@ -10,6 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use Commercetools\History\Models\Common\KeyReferenceCollection; use Commercetools\History\Models\Common\ReferenceCollection; interface SetStoresChange extends Change @@ -17,6 +18,8 @@ interface SetStoresChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -46,6 +49,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + + * @return null|KeyReferenceCollection + */ + public function getAddedItems(); + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + + * @return null|KeyReferenceCollection + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -60,4 +79,14 @@ public function setPreviousValue(?ReferenceCollection $previousValue): void; * @param ?ReferenceCollection $nextValue */ public function setNextValue(?ReferenceCollection $nextValue): void; + + /** + * @param ?KeyReferenceCollection $addedItems + */ + public function setAddedItems(?KeyReferenceCollection $addedItems): void; + + /** + * @param ?KeyReferenceCollection $removedItems + */ + public function setRemovedItems(?KeyReferenceCollection $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetStoresChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetStoresChangeBuilder.php index 77f86275449..fcafcc0b4a3 100644 --- a/lib/commercetools-history/src/Models/Change/SetStoresChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetStoresChangeBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use Commercetools\History\Models\Common\KeyReferenceCollection; use Commercetools\History\Models\Common\ReferenceCollection; /** @@ -39,6 +40,18 @@ final class SetStoresChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?KeyReferenceCollection + */ + private $addedItems; + + /** + + * @var ?KeyReferenceCollection + */ + private $removedItems; + /** * @return null|string @@ -70,6 +83,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + + * @return null|KeyReferenceCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + + * @return null|KeyReferenceCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -103,13 +138,37 @@ public function withNextValue(?ReferenceCollection $nextValue) return $this; } + /** + * @param ?KeyReferenceCollection $addedItems + * @return $this + */ + public function withAddedItems(?KeyReferenceCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?KeyReferenceCollection $removedItems + * @return $this + */ + public function withRemovedItems(?KeyReferenceCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetStoresChange { return new SetStoresChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetStoresChangeModel.php b/lib/commercetools-history/src/Models/Change/SetStoresChangeModel.php index d9d44c834f4..c52826a47ab 100644 --- a/lib/commercetools-history/src/Models/Change/SetStoresChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetStoresChangeModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use Commercetools\History\Models\Common\KeyReferenceCollection; use Commercetools\History\Models\Common\ReferenceCollection; /** @@ -46,6 +47,18 @@ final class SetStoresChangeModel extends JsonObjectModel implements SetStoresCha */ protected $nextValue; + /** + * + * @var ?KeyReferenceCollection + */ + protected $addedItems; + + /** + * + * @var ?KeyReferenceCollection + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -54,11 +67,15 @@ public function __construct( ?string $change = null, ?ReferenceCollection $previousValue = null, ?ReferenceCollection $nextValue = null, + ?KeyReferenceCollection $addedItems = null, + ?KeyReferenceCollection $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -138,6 +155,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + * + * @return null|KeyReferenceCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = KeyReferenceCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + * + * @return null|KeyReferenceCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = KeyReferenceCollection::fromArray($data); + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -163,6 +220,22 @@ public function setNextValue(?ReferenceCollection $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?KeyReferenceCollection $addedItems + */ + public function setAddedItems(?KeyReferenceCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?KeyReferenceCollection $removedItems + */ + public function setRemovedItems(?KeyReferenceCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetSupplyChannelChangeModel.php b/lib/commercetools-history/src/Models/Change/SetSupplyChannelChangeModel.php index b9c9507617c..7e7670183c0 100644 --- a/lib/commercetools-history/src/Models/Change/SetSupplyChannelChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetSupplyChannelChangeModel.php @@ -113,8 +113,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -134,8 +134,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChange.php b/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChange.php index d61b95b7183..e5405a656b2 100644 --- a/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChange.php @@ -17,6 +17,8 @@ interface SetSupplyChannelsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -46,6 +48,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + + * @return null|ReferenceCollection + */ + public function getAddedItems(); + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -60,4 +78,14 @@ public function setPreviousValue(?ReferenceCollection $previousValue): void; * @param ?ReferenceCollection $nextValue */ public function setNextValue(?ReferenceCollection $nextValue): void; + + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void; + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChangeBuilder.php index 5ead69dc61c..7bca1595aca 100644 --- a/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChangeBuilder.php @@ -39,6 +39,18 @@ final class SetSupplyChannelsChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?ReferenceCollection + */ + private $addedItems; + + /** + + * @var ?ReferenceCollection + */ + private $removedItems; + /** * @return null|string @@ -70,6 +82,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -103,13 +137,37 @@ public function withNextValue(?ReferenceCollection $nextValue) return $this; } + /** + * @param ?ReferenceCollection $addedItems + * @return $this + */ + public function withAddedItems(?ReferenceCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?ReferenceCollection $removedItems + * @return $this + */ + public function withRemovedItems(?ReferenceCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetSupplyChannelsChange { return new SetSupplyChannelsChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChangeModel.php index 492a1139b2a..ec8bd4a2d44 100644 --- a/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetSupplyChannelsChangeModel.php @@ -46,6 +46,18 @@ final class SetSupplyChannelsChangeModel extends JsonObjectModel implements SetS */ protected $nextValue; + /** + * + * @var ?ReferenceCollection + */ + protected $addedItems; + + /** + * + * @var ?ReferenceCollection + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -54,11 +66,15 @@ public function __construct( ?string $change = null, ?ReferenceCollection $previousValue = null, ?ReferenceCollection $nextValue = null, + ?ReferenceCollection $addedItems = null, + ?ReferenceCollection $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -138,6 +154,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + * + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = ReferenceCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + * + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = ReferenceCollection::fromArray($data); + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -163,6 +219,22 @@ public function setNextValue(?ReferenceCollection $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetTargetChangeModel.php b/lib/commercetools-history/src/Models/Change/SetTargetChangeModel.php index ef0a3f61119..03d379346af 100644 --- a/lib/commercetools-history/src/Models/Change/SetTargetChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetTargetChangeModel.php @@ -113,8 +113,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -134,8 +134,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/SetTaxCategoryChangeModel.php b/lib/commercetools-history/src/Models/Change/SetTaxCategoryChangeModel.php index 66898e95057..1bd7a1bc376 100644 --- a/lib/commercetools-history/src/Models/Change/SetTaxCategoryChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetTaxCategoryChangeModel.php @@ -113,8 +113,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -134,8 +134,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChange.php b/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChange.php new file mode 100644 index 00000000000..e93f5025e0d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChange.php @@ -0,0 +1,105 @@ +Holds information about the updated Transaction.

                                                                                                                      + * + + * @return null|TransactionChangeValue + */ + public function getTransaction(); + + /** + *

                                                                                                                      Name of the Custom Field.

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

                                                                                                                      id of the referenced Type.

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

                                                                                                                      Value before the change.

                                                                                                                      + * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + *

                                                                                                                      Value after the change.

                                                                                                                      + * + + * @return null|mixed + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?TransactionChangeValue $transaction + */ + public function setTransaction(?TransactionChangeValue $transaction): void; + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void; + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChangeBuilder.php new file mode 100644 index 00000000000..78718d9c66d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChangeBuilder.php @@ -0,0 +1,218 @@ + + */ +final class SetTransactionCustomFieldChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|TransactionChangeValue|TransactionChangeValueBuilder + */ + private $transaction; + + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?string + */ + private $customTypeId; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + + * @var null|mixed|mixed + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                                      Holds information about the updated Transaction.

                                                                                                                      + * + + * @return null|TransactionChangeValue + */ + public function getTransaction() + { + return $this->transaction instanceof TransactionChangeValueBuilder ? $this->transaction->build() : $this->transaction; + } + + /** + *

                                                                                                                      Name of the Custom Field.

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

                                                                                                                      id of the referenced Type.

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

                                                                                                                      Value before the change.

                                                                                                                      + * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + *

                                                                                                                      Value after the change.

                                                                                                                      + * + + * @return null|mixed + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?TransactionChangeValue $transaction + * @return $this + */ + public function withTransaction(?TransactionChangeValue $transaction) + { + $this->transaction = $transaction; + + return $this; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $customTypeId + * @return $this + */ + public function withCustomTypeId(?string $customTypeId) + { + $this->customTypeId = $customTypeId; + + return $this; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue( $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param mixed $nextValue + * @return $this + */ + public function withNextValue( $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withTransaction() instead + * @return $this + */ + public function withTransactionBuilder(?TransactionChangeValueBuilder $transaction) + { + $this->transaction = $transaction; + + return $this; + } + + public function build(): SetTransactionCustomFieldChange + { + return new SetTransactionCustomFieldChangeModel( + $this->change, + $this->transaction instanceof TransactionChangeValueBuilder ? $this->transaction->build() : $this->transaction, + $this->name, + $this->customTypeId, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetTransactionCustomFieldChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChangeCollection.php new file mode 100644 index 00000000000..47fa915e3c1 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetTransactionCustomFieldChange current() + * @method SetTransactionCustomFieldChange end() + * @method SetTransactionCustomFieldChange at($offset) + */ +class SetTransactionCustomFieldChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetTransactionCustomFieldChange $value + * @psalm-param SetTransactionCustomFieldChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetTransactionCustomFieldChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetTransactionCustomFieldChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetTransactionCustomFieldChange + */ + protected function mapper() + { + return function (?int $index): ?SetTransactionCustomFieldChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetTransactionCustomFieldChange $data */ + $data = SetTransactionCustomFieldChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChangeModel.php b/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChangeModel.php new file mode 100644 index 00000000000..f0d136a4706 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetTransactionCustomFieldChangeModel.php @@ -0,0 +1,278 @@ +change = $change; + $this->transaction = $transaction; + $this->name = $name; + $this->customTypeId = $customTypeId; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                                      Holds information about the updated Transaction.

                                                                                                                      + * + * + * @return null|TransactionChangeValue + */ + public function getTransaction() + { + if (is_null($this->transaction)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TRANSACTION); + if (is_null($data)) { + return null; + } + + $this->transaction = TransactionChangeValueModel::of($data); + } + + return $this->transaction; + } + + /** + *

                                                                                                                      Name of the Custom Field.

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

                                                                                                                      id of the referenced Type.

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

                                                                                                                      Value before the change.

                                                                                                                      + * + * + * @return null|mixed + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + $this->previousValue = $data; + } + + return $this->previousValue; + } + + /** + *

                                                                                                                      Value after the change.

                                                                                                                      + * + * + * @return null|mixed + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?TransactionChangeValue $transaction + */ + public function setTransaction(?TransactionChangeValue $transaction): void + { + $this->transaction = $transaction; + } + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?string $customTypeId + */ + public function setCustomTypeId(?string $customTypeId): void + { + $this->customTypeId = $customTypeId; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue( $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param mixed $nextValue + */ + public function setNextValue( $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChange.php b/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChange.php new file mode 100644 index 00000000000..88c5794e0a5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChange.php @@ -0,0 +1,78 @@ +Holds information about the updated Transaction.

                                                                                                                      + * + + * @return null|TransactionChangeValue + */ + public function getTransaction(); + + /** + *

                                                                                                                      Value before the change.

                                                                                                                      + * + + * @return null|CustomFields + */ + public function getPreviousValue(); + + /** + *

                                                                                                                      Value after the change.

                                                                                                                      + * + + * @return null|CustomFields + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?TransactionChangeValue $transaction + */ + public function setTransaction(?TransactionChangeValue $transaction): void; + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void; + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChangeBuilder.php new file mode 100644 index 00000000000..5176a8b911d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChangeBuilder.php @@ -0,0 +1,184 @@ + + */ +final class SetTransactionCustomTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|TransactionChangeValue|TransactionChangeValueBuilder + */ + private $transaction; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $previousValue; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                                      Holds information about the updated Transaction.

                                                                                                                      + * + + * @return null|TransactionChangeValue + */ + public function getTransaction() + { + return $this->transaction instanceof TransactionChangeValueBuilder ? $this->transaction->build() : $this->transaction; + } + + /** + *

                                                                                                                      Value before the change.

                                                                                                                      + * + + * @return null|CustomFields + */ + public function getPreviousValue() + { + return $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                                                      Value after the change.

                                                                                                                      + * + + * @return null|CustomFields + */ + public function getNextValue() + { + return $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?TransactionChangeValue $transaction + * @return $this + */ + public function withTransaction(?TransactionChangeValue $transaction) + { + $this->transaction = $transaction; + + return $this; + } + + /** + * @param ?CustomFields $previousValue + * @return $this + */ + public function withPreviousValue(?CustomFields $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?CustomFields $nextValue + * @return $this + */ + public function withNextValue(?CustomFields $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withTransaction() instead + * @return $this + */ + public function withTransactionBuilder(?TransactionChangeValueBuilder $transaction) + { + $this->transaction = $transaction; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?CustomFieldsBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?CustomFieldsBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetTransactionCustomTypeChange + { + return new SetTransactionCustomTypeChangeModel( + $this->change, + $this->transaction instanceof TransactionChangeValueBuilder ? $this->transaction->build() : $this->transaction, + $this->previousValue instanceof CustomFieldsBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof CustomFieldsBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetTransactionCustomTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChangeCollection.php new file mode 100644 index 00000000000..b08a614b15f --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetTransactionCustomTypeChange current() + * @method SetTransactionCustomTypeChange end() + * @method SetTransactionCustomTypeChange at($offset) + */ +class SetTransactionCustomTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetTransactionCustomTypeChange $value + * @psalm-param SetTransactionCustomTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetTransactionCustomTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetTransactionCustomTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetTransactionCustomTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetTransactionCustomTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetTransactionCustomTypeChange $data */ + $data = SetTransactionCustomTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChangeModel.php new file mode 100644 index 00000000000..6c00b26d7e5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetTransactionCustomTypeChangeModel.php @@ -0,0 +1,210 @@ +change = $change; + $this->transaction = $transaction; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                                      Holds information about the updated Transaction.

                                                                                                                      + * + * + * @return null|TransactionChangeValue + */ + public function getTransaction() + { + if (is_null($this->transaction)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TRANSACTION); + if (is_null($data)) { + return null; + } + + $this->transaction = TransactionChangeValueModel::of($data); + } + + return $this->transaction; + } + + /** + *

                                                                                                                      Value before the change.

                                                                                                                      + * + * + * @return null|CustomFields + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = CustomFieldsModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                                                      Value after the change.

                                                                                                                      + * + * + * @return null|CustomFields + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = CustomFieldsModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?TransactionChangeValue $transaction + */ + public function setTransaction(?TransactionChangeValue $transaction): void + { + $this->transaction = $transaction; + } + + /** + * @param ?CustomFields $previousValue + */ + public function setPreviousValue(?CustomFields $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?CustomFields $nextValue + */ + public function setNextValue(?CustomFields $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetTransitionsChange.php b/lib/commercetools-history/src/Models/Change/SetTransitionsChange.php index 9f9dc9a8eb2..e0c61533945 100644 --- a/lib/commercetools-history/src/Models/Change/SetTransitionsChange.php +++ b/lib/commercetools-history/src/Models/Change/SetTransitionsChange.php @@ -17,6 +17,8 @@ interface SetTransitionsChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; + public const FIELD_ADDED_ITEMS = 'addedItems'; + public const FIELD_REMOVED_ITEMS = 'removedItems'; /** @@ -46,6 +48,22 @@ public function getPreviousValue(); */ public function getNextValue(); + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + + * @return null|ReferenceCollection + */ + public function getAddedItems(); + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems(); + /** * @param ?string $change */ @@ -60,4 +78,14 @@ public function setPreviousValue(?ReferenceCollection $previousValue): void; * @param ?ReferenceCollection $nextValue */ public function setNextValue(?ReferenceCollection $nextValue): void; + + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void; + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void; } diff --git a/lib/commercetools-history/src/Models/Change/SetTransitionsChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetTransitionsChangeBuilder.php index ac10ec92327..cb285abea1a 100644 --- a/lib/commercetools-history/src/Models/Change/SetTransitionsChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetTransitionsChangeBuilder.php @@ -39,6 +39,18 @@ final class SetTransitionsChangeBuilder implements Builder */ private $nextValue; + /** + + * @var ?ReferenceCollection + */ + private $addedItems; + + /** + + * @var ?ReferenceCollection + */ + private $removedItems; + /** * @return null|string @@ -70,6 +82,28 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + return $this->addedItems; + } + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + return $this->removedItems; + } + /** * @param ?string $change * @return $this @@ -103,13 +137,37 @@ public function withNextValue(?ReferenceCollection $nextValue) return $this; } + /** + * @param ?ReferenceCollection $addedItems + * @return $this + */ + public function withAddedItems(?ReferenceCollection $addedItems) + { + $this->addedItems = $addedItems; + + return $this; + } + + /** + * @param ?ReferenceCollection $removedItems + * @return $this + */ + public function withRemovedItems(?ReferenceCollection $removedItems) + { + $this->removedItems = $removedItems; + + return $this; + } + public function build(): SetTransitionsChange { return new SetTransitionsChangeModel( $this->change, $this->previousValue, - $this->nextValue + $this->nextValue, + $this->addedItems, + $this->removedItems ); } diff --git a/lib/commercetools-history/src/Models/Change/SetTransitionsChangeModel.php b/lib/commercetools-history/src/Models/Change/SetTransitionsChangeModel.php index c1776946ca9..29d66c4f79c 100644 --- a/lib/commercetools-history/src/Models/Change/SetTransitionsChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetTransitionsChangeModel.php @@ -46,6 +46,18 @@ final class SetTransitionsChangeModel extends JsonObjectModel implements SetTran */ protected $nextValue; + /** + * + * @var ?ReferenceCollection + */ + protected $addedItems; + + /** + * + * @var ?ReferenceCollection + */ + protected $removedItems; + /** * @psalm-suppress MissingParamType @@ -54,11 +66,15 @@ public function __construct( ?string $change = null, ?ReferenceCollection $previousValue = null, ?ReferenceCollection $nextValue = null, + ?ReferenceCollection $addedItems = null, + ?ReferenceCollection $removedItems = null, ?string $type = null ) { $this->change = $change; $this->previousValue = $previousValue; $this->nextValue = $nextValue; + $this->addedItems = $addedItems; + $this->removedItems = $removedItems; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -138,6 +154,46 @@ public function getNextValue() return $this->nextValue; } + /** + *

                                                                                                                      Elements added to the array.

                                                                                                                      + * + * + * @return null|ReferenceCollection + */ + public function getAddedItems() + { + if (is_null($this->addedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ADDED_ITEMS); + if (is_null($data)) { + return null; + } + $this->addedItems = ReferenceCollection::fromArray($data); + } + + return $this->addedItems; + } + + /** + *

                                                                                                                      Elements removed from the array.

                                                                                                                      + * + * + * @return null|ReferenceCollection + */ + public function getRemovedItems() + { + if (is_null($this->removedItems)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_REMOVED_ITEMS); + if (is_null($data)) { + return null; + } + $this->removedItems = ReferenceCollection::fromArray($data); + } + + return $this->removedItems; + } + /** * @param ?string $change @@ -163,6 +219,22 @@ public function setNextValue(?ReferenceCollection $nextValue): void $this->nextValue = $nextValue; } + /** + * @param ?ReferenceCollection $addedItems + */ + public function setAddedItems(?ReferenceCollection $addedItems): void + { + $this->addedItems = $addedItems; + } + + /** + * @param ?ReferenceCollection $removedItems + */ + public function setRemovedItems(?ReferenceCollection $removedItems): void + { + $this->removedItems = $removedItems; + } + } diff --git a/lib/commercetools-history/src/Models/Change/SetUnitTypeChange.php b/lib/commercetools-history/src/Models/Change/SetUnitTypeChange.php new file mode 100644 index 00000000000..9861acfb1e0 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetUnitTypeChange.php @@ -0,0 +1,77 @@ +If unitType="Division", reference to the new parent unit for the Business Unit.

                                                                                                                      + * + + * @return null|BusinessUnitResourceIdentifier + */ + public function getParentUnit(); + + /** + *

                                                                                                                      Value before the change.

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

                                                                                                                      Value after the change.

                                                                                                                      + * + + * @return null|string + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?BusinessUnitResourceIdentifier $parentUnit + */ + public function setParentUnit(?BusinessUnitResourceIdentifier $parentUnit): void; + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void; + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetUnitTypeChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetUnitTypeChangeBuilder.php new file mode 100644 index 00000000000..e48c9082f78 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetUnitTypeChangeBuilder.php @@ -0,0 +1,160 @@ + + */ +final class SetUnitTypeChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|BusinessUnitResourceIdentifier|BusinessUnitResourceIdentifierBuilder + */ + private $parentUnit; + + /** + + * @var ?string + */ + private $previousValue; + + /** + + * @var ?string + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                                      If unitType="Division", reference to the new parent unit for the Business Unit.

                                                                                                                      + * + + * @return null|BusinessUnitResourceIdentifier + */ + public function getParentUnit() + { + return $this->parentUnit instanceof BusinessUnitResourceIdentifierBuilder ? $this->parentUnit->build() : $this->parentUnit; + } + + /** + *

                                                                                                                      Value before the change.

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

                                                                                                                      Value after the change.

                                                                                                                      + * + + * @return null|string + */ + public function getNextValue() + { + return $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?BusinessUnitResourceIdentifier $parentUnit + * @return $this + */ + public function withParentUnit(?BusinessUnitResourceIdentifier $parentUnit) + { + $this->parentUnit = $parentUnit; + + return $this; + } + + /** + * @param ?string $previousValue + * @return $this + */ + public function withPreviousValue(?string $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?string $nextValue + * @return $this + */ + public function withNextValue(?string $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withParentUnit() instead + * @return $this + */ + public function withParentUnitBuilder(?BusinessUnitResourceIdentifierBuilder $parentUnit) + { + $this->parentUnit = $parentUnit; + + return $this; + } + + public function build(): SetUnitTypeChange + { + return new SetUnitTypeChangeModel( + $this->change, + $this->parentUnit instanceof BusinessUnitResourceIdentifierBuilder ? $this->parentUnit->build() : $this->parentUnit, + $this->previousValue, + $this->nextValue + ); + } + + public static function of(): SetUnitTypeChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetUnitTypeChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetUnitTypeChangeCollection.php new file mode 100644 index 00000000000..bbf32bb0058 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetUnitTypeChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetUnitTypeChange current() + * @method SetUnitTypeChange end() + * @method SetUnitTypeChange at($offset) + */ +class SetUnitTypeChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetUnitTypeChange $value + * @psalm-param SetUnitTypeChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetUnitTypeChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetUnitTypeChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetUnitTypeChange + */ + protected function mapper() + { + return function (?int $index): ?SetUnitTypeChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetUnitTypeChange $data */ + $data = SetUnitTypeChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetUnitTypeChangeModel.php b/lib/commercetools-history/src/Models/Change/SetUnitTypeChangeModel.php new file mode 100644 index 00000000000..954e7f8f8bd --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetUnitTypeChangeModel.php @@ -0,0 +1,206 @@ +change = $change; + $this->parentUnit = $parentUnit; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                                      If unitType="Division", reference to the new parent unit for the Business Unit.

                                                                                                                      + * + * + * @return null|BusinessUnitResourceIdentifier + */ + public function getParentUnit() + { + if (is_null($this->parentUnit)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PARENT_UNIT); + if (is_null($data)) { + return null; + } + + $this->parentUnit = BusinessUnitResourceIdentifierModel::of($data); + } + + return $this->parentUnit; + } + + /** + *

                                                                                                                      Value before the change.

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

                                                                                                                      Value after the change.

                                                                                                                      + * + * + * @return null|string + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + $this->nextValue = (string) $data; + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?BusinessUnitResourceIdentifier $parentUnit + */ + public function setParentUnit(?BusinessUnitResourceIdentifier $parentUnit): void + { + $this->parentUnit = $parentUnit; + } + + /** + * @param ?string $previousValue + */ + public function setPreviousValue(?string $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?string $nextValue + */ + public function setNextValue(?string $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChange.php b/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChange.php index 684ed7f9e62..75209f59650 100644 --- a/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChange.php +++ b/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChange.php @@ -49,6 +49,7 @@ public function getPreviousValue(); public function getNextValue(); /** + *

                                                                                                                      Product data that was updated.

                                                                                                                      *
                                                                                                                        *
                                                                                                                      • staged, if the staged ProductCatalogData was updated.
                                                                                                                      • *
                                                                                                                      • current, if the current ProductCatalogData was updated.
                                                                                                                      • @@ -60,7 +61,8 @@ public function getNextValue(); public function getCatalogData(); /** - *

                                                                                                                        sku or key of the ProductVariant.

                                                                                                                        + *

                                                                                                                        Identifier of the updated Product Variant.

                                                                                                                        + *

                                                                                                                        This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                                                        * * @return null|string diff --git a/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChangeBuilder.php index eb44a1941be..644b69b84c8 100644 --- a/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChangeBuilder.php @@ -84,6 +84,7 @@ public function getNextValue() } /** + *

                                                                                                                        Product data that was updated.

                                                                                                                        *
                                                                                                                          *
                                                                                                                        • staged, if the staged ProductCatalogData was updated.
                                                                                                                        • *
                                                                                                                        • current, if the current ProductCatalogData was updated.
                                                                                                                        • @@ -98,7 +99,8 @@ public function getCatalogData() } /** - *

                                                                                                                          sku or key of the ProductVariant.

                                                                                                                          + *

                                                                                                                          Identifier of the updated Product Variant.

                                                                                                                          + *

                                                                                                                          This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                                                          * * @return null|string diff --git a/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChangeModel.php b/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChangeModel.php index 61e72864ddc..53c2ce0a134 100644 --- a/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetVariantAvailabilityChangeModel.php @@ -158,6 +158,7 @@ public function getNextValue() } /** + *

                                                                                                                          Product data that was updated.

                                                                                                                          *
                                                                                                                            *
                                                                                                                          • staged, if the staged ProductCatalogData was updated.
                                                                                                                          • *
                                                                                                                          • current, if the current ProductCatalogData was updated.
                                                                                                                          • @@ -181,7 +182,8 @@ public function getCatalogData() } /** - *

                                                                                                                            sku or key of the ProductVariant.

                                                                                                                            + *

                                                                                                                            Identifier of the updated Product Variant.

                                                                                                                            + *

                                                                                                                            This field holds the SKU, if defined; otherwise the key; otherwise the ID.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-history/src/Models/Change/SetVariantExclusionChange.php b/lib/commercetools-history/src/Models/Change/SetVariantExclusionChange.php new file mode 100644 index 00000000000..60ef7a394d3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetVariantExclusionChange.php @@ -0,0 +1,78 @@ +Reference to the updated Product.

                                                                                                                            + * + + * @return null|Reference + */ + public function getProduct(); + + /** + *

                                                                                                                            Value before the change.

                                                                                                                            + * + + * @return null|ProductVariantExclusion + */ + public function getPreviousValue(); + + /** + *

                                                                                                                            Value after the change.

                                                                                                                            + * + + * @return null|ProductVariantExclusion + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?Reference $product + */ + public function setProduct(?Reference $product): void; + + /** + * @param ?ProductVariantExclusion $previousValue + */ + public function setPreviousValue(?ProductVariantExclusion $previousValue): void; + + /** + * @param ?ProductVariantExclusion $nextValue + */ + public function setNextValue(?ProductVariantExclusion $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/SetVariantExclusionChangeBuilder.php b/lib/commercetools-history/src/Models/Change/SetVariantExclusionChangeBuilder.php new file mode 100644 index 00000000000..67872f0640b --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetVariantExclusionChangeBuilder.php @@ -0,0 +1,184 @@ + + */ +final class SetVariantExclusionChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|Reference|ReferenceBuilder + */ + private $product; + + /** + + * @var null|ProductVariantExclusion|ProductVariantExclusionBuilder + */ + private $previousValue; + + /** + + * @var null|ProductVariantExclusion|ProductVariantExclusionBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                                            Reference to the updated Product.

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

                                                                                                                            Value before the change.

                                                                                                                            + * + + * @return null|ProductVariantExclusion + */ + public function getPreviousValue() + { + return $this->previousValue instanceof ProductVariantExclusionBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                                                            Value after the change.

                                                                                                                            + * + + * @return null|ProductVariantExclusion + */ + public function getNextValue() + { + return $this->nextValue instanceof ProductVariantExclusionBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?Reference $product + * @return $this + */ + public function withProduct(?Reference $product) + { + $this->product = $product; + + return $this; + } + + /** + * @param ?ProductVariantExclusion $previousValue + * @return $this + */ + public function withPreviousValue(?ProductVariantExclusion $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?ProductVariantExclusion $nextValue + * @return $this + */ + public function withNextValue(?ProductVariantExclusion $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withProduct() instead + * @return $this + */ + public function withProductBuilder(?ReferenceBuilder $product) + { + $this->product = $product; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?ProductVariantExclusionBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?ProductVariantExclusionBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): SetVariantExclusionChange + { + return new SetVariantExclusionChangeModel( + $this->change, + $this->product instanceof ReferenceBuilder ? $this->product->build() : $this->product, + $this->previousValue instanceof ProductVariantExclusionBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof ProductVariantExclusionBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): SetVariantExclusionChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetVariantExclusionChangeCollection.php b/lib/commercetools-history/src/Models/Change/SetVariantExclusionChangeCollection.php new file mode 100644 index 00000000000..1cc818e8453 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetVariantExclusionChangeCollection.php @@ -0,0 +1,56 @@ + + * @method SetVariantExclusionChange current() + * @method SetVariantExclusionChange end() + * @method SetVariantExclusionChange at($offset) + */ +class SetVariantExclusionChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert SetVariantExclusionChange $value + * @psalm-param SetVariantExclusionChange|stdClass $value + * @throws InvalidArgumentException + * + * @return SetVariantExclusionChangeCollection + */ + public function add($value) + { + if (!$value instanceof SetVariantExclusionChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?SetVariantExclusionChange + */ + protected function mapper() + { + return function (?int $index): ?SetVariantExclusionChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var SetVariantExclusionChange $data */ + $data = SetVariantExclusionChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/SetVariantExclusionChangeModel.php b/lib/commercetools-history/src/Models/Change/SetVariantExclusionChangeModel.php new file mode 100644 index 00000000000..892a4639353 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/SetVariantExclusionChangeModel.php @@ -0,0 +1,210 @@ +change = $change; + $this->product = $product; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                                            Reference to the updated Product.

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

                                                                                                                            Value before the change.

                                                                                                                            + * + * + * @return null|ProductVariantExclusion + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = ProductVariantExclusionModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                                                            Value after the change.

                                                                                                                            + * + * + * @return null|ProductVariantExclusion + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = ProductVariantExclusionModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?Reference $product + */ + public function setProduct(?Reference $product): void + { + $this->product = $product; + } + + /** + * @param ?ProductVariantExclusion $previousValue + */ + public function setPreviousValue(?ProductVariantExclusion $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?ProductVariantExclusion $nextValue + */ + public function setNextValue(?ProductVariantExclusion $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Change/SetVariantSelectionChangeModel.php b/lib/commercetools-history/src/Models/Change/SetVariantSelectionChangeModel.php index bf499c48bbd..7a17243d0d1 100644 --- a/lib/commercetools-history/src/Models/Change/SetVariantSelectionChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/SetVariantSelectionChangeModel.php @@ -165,8 +165,8 @@ public function getProduct() if (is_null($data)) { return null; } - - $this->product = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->product = $className::of($data); } return $this->product; diff --git a/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChange.php b/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChange.php index 6e0d0ce82cb..3c52ff93886 100644 --- a/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChange.php +++ b/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChange.php @@ -18,6 +18,7 @@ interface TransitionCustomLineItemStateChange extends Change public const FIELD_PREVIOUS_VALUE = 'previousValue'; public const FIELD_NEXT_VALUE = 'nextValue'; public const FIELD_LINE_ITEM_ID = 'lineItemId'; + public const FIELD_CUSTOM_LINE_ITEM_ID = 'customLineItemId'; public const FIELD_STATE_ID = 'stateId'; /** @@ -49,13 +50,21 @@ public function getPreviousValue(); public function getNextValue(); /** - *

                                                                                                                            id of the updated CustomLineItem.

                                                                                                                            + *

                                                                                                                            id of the updated LineItem.

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

                                                                                                                            id of the updated CustomLineItem.

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

                                                                                                                            id of the State involved in the transition.

                                                                                                                            * @@ -84,6 +93,11 @@ public function setNextValue(?ItemStateCollection $nextValue): void; */ public function setLineItemId(?string $lineItemId): void; + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void; + /** * @param ?string $stateId */ diff --git a/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChangeBuilder.php b/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChangeBuilder.php index 4e39a8ea6c5..06dbe741906 100644 --- a/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChangeBuilder.php +++ b/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChangeBuilder.php @@ -45,6 +45,12 @@ final class TransitionCustomLineItemStateChangeBuilder implements Builder */ private $lineItemId; + /** + + * @var ?string + */ + private $customLineItemId; + /** * @var ?string @@ -83,7 +89,7 @@ public function getNextValue() } /** - *

                                                                                                                            id of the updated CustomLineItem.

                                                                                                                            + *

                                                                                                                            id of the updated LineItem.

                                                                                                                            * * @return null|string @@ -93,6 +99,17 @@ public function getLineItemId() return $this->lineItemId; } + /** + *

                                                                                                                            id of the updated CustomLineItem.

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

                                                                                                                            id of the State involved in the transition.

                                                                                                                            * @@ -148,6 +165,17 @@ public function withLineItemId(?string $lineItemId) return $this; } + /** + * @param ?string $customLineItemId + * @return $this + */ + public function withCustomLineItemId(?string $customLineItemId) + { + $this->customLineItemId = $customLineItemId; + + return $this; + } + /** * @param ?string $stateId * @return $this @@ -167,6 +195,7 @@ public function build(): TransitionCustomLineItemStateChange $this->previousValue, $this->nextValue, $this->lineItemId, + $this->customLineItemId, $this->stateId ); } diff --git a/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChangeModel.php b/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChangeModel.php index e083b621af4..f9a48687f4f 100644 --- a/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/TransitionCustomLineItemStateChangeModel.php @@ -52,6 +52,12 @@ final class TransitionCustomLineItemStateChangeModel extends JsonObjectModel imp */ protected $lineItemId; + /** + * + * @var ?string + */ + protected $customLineItemId; + /** * * @var ?string @@ -67,6 +73,7 @@ public function __construct( ?ItemStateCollection $previousValue = null, ?ItemStateCollection $nextValue = null, ?string $lineItemId = null, + ?string $customLineItemId = null, ?string $stateId = null, ?string $type = null ) { @@ -74,6 +81,7 @@ public function __construct( $this->previousValue = $previousValue; $this->nextValue = $nextValue; $this->lineItemId = $lineItemId; + $this->customLineItemId = $customLineItemId; $this->stateId = $stateId; $this->type = $type ?? self::DISCRIMINATOR_VALUE; } @@ -155,7 +163,7 @@ public function getNextValue() } /** - *

                                                                                                                            id of the updated CustomLineItem.

                                                                                                                            + *

                                                                                                                            id of the updated LineItem.

                                                                                                                            * * * @return null|string @@ -174,6 +182,26 @@ public function getLineItemId() return $this->lineItemId; } + /** + *

                                                                                                                            id of the updated CustomLineItem.

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

                                                                                                                            id of the State involved in the transition.

                                                                                                                            * @@ -227,6 +255,14 @@ public function setLineItemId(?string $lineItemId): void $this->lineItemId = $lineItemId; } + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void + { + $this->customLineItemId = $customLineItemId; + } + /** * @param ?string $stateId */ diff --git a/lib/commercetools-history/src/Models/Change/TransitionStateChangeModel.php b/lib/commercetools-history/src/Models/Change/TransitionStateChangeModel.php index ddd6eae0545..526b3049c36 100644 --- a/lib/commercetools-history/src/Models/Change/TransitionStateChangeModel.php +++ b/lib/commercetools-history/src/Models/Change/TransitionStateChangeModel.php @@ -113,8 +113,8 @@ public function getPreviousValue() if (is_null($data)) { return null; } - - $this->previousValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->previousValue = $className::of($data); } return $this->previousValue; @@ -134,8 +134,8 @@ public function getNextValue() if (is_null($data)) { return null; } - - $this->nextValue = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->nextValue = $className::of($data); } return $this->nextValue; diff --git a/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChange.php b/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChange.php new file mode 100644 index 00000000000..e131411e1eb --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChange.php @@ -0,0 +1,63 @@ +Value before the change.

                                                                                                                            + * + + * @return null|Address + */ + public function getPreviousValue(); + + /** + *

                                                                                                                            Value after the change.

                                                                                                                            + * + + * @return null|Address + */ + public function getNextValue(); + + /** + * @param ?string $change + */ + public function setChange(?string $change): void; + + /** + * @param ?Address $previousValue + */ + public function setPreviousValue(?Address $previousValue): void; + + /** + * @param ?Address $nextValue + */ + public function setNextValue(?Address $nextValue): void; +} diff --git a/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChangeBuilder.php b/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChangeBuilder.php new file mode 100644 index 00000000000..9530a44986d --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChangeBuilder.php @@ -0,0 +1,142 @@ + + */ +final class UpdateItemShippingAddressChangeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $change; + + /** + + * @var null|Address|AddressBuilder + */ + private $previousValue; + + /** + + * @var null|Address|AddressBuilder + */ + private $nextValue; + + /** + + * @return null|string + */ + public function getChange() + { + return $this->change; + } + + /** + *

                                                                                                                            Value before the change.

                                                                                                                            + * + + * @return null|Address + */ + public function getPreviousValue() + { + return $this->previousValue instanceof AddressBuilder ? $this->previousValue->build() : $this->previousValue; + } + + /** + *

                                                                                                                            Value after the change.

                                                                                                                            + * + + * @return null|Address + */ + public function getNextValue() + { + return $this->nextValue instanceof AddressBuilder ? $this->nextValue->build() : $this->nextValue; + } + + /** + * @param ?string $change + * @return $this + */ + public function withChange(?string $change) + { + $this->change = $change; + + return $this; + } + + /** + * @param ?Address $previousValue + * @return $this + */ + public function withPreviousValue(?Address $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @param ?Address $nextValue + * @return $this + */ + public function withNextValue(?Address $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + /** + * @deprecated use withPreviousValue() instead + * @return $this + */ + public function withPreviousValueBuilder(?AddressBuilder $previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + /** + * @deprecated use withNextValue() instead + * @return $this + */ + public function withNextValueBuilder(?AddressBuilder $nextValue) + { + $this->nextValue = $nextValue; + + return $this; + } + + public function build(): UpdateItemShippingAddressChange + { + return new UpdateItemShippingAddressChangeModel( + $this->change, + $this->previousValue instanceof AddressBuilder ? $this->previousValue->build() : $this->previousValue, + $this->nextValue instanceof AddressBuilder ? $this->nextValue->build() : $this->nextValue + ); + } + + public static function of(): UpdateItemShippingAddressChangeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChangeCollection.php b/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChangeCollection.php new file mode 100644 index 00000000000..fe1d8833793 --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChangeCollection.php @@ -0,0 +1,56 @@ + + * @method UpdateItemShippingAddressChange current() + * @method UpdateItemShippingAddressChange end() + * @method UpdateItemShippingAddressChange at($offset) + */ +class UpdateItemShippingAddressChangeCollection extends ChangeCollection +{ + /** + * @psalm-assert UpdateItemShippingAddressChange $value + * @psalm-param UpdateItemShippingAddressChange|stdClass $value + * @throws InvalidArgumentException + * + * @return UpdateItemShippingAddressChangeCollection + */ + public function add($value) + { + if (!$value instanceof UpdateItemShippingAddressChange) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?UpdateItemShippingAddressChange + */ + protected function mapper() + { + return function (?int $index): ?UpdateItemShippingAddressChange { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var UpdateItemShippingAddressChange $data */ + $data = UpdateItemShippingAddressChangeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChangeModel.php b/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChangeModel.php new file mode 100644 index 00000000000..52af10189ca --- /dev/null +++ b/lib/commercetools-history/src/Models/Change/UpdateItemShippingAddressChangeModel.php @@ -0,0 +1,171 @@ +change = $change; + $this->previousValue = $previousValue; + $this->nextValue = $nextValue; + $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; + } + + /** + * + * @return null|string + */ + public function getChange() + { + if (is_null($this->change)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_CHANGE); + if (is_null($data)) { + return null; + } + $this->change = (string) $data; + } + + return $this->change; + } + + /** + *

                                                                                                                            Value before the change.

                                                                                                                            + * + * + * @return null|Address + */ + public function getPreviousValue() + { + if (is_null($this->previousValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PREVIOUS_VALUE); + if (is_null($data)) { + return null; + } + + $this->previousValue = AddressModel::of($data); + } + + return $this->previousValue; + } + + /** + *

                                                                                                                            Value after the change.

                                                                                                                            + * + * + * @return null|Address + */ + public function getNextValue() + { + if (is_null($this->nextValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NEXT_VALUE); + if (is_null($data)) { + return null; + } + + $this->nextValue = AddressModel::of($data); + } + + return $this->nextValue; + } + + + /** + * @param ?string $change + */ + public function setChange(?string $change): void + { + $this->change = $change; + } + + /** + * @param ?Address $previousValue + */ + public function setPreviousValue(?Address $previousValue): void + { + $this->previousValue = $previousValue; + } + + /** + * @param ?Address $nextValue + */ + public function setNextValue(?Address $nextValue): void + { + $this->nextValue = $nextValue; + } + + + +} diff --git a/lib/commercetools-history/src/Models/ChangeHistory/ModifiedByModel.php b/lib/commercetools-history/src/Models/ChangeHistory/ModifiedByModel.php index c2e6ad8c87a..3b7fcac360a 100644 --- a/lib/commercetools-history/src/Models/ChangeHistory/ModifiedByModel.php +++ b/lib/commercetools-history/src/Models/ChangeHistory/ModifiedByModel.php @@ -210,8 +210,8 @@ public function getCustomer() if (is_null($data)) { return null; } - - $this->customer = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->customer = $className::of($data); } return $this->customer; @@ -231,8 +231,8 @@ public function getAssociate() if (is_null($data)) { return null; } - - $this->associate = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->associate = $className::of($data); } return $this->associate; diff --git a/lib/commercetools-history/src/Models/ChangeHistory/RecordModel.php b/lib/commercetools-history/src/Models/ChangeHistory/RecordModel.php index 4a816ca136b..9c32185ba52 100644 --- a/lib/commercetools-history/src/Models/ChangeHistory/RecordModel.php +++ b/lib/commercetools-history/src/Models/ChangeHistory/RecordModel.php @@ -355,8 +355,8 @@ public function getBusinessUnit() if (is_null($data)) { return null; } - - $this->businessUnit = KeyReferenceModel::of($data); + $className = KeyReferenceModel::resolveDiscriminatorClass($data); + $this->businessUnit = $className::of($data); } return $this->businessUnit; diff --git a/lib/commercetools-history/src/Models/ChangeValue/ChangeValueGiftLineItemChangeValueModel.php b/lib/commercetools-history/src/Models/ChangeValue/ChangeValueGiftLineItemChangeValueModel.php index d04e18b8244..5609f1fde1e 100644 --- a/lib/commercetools-history/src/Models/ChangeValue/ChangeValueGiftLineItemChangeValueModel.php +++ b/lib/commercetools-history/src/Models/ChangeValue/ChangeValueGiftLineItemChangeValueModel.php @@ -103,8 +103,8 @@ public function getProduct() if (is_null($data)) { return null; } - - $this->product = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->product = $className::of($data); } return $this->product; @@ -144,8 +144,8 @@ public function getSupplyChannel() if (is_null($data)) { return null; } - - $this->supplyChannel = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->supplyChannel = $className::of($data); } return $this->supplyChannel; @@ -165,8 +165,8 @@ public function getDistributionChannel() if (is_null($data)) { return null; } - - $this->distributionChannel = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->distributionChannel = $className::of($data); } return $this->distributionChannel; diff --git a/lib/commercetools-history/src/Models/Common/Address.php b/lib/commercetools-history/src/Models/Common/Address.php index 2840b883574..77623c99096 100644 --- a/lib/commercetools-history/src/Models/Common/Address.php +++ b/lib/commercetools-history/src/Models/Common/Address.php @@ -11,311 +11,21 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -interface Address extends JsonObject +interface Address extends BaseAddress { - public const FIELD_ID = 'id'; - public const FIELD_KEY = 'key'; - public const FIELD_TITLE = 'title'; - public const FIELD_SALUTATION = 'salutation'; - public const FIELD_FIRST_NAME = 'firstName'; - public const FIELD_LAST_NAME = 'lastName'; - public const FIELD_STREET_NAME = 'streetName'; - public const FIELD_STREET_NUMBER = 'streetNumber'; - public const FIELD_ADDITIONAL_STREET_INFO = 'additionalStreetInfo'; - public const FIELD_POSTAL_CODE = 'postalCode'; - public const FIELD_CITY = 'city'; - public const FIELD_REGION = 'region'; - public const FIELD_STATE = 'state'; - public const FIELD_COUNTRY = 'country'; - public const FIELD_COMPANY = 'company'; - public const FIELD_DEPARTMENT = 'department'; - public const FIELD_BUILDING = 'building'; - public const FIELD_APARTMENT = 'apartment'; - public const FIELD_P_O_BOX = 'pOBox'; - public const FIELD_PHONE = 'phone'; - public const FIELD_MOBILE = 'mobile'; - public const FIELD_EMAIL = 'email'; - public const FIELD_FAX = 'fax'; - public const FIELD_ADDITIONAL_ADDRESS_INFO = 'additionalAddressInfo'; - public const FIELD_EXTERNAL_ID = 'externalId'; + public const FIELD_CUSTOM = 'custom'; /** - *

                                                                                                                            Unique ID of the Address.

                                                                                                                            + *

                                                                                                                            Custom Fields defined for the Address.

                                                                                                                            * - * @return null|string + * @return null|CustomFields */ - public function getId(); + public function getCustom(); /** - - * @return null|string - */ - public function getKey(); - - /** - - * @return null|string - */ - public function getTitle(); - - /** - - * @return null|string - */ - public function getSalutation(); - - /** - - * @return null|string - */ - public function getFirstName(); - - /** - - * @return null|string - */ - public function getLastName(); - - /** - - * @return null|string - */ - public function getStreetName(); - - /** - - * @return null|string - */ - public function getStreetNumber(); - - /** - - * @return null|string - */ - public function getAdditionalStreetInfo(); - - /** - - * @return null|string - */ - public function getPostalCode(); - - /** - - * @return null|string - */ - public function getCity(); - - /** - - * @return null|string - */ - public function getRegion(); - - /** - - * @return null|string - */ - public function getState(); - - /** - *

                                                                                                                            Two-digit country code as per ISO 3166-1 alpha-2.

                                                                                                                            - * - - * @return null|string - */ - public function getCountry(); - - /** - - * @return null|string - */ - public function getCompany(); - - /** - - * @return null|string - */ - public function getDepartment(); - - /** - - * @return null|string - */ - public function getBuilding(); - - /** - - * @return null|string - */ - public function getApartment(); - - /** - - * @return null|string - */ - public function getPOBox(); - - /** - - * @return null|string - */ - public function getPhone(); - - /** - - * @return null|string - */ - public function getMobile(); - - /** - - * @return null|string - */ - public function getEmail(); - - /** - - * @return null|string - */ - public function getFax(); - - /** - - * @return null|string - */ - public function getAdditionalAddressInfo(); - - /** - - * @return null|string - */ - public function getExternalId(); - - /** - * @param ?string $id - */ - public function setId(?string $id): void; - - /** - * @param ?string $key - */ - public function setKey(?string $key): void; - - /** - * @param ?string $title - */ - public function setTitle(?string $title): void; - - /** - * @param ?string $salutation - */ - public function setSalutation(?string $salutation): void; - - /** - * @param ?string $firstName - */ - public function setFirstName(?string $firstName): void; - - /** - * @param ?string $lastName - */ - public function setLastName(?string $lastName): void; - - /** - * @param ?string $streetName - */ - public function setStreetName(?string $streetName): void; - - /** - * @param ?string $streetNumber - */ - public function setStreetNumber(?string $streetNumber): void; - - /** - * @param ?string $additionalStreetInfo - */ - public function setAdditionalStreetInfo(?string $additionalStreetInfo): void; - - /** - * @param ?string $postalCode - */ - public function setPostalCode(?string $postalCode): void; - - /** - * @param ?string $city - */ - public function setCity(?string $city): void; - - /** - * @param ?string $region - */ - public function setRegion(?string $region): void; - - /** - * @param ?string $state - */ - public function setState(?string $state): void; - - /** - * @param ?string $country - */ - public function setCountry(?string $country): void; - - /** - * @param ?string $company - */ - public function setCompany(?string $company): void; - - /** - * @param ?string $department - */ - public function setDepartment(?string $department): void; - - /** - * @param ?string $building - */ - public function setBuilding(?string $building): void; - - /** - * @param ?string $apartment - */ - public function setApartment(?string $apartment): void; - - /** - * @param ?string $pOBox - */ - public function setPOBox(?string $pOBox): void; - - /** - * @param ?string $phone - */ - public function setPhone(?string $phone): void; - - /** - * @param ?string $mobile - */ - public function setMobile(?string $mobile): void; - - /** - * @param ?string $email - */ - public function setEmail(?string $email): void; - - /** - * @param ?string $fax - */ - public function setFax(?string $fax): void; - - /** - * @param ?string $additionalAddressInfo - */ - public function setAdditionalAddressInfo(?string $additionalAddressInfo): void; - - /** - * @param ?string $externalId + * @param ?CustomFields $custom */ - public function setExternalId(?string $externalId): void; + public function setCustom(?CustomFields $custom): void; } diff --git a/lib/commercetools-history/src/Models/Common/AddressBuilder.php b/lib/commercetools-history/src/Models/Common/AddressBuilder.php index b78b30ee88d..4a5bb626271 100644 --- a/lib/commercetools-history/src/Models/Common/AddressBuilder.php +++ b/lib/commercetools-history/src/Models/Common/AddressBuilder.php @@ -32,6 +32,12 @@ final class AddressBuilder implements Builder */ private $key; + /** + + * @var ?string + */ + private $country; + /** * @var ?string @@ -98,12 +104,6 @@ final class AddressBuilder implements Builder */ private $state; - /** - - * @var ?string - */ - private $country; - /** * @var ?string @@ -171,7 +171,15 @@ final class AddressBuilder implements Builder private $externalId; /** - *

                                                                                                                            Unique ID of the Address.

                                                                                                                            + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + + /** + *

                                                                                                                            Unique identifier of the Address.

                                                                                                                            + *

                                                                                                                            It is not recommended to set it manually since the API overwrites this ID when creating an Address for a Customer. + * Use key instead and omit this field from the request to let the API generate the ID for the Address.

                                                                                                                            * * @return null|string @@ -182,6 +190,8 @@ public function getId() } /** + *

                                                                                                                            User-defined identifier of the Address that must be unique when multiple addresses are referenced in BusinessUnits, Customers, and itemShippingAddresses (LineItem-specific addresses) of a Cart, Order, QuoteRequest, or Quote.

                                                                                                                            + * * @return null|string */ @@ -191,6 +201,19 @@ public function getKey() } /** + *

                                                                                                                            Name of the country.

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

                                                                                                                            Title of the contact, for example 'Dr.'

                                                                                                                            + * * @return null|string */ @@ -200,6 +223,8 @@ public function getTitle() } /** + *

                                                                                                                            Salutation of the contact, for example 'Mr.' or 'Ms.'

                                                                                                                            + * * @return null|string */ @@ -209,6 +234,8 @@ public function getSalutation() } /** + *

                                                                                                                            Given name (first name) of the contact.

                                                                                                                            + * * @return null|string */ @@ -218,6 +245,8 @@ public function getFirstName() } /** + *

                                                                                                                            Family name (last name) of the contact.

                                                                                                                            + * * @return null|string */ @@ -227,6 +256,8 @@ public function getLastName() } /** + *

                                                                                                                            Name of the street.

                                                                                                                            + * * @return null|string */ @@ -236,6 +267,8 @@ public function getStreetName() } /** + *

                                                                                                                            Street number.

                                                                                                                            + * * @return null|string */ @@ -245,6 +278,8 @@ public function getStreetNumber() } /** + *

                                                                                                                            Further information on the street address.

                                                                                                                            + * * @return null|string */ @@ -254,6 +289,8 @@ public function getAdditionalStreetInfo() } /** + *

                                                                                                                            Postal code.

                                                                                                                            + * * @return null|string */ @@ -263,6 +300,8 @@ public function getPostalCode() } /** + *

                                                                                                                            Name of the city.

                                                                                                                            + * * @return null|string */ @@ -272,6 +311,8 @@ public function getCity() } /** + *

                                                                                                                            Name of the region.

                                                                                                                            + * * @return null|string */ @@ -281,6 +322,8 @@ public function getRegion() } /** + *

                                                                                                                            Name of the state, for example, Colorado.

                                                                                                                            + * * @return null|string */ @@ -290,18 +333,9 @@ public function getState() } /** - *

                                                                                                                            Two-digit country code as per ISO 3166-1 alpha-2.

                                                                                                                            + *

                                                                                                                            Name of the company.

                                                                                                                            * - * @return null|string - */ - public function getCountry() - { - return $this->country; - } - - /** - * @return null|string */ public function getCompany() @@ -310,6 +344,8 @@ public function getCompany() } /** + *

                                                                                                                            Name of the department.

                                                                                                                            + * * @return null|string */ @@ -319,6 +355,8 @@ public function getDepartment() } /** + *

                                                                                                                            Number or name of the building.

                                                                                                                            + * * @return null|string */ @@ -328,6 +366,8 @@ public function getBuilding() } /** + *

                                                                                                                            Number or name of the apartment.

                                                                                                                            + * * @return null|string */ @@ -337,6 +377,8 @@ public function getApartment() } /** + *

                                                                                                                            Post office box number.

                                                                                                                            + * * @return null|string */ @@ -346,6 +388,8 @@ public function getPOBox() } /** + *

                                                                                                                            Phone number of the contact.

                                                                                                                            + * * @return null|string */ @@ -355,6 +399,8 @@ public function getPhone() } /** + *

                                                                                                                            Mobile phone number of the contact.

                                                                                                                            + * * @return null|string */ @@ -364,6 +410,8 @@ public function getMobile() } /** + *

                                                                                                                            Email address of the contact.

                                                                                                                            + * * @return null|string */ @@ -373,6 +421,8 @@ public function getEmail() } /** + *

                                                                                                                            Fax number of the contact.

                                                                                                                            + * * @return null|string */ @@ -382,6 +432,8 @@ public function getFax() } /** + *

                                                                                                                            Further information on the Address.

                                                                                                                            + * * @return null|string */ @@ -391,6 +443,8 @@ public function getAdditionalAddressInfo() } /** + *

                                                                                                                            ID for the contact used in an external system.

                                                                                                                            + * * @return null|string */ @@ -399,6 +453,17 @@ public function getExternalId() return $this->externalId; } + /** + *

                                                                                                                            Custom Fields defined for the Address.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; + } + /** * @param ?string $id * @return $this @@ -421,6 +486,17 @@ public function withKey(?string $key) return $this; } + /** + * @param ?string $country + * @return $this + */ + public function withCountry(?string $country) + { + $this->country = $country; + + return $this; + } + /** * @param ?string $title * @return $this @@ -542,17 +618,6 @@ public function withState(?string $state) return $this; } - /** - * @param ?string $country - * @return $this - */ - public function withCountry(?string $country) - { - $this->country = $country; - - return $this; - } - /** * @param ?string $company * @return $this @@ -674,12 +739,34 @@ public function withExternalId(?string $externalId) return $this; } + /** + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + return $this; + } public function build(): Address { return new AddressModel( $this->id, $this->key, + $this->country, $this->title, $this->salutation, $this->firstName, @@ -691,7 +778,6 @@ public function build(): Address $this->city, $this->region, $this->state, - $this->country, $this->company, $this->department, $this->building, @@ -702,7 +788,8 @@ public function build(): Address $this->email, $this->fax, $this->additionalAddressInfo, - $this->externalId + $this->externalId, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom ); } diff --git a/lib/commercetools-history/src/Models/Common/AddressCollection.php b/lib/commercetools-history/src/Models/Common/AddressCollection.php index 2455e3fdce8..08afabc9877 100644 --- a/lib/commercetools-history/src/Models/Common/AddressCollection.php +++ b/lib/commercetools-history/src/Models/Common/AddressCollection.php @@ -8,17 +8,17 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\MapperSequence; +use Commercetools\History\Models\Common\BaseAddressCollection; use Commercetools\Exception\InvalidArgumentException; use stdClass; /** - * @extends MapperSequence
                                                                                                                            + * @extends BaseAddressCollection
                                                                                                                            * @method Address current() * @method Address end() * @method Address at($offset) */ -class AddressCollection extends MapperSequence +class AddressCollection extends BaseAddressCollection { /** * @psalm-assert Address $value diff --git a/lib/commercetools-history/src/Models/Common/AddressModel.php b/lib/commercetools-history/src/Models/Common/AddressModel.php index 33fe4d8f18b..a8c14188430 100644 --- a/lib/commercetools-history/src/Models/Common/AddressModel.php +++ b/lib/commercetools-history/src/Models/Common/AddressModel.php @@ -33,6 +33,12 @@ final class AddressModel extends JsonObjectModel implements Address */ protected $key; + /** + * + * @var ?string + */ + protected $country; + /** * * @var ?string @@ -99,12 +105,6 @@ final class AddressModel extends JsonObjectModel implements Address */ protected $state; - /** - * - * @var ?string - */ - protected $country; - /** * * @var ?string @@ -171,6 +171,12 @@ final class AddressModel extends JsonObjectModel implements Address */ protected $externalId; + /** + * + * @var ?CustomFields + */ + protected $custom; + /** * @psalm-suppress MissingParamType @@ -178,6 +184,7 @@ final class AddressModel extends JsonObjectModel implements Address public function __construct( ?string $id = null, ?string $key = null, + ?string $country = null, ?string $title = null, ?string $salutation = null, ?string $firstName = null, @@ -189,7 +196,6 @@ public function __construct( ?string $city = null, ?string $region = null, ?string $state = null, - ?string $country = null, ?string $company = null, ?string $department = null, ?string $building = null, @@ -200,10 +206,12 @@ public function __construct( ?string $email = null, ?string $fax = null, ?string $additionalAddressInfo = null, - ?string $externalId = null + ?string $externalId = null, + ?CustomFields $custom = null ) { $this->id = $id; $this->key = $key; + $this->country = $country; $this->title = $title; $this->salutation = $salutation; $this->firstName = $firstName; @@ -215,7 +223,6 @@ public function __construct( $this->city = $city; $this->region = $region; $this->state = $state; - $this->country = $country; $this->company = $company; $this->department = $department; $this->building = $building; @@ -227,11 +234,14 @@ public function __construct( $this->fax = $fax; $this->additionalAddressInfo = $additionalAddressInfo; $this->externalId = $externalId; + $this->custom = $custom; } /** - *

                                                                                                                            Unique ID of the Address.

                                                                                                                            + *

                                                                                                                            Unique identifier of the Address.

                                                                                                                            + *

                                                                                                                            It is not recommended to set it manually since the API overwrites this ID when creating an Address for a Customer. + * Use key instead and omit this field from the request to let the API generate the ID for the Address.

                                                                                                                            * * * @return null|string @@ -251,6 +261,8 @@ public function getId() } /** + *

                                                                                                                            User-defined identifier of the Address that must be unique when multiple addresses are referenced in BusinessUnits, Customers, and itemShippingAddresses (LineItem-specific addresses) of a Cart, Order, QuoteRequest, or Quote.

                                                                                                                            + * * * @return null|string */ @@ -269,6 +281,28 @@ public function getKey() } /** + *

                                                                                                                            Name of the country.

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

                                                                                                                            Title of the contact, for example 'Dr.'

                                                                                                                            + * * * @return null|string */ @@ -287,6 +321,8 @@ public function getTitle() } /** + *

                                                                                                                            Salutation of the contact, for example 'Mr.' or 'Ms.'

                                                                                                                            + * * * @return null|string */ @@ -305,6 +341,8 @@ public function getSalutation() } /** + *

                                                                                                                            Given name (first name) of the contact.

                                                                                                                            + * * * @return null|string */ @@ -323,6 +361,8 @@ public function getFirstName() } /** + *

                                                                                                                            Family name (last name) of the contact.

                                                                                                                            + * * * @return null|string */ @@ -341,6 +381,8 @@ public function getLastName() } /** + *

                                                                                                                            Name of the street.

                                                                                                                            + * * * @return null|string */ @@ -359,6 +401,8 @@ public function getStreetName() } /** + *

                                                                                                                            Street number.

                                                                                                                            + * * * @return null|string */ @@ -377,6 +421,8 @@ public function getStreetNumber() } /** + *

                                                                                                                            Further information on the street address.

                                                                                                                            + * * * @return null|string */ @@ -395,6 +441,8 @@ public function getAdditionalStreetInfo() } /** + *

                                                                                                                            Postal code.

                                                                                                                            + * * * @return null|string */ @@ -413,6 +461,8 @@ public function getPostalCode() } /** + *

                                                                                                                            Name of the city.

                                                                                                                            + * * * @return null|string */ @@ -431,6 +481,8 @@ public function getCity() } /** + *

                                                                                                                            Name of the region.

                                                                                                                            + * * * @return null|string */ @@ -449,6 +501,8 @@ public function getRegion() } /** + *

                                                                                                                            Name of the state, for example, Colorado.

                                                                                                                            + * * * @return null|string */ @@ -467,29 +521,11 @@ public function getState() } /** - *

                                                                                                                            Two-digit country code as per ISO 3166-1 alpha-2.

                                                                                                                            + *

                                                                                                                            Name of the company.

                                                                                                                            * * * @return null|string */ - public function getCountry() - { - if (is_null($this->country)) { - /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_COUNTRY); - if (is_null($data)) { - return null; - } - $this->country = (string) $data; - } - - return $this->country; - } - - /** - * - * @return null|string - */ public function getCompany() { if (is_null($this->company)) { @@ -505,6 +541,8 @@ public function getCompany() } /** + *

                                                                                                                            Name of the department.

                                                                                                                            + * * * @return null|string */ @@ -523,6 +561,8 @@ public function getDepartment() } /** + *

                                                                                                                            Number or name of the building.

                                                                                                                            + * * * @return null|string */ @@ -541,6 +581,8 @@ public function getBuilding() } /** + *

                                                                                                                            Number or name of the apartment.

                                                                                                                            + * * * @return null|string */ @@ -559,6 +601,8 @@ public function getApartment() } /** + *

                                                                                                                            Post office box number.

                                                                                                                            + * * * @return null|string */ @@ -577,6 +621,8 @@ public function getPOBox() } /** + *

                                                                                                                            Phone number of the contact.

                                                                                                                            + * * * @return null|string */ @@ -595,6 +641,8 @@ public function getPhone() } /** + *

                                                                                                                            Mobile phone number of the contact.

                                                                                                                            + * * * @return null|string */ @@ -613,6 +661,8 @@ public function getMobile() } /** + *

                                                                                                                            Email address of the contact.

                                                                                                                            + * * * @return null|string */ @@ -631,6 +681,8 @@ public function getEmail() } /** + *

                                                                                                                            Fax number of the contact.

                                                                                                                            + * * * @return null|string */ @@ -649,6 +701,8 @@ public function getFax() } /** + *

                                                                                                                            Further information on the Address.

                                                                                                                            + * * * @return null|string */ @@ -667,6 +721,8 @@ public function getAdditionalAddressInfo() } /** + *

                                                                                                                            ID for the contact used in an external system.

                                                                                                                            + * * * @return null|string */ @@ -684,6 +740,27 @@ public function getExternalId() return $this->externalId; } + /** + *

                                                                                                                            Custom Fields defined for the Address.

                                                                                                                            + * + * + * @return null|CustomFields + */ + public function getCustom() + { + if (is_null($this->custom)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($data)) { + return null; + } + + $this->custom = CustomFieldsModel::of($data); + } + + return $this->custom; + } + /** * @param ?string $id @@ -701,6 +778,14 @@ public function setKey(?string $key): void $this->key = $key; } + /** + * @param ?string $country + */ + public function setCountry(?string $country): void + { + $this->country = $country; + } + /** * @param ?string $title */ @@ -789,14 +874,6 @@ public function setState(?string $state): void $this->state = $state; } - /** - * @param ?string $country - */ - public function setCountry(?string $country): void - { - $this->country = $country; - } - /** * @param ?string $company */ @@ -885,6 +962,14 @@ public function setExternalId(?string $externalId): void $this->externalId = $externalId; } + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + } diff --git a/lib/commercetools-history/src/Models/Common/Asset.php b/lib/commercetools-history/src/Models/Common/Asset.php index 6f6b991784b..714a1d7609c 100644 --- a/lib/commercetools-history/src/Models/Common/Asset.php +++ b/lib/commercetools-history/src/Models/Common/Asset.php @@ -15,12 +15,16 @@ interface Asset extends JsonObject { public const FIELD_ID = 'id'; + public const FIELD_SOURCES = 'sources'; public const FIELD_NAME = 'name'; public const FIELD_DESCRIPTION = 'description'; + public const FIELD_TAGS = 'tags'; public const FIELD_CUSTOM = 'custom'; public const FIELD_KEY = 'key'; /** + *

                                                                                                                            Unique identifier of the Asset. Not required when importing Assets using the Import API.

                                                                                                                            + * * @return null|string */ @@ -28,23 +32,45 @@ public function getId(); /** + * @return null|AssetSourceCollection + */ + public function getSources(); + + /** + *

                                                                                                                            Name of the Asset.

                                                                                                                            + * + * @return null|LocalizedString */ public function getName(); /** + *

                                                                                                                            Description of the Asset.

                                                                                                                            + * * @return null|LocalizedString */ public function getDescription(); /** + *

                                                                                                                            Keywords for categorizing and organizing Assets.

                                                                                                                            + * + + * @return null|array + */ + public function getTags(); + + /** + *

                                                                                                                            Custom Fields defined for the Asset.

                                                                                                                            + * * @return null|CustomFields */ public function getCustom(); /** + *

                                                                                                                            User-defined identifier of the Asset. It is unique per Category or ProductVariant.

                                                                                                                            + * * @return null|string */ @@ -55,6 +81,11 @@ public function getKey(); */ public function setId(?string $id): void; + /** + * @param ?AssetSourceCollection $sources + */ + public function setSources(?AssetSourceCollection $sources): void; + /** * @param ?LocalizedString $name */ @@ -65,6 +96,11 @@ public function setName(?LocalizedString $name): void; */ public function setDescription(?LocalizedString $description): void; + /** + * @param ?array $tags + */ + public function setTags(?array $tags): void; + /** * @param ?CustomFields $custom */ diff --git a/lib/commercetools-history/src/Models/Common/AssetBuilder.php b/lib/commercetools-history/src/Models/Common/AssetBuilder.php index 040d9b756f4..d61426c6755 100644 --- a/lib/commercetools-history/src/Models/Common/AssetBuilder.php +++ b/lib/commercetools-history/src/Models/Common/AssetBuilder.php @@ -26,6 +26,12 @@ final class AssetBuilder implements Builder */ private $id; + /** + + * @var ?AssetSourceCollection + */ + private $sources; + /** * @var null|LocalizedString|LocalizedStringBuilder @@ -38,6 +44,12 @@ final class AssetBuilder implements Builder */ private $description; + /** + + * @var ?array + */ + private $tags; + /** * @var null|CustomFields|CustomFieldsBuilder @@ -51,6 +63,8 @@ final class AssetBuilder implements Builder private $key; /** + *

                                                                                                                            Unique identifier of the Asset. Not required when importing Assets using the Import API.

                                                                                                                            + * * @return null|string */ @@ -61,6 +75,17 @@ public function getId() /** + * @return null|AssetSourceCollection + */ + public function getSources() + { + return $this->sources; + } + + /** + *

                                                                                                                            Name of the Asset.

                                                                                                                            + * + * @return null|LocalizedString */ public function getName() @@ -69,6 +94,8 @@ public function getName() } /** + *

                                                                                                                            Description of the Asset.

                                                                                                                            + * * @return null|LocalizedString */ @@ -78,6 +105,19 @@ public function getDescription() } /** + *

                                                                                                                            Keywords for categorizing and organizing Assets.

                                                                                                                            + * + + * @return null|array + */ + public function getTags() + { + return $this->tags; + } + + /** + *

                                                                                                                            Custom Fields defined for the Asset.

                                                                                                                            + * * @return null|CustomFields */ @@ -87,6 +127,8 @@ public function getCustom() } /** + *

                                                                                                                            User-defined identifier of the Asset. It is unique per Category or ProductVariant.

                                                                                                                            + * * @return null|string */ @@ -106,6 +148,17 @@ public function withId(?string $id) return $this; } + /** + * @param ?AssetSourceCollection $sources + * @return $this + */ + public function withSources(?AssetSourceCollection $sources) + { + $this->sources = $sources; + + return $this; + } + /** * @param ?LocalizedString $name * @return $this @@ -128,6 +181,17 @@ public function withDescription(?LocalizedString $description) return $this; } + /** + * @param ?array $tags + * @return $this + */ + public function withTags(?array $tags) + { + $this->tags = $tags; + + return $this; + } + /** * @param ?CustomFields $custom * @return $this @@ -187,8 +251,10 @@ public function build(): Asset { return new AssetModel( $this->id, + $this->sources, $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name, $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description, + $this->tags, $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, $this->key ); diff --git a/lib/commercetools-history/src/Models/Common/AssetDimensions.php b/lib/commercetools-history/src/Models/Common/AssetDimensions.php index 2b41f63d69b..13991198c5b 100644 --- a/lib/commercetools-history/src/Models/Common/AssetDimensions.php +++ b/lib/commercetools-history/src/Models/Common/AssetDimensions.php @@ -18,12 +18,16 @@ interface AssetDimensions extends JsonObject public const FIELD_H = 'h'; /** + *

                                                                                                                            Width of the Asset source.

                                                                                                                            + * * @return null|int */ public function getW(); /** + *

                                                                                                                            Height of the Asset source.

                                                                                                                            + * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/AssetDimensionsBuilder.php b/lib/commercetools-history/src/Models/Common/AssetDimensionsBuilder.php index 77aeb522385..5e533033a82 100644 --- a/lib/commercetools-history/src/Models/Common/AssetDimensionsBuilder.php +++ b/lib/commercetools-history/src/Models/Common/AssetDimensionsBuilder.php @@ -33,6 +33,8 @@ final class AssetDimensionsBuilder implements Builder private $h; /** + *

                                                                                                                            Width of the Asset source.

                                                                                                                            + * * @return null|int */ @@ -42,6 +44,8 @@ public function getW() } /** + *

                                                                                                                            Height of the Asset source.

                                                                                                                            + * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/AssetDimensionsModel.php b/lib/commercetools-history/src/Models/Common/AssetDimensionsModel.php index 0e115fae26d..a6ea51aa798 100644 --- a/lib/commercetools-history/src/Models/Common/AssetDimensionsModel.php +++ b/lib/commercetools-history/src/Models/Common/AssetDimensionsModel.php @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            Width of the Asset source.

                                                                                                                            + * * * @return null|int */ @@ -65,6 +67,8 @@ public function getW() } /** + *

                                                                                                                            Height of the Asset source.

                                                                                                                            + * * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/AssetModel.php b/lib/commercetools-history/src/Models/Common/AssetModel.php index 914af522960..26fdd4a2b8d 100644 --- a/lib/commercetools-history/src/Models/Common/AssetModel.php +++ b/lib/commercetools-history/src/Models/Common/AssetModel.php @@ -27,6 +27,12 @@ final class AssetModel extends JsonObjectModel implements Asset */ protected $id; + /** + * + * @var ?AssetSourceCollection + */ + protected $sources; + /** * * @var ?LocalizedString @@ -39,6 +45,12 @@ final class AssetModel extends JsonObjectModel implements Asset */ protected $description; + /** + * + * @var ?array + */ + protected $tags; + /** * * @var ?CustomFields @@ -57,20 +69,26 @@ final class AssetModel extends JsonObjectModel implements Asset */ public function __construct( ?string $id = null, + ?AssetSourceCollection $sources = null, ?LocalizedString $name = null, ?LocalizedString $description = null, + ?array $tags = null, ?CustomFields $custom = null, ?string $key = null ) { $this->id = $id; + $this->sources = $sources; $this->name = $name; $this->description = $description; + $this->tags = $tags; $this->custom = $custom; $this->key = $key; } /** + *

                                                                                                                            Unique identifier of the Asset. Not required when importing Assets using the Import API.

                                                                                                                            + * * * @return null|string */ @@ -89,6 +107,26 @@ public function getId() } /** + * + * @return null|AssetSourceCollection + */ + public function getSources() + { + if (is_null($this->sources)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_SOURCES); + if (is_null($data)) { + return null; + } + $this->sources = AssetSourceCollection::fromArray($data); + } + + return $this->sources; + } + + /** + *

                                                                                                                            Name of the Asset.

                                                                                                                            + * * * @return null|LocalizedString */ @@ -108,6 +146,8 @@ public function getName() } /** + *

                                                                                                                            Description of the Asset.

                                                                                                                            + * * * @return null|LocalizedString */ @@ -127,6 +167,28 @@ public function getDescription() } /** + *

                                                                                                                            Keywords for categorizing and organizing Assets.

                                                                                                                            + * + * + * @return null|array + */ + public function getTags() + { + if (is_null($this->tags)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_TAGS); + if (is_null($data)) { + return null; + } + $this->tags = $data; + } + + return $this->tags; + } + + /** + *

                                                                                                                            Custom Fields defined for the Asset.

                                                                                                                            + * * * @return null|CustomFields */ @@ -146,6 +208,8 @@ public function getCustom() } /** + *

                                                                                                                            User-defined identifier of the Asset. It is unique per Category or ProductVariant.

                                                                                                                            + * * * @return null|string */ @@ -172,6 +236,14 @@ public function setId(?string $id): void $this->id = $id; } + /** + * @param ?AssetSourceCollection $sources + */ + public function setSources(?AssetSourceCollection $sources): void + { + $this->sources = $sources; + } + /** * @param ?LocalizedString $name */ @@ -188,6 +260,14 @@ public function setDescription(?LocalizedString $description): void $this->description = $description; } + /** + * @param ?array $tags + */ + public function setTags(?array $tags): void + { + $this->tags = $tags; + } + /** * @param ?CustomFields $custom */ diff --git a/lib/commercetools-history/src/Models/Common/AssetSource.php b/lib/commercetools-history/src/Models/Common/AssetSource.php index 2dfb0ffb485..f31baf05a99 100644 --- a/lib/commercetools-history/src/Models/Common/AssetSource.php +++ b/lib/commercetools-history/src/Models/Common/AssetSource.php @@ -20,24 +20,32 @@ interface AssetSource extends JsonObject public const FIELD_CONTENT_TYPE = 'contentType'; /** + *

                                                                                                                            URI of the AssetSource.

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

                                                                                                                            User-defined identifier of the AssetSource. Must be unique per Asset.

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

                                                                                                                            Width and height of the AssetSource.

                                                                                                                            + * * @return null|AssetDimensions */ public function getDimensions(); /** + *

                                                                                                                            Indicates the type of content, for example application/pdf.

                                                                                                                            + * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/AssetSourceBuilder.php b/lib/commercetools-history/src/Models/Common/AssetSourceBuilder.php index 7fd51ce727c..1bdce3f85a4 100644 --- a/lib/commercetools-history/src/Models/Common/AssetSourceBuilder.php +++ b/lib/commercetools-history/src/Models/Common/AssetSourceBuilder.php @@ -45,6 +45,8 @@ final class AssetSourceBuilder implements Builder private $contentType; /** + *

                                                                                                                            URI of the AssetSource.

                                                                                                                            + * * @return null|string */ @@ -54,6 +56,8 @@ public function getUri() } /** + *

                                                                                                                            User-defined identifier of the AssetSource. Must be unique per Asset.

                                                                                                                            + * * @return null|string */ @@ -63,6 +67,8 @@ public function getKey() } /** + *

                                                                                                                            Width and height of the AssetSource.

                                                                                                                            + * * @return null|AssetDimensions */ @@ -72,6 +78,8 @@ public function getDimensions() } /** + *

                                                                                                                            Indicates the type of content, for example application/pdf.

                                                                                                                            + * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/AssetSourceModel.php b/lib/commercetools-history/src/Models/Common/AssetSourceModel.php index 7c93be31220..1853da3f162 100644 --- a/lib/commercetools-history/src/Models/Common/AssetSourceModel.php +++ b/lib/commercetools-history/src/Models/Common/AssetSourceModel.php @@ -63,6 +63,8 @@ public function __construct( } /** + *

                                                                                                                            URI of the AssetSource.

                                                                                                                            + * * * @return null|string */ @@ -81,6 +83,8 @@ public function getUri() } /** + *

                                                                                                                            User-defined identifier of the AssetSource. Must be unique per Asset.

                                                                                                                            + * * * @return null|string */ @@ -99,6 +103,8 @@ public function getKey() } /** + *

                                                                                                                            Width and height of the AssetSource.

                                                                                                                            + * * * @return null|AssetDimensions */ @@ -118,6 +124,8 @@ public function getDimensions() } /** + *

                                                                                                                            Indicates the type of content, for example application/pdf.

                                                                                                                            + * * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/Associate.php b/lib/commercetools-history/src/Models/Common/Associate.php index 52dc4507a0a..d7ac2089618 100644 --- a/lib/commercetools-history/src/Models/Common/Associate.php +++ b/lib/commercetools-history/src/Models/Common/Associate.php @@ -15,17 +15,30 @@ interface Associate extends JsonObject { public const FIELD_ASSOCIATE_ROLE_ASSIGNMENTS = 'associateRoleAssignments'; + public const FIELD_ROLES = 'roles'; public const FIELD_CUSTOMER = 'customer'; /** + *

                                                                                                                            Roles assigned to the Associate within a Business Unit.

                                                                                                                            + * * @return null|AssociateRoleAssignmentCollection */ public function getAssociateRoleAssignments(); /** + *

                                                                                                                            Deprecated type. Use associateRoleAssignments instead.

                                                                                                                            + * - * @return null|Reference + * @return null|array + */ + public function getRoles(); + + /** + *

                                                                                                                            The Customer that acts as an Associate in the Business Unit.

                                                                                                                            + * + + * @return null|CustomerReference */ public function getCustomer(); @@ -35,7 +48,12 @@ public function getCustomer(); public function setAssociateRoleAssignments(?AssociateRoleAssignmentCollection $associateRoleAssignments): void; /** - * @param ?Reference $customer + * @param ?array $roles + */ + public function setRoles(?array $roles): void; + + /** + * @param ?CustomerReference $customer */ - public function setCustomer(?Reference $customer): void; + public function setCustomer(?CustomerReference $customer): void; } diff --git a/lib/commercetools-history/src/Models/Common/AssociateBuilder.php b/lib/commercetools-history/src/Models/Common/AssociateBuilder.php index 7c24d319019..c9c5b29bf1a 100644 --- a/lib/commercetools-history/src/Models/Common/AssociateBuilder.php +++ b/lib/commercetools-history/src/Models/Common/AssociateBuilder.php @@ -28,11 +28,19 @@ final class AssociateBuilder implements Builder /** - * @var null|Reference|ReferenceBuilder + * @var ?array + */ + private $roles; + + /** + + * @var null|CustomerReference|CustomerReferenceBuilder */ private $customer; /** + *

                                                                                                                            Roles assigned to the Associate within a Business Unit.

                                                                                                                            + * * @return null|AssociateRoleAssignmentCollection */ @@ -42,12 +50,25 @@ public function getAssociateRoleAssignments() } /** + *

                                                                                                                            Deprecated type. Use associateRoleAssignments instead.

                                                                                                                            + * + + * @return null|array + */ + public function getRoles() + { + return $this->roles; + } + + /** + *

                                                                                                                            The Customer that acts as an Associate in the Business Unit.

                                                                                                                            + * - * @return null|Reference + * @return null|CustomerReference */ public function getCustomer() { - return $this->customer instanceof ReferenceBuilder ? $this->customer->build() : $this->customer; + return $this->customer instanceof CustomerReferenceBuilder ? $this->customer->build() : $this->customer; } /** @@ -62,10 +83,21 @@ public function withAssociateRoleAssignments(?AssociateRoleAssignmentCollection } /** - * @param ?Reference $customer + * @param ?array $roles + * @return $this + */ + public function withRoles(?array $roles) + { + $this->roles = $roles; + + return $this; + } + + /** + * @param ?CustomerReference $customer * @return $this */ - public function withCustomer(?Reference $customer) + public function withCustomer(?CustomerReference $customer) { $this->customer = $customer; @@ -76,7 +108,7 @@ public function withCustomer(?Reference $customer) * @deprecated use withCustomer() instead * @return $this */ - public function withCustomerBuilder(?ReferenceBuilder $customer) + public function withCustomerBuilder(?CustomerReferenceBuilder $customer) { $this->customer = $customer; @@ -87,7 +119,8 @@ public function build(): Associate { return new AssociateModel( $this->associateRoleAssignments, - $this->customer instanceof ReferenceBuilder ? $this->customer->build() : $this->customer + $this->roles, + $this->customer instanceof CustomerReferenceBuilder ? $this->customer->build() : $this->customer ); } diff --git a/lib/commercetools-history/src/Models/Common/AssociateModel.php b/lib/commercetools-history/src/Models/Common/AssociateModel.php index 1f9d1ef1b5c..7096e7f97a3 100644 --- a/lib/commercetools-history/src/Models/Common/AssociateModel.php +++ b/lib/commercetools-history/src/Models/Common/AssociateModel.php @@ -29,7 +29,13 @@ final class AssociateModel extends JsonObjectModel implements Associate /** * - * @var ?Reference + * @var ?array + */ + protected $roles; + + /** + * + * @var ?CustomerReference */ protected $customer; @@ -39,14 +45,18 @@ final class AssociateModel extends JsonObjectModel implements Associate */ public function __construct( ?AssociateRoleAssignmentCollection $associateRoleAssignments = null, - ?Reference $customer = null + ?array $roles = null, + ?CustomerReference $customer = null ) { $this->associateRoleAssignments = $associateRoleAssignments; + $this->roles = $roles; $this->customer = $customer; } /** + *

                                                                                                                            Roles assigned to the Associate within a Business Unit.

                                                                                                                            + * * * @return null|AssociateRoleAssignmentCollection */ @@ -65,8 +75,30 @@ public function getAssociateRoleAssignments() } /** + *

                                                                                                                            Deprecated type. Use associateRoleAssignments instead.

                                                                                                                            + * * - * @return null|Reference + * @return null|array + */ + public function getRoles() + { + if (is_null($this->roles)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ROLES); + if (is_null($data)) { + return null; + } + $this->roles = $data; + } + + return $this->roles; + } + + /** + *

                                                                                                                            The Customer that acts as an Associate in the Business Unit.

                                                                                                                            + * + * + * @return null|CustomerReference */ public function getCustomer() { @@ -77,7 +109,7 @@ public function getCustomer() return null; } - $this->customer = ReferenceModel::of($data); + $this->customer = CustomerReferenceModel::of($data); } return $this->customer; @@ -93,9 +125,17 @@ public function setAssociateRoleAssignments(?AssociateRoleAssignmentCollection $ } /** - * @param ?Reference $customer + * @param ?array $roles + */ + public function setRoles(?array $roles): void + { + $this->roles = $roles; + } + + /** + * @param ?CustomerReference $customer */ - public function setCustomer(?Reference $customer): void + public function setCustomer(?CustomerReference $customer): void { $this->customer = $customer; } diff --git a/lib/commercetools-history/src/Models/Common/AssociateRoleAssignment.php b/lib/commercetools-history/src/Models/Common/AssociateRoleAssignment.php index 383dfc475aa..120521812d8 100644 --- a/lib/commercetools-history/src/Models/Common/AssociateRoleAssignment.php +++ b/lib/commercetools-history/src/Models/Common/AssociateRoleAssignment.php @@ -18,13 +18,15 @@ interface AssociateRoleAssignment extends JsonObject public const FIELD_INHERITANCE = 'inheritance'; /** + *

                                                                                                                            Role the Associate holds within a Business Unit.

                                                                                                                            + * - * @return null|KeyReference + * @return null|AssociateRoleKeyReference */ public function getAssociateRole(); /** - *

                                                                                                                            Determines whether an AssociateRoleAssignment can be inherited by child Business Units.

                                                                                                                            + *

                                                                                                                            Determines whether the AssociateRoleAssignment can be inherited by child Business Units.

                                                                                                                            * * @return null|string @@ -32,9 +34,9 @@ public function getAssociateRole(); public function getInheritance(); /** - * @param ?KeyReference $associateRole + * @param ?AssociateRoleKeyReference $associateRole */ - public function setAssociateRole(?KeyReference $associateRole): void; + public function setAssociateRole(?AssociateRoleKeyReference $associateRole): void; /** * @param ?string $inheritance diff --git a/lib/commercetools-history/src/Models/Common/AssociateRoleAssignmentBuilder.php b/lib/commercetools-history/src/Models/Common/AssociateRoleAssignmentBuilder.php index 97ff0848b58..ff8f32ee760 100644 --- a/lib/commercetools-history/src/Models/Common/AssociateRoleAssignmentBuilder.php +++ b/lib/commercetools-history/src/Models/Common/AssociateRoleAssignmentBuilder.php @@ -22,7 +22,7 @@ final class AssociateRoleAssignmentBuilder implements Builder { /** - * @var null|KeyReference|KeyReferenceBuilder + * @var null|AssociateRoleKeyReference|AssociateRoleKeyReferenceBuilder */ private $associateRole; @@ -33,16 +33,18 @@ final class AssociateRoleAssignmentBuilder implements Builder private $inheritance; /** + *

                                                                                                                            Role the Associate holds within a Business Unit.

                                                                                                                            + * - * @return null|KeyReference + * @return null|AssociateRoleKeyReference */ public function getAssociateRole() { - return $this->associateRole instanceof KeyReferenceBuilder ? $this->associateRole->build() : $this->associateRole; + return $this->associateRole instanceof AssociateRoleKeyReferenceBuilder ? $this->associateRole->build() : $this->associateRole; } /** - *

                                                                                                                            Determines whether an AssociateRoleAssignment can be inherited by child Business Units.

                                                                                                                            + *

                                                                                                                            Determines whether the AssociateRoleAssignment can be inherited by child Business Units.

                                                                                                                            * * @return null|string @@ -53,10 +55,10 @@ public function getInheritance() } /** - * @param ?KeyReference $associateRole + * @param ?AssociateRoleKeyReference $associateRole * @return $this */ - public function withAssociateRole(?KeyReference $associateRole) + public function withAssociateRole(?AssociateRoleKeyReference $associateRole) { $this->associateRole = $associateRole; @@ -78,7 +80,7 @@ public function withInheritance(?string $inheritance) * @deprecated use withAssociateRole() instead * @return $this */ - public function withAssociateRoleBuilder(?KeyReferenceBuilder $associateRole) + public function withAssociateRoleBuilder(?AssociateRoleKeyReferenceBuilder $associateRole) { $this->associateRole = $associateRole; @@ -88,7 +90,7 @@ public function withAssociateRoleBuilder(?KeyReferenceBuilder $associateRole) public function build(): AssociateRoleAssignment { return new AssociateRoleAssignmentModel( - $this->associateRole instanceof KeyReferenceBuilder ? $this->associateRole->build() : $this->associateRole, + $this->associateRole instanceof AssociateRoleKeyReferenceBuilder ? $this->associateRole->build() : $this->associateRole, $this->inheritance ); } diff --git a/lib/commercetools-history/src/Models/Common/AssociateRoleAssignmentModel.php b/lib/commercetools-history/src/Models/Common/AssociateRoleAssignmentModel.php index 4ac0b46bfa8..d8bd87a35c8 100644 --- a/lib/commercetools-history/src/Models/Common/AssociateRoleAssignmentModel.php +++ b/lib/commercetools-history/src/Models/Common/AssociateRoleAssignmentModel.php @@ -23,7 +23,7 @@ final class AssociateRoleAssignmentModel extends JsonObjectModel implements Asso /** * - * @var ?KeyReference + * @var ?AssociateRoleKeyReference */ protected $associateRole; @@ -38,7 +38,7 @@ final class AssociateRoleAssignmentModel extends JsonObjectModel implements Asso * @psalm-suppress MissingParamType */ public function __construct( - ?KeyReference $associateRole = null, + ?AssociateRoleKeyReference $associateRole = null, ?string $inheritance = null ) { $this->associateRole = $associateRole; @@ -47,8 +47,10 @@ public function __construct( } /** + *

                                                                                                                            Role the Associate holds within a Business Unit.

                                                                                                                            * - * @return null|KeyReference + * + * @return null|AssociateRoleKeyReference */ public function getAssociateRole() { @@ -59,14 +61,14 @@ public function getAssociateRole() return null; } - $this->associateRole = KeyReferenceModel::of($data); + $this->associateRole = AssociateRoleKeyReferenceModel::of($data); } return $this->associateRole; } /** - *

                                                                                                                            Determines whether an AssociateRoleAssignment can be inherited by child Business Units.

                                                                                                                            + *

                                                                                                                            Determines whether the AssociateRoleAssignment can be inherited by child Business Units.

                                                                                                                            * * * @return null|string @@ -87,9 +89,9 @@ public function getInheritance() /** - * @param ?KeyReference $associateRole + * @param ?AssociateRoleKeyReference $associateRole */ - public function setAssociateRole(?KeyReference $associateRole): void + public function setAssociateRole(?AssociateRoleKeyReference $associateRole): void { $this->associateRole = $associateRole; } diff --git a/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReference.php b/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReference.php new file mode 100644 index 00000000000..35b34169c29 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReference.php @@ -0,0 +1,30 @@ +Unique and immutable key of the referenced AssociateRole.

                                                                                                                            + * + + * @return null|string + */ + public function getKey(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; +} diff --git a/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReferenceBuilder.php new file mode 100644 index 00000000000..cf1cd33ad6b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class AssociateRoleKeyReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + *

                                                                                                                            Unique and immutable key of the referenced AssociateRole.

                                                                                                                            + * + + * @return null|string + */ + public function getKey() + { + return $this->key; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + + public function build(): AssociateRoleKeyReference + { + return new AssociateRoleKeyReferenceModel( + $this->key + ); + } + + public static function of(): AssociateRoleKeyReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReferenceCollection.php b/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReferenceCollection.php new file mode 100644 index 00000000000..b969b6c1512 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method AssociateRoleKeyReference current() + * @method AssociateRoleKeyReference end() + * @method AssociateRoleKeyReference at($offset) + */ +class AssociateRoleKeyReferenceCollection extends KeyReferenceCollection +{ + /** + * @psalm-assert AssociateRoleKeyReference $value + * @psalm-param AssociateRoleKeyReference|stdClass $value + * @throws InvalidArgumentException + * + * @return AssociateRoleKeyReferenceCollection + */ + public function add($value) + { + if (!$value instanceof AssociateRoleKeyReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?AssociateRoleKeyReference + */ + protected function mapper() + { + return function (?int $index): ?AssociateRoleKeyReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var AssociateRoleKeyReference $data */ + $data = AssociateRoleKeyReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReferenceModel.php b/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReferenceModel.php new file mode 100644 index 00000000000..5eb18812387 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/AssociateRoleKeyReferenceModel.php @@ -0,0 +1,99 @@ +key = $key; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique and immutable key of the referenced AssociateRole.

                                                                                                                            + * + * + * @return null|string + */ + public function getKey() + { + if (is_null($this->key)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_KEY); + if (is_null($data)) { + return null; + } + $this->key = (string) $data; + } + + return $this->key; + } + + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/Attribute.php b/lib/commercetools-history/src/Models/Common/Attribute.php new file mode 100644 index 00000000000..e0a189833dd --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/Attribute.php @@ -0,0 +1,55 @@ +Name of the Attribute.

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

                                                                                                                            The AttributeType determines the format of the Attribute value to be provided:

                                                                                                                            + * + * + + * @return null|mixed + */ + public function getValue(); + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param mixed $value + */ + public function setValue( $value): void; +} diff --git a/lib/commercetools-history/src/Models/Common/AttributeBuilder.php b/lib/commercetools-history/src/Models/Common/AttributeBuilder.php new file mode 100644 index 00000000000..97555462ced --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/AttributeBuilder.php @@ -0,0 +1,102 @@ + + */ +final class AttributeBuilder implements Builder +{ + /** + + * @var ?string + */ + private $name; + + /** + + * @var null|mixed|mixed + */ + private $value; + + /** + *

                                                                                                                            Name of the Attribute.

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

                                                                                                                            The AttributeType determines the format of the Attribute value to be provided:

                                                                                                                            + * + * + + * @return null|mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param mixed $value + * @return $this + */ + public function withValue( $value) + { + $this->value = $value; + + return $this; + } + + + public function build(): Attribute + { + return new AttributeModel( + $this->name, + $this->value + ); + } + + public static function of(): AttributeBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/AttributeCollection.php b/lib/commercetools-history/src/Models/Common/AttributeCollection.php new file mode 100644 index 00000000000..f418efafee4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/AttributeCollection.php @@ -0,0 +1,56 @@ + + * @method Attribute current() + * @method Attribute end() + * @method Attribute at($offset) + */ +class AttributeCollection extends MapperSequence +{ + /** + * @psalm-assert Attribute $value + * @psalm-param Attribute|stdClass $value + * @throws InvalidArgumentException + * + * @return AttributeCollection + */ + public function add($value) + { + if (!$value instanceof Attribute) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?Attribute + */ + protected function mapper() + { + return function (?int $index): ?Attribute { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var Attribute $data */ + $data = AttributeModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/AttributeDefinition.php b/lib/commercetools-history/src/Models/Common/AttributeDefinition.php index f8fa3c3605e..f57d8f42d02 100644 --- a/lib/commercetools-history/src/Models/Common/AttributeDefinition.php +++ b/lib/commercetools-history/src/Models/Common/AttributeDefinition.php @@ -18,19 +18,22 @@ interface AttributeDefinition extends JsonObject public const FIELD_NAME = 'name'; public const FIELD_LABEL = 'label'; public const FIELD_IS_REQUIRED = 'isRequired'; + public const FIELD_LEVEL = 'level'; public const FIELD_ATTRIBUTE_CONSTRAINT = 'attributeConstraint'; public const FIELD_INPUT_TIP = 'inputTip'; public const FIELD_INPUT_HINT = 'inputHint'; public const FIELD_IS_SEARCHABLE = 'isSearchable'; /** + *

                                                                                                                            Describes the Type of the Attribute.

                                                                                                                            + * * @return null|AttributeType */ public function getType(); /** - *

                                                                                                                            The unique name of the attribute used in the API. The name must be between two and 256 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (_) and the hyphen-minus (-). When using the same name for an attribute in two or more product types all fields of the AttributeDefinition of this attribute need to be the same across the product types, otherwise an AttributeDefinitionAlreadyExists error code will be returned. An exception to this are the values of an enum or lenum type and sets thereof.

                                                                                                                            + *

                                                                                                                            User-defined name of the Attribute that is unique within the Project.

                                                                                                                            * * @return null|string @@ -38,13 +41,15 @@ public function getType(); public function getName(); /** + *

                                                                                                                            Human-readable label for the Attribute.

                                                                                                                            + * * @return null|LocalizedString */ public function getLabel(); /** - *

                                                                                                                            Whether the attribute is required to have a value.

                                                                                                                            + *

                                                                                                                            If true, the Attribute must have a value on a ProductVariant.

                                                                                                                            * * @return null|bool @@ -52,25 +57,44 @@ public function getLabel(); public function getIsRequired(); /** + *

                                                                                                                            Specifies whether the Attribute is defined at the Product or Variant level.

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

                                                                                                                            Specifies how Attributes are validated across all variants of a Product.

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

                                                                                                                            Provides additional Attribute information to aid content managers configure Product details.

                                                                                                                            + * * @return null|LocalizedString */ public function getInputTip(); /** + *

                                                                                                                            Provides a visual representation directive for values of this Attribute (only relevant for AttributeTextType and AttributeLocalizableTextType).

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

                                                                                                                            Whether the attribute's values should generally be enabled in product search. This determines whether the value is stored in products for matching terms in the context of full-text search queries and can be used in facets & filters as part of product search queries. The exact features that are enabled/disabled with this flag depend on the concrete attribute type and are described there. The max size of a searchable field is restricted to 10922 characters. This constraint is enforced at both product creation and product update. If the length of the input exceeds the maximum size an InvalidField error is returned.

                                                                                                                            + *

                                                                                                                            If true, the Attribute's values are available in the Product Search or the Product Projection Search API for use in full-text search queries, filters, and facets. + * However, if an Attribute's level is set as Product, then Product Projection Search does not support the Attribute.

                                                                                                                            + *

                                                                                                                            The exact features that are available with this flag depend on the specific AttributeType. + * The maximum size of a searchable field is restricted by the Field content size limit. + * This constraint is enforced at both Product creation and Product update. + * If the length of the input exceeds the maximum size, an InvalidField error is returned.

                                                                                                                            * * @return null|bool @@ -97,6 +121,11 @@ public function setLabel(?LocalizedString $label): void; */ public function setIsRequired(?bool $isRequired): void; + /** + * @param ?string $level + */ + public function setLevel(?string $level): void; + /** * @param ?string $attributeConstraint */ diff --git a/lib/commercetools-history/src/Models/Common/AttributeDefinitionBuilder.php b/lib/commercetools-history/src/Models/Common/AttributeDefinitionBuilder.php index a1f99900cab..08643fa68b3 100644 --- a/lib/commercetools-history/src/Models/Common/AttributeDefinitionBuilder.php +++ b/lib/commercetools-history/src/Models/Common/AttributeDefinitionBuilder.php @@ -44,6 +44,12 @@ final class AttributeDefinitionBuilder implements Builder */ private $isRequired; + /** + + * @var ?string + */ + private $level; + /** * @var ?string @@ -69,6 +75,8 @@ final class AttributeDefinitionBuilder implements Builder private $isSearchable; /** + *

                                                                                                                            Describes the Type of the Attribute.

                                                                                                                            + * * @return null|AttributeType */ @@ -78,7 +86,7 @@ public function getType() } /** - *

                                                                                                                            The unique name of the attribute used in the API. The name must be between two and 256 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (_) and the hyphen-minus (-). When using the same name for an attribute in two or more product types all fields of the AttributeDefinition of this attribute need to be the same across the product types, otherwise an AttributeDefinitionAlreadyExists error code will be returned. An exception to this are the values of an enum or lenum type and sets thereof.

                                                                                                                            + *

                                                                                                                            User-defined name of the Attribute that is unique within the Project.

                                                                                                                            * * @return null|string @@ -89,6 +97,8 @@ public function getName() } /** + *

                                                                                                                            Human-readable label for the Attribute.

                                                                                                                            + * * @return null|LocalizedString */ @@ -98,7 +108,7 @@ public function getLabel() } /** - *

                                                                                                                            Whether the attribute is required to have a value.

                                                                                                                            + *

                                                                                                                            If true, the Attribute must have a value on a ProductVariant.

                                                                                                                            * * @return null|bool @@ -109,6 +119,19 @@ public function getIsRequired() } /** + *

                                                                                                                            Specifies whether the Attribute is defined at the Product or Variant level.

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

                                                                                                                            Specifies how Attributes are validated across all variants of a Product.

                                                                                                                            + * * @return null|string */ @@ -118,6 +141,8 @@ public function getAttributeConstraint() } /** + *

                                                                                                                            Provides additional Attribute information to aid content managers configure Product details.

                                                                                                                            + * * @return null|LocalizedString */ @@ -127,6 +152,8 @@ public function getInputTip() } /** + *

                                                                                                                            Provides a visual representation directive for values of this Attribute (only relevant for AttributeTextType and AttributeLocalizableTextType).

                                                                                                                            + * * @return null|string */ @@ -136,7 +163,12 @@ public function getInputHint() } /** - *

                                                                                                                            Whether the attribute's values should generally be enabled in product search. This determines whether the value is stored in products for matching terms in the context of full-text search queries and can be used in facets & filters as part of product search queries. The exact features that are enabled/disabled with this flag depend on the concrete attribute type and are described there. The max size of a searchable field is restricted to 10922 characters. This constraint is enforced at both product creation and product update. If the length of the input exceeds the maximum size an InvalidField error is returned.

                                                                                                                            + *

                                                                                                                            If true, the Attribute's values are available in the Product Search or the Product Projection Search API for use in full-text search queries, filters, and facets. + * However, if an Attribute's level is set as Product, then Product Projection Search does not support the Attribute.

                                                                                                                            + *

                                                                                                                            The exact features that are available with this flag depend on the specific AttributeType. + * The maximum size of a searchable field is restricted by the Field content size limit. + * This constraint is enforced at both Product creation and Product update. + * If the length of the input exceeds the maximum size, an InvalidField error is returned.

                                                                                                                            * * @return null|bool @@ -190,6 +222,17 @@ public function withIsRequired(?bool $isRequired) return $this; } + /** + * @param ?string $level + * @return $this + */ + public function withLevel(?string $level) + { + $this->level = $level; + + return $this; + } + /** * @param ?string $attributeConstraint * @return $this @@ -274,6 +317,7 @@ public function build(): AttributeDefinition $this->name, $this->label instanceof LocalizedStringBuilder ? $this->label->build() : $this->label, $this->isRequired, + $this->level, $this->attributeConstraint, $this->inputTip instanceof LocalizedStringBuilder ? $this->inputTip->build() : $this->inputTip, $this->inputHint, diff --git a/lib/commercetools-history/src/Models/Common/AttributeDefinitionModel.php b/lib/commercetools-history/src/Models/Common/AttributeDefinitionModel.php index 449d45fb27a..ccbde041745 100644 --- a/lib/commercetools-history/src/Models/Common/AttributeDefinitionModel.php +++ b/lib/commercetools-history/src/Models/Common/AttributeDefinitionModel.php @@ -45,6 +45,12 @@ final class AttributeDefinitionModel extends JsonObjectModel implements Attribut */ protected $isRequired; + /** + * + * @var ?string + */ + protected $level; + /** * * @var ?string @@ -78,6 +84,7 @@ public function __construct( ?string $name = null, ?LocalizedString $label = null, ?bool $isRequired = null, + ?string $level = null, ?string $attributeConstraint = null, ?LocalizedString $inputTip = null, ?string $inputHint = null, @@ -87,6 +94,7 @@ public function __construct( $this->name = $name; $this->label = $label; $this->isRequired = $isRequired; + $this->level = $level; $this->attributeConstraint = $attributeConstraint; $this->inputTip = $inputTip; $this->inputHint = $inputHint; @@ -95,6 +103,8 @@ public function __construct( } /** + *

                                                                                                                            Describes the Type of the Attribute.

                                                                                                                            + * * * @return null|AttributeType */ @@ -114,7 +124,7 @@ public function getType() } /** - *

                                                                                                                            The unique name of the attribute used in the API. The name must be between two and 256 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (_) and the hyphen-minus (-). When using the same name for an attribute in two or more product types all fields of the AttributeDefinition of this attribute need to be the same across the product types, otherwise an AttributeDefinitionAlreadyExists error code will be returned. An exception to this are the values of an enum or lenum type and sets thereof.

                                                                                                                            + *

                                                                                                                            User-defined name of the Attribute that is unique within the Project.

                                                                                                                            * * * @return null|string @@ -134,6 +144,8 @@ public function getName() } /** + *

                                                                                                                            Human-readable label for the Attribute.

                                                                                                                            + * * * @return null|LocalizedString */ @@ -153,7 +165,7 @@ public function getLabel() } /** - *

                                                                                                                            Whether the attribute is required to have a value.

                                                                                                                            + *

                                                                                                                            If true, the Attribute must have a value on a ProductVariant.

                                                                                                                            * * * @return null|bool @@ -173,6 +185,28 @@ public function getIsRequired() } /** + *

                                                                                                                            Specifies whether the Attribute is defined at the Product or Variant level.

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

                                                                                                                            Specifies how Attributes are validated across all variants of a Product.

                                                                                                                            + * * * @return null|string */ @@ -191,6 +225,8 @@ public function getAttributeConstraint() } /** + *

                                                                                                                            Provides additional Attribute information to aid content managers configure Product details.

                                                                                                                            + * * * @return null|LocalizedString */ @@ -210,6 +246,8 @@ public function getInputTip() } /** + *

                                                                                                                            Provides a visual representation directive for values of this Attribute (only relevant for AttributeTextType and AttributeLocalizableTextType).

                                                                                                                            + * * * @return null|string */ @@ -228,7 +266,12 @@ public function getInputHint() } /** - *

                                                                                                                            Whether the attribute's values should generally be enabled in product search. This determines whether the value is stored in products for matching terms in the context of full-text search queries and can be used in facets & filters as part of product search queries. The exact features that are enabled/disabled with this flag depend on the concrete attribute type and are described there. The max size of a searchable field is restricted to 10922 characters. This constraint is enforced at both product creation and product update. If the length of the input exceeds the maximum size an InvalidField error is returned.

                                                                                                                            + *

                                                                                                                            If true, the Attribute's values are available in the Product Search or the Product Projection Search API for use in full-text search queries, filters, and facets. + * However, if an Attribute's level is set as Product, then Product Projection Search does not support the Attribute.

                                                                                                                            + *

                                                                                                                            The exact features that are available with this flag depend on the specific AttributeType. + * The maximum size of a searchable field is restricted by the Field content size limit. + * This constraint is enforced at both Product creation and Product update. + * If the length of the input exceeds the maximum size, an InvalidField error is returned.

                                                                                                                            * * * @return null|bool @@ -280,6 +323,14 @@ public function setIsRequired(?bool $isRequired): void $this->isRequired = $isRequired; } + /** + * @param ?string $level + */ + public function setLevel(?string $level): void + { + $this->level = $level; + } + /** * @param ?string $attributeConstraint */ diff --git a/lib/commercetools-history/src/Models/Common/AttributeModel.php b/lib/commercetools-history/src/Models/Common/AttributeModel.php new file mode 100644 index 00000000000..e085a64878f --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/AttributeModel.php @@ -0,0 +1,118 @@ +name = $name; + $this->value = $value; + + } + + /** + *

                                                                                                                            Name of the Attribute.

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

                                                                                                                            The AttributeType determines the format of the Attribute value to be provided:

                                                                                                                            + * + * + * + * @return null|mixed + */ + public function getValue() + { + if (is_null($this->value)) { + /** @psalm-var mixed $data */ + $data = $this->raw(self::FIELD_VALUE); + if (is_null($data)) { + return null; + } + $this->value = $data; + } + + return $this->value; + } + + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param mixed $value + */ + public function setValue( $value): void + { + $this->value = $value; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/BaseAddress.php b/lib/commercetools-history/src/Models/Common/BaseAddress.php new file mode 100644 index 00000000000..7ab17b0a611 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BaseAddress.php @@ -0,0 +1,369 @@ +Unique identifier of the Address.

                                                                                                                            + *

                                                                                                                            It is not recommended to set it manually since the API overwrites this ID when creating an Address for a Customer. + * Use key instead and omit this field from the request to let the API generate the ID for the Address.

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

                                                                                                                            User-defined identifier of the Address that must be unique when multiple addresses are referenced in BusinessUnits, Customers, and itemShippingAddresses (LineItem-specific addresses) of a Cart, Order, QuoteRequest, or Quote.

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

                                                                                                                            Name of the country.

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

                                                                                                                            Title of the contact, for example 'Dr.'

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

                                                                                                                            Salutation of the contact, for example 'Mr.' or 'Ms.'

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

                                                                                                                            Given name (first name) of the contact.

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

                                                                                                                            Family name (last name) of the contact.

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

                                                                                                                            Name of the street.

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

                                                                                                                            Street number.

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

                                                                                                                            Further information on the street address.

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

                                                                                                                            Postal code.

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

                                                                                                                            Name of the city.

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

                                                                                                                            Name of the region.

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

                                                                                                                            Name of the state, for example, Colorado.

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

                                                                                                                            Name of the company.

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

                                                                                                                            Name of the department.

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

                                                                                                                            Number or name of the building.

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

                                                                                                                            Number or name of the apartment.

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

                                                                                                                            Post office box number.

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

                                                                                                                            Phone number of the contact.

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

                                                                                                                            Mobile phone number of the contact.

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

                                                                                                                            Email address of the contact.

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

                                                                                                                            Fax number of the contact.

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

                                                                                                                            Further information on the Address.

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

                                                                                                                            ID for the contact used in an external system.

                                                                                                                            + * + + * @return null|string + */ + public function getExternalId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?string $country + */ + public function setCountry(?string $country): void; + + /** + * @param ?string $title + */ + public function setTitle(?string $title): void; + + /** + * @param ?string $salutation + */ + public function setSalutation(?string $salutation): void; + + /** + * @param ?string $firstName + */ + public function setFirstName(?string $firstName): void; + + /** + * @param ?string $lastName + */ + public function setLastName(?string $lastName): void; + + /** + * @param ?string $streetName + */ + public function setStreetName(?string $streetName): void; + + /** + * @param ?string $streetNumber + */ + public function setStreetNumber(?string $streetNumber): void; + + /** + * @param ?string $additionalStreetInfo + */ + public function setAdditionalStreetInfo(?string $additionalStreetInfo): void; + + /** + * @param ?string $postalCode + */ + public function setPostalCode(?string $postalCode): void; + + /** + * @param ?string $city + */ + public function setCity(?string $city): void; + + /** + * @param ?string $region + */ + public function setRegion(?string $region): void; + + /** + * @param ?string $state + */ + public function setState(?string $state): void; + + /** + * @param ?string $company + */ + public function setCompany(?string $company): void; + + /** + * @param ?string $department + */ + public function setDepartment(?string $department): void; + + /** + * @param ?string $building + */ + public function setBuilding(?string $building): void; + + /** + * @param ?string $apartment + */ + public function setApartment(?string $apartment): void; + + /** + * @param ?string $pOBox + */ + public function setPOBox(?string $pOBox): void; + + /** + * @param ?string $phone + */ + public function setPhone(?string $phone): void; + + /** + * @param ?string $mobile + */ + public function setMobile(?string $mobile): void; + + /** + * @param ?string $email + */ + public function setEmail(?string $email): void; + + /** + * @param ?string $fax + */ + public function setFax(?string $fax): void; + + /** + * @param ?string $additionalAddressInfo + */ + public function setAdditionalAddressInfo(?string $additionalAddressInfo): void; + + /** + * @param ?string $externalId + */ + public function setExternalId(?string $externalId): void; +} diff --git a/lib/commercetools-history/src/Models/Common/BaseAddressBuilder.php b/lib/commercetools-history/src/Models/Common/BaseAddressBuilder.php new file mode 100644 index 00000000000..f907911ca02 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BaseAddressBuilder.php @@ -0,0 +1,761 @@ + + */ +final class BaseAddressBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $key; + + /** + + * @var ?string + */ + private $country; + + /** + + * @var ?string + */ + private $title; + + /** + + * @var ?string + */ + private $salutation; + + /** + + * @var ?string + */ + private $firstName; + + /** + + * @var ?string + */ + private $lastName; + + /** + + * @var ?string + */ + private $streetName; + + /** + + * @var ?string + */ + private $streetNumber; + + /** + + * @var ?string + */ + private $additionalStreetInfo; + + /** + + * @var ?string + */ + private $postalCode; + + /** + + * @var ?string + */ + private $city; + + /** + + * @var ?string + */ + private $region; + + /** + + * @var ?string + */ + private $state; + + /** + + * @var ?string + */ + private $company; + + /** + + * @var ?string + */ + private $department; + + /** + + * @var ?string + */ + private $building; + + /** + + * @var ?string + */ + private $apartment; + + /** + + * @var ?string + */ + private $pOBox; + + /** + + * @var ?string + */ + private $phone; + + /** + + * @var ?string + */ + private $mobile; + + /** + + * @var ?string + */ + private $email; + + /** + + * @var ?string + */ + private $fax; + + /** + + * @var ?string + */ + private $additionalAddressInfo; + + /** + + * @var ?string + */ + private $externalId; + + /** + *

                                                                                                                            Unique identifier of the Address.

                                                                                                                            + *

                                                                                                                            It is not recommended to set it manually since the API overwrites this ID when creating an Address for a Customer. + * Use key instead and omit this field from the request to let the API generate the ID for the Address.

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

                                                                                                                            User-defined identifier of the Address that must be unique when multiple addresses are referenced in BusinessUnits, Customers, and itemShippingAddresses (LineItem-specific addresses) of a Cart, Order, QuoteRequest, or Quote.

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

                                                                                                                            Name of the country.

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

                                                                                                                            Title of the contact, for example 'Dr.'

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

                                                                                                                            Salutation of the contact, for example 'Mr.' or 'Ms.'

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

                                                                                                                            Given name (first name) of the contact.

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

                                                                                                                            Family name (last name) of the contact.

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

                                                                                                                            Name of the street.

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

                                                                                                                            Street number.

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

                                                                                                                            Further information on the street address.

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

                                                                                                                            Postal code.

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

                                                                                                                            Name of the city.

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

                                                                                                                            Name of the region.

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

                                                                                                                            Name of the state, for example, Colorado.

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

                                                                                                                            Name of the company.

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

                                                                                                                            Name of the department.

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

                                                                                                                            Number or name of the building.

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

                                                                                                                            Number or name of the apartment.

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

                                                                                                                            Post office box number.

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

                                                                                                                            Phone number of the contact.

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

                                                                                                                            Mobile phone number of the contact.

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

                                                                                                                            Email address of the contact.

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

                                                                                                                            Fax number of the contact.

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

                                                                                                                            Further information on the Address.

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

                                                                                                                            ID for the contact used in an external system.

                                                                                                                            + * + + * @return null|string + */ + public function getExternalId() + { + return $this->externalId; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?string $country + * @return $this + */ + public function withCountry(?string $country) + { + $this->country = $country; + + return $this; + } + + /** + * @param ?string $title + * @return $this + */ + public function withTitle(?string $title) + { + $this->title = $title; + + return $this; + } + + /** + * @param ?string $salutation + * @return $this + */ + public function withSalutation(?string $salutation) + { + $this->salutation = $salutation; + + return $this; + } + + /** + * @param ?string $firstName + * @return $this + */ + public function withFirstName(?string $firstName) + { + $this->firstName = $firstName; + + return $this; + } + + /** + * @param ?string $lastName + * @return $this + */ + public function withLastName(?string $lastName) + { + $this->lastName = $lastName; + + return $this; + } + + /** + * @param ?string $streetName + * @return $this + */ + public function withStreetName(?string $streetName) + { + $this->streetName = $streetName; + + return $this; + } + + /** + * @param ?string $streetNumber + * @return $this + */ + public function withStreetNumber(?string $streetNumber) + { + $this->streetNumber = $streetNumber; + + return $this; + } + + /** + * @param ?string $additionalStreetInfo + * @return $this + */ + public function withAdditionalStreetInfo(?string $additionalStreetInfo) + { + $this->additionalStreetInfo = $additionalStreetInfo; + + return $this; + } + + /** + * @param ?string $postalCode + * @return $this + */ + public function withPostalCode(?string $postalCode) + { + $this->postalCode = $postalCode; + + return $this; + } + + /** + * @param ?string $city + * @return $this + */ + public function withCity(?string $city) + { + $this->city = $city; + + return $this; + } + + /** + * @param ?string $region + * @return $this + */ + public function withRegion(?string $region) + { + $this->region = $region; + + return $this; + } + + /** + * @param ?string $state + * @return $this + */ + public function withState(?string $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?string $company + * @return $this + */ + public function withCompany(?string $company) + { + $this->company = $company; + + return $this; + } + + /** + * @param ?string $department + * @return $this + */ + public function withDepartment(?string $department) + { + $this->department = $department; + + return $this; + } + + /** + * @param ?string $building + * @return $this + */ + public function withBuilding(?string $building) + { + $this->building = $building; + + return $this; + } + + /** + * @param ?string $apartment + * @return $this + */ + public function withApartment(?string $apartment) + { + $this->apartment = $apartment; + + return $this; + } + + /** + * @param ?string $pOBox + * @return $this + */ + public function withPOBox(?string $pOBox) + { + $this->pOBox = $pOBox; + + return $this; + } + + /** + * @param ?string $phone + * @return $this + */ + public function withPhone(?string $phone) + { + $this->phone = $phone; + + return $this; + } + + /** + * @param ?string $mobile + * @return $this + */ + public function withMobile(?string $mobile) + { + $this->mobile = $mobile; + + return $this; + } + + /** + * @param ?string $email + * @return $this + */ + public function withEmail(?string $email) + { + $this->email = $email; + + return $this; + } + + /** + * @param ?string $fax + * @return $this + */ + public function withFax(?string $fax) + { + $this->fax = $fax; + + return $this; + } + + /** + * @param ?string $additionalAddressInfo + * @return $this + */ + public function withAdditionalAddressInfo(?string $additionalAddressInfo) + { + $this->additionalAddressInfo = $additionalAddressInfo; + + return $this; + } + + /** + * @param ?string $externalId + * @return $this + */ + public function withExternalId(?string $externalId) + { + $this->externalId = $externalId; + + return $this; + } + + + public function build(): BaseAddress + { + return new BaseAddressModel( + $this->id, + $this->key, + $this->country, + $this->title, + $this->salutation, + $this->firstName, + $this->lastName, + $this->streetName, + $this->streetNumber, + $this->additionalStreetInfo, + $this->postalCode, + $this->city, + $this->region, + $this->state, + $this->company, + $this->department, + $this->building, + $this->apartment, + $this->pOBox, + $this->phone, + $this->mobile, + $this->email, + $this->fax, + $this->additionalAddressInfo, + $this->externalId + ); + } + + public static function of(): BaseAddressBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/BaseAddressCollection.php b/lib/commercetools-history/src/Models/Common/BaseAddressCollection.php new file mode 100644 index 00000000000..f93901a7779 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BaseAddressCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method BaseAddress current() + * @method BaseAddress end() + * @method BaseAddress at($offset) + */ +class BaseAddressCollection extends MapperSequence +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return BaseAddressCollection + */ + public function add($value) + { + if (!$value instanceof BaseAddress) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?BaseAddress { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = BaseAddressModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/BaseAddressModel.php b/lib/commercetools-history/src/Models/Common/BaseAddressModel.php new file mode 100644 index 00000000000..c03885d7a9a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BaseAddressModel.php @@ -0,0 +1,938 @@ +id = $id; + $this->key = $key; + $this->country = $country; + $this->title = $title; + $this->salutation = $salutation; + $this->firstName = $firstName; + $this->lastName = $lastName; + $this->streetName = $streetName; + $this->streetNumber = $streetNumber; + $this->additionalStreetInfo = $additionalStreetInfo; + $this->postalCode = $postalCode; + $this->city = $city; + $this->region = $region; + $this->state = $state; + $this->company = $company; + $this->department = $department; + $this->building = $building; + $this->apartment = $apartment; + $this->pOBox = $pOBox; + $this->phone = $phone; + $this->mobile = $mobile; + $this->email = $email; + $this->fax = $fax; + $this->additionalAddressInfo = $additionalAddressInfo; + $this->externalId = $externalId; + + } + + /** + *

                                                                                                                            Unique identifier of the Address.

                                                                                                                            + *

                                                                                                                            It is not recommended to set it manually since the API overwrites this ID when creating an Address for a Customer. + * Use key instead and omit this field from the request to let the API generate the ID for the Address.

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

                                                                                                                            User-defined identifier of the Address that must be unique when multiple addresses are referenced in BusinessUnits, Customers, and itemShippingAddresses (LineItem-specific addresses) of a Cart, Order, QuoteRequest, or Quote.

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

                                                                                                                            Name of the country.

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

                                                                                                                            Title of the contact, for example 'Dr.'

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

                                                                                                                            Salutation of the contact, for example 'Mr.' or 'Ms.'

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

                                                                                                                            Given name (first name) of the contact.

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

                                                                                                                            Family name (last name) of the contact.

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

                                                                                                                            Name of the street.

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

                                                                                                                            Street number.

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

                                                                                                                            Further information on the street address.

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

                                                                                                                            Postal code.

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

                                                                                                                            Name of the city.

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

                                                                                                                            Name of the region.

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

                                                                                                                            Name of the state, for example, Colorado.

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

                                                                                                                            Name of the company.

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

                                                                                                                            Name of the department.

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

                                                                                                                            Number or name of the building.

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

                                                                                                                            Number or name of the apartment.

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

                                                                                                                            Post office box number.

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

                                                                                                                            Phone number of the contact.

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

                                                                                                                            Mobile phone number of the contact.

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

                                                                                                                            Email address of the contact.

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

                                                                                                                            Fax number of the contact.

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

                                                                                                                            Further information on the Address.

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

                                                                                                                            ID for the contact used in an external system.

                                                                                                                            + * + * + * @return null|string + */ + public function getExternalId() + { + if (is_null($this->externalId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_EXTERNAL_ID); + if (is_null($data)) { + return null; + } + $this->externalId = (string) $data; + } + + return $this->externalId; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?string $country + */ + public function setCountry(?string $country): void + { + $this->country = $country; + } + + /** + * @param ?string $title + */ + public function setTitle(?string $title): void + { + $this->title = $title; + } + + /** + * @param ?string $salutation + */ + public function setSalutation(?string $salutation): void + { + $this->salutation = $salutation; + } + + /** + * @param ?string $firstName + */ + public function setFirstName(?string $firstName): void + { + $this->firstName = $firstName; + } + + /** + * @param ?string $lastName + */ + public function setLastName(?string $lastName): void + { + $this->lastName = $lastName; + } + + /** + * @param ?string $streetName + */ + public function setStreetName(?string $streetName): void + { + $this->streetName = $streetName; + } + + /** + * @param ?string $streetNumber + */ + public function setStreetNumber(?string $streetNumber): void + { + $this->streetNumber = $streetNumber; + } + + /** + * @param ?string $additionalStreetInfo + */ + public function setAdditionalStreetInfo(?string $additionalStreetInfo): void + { + $this->additionalStreetInfo = $additionalStreetInfo; + } + + /** + * @param ?string $postalCode + */ + public function setPostalCode(?string $postalCode): void + { + $this->postalCode = $postalCode; + } + + /** + * @param ?string $city + */ + public function setCity(?string $city): void + { + $this->city = $city; + } + + /** + * @param ?string $region + */ + public function setRegion(?string $region): void + { + $this->region = $region; + } + + /** + * @param ?string $state + */ + public function setState(?string $state): void + { + $this->state = $state; + } + + /** + * @param ?string $company + */ + public function setCompany(?string $company): void + { + $this->company = $company; + } + + /** + * @param ?string $department + */ + public function setDepartment(?string $department): void + { + $this->department = $department; + } + + /** + * @param ?string $building + */ + public function setBuilding(?string $building): void + { + $this->building = $building; + } + + /** + * @param ?string $apartment + */ + public function setApartment(?string $apartment): void + { + $this->apartment = $apartment; + } + + /** + * @param ?string $pOBox + */ + public function setPOBox(?string $pOBox): void + { + $this->pOBox = $pOBox; + } + + /** + * @param ?string $phone + */ + public function setPhone(?string $phone): void + { + $this->phone = $phone; + } + + /** + * @param ?string $mobile + */ + public function setMobile(?string $mobile): void + { + $this->mobile = $mobile; + } + + /** + * @param ?string $email + */ + public function setEmail(?string $email): void + { + $this->email = $email; + } + + /** + * @param ?string $fax + */ + public function setFax(?string $fax): void + { + $this->fax = $fax; + } + + /** + * @param ?string $additionalAddressInfo + */ + public function setAdditionalAddressInfo(?string $additionalAddressInfo): void + { + $this->additionalAddressInfo = $additionalAddressInfo; + } + + /** + * @param ?string $externalId + */ + public function setExternalId(?string $externalId): void + { + $this->externalId = $externalId; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReference.php b/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReference.php new file mode 100644 index 00000000000..004a215df4f --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReference.php @@ -0,0 +1,30 @@ +Unique and immutable key of the referenced BusinessUnit.

                                                                                                                            + * + + * @return null|string + */ + public function getKey(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; +} diff --git a/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReferenceBuilder.php new file mode 100644 index 00000000000..17cd614907a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class BusinessUnitKeyReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + *

                                                                                                                            Unique and immutable key of the referenced BusinessUnit.

                                                                                                                            + * + + * @return null|string + */ + public function getKey() + { + return $this->key; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + + public function build(): BusinessUnitKeyReference + { + return new BusinessUnitKeyReferenceModel( + $this->key + ); + } + + public static function of(): BusinessUnitKeyReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReferenceCollection.php b/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReferenceCollection.php new file mode 100644 index 00000000000..6dabbc1c142 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method BusinessUnitKeyReference current() + * @method BusinessUnitKeyReference end() + * @method BusinessUnitKeyReference at($offset) + */ +class BusinessUnitKeyReferenceCollection extends KeyReferenceCollection +{ + /** + * @psalm-assert BusinessUnitKeyReference $value + * @psalm-param BusinessUnitKeyReference|stdClass $value + * @throws InvalidArgumentException + * + * @return BusinessUnitKeyReferenceCollection + */ + public function add($value) + { + if (!$value instanceof BusinessUnitKeyReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?BusinessUnitKeyReference + */ + protected function mapper() + { + return function (?int $index): ?BusinessUnitKeyReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var BusinessUnitKeyReference $data */ + $data = BusinessUnitKeyReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReferenceModel.php b/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReferenceModel.php new file mode 100644 index 00000000000..5a347f94944 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BusinessUnitKeyReferenceModel.php @@ -0,0 +1,99 @@ +key = $key; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique and immutable key of the referenced BusinessUnit.

                                                                                                                            + * + * + * @return null|string + */ + public function getKey() + { + if (is_null($this->key)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_KEY); + if (is_null($data)) { + return null; + } + $this->key = (string) $data; + } + + return $this->key; + } + + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifier.php b/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifier.php new file mode 100644 index 00000000000..0d3f4847183 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifier.php @@ -0,0 +1,43 @@ +Unique identifier of the referenced BusinessUnit. Required if key is absent.

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

                                                                                                                            Unique key of the referenced BusinessUnit. Required if id is absent.

                                                                                                                            + * + + * @return null|string + */ + public function getKey(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; +} diff --git a/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifierBuilder.php b/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifierBuilder.php new file mode 100644 index 00000000000..45e44c7b77c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifierBuilder.php @@ -0,0 +1,121 @@ + + */ +final class BusinessUnitResourceIdentifierBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $key; + + /** + + * @var ?string + */ + private $typeId; + + /** + *

                                                                                                                            Unique identifier of the referenced BusinessUnit. Required if key is absent.

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

                                                                                                                            Unique key of the referenced BusinessUnit. Required if id is absent.

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

                                                                                                                            Type of resource the value should reference. Supported resource type identifiers are:

                                                                                                                            + * + + * @return null|string + */ + public function getTypeId() + { + return $this->typeId; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?string $typeId + * @return $this + */ + public function withTypeId(?string $typeId) + { + $this->typeId = $typeId; + + return $this; + } + + + public function build(): BusinessUnitResourceIdentifier + { + return new BusinessUnitResourceIdentifierModel( + $this->id, + $this->key, + $this->typeId + ); + } + + public static function of(): BusinessUnitResourceIdentifierBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifierCollection.php b/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifierCollection.php new file mode 100644 index 00000000000..660605aa287 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifierCollection.php @@ -0,0 +1,56 @@ + + * @method BusinessUnitResourceIdentifier current() + * @method BusinessUnitResourceIdentifier end() + * @method BusinessUnitResourceIdentifier at($offset) + */ +class BusinessUnitResourceIdentifierCollection extends ResourceIdentifierCollection +{ + /** + * @psalm-assert BusinessUnitResourceIdentifier $value + * @psalm-param BusinessUnitResourceIdentifier|stdClass $value + * @throws InvalidArgumentException + * + * @return BusinessUnitResourceIdentifierCollection + */ + public function add($value) + { + if (!$value instanceof BusinessUnitResourceIdentifier) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?BusinessUnitResourceIdentifier + */ + protected function mapper() + { + return function (?int $index): ?BusinessUnitResourceIdentifier { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var BusinessUnitResourceIdentifier $data */ + $data = BusinessUnitResourceIdentifierModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifierModel.php b/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifierModel.php new file mode 100644 index 00000000000..48582b020e4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/BusinessUnitResourceIdentifierModel.php @@ -0,0 +1,144 @@ +id = $id; + $this->key = $key; + $this->typeId = $typeId; + + } + + /** + *

                                                                                                                            Unique identifier of the referenced BusinessUnit. Required if key is absent.

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

                                                                                                                            Unique key of the referenced BusinessUnit. Required if id is absent.

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

                                                                                                                            Type of resource the value should reference. Supported resource type identifiers are:

                                                                                                                            + * + * + * @return null|string + */ + public function getTypeId() + { + if (is_null($this->typeId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE_ID); + if (is_null($data)) { + return null; + } + $this->typeId = (string) $data; + } + + return $this->typeId; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?string $typeId + */ + public function setTypeId(?string $typeId): void + { + $this->typeId = $typeId; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountReference.php b/lib/commercetools-history/src/Models/Common/CartDiscountReference.php new file mode 100644 index 00000000000..1d0ba8dd171 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced CartDiscount.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/CartDiscountReferenceBuilder.php new file mode 100644 index 00000000000..0098fb9a871 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class CartDiscountReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced CartDiscount.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): CartDiscountReference + { + return new CartDiscountReferenceModel( + $this->id + ); + } + + public static function of(): CartDiscountReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountReferenceCollection.php b/lib/commercetools-history/src/Models/Common/CartDiscountReferenceCollection.php new file mode 100644 index 00000000000..010179d9189 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method CartDiscountReference current() + * @method CartDiscountReference end() + * @method CartDiscountReference at($offset) + */ +class CartDiscountReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert CartDiscountReference $value + * @psalm-param CartDiscountReference|stdClass $value + * @throws InvalidArgumentException + * + * @return CartDiscountReferenceCollection + */ + public function add($value) + { + if (!$value instanceof CartDiscountReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CartDiscountReference + */ + protected function mapper() + { + return function (?int $index): ?CartDiscountReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CartDiscountReference $data */ + $data = CartDiscountReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountReferenceModel.php b/lib/commercetools-history/src/Models/Common/CartDiscountReferenceModel.php new file mode 100644 index 00000000000..0ca194128d5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced CartDiscount.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountTarget.php b/lib/commercetools-history/src/Models/Common/CartDiscountTarget.php new file mode 100644 index 00000000000..c0ebf1397ec --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountTarget.php @@ -0,0 +1,29 @@ + + */ +final class CartDiscountTargetBuilder implements Builder +{ + /** + + * @var ?string + */ + private $type; + + /** + + * @return null|string + */ + public function getType() + { + return $this->type; + } + + /** + * @param ?string $type + * @return $this + */ + public function withType(?string $type) + { + $this->type = $type; + + return $this; + } + + + public function build(): CartDiscountTarget + { + return new CartDiscountTargetModel( + $this->type + ); + } + + public static function of(): CartDiscountTargetBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountTargetCollection.php b/lib/commercetools-history/src/Models/Common/CartDiscountTargetCollection.php new file mode 100644 index 00000000000..3e28c8018ba --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountTargetCollection.php @@ -0,0 +1,56 @@ + + * @method CartDiscountTarget current() + * @method CartDiscountTarget end() + * @method CartDiscountTarget at($offset) + */ +class CartDiscountTargetCollection extends MapperSequence +{ + /** + * @psalm-assert CartDiscountTarget $value + * @psalm-param CartDiscountTarget|stdClass $value + * @throws InvalidArgumentException + * + * @return CartDiscountTargetCollection + */ + public function add($value) + { + if (!$value instanceof CartDiscountTarget) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CartDiscountTarget + */ + protected function mapper() + { + return function (?int $index): ?CartDiscountTarget { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CartDiscountTarget $data */ + $data = CartDiscountTargetModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountTargetModel.php b/lib/commercetools-history/src/Models/Common/CartDiscountTargetModel.php new file mode 100644 index 00000000000..cc1347e5ab5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountTargetModel.php @@ -0,0 +1,70 @@ +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; + } + + + /** + * @param ?string $type + */ + public function setType(?string $type): void + { + $this->type = $type; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountValue.php b/lib/commercetools-history/src/Models/Common/CartDiscountValue.php new file mode 100644 index 00000000000..4ec4f021bea --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountValue.php @@ -0,0 +1,29 @@ + + */ +final class CartDiscountValueBuilder implements Builder +{ + /** + + * @var ?string + */ + private $type; + + /** + + * @return null|string + */ + public function getType() + { + return $this->type; + } + + /** + * @param ?string $type + * @return $this + */ + public function withType(?string $type) + { + $this->type = $type; + + return $this; + } + + + public function build(): CartDiscountValue + { + return new CartDiscountValueModel( + $this->type + ); + } + + public static function of(): CartDiscountValueBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountValueCollection.php b/lib/commercetools-history/src/Models/Common/CartDiscountValueCollection.php new file mode 100644 index 00000000000..6510c2ba742 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountValueCollection.php @@ -0,0 +1,56 @@ + + * @method CartDiscountValue current() + * @method CartDiscountValue end() + * @method CartDiscountValue at($offset) + */ +class CartDiscountValueCollection extends MapperSequence +{ + /** + * @psalm-assert CartDiscountValue $value + * @psalm-param CartDiscountValue|stdClass $value + * @throws InvalidArgumentException + * + * @return CartDiscountValueCollection + */ + public function add($value) + { + if (!$value instanceof CartDiscountValue) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CartDiscountValue + */ + protected function mapper() + { + return function (?int $index): ?CartDiscountValue { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CartDiscountValue $data */ + $data = CartDiscountValueModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CartDiscountValueModel.php b/lib/commercetools-history/src/Models/Common/CartDiscountValueModel.php new file mode 100644 index 00000000000..230532114e8 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CartDiscountValueModel.php @@ -0,0 +1,70 @@ +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; + } + + + /** + * @param ?string $type + */ + public function setType(?string $type): void + { + $this->type = $type; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CategoryOrderHints.php b/lib/commercetools-history/src/Models/Common/CategoryOrderHints.php index e66c7a12569..f80717b0a59 100644 --- a/lib/commercetools-history/src/Models/Common/CategoryOrderHints.php +++ b/lib/commercetools-history/src/Models/Common/CategoryOrderHints.php @@ -8,13 +8,8 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\JsonObject; -use Commercetools\Base\DateTimeImmutableCollection; +use Commercetools\Base\CMap; -interface CategoryOrderHints extends JsonObject +interface CategoryOrderHints extends CMap { - - public const FIELD_PATTERN0 = '/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/'; - - } diff --git a/lib/commercetools-history/src/Models/Common/CategoryOrderHintsBuilder.php b/lib/commercetools-history/src/Models/Common/CategoryOrderHintsBuilder.php index 64904eeff57..3c4f41dbd15 100644 --- a/lib/commercetools-history/src/Models/Common/CategoryOrderHintsBuilder.php +++ b/lib/commercetools-history/src/Models/Common/CategoryOrderHintsBuilder.php @@ -8,30 +8,39 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\Builder; -use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\Base\JsonObject; -use Commercetools\Base\JsonObjectModel; -use Commercetools\Base\MapperFactory; use stdClass; +use Commercetools\Base\MapperMap; +use Commercetools\Base\Builder; /** * @implements Builder + * @extends MapperMap */ -final class CategoryOrderHintsBuilder implements Builder +final class CategoryOrderHintsBuilder extends MapperMap implements Builder { - - - - - public function build(): CategoryOrderHints + /** + * @psalm-return callable(string):?CategoryOrderHints + */ + protected function mapper() { - return new CategoryOrderHintsModel( - ); + return + /** + * @psalm-return ?CategoryOrderHints + */ + function(string $key) { + $data = $this->get($key); + if ($data instanceof stdClass) { + $data = CategoryOrderHintsModel::of($data); + } + return $data; + }; } - public static function of(): CategoryOrderHintsBuilder + /** + * @return CategoryOrderHints + */ + public function build() { - return new self(); + return new CategoryOrderHintsModel($this->toArray()); } } diff --git a/lib/commercetools-history/src/Models/Common/CategoryOrderHintsModel.php b/lib/commercetools-history/src/Models/Common/CategoryOrderHintsModel.php index 928b73e6573..13154568298 100644 --- a/lib/commercetools-history/src/Models/Common/CategoryOrderHintsModel.php +++ b/lib/commercetools-history/src/Models/Common/CategoryOrderHintsModel.php @@ -8,48 +8,24 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\Base\JsonObject; -use Commercetools\Base\JsonObjectModel; -use Commercetools\Base\MapperFactory; -use stdClass; +use Commercetools\Base\MapperMap; /** * @internal */ -final class CategoryOrderHintsModel extends JsonObjectModel implements CategoryOrderHints +final class CategoryOrderHintsModel extends MapperMap implements CategoryOrderHints { - - - - /** - * @psalm-suppress MissingParamType + * @psalm-return callable(string):?mixed */ - public function __construct( - ) { - - } - - - - - /** - * @return mixed - */ - public function by(string $key) + protected function mapper() { - $data = $this->raw($key); - if (is_null($data)) { - return null; - } - if (preg_match(CategoryOrderHints::FIELD_PATTERN0, $key) === 1) { - /** @psalm-var scalar $data */ - return (string)$data; - } - - return $data; + return + /** + * @psalm-return ?mixed + */ + function(string $key) { + return $this->get($key); + }; } - - } diff --git a/lib/commercetools-history/src/Models/Common/CategoryReference.php b/lib/commercetools-history/src/Models/Common/CategoryReference.php new file mode 100644 index 00000000000..e7bb540d093 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CategoryReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced Category.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/CategoryReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/CategoryReferenceBuilder.php new file mode 100644 index 00000000000..b473203161b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CategoryReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class CategoryReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced Category.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): CategoryReference + { + return new CategoryReferenceModel( + $this->id + ); + } + + public static function of(): CategoryReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CategoryReferenceCollection.php b/lib/commercetools-history/src/Models/Common/CategoryReferenceCollection.php new file mode 100644 index 00000000000..5758c1b67fa --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CategoryReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method CategoryReference current() + * @method CategoryReference end() + * @method CategoryReference at($offset) + */ +class CategoryReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert CategoryReference $value + * @psalm-param CategoryReference|stdClass $value + * @throws InvalidArgumentException + * + * @return CategoryReferenceCollection + */ + public function add($value) + { + if (!$value instanceof CategoryReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CategoryReference + */ + protected function mapper() + { + return function (?int $index): ?CategoryReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CategoryReference $data */ + $data = CategoryReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CategoryReferenceModel.php b/lib/commercetools-history/src/Models/Common/CategoryReferenceModel.php new file mode 100644 index 00000000000..a8aff7ffce2 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CategoryReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced Category.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CentPrecisionMoney.php b/lib/commercetools-history/src/Models/Common/CentPrecisionMoney.php new file mode 100644 index 00000000000..0cdbc1f50cc --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CentPrecisionMoney.php @@ -0,0 +1,30 @@ +The number of default fraction digits for the given currency, like 2 for EUR or 0 for JPY.

                                                                                                                            + * + + * @return null|int + */ + public function getFractionDigits(); + + /** + * @param ?int $fractionDigits + */ + public function setFractionDigits(?int $fractionDigits): void; +} diff --git a/lib/commercetools-history/src/Models/Common/CentPrecisionMoneyBuilder.php b/lib/commercetools-history/src/Models/Common/CentPrecisionMoneyBuilder.php new file mode 100644 index 00000000000..7fd693c8c0a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CentPrecisionMoneyBuilder.php @@ -0,0 +1,125 @@ + + */ +final class CentPrecisionMoneyBuilder implements Builder +{ + /** + + * @var ?int + */ + private $centAmount; + + /** + + * @var ?string + */ + private $currencyCode; + + /** + + * @var ?int + */ + private $fractionDigits; + + /** + *

                                                                                                                            Amount in the smallest indivisible unit of a currency, such as:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as 500).
                                                                                                                            • + *
                                                                                                                            • The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as 5).
                                                                                                                            • + *
                                                                                                                            + * + + * @return null|int + */ + public function getCentAmount() + { + return $this->centAmount; + } + + /** + *

                                                                                                                            Currency code compliant to ISO 4217.

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

                                                                                                                            The number of default fraction digits for the given currency, like 2 for EUR or 0 for JPY.

                                                                                                                            + * + + * @return null|int + */ + public function getFractionDigits() + { + return $this->fractionDigits; + } + + /** + * @param ?int $centAmount + * @return $this + */ + public function withCentAmount(?int $centAmount) + { + $this->centAmount = $centAmount; + + return $this; + } + + /** + * @param ?string $currencyCode + * @return $this + */ + public function withCurrencyCode(?string $currencyCode) + { + $this->currencyCode = $currencyCode; + + return $this; + } + + /** + * @param ?int $fractionDigits + * @return $this + */ + public function withFractionDigits(?int $fractionDigits) + { + $this->fractionDigits = $fractionDigits; + + return $this; + } + + + public function build(): CentPrecisionMoney + { + return new CentPrecisionMoneyModel( + $this->centAmount, + $this->currencyCode, + $this->fractionDigits + ); + } + + public static function of(): CentPrecisionMoneyBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CentPrecisionMoneyCollection.php b/lib/commercetools-history/src/Models/Common/CentPrecisionMoneyCollection.php new file mode 100644 index 00000000000..3131e7a5305 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CentPrecisionMoneyCollection.php @@ -0,0 +1,56 @@ + + * @method CentPrecisionMoney current() + * @method CentPrecisionMoney end() + * @method CentPrecisionMoney at($offset) + */ +class CentPrecisionMoneyCollection extends TypedMoneyCollection +{ + /** + * @psalm-assert CentPrecisionMoney $value + * @psalm-param CentPrecisionMoney|stdClass $value + * @throws InvalidArgumentException + * + * @return CentPrecisionMoneyCollection + */ + public function add($value) + { + if (!$value instanceof CentPrecisionMoney) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CentPrecisionMoney + */ + protected function mapper() + { + return function (?int $index): ?CentPrecisionMoney { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CentPrecisionMoney $data */ + $data = CentPrecisionMoneyModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CentPrecisionMoneyModel.php b/lib/commercetools-history/src/Models/Common/CentPrecisionMoneyModel.php new file mode 100644 index 00000000000..9cc9968cf0b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CentPrecisionMoneyModel.php @@ -0,0 +1,175 @@ +centAmount = $centAmount; + $this->currencyCode = $currencyCode; + $this->fractionDigits = $fractionDigits; + $this->type = $type ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Amount in the smallest indivisible unit of a currency, such as:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as 500).
                                                                                                                            • + *
                                                                                                                            • The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as 5).
                                                                                                                            • + *
                                                                                                                            + * + * + * @return null|int + */ + public function getCentAmount() + { + if (is_null($this->centAmount)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_CENT_AMOUNT); + if (is_null($data)) { + return null; + } + $this->centAmount = (int) $data; + } + + return $this->centAmount; + } + + /** + *

                                                                                                                            Currency code compliant to ISO 4217.

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

                                                                                                                            Type of money used.

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

                                                                                                                            The number of default fraction digits for the given currency, like 2 for EUR or 0 for JPY.

                                                                                                                            + * + * + * @return null|int + */ + public function getFractionDigits() + { + if (is_null($this->fractionDigits)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_FRACTION_DIGITS); + if (is_null($data)) { + return null; + } + $this->fractionDigits = (int) $data; + } + + return $this->fractionDigits; + } + + + /** + * @param ?int $centAmount + */ + public function setCentAmount(?int $centAmount): void + { + $this->centAmount = $centAmount; + } + + /** + * @param ?string $currencyCode + */ + public function setCurrencyCode(?string $currencyCode): void + { + $this->currencyCode = $currencyCode; + } + + /** + * @param ?int $fractionDigits + */ + public function setFractionDigits(?int $fractionDigits): void + { + $this->fractionDigits = $fractionDigits; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ChannelReference.php b/lib/commercetools-history/src/Models/Common/ChannelReference.php new file mode 100644 index 00000000000..e000b7e982b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ChannelReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced Channel.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ChannelReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/ChannelReferenceBuilder.php new file mode 100644 index 00000000000..183366a8d7c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ChannelReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class ChannelReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced Channel.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): ChannelReference + { + return new ChannelReferenceModel( + $this->id + ); + } + + public static function of(): ChannelReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ChannelReferenceCollection.php b/lib/commercetools-history/src/Models/Common/ChannelReferenceCollection.php new file mode 100644 index 00000000000..f82e205ff3a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ChannelReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method ChannelReference current() + * @method ChannelReference end() + * @method ChannelReference at($offset) + */ +class ChannelReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert ChannelReference $value + * @psalm-param ChannelReference|stdClass $value + * @throws InvalidArgumentException + * + * @return ChannelReferenceCollection + */ + public function add($value) + { + if (!$value instanceof ChannelReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ChannelReference + */ + protected function mapper() + { + return function (?int $index): ?ChannelReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ChannelReference $data */ + $data = ChannelReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ChannelReferenceModel.php b/lib/commercetools-history/src/Models/Common/ChannelReferenceModel.php new file mode 100644 index 00000000000..9b421e62cf3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ChannelReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced Channel.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ClientLogging.php b/lib/commercetools-history/src/Models/Common/ClientLogging.php new file mode 100644 index 00000000000..e327158d5f3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ClientLogging.php @@ -0,0 +1,87 @@ +id of the API Client which created the resource.

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

                                                                                                                            External user ID provided by X-External-User-ID HTTP Header.

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

                                                                                                                            Indicates the Customer who modified the resource using a token from the password flow.

                                                                                                                            + * + + * @return null|CustomerReference + */ + public function getCustomer(); + + /** + *

                                                                                                                            Indicates that the resource was modified during an anonymous session with the logged ID.

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

                                                                                                                            Indicates the Customer who created or modified the resource in the context of a Business Unit. Only available for B2B-enabled Projects when an Associate acts on behalf of a company using the associate endpoints.

                                                                                                                            + * + + * @return null|CustomerReference + */ + public function getAssociate(); + + /** + * @param ?string $clientId + */ + public function setClientId(?string $clientId): void; + + /** + * @param ?string $externalUserId + */ + public function setExternalUserId(?string $externalUserId): void; + + /** + * @param ?CustomerReference $customer + */ + public function setCustomer(?CustomerReference $customer): void; + + /** + * @param ?string $anonymousId + */ + public function setAnonymousId(?string $anonymousId): void; + + /** + * @param ?CustomerReference $associate + */ + public function setAssociate(?CustomerReference $associate): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ClientLoggingBuilder.php b/lib/commercetools-history/src/Models/Common/ClientLoggingBuilder.php new file mode 100644 index 00000000000..93be101aeac --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ClientLoggingBuilder.php @@ -0,0 +1,200 @@ + + */ +final class ClientLoggingBuilder implements Builder +{ + /** + + * @var ?string + */ + private $clientId; + + /** + + * @var ?string + */ + private $externalUserId; + + /** + + * @var null|CustomerReference|CustomerReferenceBuilder + */ + private $customer; + + /** + + * @var ?string + */ + private $anonymousId; + + /** + + * @var null|CustomerReference|CustomerReferenceBuilder + */ + private $associate; + + /** + *

                                                                                                                            id of the API Client which created the resource.

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

                                                                                                                            External user ID provided by X-External-User-ID HTTP Header.

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

                                                                                                                            Indicates the Customer who modified the resource using a token from the password flow.

                                                                                                                            + * + + * @return null|CustomerReference + */ + public function getCustomer() + { + return $this->customer instanceof CustomerReferenceBuilder ? $this->customer->build() : $this->customer; + } + + /** + *

                                                                                                                            Indicates that the resource was modified during an anonymous session with the logged ID.

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

                                                                                                                            Indicates the Customer who created or modified the resource in the context of a Business Unit. Only available for B2B-enabled Projects when an Associate acts on behalf of a company using the associate endpoints.

                                                                                                                            + * + + * @return null|CustomerReference + */ + public function getAssociate() + { + return $this->associate instanceof CustomerReferenceBuilder ? $this->associate->build() : $this->associate; + } + + /** + * @param ?string $clientId + * @return $this + */ + public function withClientId(?string $clientId) + { + $this->clientId = $clientId; + + return $this; + } + + /** + * @param ?string $externalUserId + * @return $this + */ + public function withExternalUserId(?string $externalUserId) + { + $this->externalUserId = $externalUserId; + + return $this; + } + + /** + * @param ?CustomerReference $customer + * @return $this + */ + public function withCustomer(?CustomerReference $customer) + { + $this->customer = $customer; + + return $this; + } + + /** + * @param ?string $anonymousId + * @return $this + */ + public function withAnonymousId(?string $anonymousId) + { + $this->anonymousId = $anonymousId; + + return $this; + } + + /** + * @param ?CustomerReference $associate + * @return $this + */ + public function withAssociate(?CustomerReference $associate) + { + $this->associate = $associate; + + return $this; + } + + /** + * @deprecated use withCustomer() instead + * @return $this + */ + public function withCustomerBuilder(?CustomerReferenceBuilder $customer) + { + $this->customer = $customer; + + return $this; + } + + /** + * @deprecated use withAssociate() instead + * @return $this + */ + public function withAssociateBuilder(?CustomerReferenceBuilder $associate) + { + $this->associate = $associate; + + return $this; + } + + public function build(): ClientLogging + { + return new ClientLoggingModel( + $this->clientId, + $this->externalUserId, + $this->customer instanceof CustomerReferenceBuilder ? $this->customer->build() : $this->customer, + $this->anonymousId, + $this->associate instanceof CustomerReferenceBuilder ? $this->associate->build() : $this->associate + ); + } + + public static function of(): ClientLoggingBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ClientLoggingCollection.php b/lib/commercetools-history/src/Models/Common/ClientLoggingCollection.php new file mode 100644 index 00000000000..6fc2c965da0 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ClientLoggingCollection.php @@ -0,0 +1,56 @@ + + * @method ClientLogging current() + * @method ClientLogging end() + * @method ClientLogging at($offset) + */ +class ClientLoggingCollection extends MapperSequence +{ + /** + * @psalm-assert ClientLogging $value + * @psalm-param ClientLogging|stdClass $value + * @throws InvalidArgumentException + * + * @return ClientLoggingCollection + */ + public function add($value) + { + if (!$value instanceof ClientLogging) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ClientLogging + */ + protected function mapper() + { + return function (?int $index): ?ClientLogging { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ClientLogging $data */ + $data = ClientLoggingModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ClientLoggingModel.php b/lib/commercetools-history/src/Models/Common/ClientLoggingModel.php new file mode 100644 index 00000000000..01b44db0a3e --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ClientLoggingModel.php @@ -0,0 +1,218 @@ +clientId = $clientId; + $this->externalUserId = $externalUserId; + $this->customer = $customer; + $this->anonymousId = $anonymousId; + $this->associate = $associate; + + } + + /** + *

                                                                                                                            id of the API Client which created the resource.

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

                                                                                                                            External user ID provided by X-External-User-ID HTTP Header.

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

                                                                                                                            Indicates the Customer who modified the resource using a token from the password flow.

                                                                                                                            + * + * + * @return null|CustomerReference + */ + public function getCustomer() + { + if (is_null($this->customer)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOMER); + if (is_null($data)) { + return null; + } + + $this->customer = CustomerReferenceModel::of($data); + } + + return $this->customer; + } + + /** + *

                                                                                                                            Indicates that the resource was modified during an anonymous session with the logged ID.

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

                                                                                                                            Indicates the Customer who created or modified the resource in the context of a Business Unit. Only available for B2B-enabled Projects when an Associate acts on behalf of a company using the associate endpoints.

                                                                                                                            + * + * + * @return null|CustomerReference + */ + public function getAssociate() + { + if (is_null($this->associate)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_ASSOCIATE); + if (is_null($data)) { + return null; + } + + $this->associate = CustomerReferenceModel::of($data); + } + + return $this->associate; + } + + + /** + * @param ?string $clientId + */ + public function setClientId(?string $clientId): void + { + $this->clientId = $clientId; + } + + /** + * @param ?string $externalUserId + */ + public function setExternalUserId(?string $externalUserId): void + { + $this->externalUserId = $externalUserId; + } + + /** + * @param ?CustomerReference $customer + */ + public function setCustomer(?CustomerReference $customer): void + { + $this->customer = $customer; + } + + /** + * @param ?string $anonymousId + */ + public function setAnonymousId(?string $anonymousId): void + { + $this->anonymousId = $anonymousId; + } + + /** + * @param ?CustomerReference $associate + */ + public function setAssociate(?CustomerReference $associate): void + { + $this->associate = $associate; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldEnumValue.php b/lib/commercetools-history/src/Models/Common/CustomFieldEnumValue.php new file mode 100644 index 00000000000..11406d42b44 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomFieldEnumValue.php @@ -0,0 +1,45 @@ +Key of the value used as a programmatic identifier.

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

                                                                                                                            Descriptive label of the value.

                                                                                                                            + * + + * @return null|string + */ + public function getLabel(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?string $label + */ + public function setLabel(?string $label): void; +} diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldEnumValueBuilder.php b/lib/commercetools-history/src/Models/Common/CustomFieldEnumValueBuilder.php new file mode 100644 index 00000000000..5cee2dd1c81 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomFieldEnumValueBuilder.php @@ -0,0 +1,92 @@ + + */ +final class CustomFieldEnumValueBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + + * @var ?string + */ + private $label; + + /** + *

                                                                                                                            Key of the value used as a programmatic identifier.

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

                                                                                                                            Descriptive label of the value.

                                                                                                                            + * + + * @return null|string + */ + public function getLabel() + { + return $this->label; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?string $label + * @return $this + */ + public function withLabel(?string $label) + { + $this->label = $label; + + return $this; + } + + + public function build(): CustomFieldEnumValue + { + return new CustomFieldEnumValueModel( + $this->key, + $this->label + ); + } + + public static function of(): CustomFieldEnumValueBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldEnumValueCollection.php b/lib/commercetools-history/src/Models/Common/CustomFieldEnumValueCollection.php new file mode 100644 index 00000000000..51666b3f24c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomFieldEnumValueCollection.php @@ -0,0 +1,56 @@ + + * @method CustomFieldEnumValue current() + * @method CustomFieldEnumValue end() + * @method CustomFieldEnumValue at($offset) + */ +class CustomFieldEnumValueCollection extends MapperSequence +{ + /** + * @psalm-assert CustomFieldEnumValue $value + * @psalm-param CustomFieldEnumValue|stdClass $value + * @throws InvalidArgumentException + * + * @return CustomFieldEnumValueCollection + */ + public function add($value) + { + if (!$value instanceof CustomFieldEnumValue) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CustomFieldEnumValue + */ + protected function mapper() + { + return function (?int $index): ?CustomFieldEnumValue { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CustomFieldEnumValue $data */ + $data = CustomFieldEnumValueModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldEnumValueModel.php b/lib/commercetools-history/src/Models/Common/CustomFieldEnumValueModel.php new file mode 100644 index 00000000000..3b9094988a6 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomFieldEnumValueModel.php @@ -0,0 +1,108 @@ +key = $key; + $this->label = $label; + + } + + /** + *

                                                                                                                            Key of the value used as a programmatic identifier.

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

                                                                                                                            Descriptive label of the value.

                                                                                                                            + * + * + * @return null|string + */ + public function getLabel() + { + if (is_null($this->label)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LABEL); + if (is_null($data)) { + return null; + } + $this->label = (string) $data; + } + + return $this->label; + } + + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?string $label + */ + public function setLabel(?string $label): void + { + $this->label = $label; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValue.php b/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValue.php new file mode 100644 index 00000000000..914b67125aa --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValue.php @@ -0,0 +1,45 @@ +Key of the value used as a programmatic identifier.

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

                                                                                                                            Descriptive localized label of the value.

                                                                                                                            + * + + * @return null|LocalizedString + */ + public function getLabel(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?LocalizedString $label + */ + public function setLabel(?LocalizedString $label): void; +} diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValueBuilder.php b/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValueBuilder.php new file mode 100644 index 00000000000..30ab0732938 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValueBuilder.php @@ -0,0 +1,102 @@ + + */ +final class CustomFieldLocalizedEnumValueBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $label; + + /** + *

                                                                                                                            Key of the value used as a programmatic identifier.

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

                                                                                                                            Descriptive localized label of the value.

                                                                                                                            + * + + * @return null|LocalizedString + */ + public function getLabel() + { + return $this->label instanceof LocalizedStringBuilder ? $this->label->build() : $this->label; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?LocalizedString $label + * @return $this + */ + public function withLabel(?LocalizedString $label) + { + $this->label = $label; + + return $this; + } + + /** + * @deprecated use withLabel() instead + * @return $this + */ + public function withLabelBuilder(?LocalizedStringBuilder $label) + { + $this->label = $label; + + return $this; + } + + public function build(): CustomFieldLocalizedEnumValue + { + return new CustomFieldLocalizedEnumValueModel( + $this->key, + $this->label instanceof LocalizedStringBuilder ? $this->label->build() : $this->label + ); + } + + public static function of(): CustomFieldLocalizedEnumValueBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValueCollection.php b/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValueCollection.php new file mode 100644 index 00000000000..afc2a069ff7 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValueCollection.php @@ -0,0 +1,56 @@ + + * @method CustomFieldLocalizedEnumValue current() + * @method CustomFieldLocalizedEnumValue end() + * @method CustomFieldLocalizedEnumValue at($offset) + */ +class CustomFieldLocalizedEnumValueCollection extends MapperSequence +{ + /** + * @psalm-assert CustomFieldLocalizedEnumValue $value + * @psalm-param CustomFieldLocalizedEnumValue|stdClass $value + * @throws InvalidArgumentException + * + * @return CustomFieldLocalizedEnumValueCollection + */ + public function add($value) + { + if (!$value instanceof CustomFieldLocalizedEnumValue) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CustomFieldLocalizedEnumValue + */ + protected function mapper() + { + return function (?int $index): ?CustomFieldLocalizedEnumValue { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CustomFieldLocalizedEnumValue $data */ + $data = CustomFieldLocalizedEnumValueModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValueModel.php b/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValueModel.php new file mode 100644 index 00000000000..5719aa82c50 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomFieldLocalizedEnumValueModel.php @@ -0,0 +1,109 @@ +key = $key; + $this->label = $label; + + } + + /** + *

                                                                                                                            Key of the value used as a programmatic identifier.

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

                                                                                                                            Descriptive localized label of the value.

                                                                                                                            + * + * + * @return null|LocalizedString + */ + public function getLabel() + { + if (is_null($this->label)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_LABEL); + if (is_null($data)) { + return null; + } + + $this->label = LocalizedStringModel::of($data); + } + + return $this->label; + } + + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?LocalizedString $label + */ + public function setLabel(?LocalizedString $label): void + { + $this->label = $label; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CustomFields.php b/lib/commercetools-history/src/Models/Common/CustomFields.php index da44aaa3c52..aaedddf99ef 100644 --- a/lib/commercetools-history/src/Models/Common/CustomFields.php +++ b/lib/commercetools-history/src/Models/Common/CustomFields.php @@ -18,26 +18,28 @@ interface CustomFields extends JsonObject public const FIELD_FIELDS = 'fields'; /** + *

                                                                                                                            Reference to the Type that holds the FieldDefinitions for the Custom Fields.

                                                                                                                            + * - * @return null|Reference + * @return null|TypeReference */ public function getType(); /** - *

                                                                                                                            A valid JSON object, based on FieldDefinition.

                                                                                                                            + *

                                                                                                                            Object containing the Custom Fields for the customized resource or data type.

                                                                                                                            * - * @return null|mixed + * @return null|FieldContainer */ public function getFields(); /** - * @param ?Reference $type + * @param ?TypeReference $type */ - public function setType(?Reference $type): void; + public function setType(?TypeReference $type): void; /** - * @param ?JsonObject $fields + * @param ?FieldContainer $fields */ - public function setFields(?JsonObject $fields): void; + public function setFields(?FieldContainer $fields): void; } diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldsBuilder.php b/lib/commercetools-history/src/Models/Common/CustomFieldsBuilder.php index 5bc347e0dfb..bcc515538b8 100644 --- a/lib/commercetools-history/src/Models/Common/CustomFieldsBuilder.php +++ b/lib/commercetools-history/src/Models/Common/CustomFieldsBuilder.php @@ -22,41 +22,43 @@ final class CustomFieldsBuilder implements Builder { /** - * @var null|Reference|ReferenceBuilder + * @var null|TypeReference|TypeReferenceBuilder */ private $type; /** - * @var ?JsonObject + * @var null|FieldContainer|FieldContainerBuilder */ private $fields; /** + *

                                                                                                                            Reference to the Type that holds the FieldDefinitions for the Custom Fields.

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

                                                                                                                            A valid JSON object, based on FieldDefinition.

                                                                                                                            + *

                                                                                                                            Object containing the Custom Fields for the customized resource or data type.

                                                                                                                            * - * @return null|JsonObject + * @return null|FieldContainer */ public function getFields() { - return $this->fields; + return $this->fields instanceof FieldContainerBuilder ? $this->fields->build() : $this->fields; } /** - * @param ?Reference $type + * @param ?TypeReference $type * @return $this */ - public function withType(?Reference $type) + public function withType(?TypeReference $type) { $this->type = $type; @@ -64,10 +66,10 @@ public function withType(?Reference $type) } /** - * @param ?JsonObject $fields + * @param ?FieldContainer $fields * @return $this */ - public function withFields(?JsonObject $fields) + public function withFields(?FieldContainer $fields) { $this->fields = $fields; @@ -78,18 +80,29 @@ public function withFields(?JsonObject $fields) * @deprecated use withType() instead * @return $this */ - public function withTypeBuilder(?ReferenceBuilder $type) + public function withTypeBuilder(?TypeReferenceBuilder $type) { $this->type = $type; return $this; } + /** + * @deprecated use withFields() instead + * @return $this + */ + public function withFieldsBuilder(?FieldContainerBuilder $fields) + { + $this->fields = $fields; + + return $this; + } + public function build(): CustomFields { return new CustomFieldsModel( - $this->type instanceof ReferenceBuilder ? $this->type->build() : $this->type, - $this->fields + $this->type instanceof TypeReferenceBuilder ? $this->type->build() : $this->type, + $this->fields instanceof FieldContainerBuilder ? $this->fields->build() : $this->fields ); } diff --git a/lib/commercetools-history/src/Models/Common/CustomFieldsModel.php b/lib/commercetools-history/src/Models/Common/CustomFieldsModel.php index 48820f8a7cd..9be806cc5cf 100644 --- a/lib/commercetools-history/src/Models/Common/CustomFieldsModel.php +++ b/lib/commercetools-history/src/Models/Common/CustomFieldsModel.php @@ -23,13 +23,13 @@ final class CustomFieldsModel extends JsonObjectModel implements CustomFields /** * - * @var ?Reference + * @var ?TypeReference */ protected $type; /** * - * @var ?mixed + * @var ?FieldContainer */ protected $fields; @@ -38,8 +38,8 @@ final class CustomFieldsModel extends JsonObjectModel implements CustomFields * @psalm-suppress MissingParamType */ public function __construct( - ?Reference $type = null, - ?JsonObject $fields = null + ?TypeReference $type = null, + ?FieldContainer $fields = null ) { $this->type = $type; $this->fields = $fields; @@ -47,8 +47,10 @@ public function __construct( } /** + *

                                                                                                                            Reference to the Type that holds the FieldDefinitions for the Custom Fields.

                                                                                                                            * - * @return null|Reference + * + * @return null|TypeReference */ public function getType() { @@ -59,17 +61,17 @@ public function getType() return null; } - $this->type = ReferenceModel::of($data); + $this->type = TypeReferenceModel::of($data); } return $this->type; } /** - *

                                                                                                                            A valid JSON object, based on FieldDefinition.

                                                                                                                            + *

                                                                                                                            Object containing the Custom Fields for the customized resource or data type.

                                                                                                                            * * - * @return null|mixed + * @return null|FieldContainer */ public function getFields() { @@ -79,7 +81,8 @@ public function getFields() if (is_null($data)) { return null; } - $this->fields = JsonObjectModel::of($data); + + $this->fields = FieldContainerModel::of($data); } return $this->fields; @@ -87,17 +90,17 @@ public function getFields() /** - * @param ?Reference $type + * @param ?TypeReference $type */ - public function setType(?Reference $type): void + public function setType(?TypeReference $type): void { $this->type = $type; } /** - * @param ?JsonObject $fields + * @param ?FieldContainer $fields */ - public function setFields(?JsonObject $fields): void + public function setFields(?FieldContainer $fields): void { $this->fields = $fields; } diff --git a/lib/commercetools-history/src/Models/Common/CustomLineItem.php b/lib/commercetools-history/src/Models/Common/CustomLineItem.php index 55436eba987..6e26ce3ede0 100644 --- a/lib/commercetools-history/src/Models/Common/CustomLineItem.php +++ b/lib/commercetools-history/src/Models/Common/CustomLineItem.php @@ -15,15 +15,26 @@ interface CustomLineItem extends JsonObject { public const FIELD_ID = 'id'; + public const FIELD_KEY = 'key'; public const FIELD_NAME = 'name'; public const FIELD_MONEY = 'money'; public const FIELD_TAXED_PRICE = 'taxedPrice'; + public const FIELD_TAXED_PRICE_PORTIONS = 'taxedPricePortions'; public const FIELD_TOTAL_PRICE = 'totalPrice'; public const FIELD_SLUG = 'slug'; public const FIELD_QUANTITY = 'quantity'; + public const FIELD_STATE = 'state'; + public const FIELD_TAX_CATEGORY = 'taxCategory'; + public const FIELD_TAX_RATE = 'taxRate'; + public const FIELD_PER_METHOD_TAX_RATE = 'perMethodTaxRate'; + public const FIELD_DISCOUNTED_PRICE_PER_QUANTITY = 'discountedPricePerQuantity'; + public const FIELD_CUSTOM = 'custom'; + public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; + public const FIELD_PRICE_MODE = 'priceMode'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; /** - *

                                                                                                                            The unique ID of this CustomLineItem.

                                                                                                                            + *

                                                                                                                            Unique identifier of the Custom Line Item.

                                                                                                                            * * @return null|string @@ -31,31 +42,59 @@ interface CustomLineItem extends JsonObject public function getId(); /** + *

                                                                                                                            User-defined unique identifier of the Custom Line Item.

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

                                                                                                                            Name of the Custom Line Item.

                                                                                                                            + * * @return null|LocalizedString */ public function getName(); /** + *

                                                                                                                            Money value of the Custom Line Item.

                                                                                                                            + * - * @return null|Money + * @return null|TypedMoney */ public function getMoney(); /** + *

                                                                                                                            Automatically set after the taxRate is set.

                                                                                                                            + * * @return null|TaxedItemPrice */ public function getTaxedPrice(); /** + *

                                                                                                                            Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. + * Automatically set after perMethodTaxRate is set.

                                                                                                                            + * + + * @return null|MethodTaxedPriceCollection + */ + public function getTaxedPricePortions(); + + /** + *

                                                                                                                            Total price of the Custom Line Item (money multiplied by quantity). + * If the Custom Line Item is discounted, the total price is discountedPricePerQuantity multiplied by quantity.

                                                                                                                            + *

                                                                                                                            Includes taxes if the TaxRate includedInPrice is true.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalPrice(); /** - *

                                                                                                                            A unique String in the cart to identify this CustomLineItem.

                                                                                                                            + *

                                                                                                                            User-defined identifier used in a deep-link URL for the Custom Line Item. + * It matches the pattern [a-zA-Z0-9_-]{2,256}.

                                                                                                                            * * @return null|string @@ -63,27 +102,108 @@ public function getTotalPrice(); public function getSlug(); /** - *

                                                                                                                            The amount of a CustomLineItem in the cart. Must be a positive integer.

                                                                                                                            + *

                                                                                                                            Number of Custom Line Items in the Cart or Order.

                                                                                                                            * * @return null|int */ public function getQuantity(); + /** + *

                                                                                                                            Tracks specific quantities of the Custom Line Item within a given State. When a Custom Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Custom Line Items are managed on the Order.

                                                                                                                            + * + + * @return null|ItemStateCollection + */ + public function getState(); + + /** + *

                                                                                                                            Used to select a Tax Rate when a Cart has the Platform TaxMode.

                                                                                                                            + * + + * @return null|TaxCategoryReference + */ + public function getTaxCategory(); + + /** + *
                                                                                                                              + *
                                                                                                                            • For a Cart with Platform TaxMode, the taxRate of Custom Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
                                                                                                                            • + *
                                                                                                                            • For a Cart with External TaxMode, the taxRate of Custom Line Items can be set using ExternalTaxRateDraft.
                                                                                                                            • + *
                                                                                                                            + * + + * @return null|TaxRate + */ + public function getTaxRate(); + + /** + *

                                                                                                                            Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. + * For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

                                                                                                                            + * + + * @return null|MethodTaxRateCollection + */ + public function getPerMethodTaxRate(); + + /** + *

                                                                                                                            Discounted price of a single quantity of the Custom Line Item.

                                                                                                                            + * + + * @return null|DiscountedLineItemPriceForQuantityCollection + */ + public function getDiscountedPricePerQuantity(); + + /** + *

                                                                                                                            Custom Fields of the Custom Line Item.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom(); + + /** + *

                                                                                                                            Container for Custom Line Item-specific addresses.

                                                                                                                            + * + + * @return null|ItemShippingDetails + */ + public function getShippingDetails(); + + /** + *

                                                                                                                            Indicates whether Cart Discounts with a matching CartDiscountCustomLineItemsTarget, MultiBuyCustomLineItemsTarget, or CartDiscountPatternTarget are applied to the Custom Line Item.

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

                                                                                                                            Recurring Order and frequency data.

                                                                                                                            + * + + * @return null|CustomLineItemRecurrenceInfo + */ + public function getRecurrenceInfo(); + /** * @param ?string $id */ public function setId(?string $id): void; + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + /** * @param ?LocalizedString $name */ public function setName(?LocalizedString $name): void; /** - * @param ?Money $money + * @param ?TypedMoney $money */ - public function setMoney(?Money $money): void; + public function setMoney(?TypedMoney $money): void; /** * @param ?TaxedItemPrice $taxedPrice @@ -91,9 +211,14 @@ public function setMoney(?Money $money): void; public function setTaxedPrice(?TaxedItemPrice $taxedPrice): void; /** - * @param ?Money $totalPrice + * @param ?MethodTaxedPriceCollection $taxedPricePortions + */ + public function setTaxedPricePortions(?MethodTaxedPriceCollection $taxedPricePortions): void; + + /** + * @param ?CentPrecisionMoney $totalPrice */ - public function setTotalPrice(?Money $totalPrice): void; + public function setTotalPrice(?CentPrecisionMoney $totalPrice): void; /** * @param ?string $slug @@ -104,4 +229,49 @@ public function setSlug(?string $slug): void; * @param ?int $quantity */ public function setQuantity(?int $quantity): void; + + /** + * @param ?ItemStateCollection $state + */ + public function setState(?ItemStateCollection $state): void; + + /** + * @param ?TaxCategoryReference $taxCategory + */ + public function setTaxCategory(?TaxCategoryReference $taxCategory): void; + + /** + * @param ?TaxRate $taxRate + */ + public function setTaxRate(?TaxRate $taxRate): void; + + /** + * @param ?MethodTaxRateCollection $perMethodTaxRate + */ + public function setPerMethodTaxRate(?MethodTaxRateCollection $perMethodTaxRate): void; + + /** + * @param ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity + */ + public function setDiscountedPricePerQuantity(?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity): void; + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void; + + /** + * @param ?ItemShippingDetails $shippingDetails + */ + public function setShippingDetails(?ItemShippingDetails $shippingDetails): void; + + /** + * @param ?string $priceMode + */ + public function setPriceMode(?string $priceMode): void; + + /** + * @param ?CustomLineItemRecurrenceInfo $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfo $recurrenceInfo): void; } diff --git a/lib/commercetools-history/src/Models/Common/CustomLineItemBuilder.php b/lib/commercetools-history/src/Models/Common/CustomLineItemBuilder.php index 19fb2814c99..1146789030c 100644 --- a/lib/commercetools-history/src/Models/Common/CustomLineItemBuilder.php +++ b/lib/commercetools-history/src/Models/Common/CustomLineItemBuilder.php @@ -26,6 +26,12 @@ final class CustomLineItemBuilder implements Builder */ private $id; + /** + + * @var ?string + */ + private $key; + /** * @var null|LocalizedString|LocalizedStringBuilder @@ -34,7 +40,7 @@ final class CustomLineItemBuilder implements Builder /** - * @var null|Money|MoneyBuilder + * @var null|TypedMoney|TypedMoneyBuilder */ private $money; @@ -46,7 +52,13 @@ final class CustomLineItemBuilder implements Builder /** - * @var null|Money|MoneyBuilder + * @var ?MethodTaxedPriceCollection + */ + private $taxedPricePortions; + + /** + + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder */ private $totalPrice; @@ -63,7 +75,61 @@ final class CustomLineItemBuilder implements Builder private $quantity; /** - *

                                                                                                                            The unique ID of this CustomLineItem.

                                                                                                                            + + * @var ?ItemStateCollection + */ + private $state; + + /** + + * @var null|TaxCategoryReference|TaxCategoryReferenceBuilder + */ + private $taxCategory; + + /** + + * @var null|TaxRate|TaxRateBuilder + */ + private $taxRate; + + /** + + * @var ?MethodTaxRateCollection + */ + private $perMethodTaxRate; + + /** + + * @var ?DiscountedLineItemPriceForQuantityCollection + */ + private $discountedPricePerQuantity; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + + /** + + * @var null|ItemShippingDetails|ItemShippingDetailsBuilder + */ + private $shippingDetails; + + /** + + * @var ?string + */ + private $priceMode; + + /** + + * @var null|CustomLineItemRecurrenceInfo|CustomLineItemRecurrenceInfoBuilder + */ + private $recurrenceInfo; + + /** + *

                                                                                                                            Unique identifier of the Custom Line Item.

                                                                                                                            * * @return null|string @@ -74,6 +140,19 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the Custom Line Item.

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

                                                                                                                            Name of the Custom Line Item.

                                                                                                                            + * * @return null|LocalizedString */ @@ -83,15 +162,19 @@ public function getName() } /** + *

                                                                                                                            Money value of the Custom Line Item.

                                                                                                                            + * - * @return null|Money + * @return null|TypedMoney */ public function getMoney() { - return $this->money instanceof MoneyBuilder ? $this->money->build() : $this->money; + return $this->money instanceof TypedMoneyBuilder ? $this->money->build() : $this->money; } /** + *

                                                                                                                            Automatically set after the taxRate is set.

                                                                                                                            + * * @return null|TaxedItemPrice */ @@ -101,16 +184,33 @@ public function getTaxedPrice() } /** + *

                                                                                                                            Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. + * Automatically set after perMethodTaxRate is set.

                                                                                                                            + * + + * @return null|MethodTaxedPriceCollection + */ + public function getTaxedPricePortions() + { + return $this->taxedPricePortions; + } + + /** + *

                                                                                                                            Total price of the Custom Line Item (money multiplied by quantity). + * If the Custom Line Item is discounted, the total price is discountedPricePerQuantity multiplied by quantity.

                                                                                                                            + *

                                                                                                                            Includes taxes if the TaxRate includedInPrice is true.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalPrice() { - return $this->totalPrice instanceof MoneyBuilder ? $this->totalPrice->build() : $this->totalPrice; + return $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice; } /** - *

                                                                                                                            A unique String in the cart to identify this CustomLineItem.

                                                                                                                            + *

                                                                                                                            User-defined identifier used in a deep-link URL for the Custom Line Item. + * It matches the pattern [a-zA-Z0-9_-]{2,256}.

                                                                                                                            * * @return null|string @@ -121,7 +221,7 @@ public function getSlug() } /** - *

                                                                                                                            The amount of a CustomLineItem in the cart. Must be a positive integer.

                                                                                                                            + *

                                                                                                                            Number of Custom Line Items in the Cart or Order.

                                                                                                                            * * @return null|int @@ -131,6 +231,109 @@ public function getQuantity() return $this->quantity; } + /** + *

                                                                                                                            Tracks specific quantities of the Custom Line Item within a given State. When a Custom Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Custom Line Items are managed on the Order.

                                                                                                                            + * + + * @return null|ItemStateCollection + */ + public function getState() + { + return $this->state; + } + + /** + *

                                                                                                                            Used to select a Tax Rate when a Cart has the Platform TaxMode.

                                                                                                                            + * + + * @return null|TaxCategoryReference + */ + public function getTaxCategory() + { + return $this->taxCategory instanceof TaxCategoryReferenceBuilder ? $this->taxCategory->build() : $this->taxCategory; + } + + /** + *
                                                                                                                              + *
                                                                                                                            • For a Cart with Platform TaxMode, the taxRate of Custom Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
                                                                                                                            • + *
                                                                                                                            • For a Cart with External TaxMode, the taxRate of Custom Line Items can be set using ExternalTaxRateDraft.
                                                                                                                            • + *
                                                                                                                            + * + + * @return null|TaxRate + */ + public function getTaxRate() + { + return $this->taxRate instanceof TaxRateBuilder ? $this->taxRate->build() : $this->taxRate; + } + + /** + *

                                                                                                                            Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. + * For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

                                                                                                                            + * + + * @return null|MethodTaxRateCollection + */ + public function getPerMethodTaxRate() + { + return $this->perMethodTaxRate; + } + + /** + *

                                                                                                                            Discounted price of a single quantity of the Custom Line Item.

                                                                                                                            + * + + * @return null|DiscountedLineItemPriceForQuantityCollection + */ + public function getDiscountedPricePerQuantity() + { + return $this->discountedPricePerQuantity; + } + + /** + *

                                                                                                                            Custom Fields of the Custom Line Item.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; + } + + /** + *

                                                                                                                            Container for Custom Line Item-specific addresses.

                                                                                                                            + * + + * @return null|ItemShippingDetails + */ + public function getShippingDetails() + { + return $this->shippingDetails instanceof ItemShippingDetailsBuilder ? $this->shippingDetails->build() : $this->shippingDetails; + } + + /** + *

                                                                                                                            Indicates whether Cart Discounts with a matching CartDiscountCustomLineItemsTarget, MultiBuyCustomLineItemsTarget, or CartDiscountPatternTarget are applied to the Custom Line Item.

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

                                                                                                                            Recurring Order and frequency data.

                                                                                                                            + * + + * @return null|CustomLineItemRecurrenceInfo + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + /** * @param ?string $id * @return $this @@ -142,6 +345,17 @@ public function withId(?string $id) return $this; } + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + /** * @param ?LocalizedString $name * @return $this @@ -154,10 +368,10 @@ public function withName(?LocalizedString $name) } /** - * @param ?Money $money + * @param ?TypedMoney $money * @return $this */ - public function withMoney(?Money $money) + public function withMoney(?TypedMoney $money) { $this->money = $money; @@ -176,10 +390,21 @@ public function withTaxedPrice(?TaxedItemPrice $taxedPrice) } /** - * @param ?Money $totalPrice + * @param ?MethodTaxedPriceCollection $taxedPricePortions + * @return $this + */ + public function withTaxedPricePortions(?MethodTaxedPriceCollection $taxedPricePortions) + { + $this->taxedPricePortions = $taxedPricePortions; + + return $this; + } + + /** + * @param ?CentPrecisionMoney $totalPrice * @return $this */ - public function withTotalPrice(?Money $totalPrice) + public function withTotalPrice(?CentPrecisionMoney $totalPrice) { $this->totalPrice = $totalPrice; @@ -208,6 +433,105 @@ public function withQuantity(?int $quantity) return $this; } + /** + * @param ?ItemStateCollection $state + * @return $this + */ + public function withState(?ItemStateCollection $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?TaxCategoryReference $taxCategory + * @return $this + */ + public function withTaxCategory(?TaxCategoryReference $taxCategory) + { + $this->taxCategory = $taxCategory; + + return $this; + } + + /** + * @param ?TaxRate $taxRate + * @return $this + */ + public function withTaxRate(?TaxRate $taxRate) + { + $this->taxRate = $taxRate; + + return $this; + } + + /** + * @param ?MethodTaxRateCollection $perMethodTaxRate + * @return $this + */ + public function withPerMethodTaxRate(?MethodTaxRateCollection $perMethodTaxRate) + { + $this->perMethodTaxRate = $perMethodTaxRate; + + return $this; + } + + /** + * @param ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity + * @return $this + */ + public function withDiscountedPricePerQuantity(?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity) + { + $this->discountedPricePerQuantity = $discountedPricePerQuantity; + + return $this; + } + + /** + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @param ?ItemShippingDetails $shippingDetails + * @return $this + */ + public function withShippingDetails(?ItemShippingDetails $shippingDetails) + { + $this->shippingDetails = $shippingDetails; + + return $this; + } + + /** + * @param ?string $priceMode + * @return $this + */ + public function withPriceMode(?string $priceMode) + { + $this->priceMode = $priceMode; + + return $this; + } + + /** + * @param ?CustomLineItemRecurrenceInfo $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?CustomLineItemRecurrenceInfo $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withName() instead * @return $this @@ -223,7 +547,7 @@ public function withNameBuilder(?LocalizedStringBuilder $name) * @deprecated use withMoney() instead * @return $this */ - public function withMoneyBuilder(?MoneyBuilder $money) + public function withMoneyBuilder(?TypedMoneyBuilder $money) { $this->money = $money; @@ -245,23 +569,89 @@ public function withTaxedPriceBuilder(?TaxedItemPriceBuilder $taxedPrice) * @deprecated use withTotalPrice() instead * @return $this */ - public function withTotalPriceBuilder(?MoneyBuilder $totalPrice) + public function withTotalPriceBuilder(?CentPrecisionMoneyBuilder $totalPrice) { $this->totalPrice = $totalPrice; return $this; } + /** + * @deprecated use withTaxCategory() instead + * @return $this + */ + public function withTaxCategoryBuilder(?TaxCategoryReferenceBuilder $taxCategory) + { + $this->taxCategory = $taxCategory; + + return $this; + } + + /** + * @deprecated use withTaxRate() instead + * @return $this + */ + public function withTaxRateBuilder(?TaxRateBuilder $taxRate) + { + $this->taxRate = $taxRate; + + return $this; + } + + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @deprecated use withShippingDetails() instead + * @return $this + */ + public function withShippingDetailsBuilder(?ItemShippingDetailsBuilder $shippingDetails) + { + $this->shippingDetails = $shippingDetails; + + return $this; + } + + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?CustomLineItemRecurrenceInfoBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + public function build(): CustomLineItem { return new CustomLineItemModel( $this->id, + $this->key, $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name, - $this->money instanceof MoneyBuilder ? $this->money->build() : $this->money, + $this->money instanceof TypedMoneyBuilder ? $this->money->build() : $this->money, $this->taxedPrice instanceof TaxedItemPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice, - $this->totalPrice instanceof MoneyBuilder ? $this->totalPrice->build() : $this->totalPrice, + $this->taxedPricePortions, + $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice, $this->slug, - $this->quantity + $this->quantity, + $this->state, + $this->taxCategory instanceof TaxCategoryReferenceBuilder ? $this->taxCategory->build() : $this->taxCategory, + $this->taxRate instanceof TaxRateBuilder ? $this->taxRate->build() : $this->taxRate, + $this->perMethodTaxRate, + $this->discountedPricePerQuantity, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, + $this->shippingDetails instanceof ItemShippingDetailsBuilder ? $this->shippingDetails->build() : $this->shippingDetails, + $this->priceMode, + $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo ); } diff --git a/lib/commercetools-history/src/Models/Common/CustomLineItemModel.php b/lib/commercetools-history/src/Models/Common/CustomLineItemModel.php index ff8544d3523..2bd570129b0 100644 --- a/lib/commercetools-history/src/Models/Common/CustomLineItemModel.php +++ b/lib/commercetools-history/src/Models/Common/CustomLineItemModel.php @@ -27,6 +27,12 @@ final class CustomLineItemModel extends JsonObjectModel implements CustomLineIte */ protected $id; + /** + * + * @var ?string + */ + protected $key; + /** * * @var ?LocalizedString @@ -35,7 +41,7 @@ final class CustomLineItemModel extends JsonObjectModel implements CustomLineIte /** * - * @var ?Money + * @var ?TypedMoney */ protected $money; @@ -47,7 +53,13 @@ final class CustomLineItemModel extends JsonObjectModel implements CustomLineIte /** * - * @var ?Money + * @var ?MethodTaxedPriceCollection + */ + protected $taxedPricePortions; + + /** + * + * @var ?CentPrecisionMoney */ protected $totalPrice; @@ -63,31 +75,107 @@ final class CustomLineItemModel extends JsonObjectModel implements CustomLineIte */ protected $quantity; + /** + * + * @var ?ItemStateCollection + */ + protected $state; + + /** + * + * @var ?TaxCategoryReference + */ + protected $taxCategory; + + /** + * + * @var ?TaxRate + */ + protected $taxRate; + + /** + * + * @var ?MethodTaxRateCollection + */ + protected $perMethodTaxRate; + + /** + * + * @var ?DiscountedLineItemPriceForQuantityCollection + */ + protected $discountedPricePerQuantity; + + /** + * + * @var ?CustomFields + */ + protected $custom; + + /** + * + * @var ?ItemShippingDetails + */ + protected $shippingDetails; + + /** + * + * @var ?string + */ + protected $priceMode; + + /** + * + * @var ?CustomLineItemRecurrenceInfo + */ + protected $recurrenceInfo; + /** * @psalm-suppress MissingParamType */ public function __construct( ?string $id = null, + ?string $key = null, ?LocalizedString $name = null, - ?Money $money = null, + ?TypedMoney $money = null, ?TaxedItemPrice $taxedPrice = null, - ?Money $totalPrice = null, + ?MethodTaxedPriceCollection $taxedPricePortions = null, + ?CentPrecisionMoney $totalPrice = null, ?string $slug = null, - ?int $quantity = null + ?int $quantity = null, + ?ItemStateCollection $state = null, + ?TaxCategoryReference $taxCategory = null, + ?TaxRate $taxRate = null, + ?MethodTaxRateCollection $perMethodTaxRate = null, + ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity = null, + ?CustomFields $custom = null, + ?ItemShippingDetails $shippingDetails = null, + ?string $priceMode = null, + ?CustomLineItemRecurrenceInfo $recurrenceInfo = null ) { $this->id = $id; + $this->key = $key; $this->name = $name; $this->money = $money; $this->taxedPrice = $taxedPrice; + $this->taxedPricePortions = $taxedPricePortions; $this->totalPrice = $totalPrice; $this->slug = $slug; $this->quantity = $quantity; + $this->state = $state; + $this->taxCategory = $taxCategory; + $this->taxRate = $taxRate; + $this->perMethodTaxRate = $perMethodTaxRate; + $this->discountedPricePerQuantity = $discountedPricePerQuantity; + $this->custom = $custom; + $this->shippingDetails = $shippingDetails; + $this->priceMode = $priceMode; + $this->recurrenceInfo = $recurrenceInfo; } /** - *

                                                                                                                            The unique ID of this CustomLineItem.

                                                                                                                            + *

                                                                                                                            Unique identifier of the Custom Line Item.

                                                                                                                            * * * @return null|string @@ -107,6 +195,28 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the Custom Line Item.

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

                                                                                                                            Name of the Custom Line Item.

                                                                                                                            + * * * @return null|LocalizedString */ @@ -126,8 +236,10 @@ public function getName() } /** + *

                                                                                                                            Money value of the Custom Line Item.

                                                                                                                            + * * - * @return null|Money + * @return null|TypedMoney */ public function getMoney() { @@ -137,14 +249,16 @@ public function getMoney() if (is_null($data)) { return null; } - - $this->money = MoneyModel::of($data); + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->money = $className::of($data); } return $this->money; } /** + *

                                                                                                                            Automatically set after the taxRate is set.

                                                                                                                            + * * * @return null|TaxedItemPrice */ @@ -164,8 +278,33 @@ public function getTaxedPrice() } /** + *

                                                                                                                            Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. + * Automatically set after perMethodTaxRate is set.

                                                                                                                            + * + * + * @return null|MethodTaxedPriceCollection + */ + public function getTaxedPricePortions() + { + if (is_null($this->taxedPricePortions)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_TAXED_PRICE_PORTIONS); + if (is_null($data)) { + return null; + } + $this->taxedPricePortions = MethodTaxedPriceCollection::fromArray($data); + } + + return $this->taxedPricePortions; + } + + /** + *

                                                                                                                            Total price of the Custom Line Item (money multiplied by quantity). + * If the Custom Line Item is discounted, the total price is discountedPricePerQuantity multiplied by quantity.

                                                                                                                            + *

                                                                                                                            Includes taxes if the TaxRate includedInPrice is true.

                                                                                                                            + * * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalPrice() { @@ -176,14 +315,15 @@ public function getTotalPrice() return null; } - $this->totalPrice = MoneyModel::of($data); + $this->totalPrice = CentPrecisionMoneyModel::of($data); } return $this->totalPrice; } /** - *

                                                                                                                            A unique String in the cart to identify this CustomLineItem.

                                                                                                                            + *

                                                                                                                            User-defined identifier used in a deep-link URL for the Custom Line Item. + * It matches the pattern [a-zA-Z0-9_-]{2,256}.

                                                                                                                            * * * @return null|string @@ -203,7 +343,7 @@ public function getSlug() } /** - *

                                                                                                                            The amount of a CustomLineItem in the cart. Must be a positive integer.

                                                                                                                            + *

                                                                                                                            Number of Custom Line Items in the Cart or Order.

                                                                                                                            * * * @return null|int @@ -222,6 +362,195 @@ public function getQuantity() return $this->quantity; } + /** + *

                                                                                                                            Tracks specific quantities of the Custom Line Item within a given State. When a Custom Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Custom Line Items are managed on the Order.

                                                                                                                            + * + * + * @return null|ItemStateCollection + */ + public function getState() + { + if (is_null($this->state)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_STATE); + if (is_null($data)) { + return null; + } + $this->state = ItemStateCollection::fromArray($data); + } + + return $this->state; + } + + /** + *

                                                                                                                            Used to select a Tax Rate when a Cart has the Platform TaxMode.

                                                                                                                            + * + * + * @return null|TaxCategoryReference + */ + public function getTaxCategory() + { + if (is_null($this->taxCategory)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TAX_CATEGORY); + if (is_null($data)) { + return null; + } + + $this->taxCategory = TaxCategoryReferenceModel::of($data); + } + + return $this->taxCategory; + } + + /** + *
                                                                                                                              + *
                                                                                                                            • For a Cart with Platform TaxMode, the taxRate of Custom Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
                                                                                                                            • + *
                                                                                                                            • For a Cart with External TaxMode, the taxRate of Custom Line Items can be set using ExternalTaxRateDraft.
                                                                                                                            • + *
                                                                                                                            + * + * + * @return null|TaxRate + */ + public function getTaxRate() + { + if (is_null($this->taxRate)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TAX_RATE); + if (is_null($data)) { + return null; + } + + $this->taxRate = TaxRateModel::of($data); + } + + return $this->taxRate; + } + + /** + *

                                                                                                                            Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. + * For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

                                                                                                                            + * + * + * @return null|MethodTaxRateCollection + */ + public function getPerMethodTaxRate() + { + if (is_null($this->perMethodTaxRate)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_PER_METHOD_TAX_RATE); + if (is_null($data)) { + return null; + } + $this->perMethodTaxRate = MethodTaxRateCollection::fromArray($data); + } + + return $this->perMethodTaxRate; + } + + /** + *

                                                                                                                            Discounted price of a single quantity of the Custom Line Item.

                                                                                                                            + * + * + * @return null|DiscountedLineItemPriceForQuantityCollection + */ + public function getDiscountedPricePerQuantity() + { + if (is_null($this->discountedPricePerQuantity)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_DISCOUNTED_PRICE_PER_QUANTITY); + if (is_null($data)) { + return null; + } + $this->discountedPricePerQuantity = DiscountedLineItemPriceForQuantityCollection::fromArray($data); + } + + return $this->discountedPricePerQuantity; + } + + /** + *

                                                                                                                            Custom Fields of the Custom Line Item.

                                                                                                                            + * + * + * @return null|CustomFields + */ + public function getCustom() + { + if (is_null($this->custom)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($data)) { + return null; + } + + $this->custom = CustomFieldsModel::of($data); + } + + return $this->custom; + } + + /** + *

                                                                                                                            Container for Custom Line Item-specific addresses.

                                                                                                                            + * + * + * @return null|ItemShippingDetails + */ + public function getShippingDetails() + { + if (is_null($this->shippingDetails)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SHIPPING_DETAILS); + if (is_null($data)) { + return null; + } + + $this->shippingDetails = ItemShippingDetailsModel::of($data); + } + + return $this->shippingDetails; + } + + /** + *

                                                                                                                            Indicates whether Cart Discounts with a matching CartDiscountCustomLineItemsTarget, MultiBuyCustomLineItemsTarget, or CartDiscountPatternTarget are applied to the Custom Line Item.

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

                                                                                                                            Recurring Order and frequency data.

                                                                                                                            + * + * + * @return null|CustomLineItemRecurrenceInfo + */ + public function getRecurrenceInfo() + { + if (is_null($this->recurrenceInfo)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRENCE_INFO); + if (is_null($data)) { + return null; + } + + $this->recurrenceInfo = CustomLineItemRecurrenceInfoModel::of($data); + } + + return $this->recurrenceInfo; + } + /** * @param ?string $id @@ -231,6 +560,14 @@ public function setId(?string $id): void $this->id = $id; } + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + /** * @param ?LocalizedString $name */ @@ -240,9 +577,9 @@ public function setName(?LocalizedString $name): void } /** - * @param ?Money $money + * @param ?TypedMoney $money */ - public function setMoney(?Money $money): void + public function setMoney(?TypedMoney $money): void { $this->money = $money; } @@ -256,9 +593,17 @@ public function setTaxedPrice(?TaxedItemPrice $taxedPrice): void } /** - * @param ?Money $totalPrice + * @param ?MethodTaxedPriceCollection $taxedPricePortions + */ + public function setTaxedPricePortions(?MethodTaxedPriceCollection $taxedPricePortions): void + { + $this->taxedPricePortions = $taxedPricePortions; + } + + /** + * @param ?CentPrecisionMoney $totalPrice */ - public function setTotalPrice(?Money $totalPrice): void + public function setTotalPrice(?CentPrecisionMoney $totalPrice): void { $this->totalPrice = $totalPrice; } @@ -279,6 +624,78 @@ public function setQuantity(?int $quantity): void $this->quantity = $quantity; } + /** + * @param ?ItemStateCollection $state + */ + public function setState(?ItemStateCollection $state): void + { + $this->state = $state; + } + + /** + * @param ?TaxCategoryReference $taxCategory + */ + public function setTaxCategory(?TaxCategoryReference $taxCategory): void + { + $this->taxCategory = $taxCategory; + } + + /** + * @param ?TaxRate $taxRate + */ + public function setTaxRate(?TaxRate $taxRate): void + { + $this->taxRate = $taxRate; + } + + /** + * @param ?MethodTaxRateCollection $perMethodTaxRate + */ + public function setPerMethodTaxRate(?MethodTaxRateCollection $perMethodTaxRate): void + { + $this->perMethodTaxRate = $perMethodTaxRate; + } + + /** + * @param ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity + */ + public function setDiscountedPricePerQuantity(?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity): void + { + $this->discountedPricePerQuantity = $discountedPricePerQuantity; + } + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + + /** + * @param ?ItemShippingDetails $shippingDetails + */ + public function setShippingDetails(?ItemShippingDetails $shippingDetails): void + { + $this->shippingDetails = $shippingDetails; + } + + /** + * @param ?string $priceMode + */ + public function setPriceMode(?string $priceMode): void + { + $this->priceMode = $priceMode; + } + + /** + * @param ?CustomLineItemRecurrenceInfo $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfo $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } + } diff --git a/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfo.php b/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfo.php new file mode 100644 index 00000000000..29b0048062b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfo.php @@ -0,0 +1,31 @@ +Reference to a RecurrencePolicy.

                                                                                                                            + * + + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy(); + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy): void; +} diff --git a/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfoBuilder.php b/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfoBuilder.php new file mode 100644 index 00000000000..9f4f61d5a5f --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfoBuilder.php @@ -0,0 +1,73 @@ + + */ +final class CustomLineItemRecurrenceInfoBuilder implements Builder +{ + /** + + * @var null|RecurrencePolicyReference|RecurrencePolicyReferenceBuilder + */ + private $recurrencePolicy; + + /** + *

                                                                                                                            Reference to a RecurrencePolicy.

                                                                                                                            + * + + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy() + { + return $this->recurrencePolicy instanceof RecurrencePolicyReferenceBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy; + } + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + + /** + * @deprecated use withRecurrencePolicy() instead + * @return $this + */ + public function withRecurrencePolicyBuilder(?RecurrencePolicyReferenceBuilder $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + + public function build(): CustomLineItemRecurrenceInfo + { + return new CustomLineItemRecurrenceInfoModel( + $this->recurrencePolicy instanceof RecurrencePolicyReferenceBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy + ); + } + + public static function of(): CustomLineItemRecurrenceInfoBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfoCollection.php b/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfoCollection.php new file mode 100644 index 00000000000..63c6ba06c23 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfoCollection.php @@ -0,0 +1,56 @@ + + * @method CustomLineItemRecurrenceInfo current() + * @method CustomLineItemRecurrenceInfo end() + * @method CustomLineItemRecurrenceInfo at($offset) + */ +class CustomLineItemRecurrenceInfoCollection extends MapperSequence +{ + /** + * @psalm-assert CustomLineItemRecurrenceInfo $value + * @psalm-param CustomLineItemRecurrenceInfo|stdClass $value + * @throws InvalidArgumentException + * + * @return CustomLineItemRecurrenceInfoCollection + */ + public function add($value) + { + if (!$value instanceof CustomLineItemRecurrenceInfo) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CustomLineItemRecurrenceInfo + */ + protected function mapper() + { + return function (?int $index): ?CustomLineItemRecurrenceInfo { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CustomLineItemRecurrenceInfo $data */ + $data = CustomLineItemRecurrenceInfoModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfoModel.php b/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfoModel.php new file mode 100644 index 00000000000..1bdd578fd04 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomLineItemRecurrenceInfoModel.php @@ -0,0 +1,73 @@ +recurrencePolicy = $recurrencePolicy; + + } + + /** + *

                                                                                                                            Reference to a RecurrencePolicy.

                                                                                                                            + * + * + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy() + { + if (is_null($this->recurrencePolicy)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRENCE_POLICY); + if (is_null($data)) { + return null; + } + + $this->recurrencePolicy = RecurrencePolicyReferenceModel::of($data); + } + + return $this->recurrencePolicy; + } + + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy): void + { + $this->recurrencePolicy = $recurrencePolicy; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerGroupAssignment.php b/lib/commercetools-history/src/Models/Common/CustomerGroupAssignment.php new file mode 100644 index 00000000000..7765311f8af --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerGroupAssignment.php @@ -0,0 +1,31 @@ +Reference to a Customer Group.

                                                                                                                            + * + + * @return null|CustomerGroupReference + */ + public function getCustomerGroup(); + + /** + * @param ?CustomerGroupReference $customerGroup + */ + public function setCustomerGroup(?CustomerGroupReference $customerGroup): void; +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerGroupAssignmentBuilder.php b/lib/commercetools-history/src/Models/Common/CustomerGroupAssignmentBuilder.php new file mode 100644 index 00000000000..25bb4f83c7c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerGroupAssignmentBuilder.php @@ -0,0 +1,73 @@ + + */ +final class CustomerGroupAssignmentBuilder implements Builder +{ + /** + + * @var null|CustomerGroupReference|CustomerGroupReferenceBuilder + */ + private $customerGroup; + + /** + *

                                                                                                                            Reference to a Customer Group.

                                                                                                                            + * + + * @return null|CustomerGroupReference + */ + public function getCustomerGroup() + { + return $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup; + } + + /** + * @param ?CustomerGroupReference $customerGroup + * @return $this + */ + public function withCustomerGroup(?CustomerGroupReference $customerGroup) + { + $this->customerGroup = $customerGroup; + + return $this; + } + + /** + * @deprecated use withCustomerGroup() instead + * @return $this + */ + public function withCustomerGroupBuilder(?CustomerGroupReferenceBuilder $customerGroup) + { + $this->customerGroup = $customerGroup; + + return $this; + } + + public function build(): CustomerGroupAssignment + { + return new CustomerGroupAssignmentModel( + $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup + ); + } + + public static function of(): CustomerGroupAssignmentBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerGroupAssignmentCollection.php b/lib/commercetools-history/src/Models/Common/CustomerGroupAssignmentCollection.php new file mode 100644 index 00000000000..0988e6858ee --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerGroupAssignmentCollection.php @@ -0,0 +1,56 @@ + + * @method CustomerGroupAssignment current() + * @method CustomerGroupAssignment end() + * @method CustomerGroupAssignment at($offset) + */ +class CustomerGroupAssignmentCollection extends MapperSequence +{ + /** + * @psalm-assert CustomerGroupAssignment $value + * @psalm-param CustomerGroupAssignment|stdClass $value + * @throws InvalidArgumentException + * + * @return CustomerGroupAssignmentCollection + */ + public function add($value) + { + if (!$value instanceof CustomerGroupAssignment) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CustomerGroupAssignment + */ + protected function mapper() + { + return function (?int $index): ?CustomerGroupAssignment { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CustomerGroupAssignment $data */ + $data = CustomerGroupAssignmentModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerGroupAssignmentModel.php b/lib/commercetools-history/src/Models/Common/CustomerGroupAssignmentModel.php new file mode 100644 index 00000000000..0fd27314090 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerGroupAssignmentModel.php @@ -0,0 +1,73 @@ +customerGroup = $customerGroup; + + } + + /** + *

                                                                                                                            Reference to a Customer Group.

                                                                                                                            + * + * + * @return null|CustomerGroupReference + */ + public function getCustomerGroup() + { + if (is_null($this->customerGroup)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOMER_GROUP); + if (is_null($data)) { + return null; + } + + $this->customerGroup = CustomerGroupReferenceModel::of($data); + } + + return $this->customerGroup; + } + + + /** + * @param ?CustomerGroupReference $customerGroup + */ + public function setCustomerGroup(?CustomerGroupReference $customerGroup): void + { + $this->customerGroup = $customerGroup; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerGroupReference.php b/lib/commercetools-history/src/Models/Common/CustomerGroupReference.php new file mode 100644 index 00000000000..2b7b8f0ed44 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerGroupReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced CustomerGroup.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerGroupReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/CustomerGroupReferenceBuilder.php new file mode 100644 index 00000000000..8e010181189 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerGroupReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class CustomerGroupReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced CustomerGroup.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): CustomerGroupReference + { + return new CustomerGroupReferenceModel( + $this->id + ); + } + + public static function of(): CustomerGroupReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerGroupReferenceCollection.php b/lib/commercetools-history/src/Models/Common/CustomerGroupReferenceCollection.php new file mode 100644 index 00000000000..61b16177100 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerGroupReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method CustomerGroupReference current() + * @method CustomerGroupReference end() + * @method CustomerGroupReference at($offset) + */ +class CustomerGroupReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert CustomerGroupReference $value + * @psalm-param CustomerGroupReference|stdClass $value + * @throws InvalidArgumentException + * + * @return CustomerGroupReferenceCollection + */ + public function add($value) + { + if (!$value instanceof CustomerGroupReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CustomerGroupReference + */ + protected function mapper() + { + return function (?int $index): ?CustomerGroupReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CustomerGroupReference $data */ + $data = CustomerGroupReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerGroupReferenceModel.php b/lib/commercetools-history/src/Models/Common/CustomerGroupReferenceModel.php new file mode 100644 index 00000000000..36f8a9eb385 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerGroupReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced CustomerGroup.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerReference.php b/lib/commercetools-history/src/Models/Common/CustomerReference.php new file mode 100644 index 00000000000..1eba21e6d92 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced Customer.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/CustomerReferenceBuilder.php new file mode 100644 index 00000000000..21aae581588 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class CustomerReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced Customer.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): CustomerReference + { + return new CustomerReferenceModel( + $this->id + ); + } + + public static function of(): CustomerReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerReferenceCollection.php b/lib/commercetools-history/src/Models/Common/CustomerReferenceCollection.php new file mode 100644 index 00000000000..c6b0dbff278 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method CustomerReference current() + * @method CustomerReference end() + * @method CustomerReference at($offset) + */ +class CustomerReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert CustomerReference $value + * @psalm-param CustomerReference|stdClass $value + * @throws InvalidArgumentException + * + * @return CustomerReferenceCollection + */ + public function add($value) + { + if (!$value instanceof CustomerReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CustomerReference + */ + protected function mapper() + { + return function (?int $index): ?CustomerReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CustomerReference $data */ + $data = CustomerReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/CustomerReferenceModel.php b/lib/commercetools-history/src/Models/Common/CustomerReferenceModel.php new file mode 100644 index 00000000000..5c44463e2ee --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/CustomerReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced Customer.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/Delivery.php b/lib/commercetools-history/src/Models/Common/Delivery.php index 7ad32aa985f..91316f84c36 100644 --- a/lib/commercetools-history/src/Models/Common/Delivery.php +++ b/lib/commercetools-history/src/Models/Common/Delivery.php @@ -10,11 +10,13 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use DateTimeImmutable; interface Delivery extends JsonObject { public const FIELD_ID = 'id'; + public const FIELD_KEY = 'key'; public const FIELD_CREATED_AT = 'createdAt'; public const FIELD_ITEMS = 'items'; public const FIELD_PARCELS = 'parcels'; @@ -22,37 +24,55 @@ interface Delivery extends JsonObject public const FIELD_CUSTOM = 'custom'; /** + *

                                                                                                                            Unique identifier of the Delivery.

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

                                                                                                                            User-defined unique identifier of the Delivery.

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

                                                                                                                            Date and time (UTC) the Delivery was created.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ public function getCreatedAt(); /** + *

                                                                                                                            Line Items or Custom Line Items that are delivered.

                                                                                                                            + * * @return null|DeliveryItemCollection */ public function getItems(); /** + *

                                                                                                                            Information regarding the appearance, content, and shipment of a Parcel.

                                                                                                                            + * * @return null|ParcelCollection */ public function getParcels(); /** + *

                                                                                                                            Address to which Parcels are delivered.

                                                                                                                            + * * @return null|Address */ public function getAddress(); /** - *

                                                                                                                            Custom Fields for the Transaction.

                                                                                                                            + *

                                                                                                                            Custom Fields of the Delivery.

                                                                                                                            * * @return null|CustomFields @@ -65,9 +85,14 @@ public function getCustom(); public function setId(?string $id): void; /** - * @param ?string $createdAt + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?DateTimeImmutable $createdAt */ - public function setCreatedAt(?string $createdAt): void; + public function setCreatedAt(?DateTimeImmutable $createdAt): void; /** * @param ?DeliveryItemCollection $items diff --git a/lib/commercetools-history/src/Models/Common/DeliveryBuilder.php b/lib/commercetools-history/src/Models/Common/DeliveryBuilder.php index da697682f31..45af51bc742 100644 --- a/lib/commercetools-history/src/Models/Common/DeliveryBuilder.php +++ b/lib/commercetools-history/src/Models/Common/DeliveryBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @implements Builder @@ -30,6 +31,12 @@ final class DeliveryBuilder implements Builder * @var ?string */ + private $key; + + /** + + * @var ?DateTimeImmutable + */ private $createdAt; /** @@ -57,6 +64,8 @@ final class DeliveryBuilder implements Builder private $custom; /** + *

                                                                                                                            Unique identifier of the Delivery.

                                                                                                                            + * * @return null|string */ @@ -66,15 +75,30 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the Delivery.

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

                                                                                                                            Date and time (UTC) the Delivery was created.

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

                                                                                                                            Line Items or Custom Line Items that are delivered.

                                                                                                                            + * * @return null|DeliveryItemCollection */ @@ -84,6 +108,8 @@ public function getItems() } /** + *

                                                                                                                            Information regarding the appearance, content, and shipment of a Parcel.

                                                                                                                            + * * @return null|ParcelCollection */ @@ -93,6 +119,8 @@ public function getParcels() } /** + *

                                                                                                                            Address to which Parcels are delivered.

                                                                                                                            + * * @return null|Address */ @@ -102,7 +130,7 @@ public function getAddress() } /** - *

                                                                                                                            Custom Fields for the Transaction.

                                                                                                                            + *

                                                                                                                            Custom Fields of the Delivery.

                                                                                                                            * * @return null|CustomFields @@ -124,10 +152,21 @@ public function withId(?string $id) } /** - * @param ?string $createdAt + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt * @return $this */ - public function withCreatedAt(?string $createdAt) + public function withCreatedAt(?DateTimeImmutable $createdAt) { $this->createdAt = $createdAt; @@ -204,6 +243,7 @@ public function build(): Delivery { return new DeliveryModel( $this->id, + $this->key, $this->createdAt, $this->items, $this->parcels, diff --git a/lib/commercetools-history/src/Models/Common/DeliveryItem.php b/lib/commercetools-history/src/Models/Common/DeliveryItem.php index 4896bd7e4a1..0ffd24d7315 100644 --- a/lib/commercetools-history/src/Models/Common/DeliveryItem.php +++ b/lib/commercetools-history/src/Models/Common/DeliveryItem.php @@ -18,12 +18,16 @@ interface DeliveryItem extends JsonObject public const FIELD_QUANTITY = 'quantity'; /** + *

                                                                                                                            id of the LineItem or CustomLineItem delivered.

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

                                                                                                                            Number of Line Items or Custom Line Items delivered.

                                                                                                                            + * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/DeliveryItemBuilder.php b/lib/commercetools-history/src/Models/Common/DeliveryItemBuilder.php index 7d54ddf58e6..44e57750d8a 100644 --- a/lib/commercetools-history/src/Models/Common/DeliveryItemBuilder.php +++ b/lib/commercetools-history/src/Models/Common/DeliveryItemBuilder.php @@ -33,6 +33,8 @@ final class DeliveryItemBuilder implements Builder private $quantity; /** + *

                                                                                                                            id of the LineItem or CustomLineItem delivered.

                                                                                                                            + * * @return null|string */ @@ -42,6 +44,8 @@ public function getId() } /** + *

                                                                                                                            Number of Line Items or Custom Line Items delivered.

                                                                                                                            + * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/DeliveryItemModel.php b/lib/commercetools-history/src/Models/Common/DeliveryItemModel.php index 24ca9af5302..ecb28128259 100644 --- a/lib/commercetools-history/src/Models/Common/DeliveryItemModel.php +++ b/lib/commercetools-history/src/Models/Common/DeliveryItemModel.php @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            id of the LineItem or CustomLineItem delivered.

                                                                                                                            + * * * @return null|string */ @@ -65,6 +67,8 @@ public function getId() } /** + *

                                                                                                                            Number of Line Items or Custom Line Items delivered.

                                                                                                                            + * * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/DeliveryModel.php b/lib/commercetools-history/src/Models/Common/DeliveryModel.php index 81973bcc685..bec97304d61 100644 --- a/lib/commercetools-history/src/Models/Common/DeliveryModel.php +++ b/lib/commercetools-history/src/Models/Common/DeliveryModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @internal @@ -31,6 +32,12 @@ final class DeliveryModel extends JsonObjectModel implements Delivery * * @var ?string */ + protected $key; + + /** + * + * @var ?DateTimeImmutable + */ protected $createdAt; /** @@ -63,13 +70,15 @@ final class DeliveryModel extends JsonObjectModel implements Delivery */ public function __construct( ?string $id = null, - ?string $createdAt = null, + ?string $key = null, + ?DateTimeImmutable $createdAt = null, ?DeliveryItemCollection $items = null, ?ParcelCollection $parcels = null, ?Address $address = null, ?CustomFields $custom = null ) { $this->id = $id; + $this->key = $key; $this->createdAt = $createdAt; $this->items = $items; $this->parcels = $parcels; @@ -79,6 +88,8 @@ public function __construct( } /** + *

                                                                                                                            Unique identifier of the Delivery.

                                                                                                                            + * * * @return null|string */ @@ -97,9 +108,31 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the Delivery.

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

                                                                                                                            Date and time (UTC) the Delivery was created.

                                                                                                                            + * + * + * @return null|DateTimeImmutable + */ public function getCreatedAt() { if (is_null($this->createdAt)) { @@ -108,13 +141,19 @@ public function getCreatedAt() if (is_null($data)) { return null; } - $this->createdAt = (string) $data; + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; } return $this->createdAt; } /** + *

                                                                                                                            Line Items or Custom Line Items that are delivered.

                                                                                                                            + * * * @return null|DeliveryItemCollection */ @@ -133,6 +172,8 @@ public function getItems() } /** + *

                                                                                                                            Information regarding the appearance, content, and shipment of a Parcel.

                                                                                                                            + * * * @return null|ParcelCollection */ @@ -151,6 +192,8 @@ public function getParcels() } /** + *

                                                                                                                            Address to which Parcels are delivered.

                                                                                                                            + * * * @return null|Address */ @@ -170,7 +213,7 @@ public function getAddress() } /** - *

                                                                                                                            Custom Fields for the Transaction.

                                                                                                                            + *

                                                                                                                            Custom Fields of the Delivery.

                                                                                                                            * * * @return null|CustomFields @@ -200,9 +243,17 @@ public function setId(?string $id): void } /** - * @param ?string $createdAt + * @param ?string $key */ - public function setCreatedAt(?string $createdAt): void + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void { $this->createdAt = $createdAt; } @@ -240,5 +291,14 @@ public function setCustom(?CustomFields $custom): void } + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Delivery::FIELD_CREATED_AT]) && $data[Delivery::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Delivery::FIELD_CREATED_AT] = $data[Delivery::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } } diff --git a/lib/commercetools-history/src/Models/Common/DiscountCodeInfo.php b/lib/commercetools-history/src/Models/Common/DiscountCodeInfo.php index f393085ad4e..1ad017e33ae 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountCodeInfo.php +++ b/lib/commercetools-history/src/Models/Common/DiscountCodeInfo.php @@ -18,21 +18,25 @@ interface DiscountCodeInfo extends JsonObject public const FIELD_STATE = 'state'; /** + *

                                                                                                                            Discount Code associated with the Cart or Order.

                                                                                                                            + * - * @return null|Reference + * @return null|DiscountCodeReference */ public function getDiscountCode(); /** + *

                                                                                                                            Indicates the state of the Discount Code applied to the Cart or Order.

                                                                                                                            + * * @return null|string */ public function getState(); /** - * @param ?Reference $discountCode + * @param ?DiscountCodeReference $discountCode */ - public function setDiscountCode(?Reference $discountCode): void; + public function setDiscountCode(?DiscountCodeReference $discountCode): void; /** * @param ?string $state diff --git a/lib/commercetools-history/src/Models/Common/DiscountCodeInfoBuilder.php b/lib/commercetools-history/src/Models/Common/DiscountCodeInfoBuilder.php index 2ca2f55fe1b..14bd4b53f39 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountCodeInfoBuilder.php +++ b/lib/commercetools-history/src/Models/Common/DiscountCodeInfoBuilder.php @@ -22,7 +22,7 @@ final class DiscountCodeInfoBuilder implements Builder { /** - * @var null|Reference|ReferenceBuilder + * @var null|DiscountCodeReference|DiscountCodeReferenceBuilder */ private $discountCode; @@ -33,15 +33,19 @@ final class DiscountCodeInfoBuilder implements Builder private $state; /** + *

                                                                                                                            Discount Code associated with the Cart or Order.

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

                                                                                                                            Indicates the state of the Discount Code applied to the Cart or Order.

                                                                                                                            + * * @return null|string */ @@ -51,10 +55,10 @@ public function getState() } /** - * @param ?Reference $discountCode + * @param ?DiscountCodeReference $discountCode * @return $this */ - public function withDiscountCode(?Reference $discountCode) + public function withDiscountCode(?DiscountCodeReference $discountCode) { $this->discountCode = $discountCode; @@ -76,7 +80,7 @@ public function withState(?string $state) * @deprecated use withDiscountCode() instead * @return $this */ - public function withDiscountCodeBuilder(?ReferenceBuilder $discountCode) + public function withDiscountCodeBuilder(?DiscountCodeReferenceBuilder $discountCode) { $this->discountCode = $discountCode; @@ -86,7 +90,7 @@ public function withDiscountCodeBuilder(?ReferenceBuilder $discountCode) public function build(): DiscountCodeInfo { return new DiscountCodeInfoModel( - $this->discountCode instanceof ReferenceBuilder ? $this->discountCode->build() : $this->discountCode, + $this->discountCode instanceof DiscountCodeReferenceBuilder ? $this->discountCode->build() : $this->discountCode, $this->state ); } diff --git a/lib/commercetools-history/src/Models/Common/DiscountCodeInfoModel.php b/lib/commercetools-history/src/Models/Common/DiscountCodeInfoModel.php index 78b7142f6e1..5d9121c88bc 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountCodeInfoModel.php +++ b/lib/commercetools-history/src/Models/Common/DiscountCodeInfoModel.php @@ -23,7 +23,7 @@ final class DiscountCodeInfoModel extends JsonObjectModel implements DiscountCod /** * - * @var ?Reference + * @var ?DiscountCodeReference */ protected $discountCode; @@ -38,7 +38,7 @@ final class DiscountCodeInfoModel extends JsonObjectModel implements DiscountCod * @psalm-suppress MissingParamType */ public function __construct( - ?Reference $discountCode = null, + ?DiscountCodeReference $discountCode = null, ?string $state = null ) { $this->discountCode = $discountCode; @@ -47,8 +47,10 @@ public function __construct( } /** + *

                                                                                                                            Discount Code associated with the Cart or Order.

                                                                                                                            * - * @return null|Reference + * + * @return null|DiscountCodeReference */ public function getDiscountCode() { @@ -59,13 +61,15 @@ public function getDiscountCode() return null; } - $this->discountCode = ReferenceModel::of($data); + $this->discountCode = DiscountCodeReferenceModel::of($data); } return $this->discountCode; } /** + *

                                                                                                                            Indicates the state of the Discount Code applied to the Cart or Order.

                                                                                                                            + * * * @return null|string */ @@ -85,9 +89,9 @@ public function getState() /** - * @param ?Reference $discountCode + * @param ?DiscountCodeReference $discountCode */ - public function setDiscountCode(?Reference $discountCode): void + public function setDiscountCode(?DiscountCodeReference $discountCode): void { $this->discountCode = $discountCode; } diff --git a/lib/commercetools-history/src/Models/Common/DiscountCodeReference.php b/lib/commercetools-history/src/Models/Common/DiscountCodeReference.php new file mode 100644 index 00000000000..88f06537a56 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountCodeReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced DiscountCode.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountCodeReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/DiscountCodeReferenceBuilder.php new file mode 100644 index 00000000000..18e27943fa4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountCodeReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class DiscountCodeReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced DiscountCode.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): DiscountCodeReference + { + return new DiscountCodeReferenceModel( + $this->id + ); + } + + public static function of(): DiscountCodeReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountCodeReferenceCollection.php b/lib/commercetools-history/src/Models/Common/DiscountCodeReferenceCollection.php new file mode 100644 index 00000000000..6629b17150f --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountCodeReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method DiscountCodeReference current() + * @method DiscountCodeReference end() + * @method DiscountCodeReference at($offset) + */ +class DiscountCodeReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert DiscountCodeReference $value + * @psalm-param DiscountCodeReference|stdClass $value + * @throws InvalidArgumentException + * + * @return DiscountCodeReferenceCollection + */ + public function add($value) + { + if (!$value instanceof DiscountCodeReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?DiscountCodeReference + */ + protected function mapper() + { + return function (?int $index): ?DiscountCodeReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var DiscountCodeReference $data */ + $data = DiscountCodeReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountCodeReferenceModel.php b/lib/commercetools-history/src/Models/Common/DiscountCodeReferenceModel.php new file mode 100644 index 00000000000..9f42335ef7b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountCodeReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced DiscountCode.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountOnTotalPrice.php b/lib/commercetools-history/src/Models/Common/DiscountOnTotalPrice.php new file mode 100644 index 00000000000..6d89a85a4b5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountOnTotalPrice.php @@ -0,0 +1,77 @@ +Money value of the discount on the total price of the Cart or Order.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getDiscountedAmount(); + + /** + *

                                                                                                                            Discounts that impact the total price of the Cart or Order.

                                                                                                                            + * + + * @return null|DiscountedTotalPricePortionCollection + */ + public function getIncludedDiscounts(); + + /** + *

                                                                                                                            Money value of the discount on the total net price of the Cart or Order.

                                                                                                                            + *

                                                                                                                            The same percentage of discount applies as on the discountedAmount. + * Present only when taxedPrice of the Cart or Order exists.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getDiscountedNetAmount(); + + /** + *

                                                                                                                            Money value of the discount on the total gross price of the Cart or Order.

                                                                                                                            + *

                                                                                                                            The same percentage of discount applies as on the discountedAmount. + * Present only when taxedPrice of the Cart or Order exists.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getDiscountedGrossAmount(); + + /** + * @param ?TypedMoney $discountedAmount + */ + public function setDiscountedAmount(?TypedMoney $discountedAmount): void; + + /** + * @param ?DiscountedTotalPricePortionCollection $includedDiscounts + */ + public function setIncludedDiscounts(?DiscountedTotalPricePortionCollection $includedDiscounts): void; + + /** + * @param ?TypedMoney $discountedNetAmount + */ + public function setDiscountedNetAmount(?TypedMoney $discountedNetAmount): void; + + /** + * @param ?TypedMoney $discountedGrossAmount + */ + public function setDiscountedGrossAmount(?TypedMoney $discountedGrossAmount): void; +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountOnTotalPriceBuilder.php b/lib/commercetools-history/src/Models/Common/DiscountOnTotalPriceBuilder.php new file mode 100644 index 00000000000..f7a6f5f680c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountOnTotalPriceBuilder.php @@ -0,0 +1,186 @@ + + */ +final class DiscountOnTotalPriceBuilder implements Builder +{ + /** + + * @var null|TypedMoney|TypedMoneyBuilder + */ + private $discountedAmount; + + /** + + * @var ?DiscountedTotalPricePortionCollection + */ + private $includedDiscounts; + + /** + + * @var null|TypedMoney|TypedMoneyBuilder + */ + private $discountedNetAmount; + + /** + + * @var null|TypedMoney|TypedMoneyBuilder + */ + private $discountedGrossAmount; + + /** + *

                                                                                                                            Money value of the discount on the total price of the Cart or Order.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getDiscountedAmount() + { + return $this->discountedAmount instanceof TypedMoneyBuilder ? $this->discountedAmount->build() : $this->discountedAmount; + } + + /** + *

                                                                                                                            Discounts that impact the total price of the Cart or Order.

                                                                                                                            + * + + * @return null|DiscountedTotalPricePortionCollection + */ + public function getIncludedDiscounts() + { + return $this->includedDiscounts; + } + + /** + *

                                                                                                                            Money value of the discount on the total net price of the Cart or Order.

                                                                                                                            + *

                                                                                                                            The same percentage of discount applies as on the discountedAmount. + * Present only when taxedPrice of the Cart or Order exists.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getDiscountedNetAmount() + { + return $this->discountedNetAmount instanceof TypedMoneyBuilder ? $this->discountedNetAmount->build() : $this->discountedNetAmount; + } + + /** + *

                                                                                                                            Money value of the discount on the total gross price of the Cart or Order.

                                                                                                                            + *

                                                                                                                            The same percentage of discount applies as on the discountedAmount. + * Present only when taxedPrice of the Cart or Order exists.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getDiscountedGrossAmount() + { + return $this->discountedGrossAmount instanceof TypedMoneyBuilder ? $this->discountedGrossAmount->build() : $this->discountedGrossAmount; + } + + /** + * @param ?TypedMoney $discountedAmount + * @return $this + */ + public function withDiscountedAmount(?TypedMoney $discountedAmount) + { + $this->discountedAmount = $discountedAmount; + + return $this; + } + + /** + * @param ?DiscountedTotalPricePortionCollection $includedDiscounts + * @return $this + */ + public function withIncludedDiscounts(?DiscountedTotalPricePortionCollection $includedDiscounts) + { + $this->includedDiscounts = $includedDiscounts; + + return $this; + } + + /** + * @param ?TypedMoney $discountedNetAmount + * @return $this + */ + public function withDiscountedNetAmount(?TypedMoney $discountedNetAmount) + { + $this->discountedNetAmount = $discountedNetAmount; + + return $this; + } + + /** + * @param ?TypedMoney $discountedGrossAmount + * @return $this + */ + public function withDiscountedGrossAmount(?TypedMoney $discountedGrossAmount) + { + $this->discountedGrossAmount = $discountedGrossAmount; + + return $this; + } + + /** + * @deprecated use withDiscountedAmount() instead + * @return $this + */ + public function withDiscountedAmountBuilder(?TypedMoneyBuilder $discountedAmount) + { + $this->discountedAmount = $discountedAmount; + + return $this; + } + + /** + * @deprecated use withDiscountedNetAmount() instead + * @return $this + */ + public function withDiscountedNetAmountBuilder(?TypedMoneyBuilder $discountedNetAmount) + { + $this->discountedNetAmount = $discountedNetAmount; + + return $this; + } + + /** + * @deprecated use withDiscountedGrossAmount() instead + * @return $this + */ + public function withDiscountedGrossAmountBuilder(?TypedMoneyBuilder $discountedGrossAmount) + { + $this->discountedGrossAmount = $discountedGrossAmount; + + return $this; + } + + public function build(): DiscountOnTotalPrice + { + return new DiscountOnTotalPriceModel( + $this->discountedAmount instanceof TypedMoneyBuilder ? $this->discountedAmount->build() : $this->discountedAmount, + $this->includedDiscounts, + $this->discountedNetAmount instanceof TypedMoneyBuilder ? $this->discountedNetAmount->build() : $this->discountedNetAmount, + $this->discountedGrossAmount instanceof TypedMoneyBuilder ? $this->discountedGrossAmount->build() : $this->discountedGrossAmount + ); + } + + public static function of(): DiscountOnTotalPriceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountOnTotalPriceCollection.php b/lib/commercetools-history/src/Models/Common/DiscountOnTotalPriceCollection.php new file mode 100644 index 00000000000..b7974e912e8 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountOnTotalPriceCollection.php @@ -0,0 +1,56 @@ + + * @method DiscountOnTotalPrice current() + * @method DiscountOnTotalPrice end() + * @method DiscountOnTotalPrice at($offset) + */ +class DiscountOnTotalPriceCollection extends MapperSequence +{ + /** + * @psalm-assert DiscountOnTotalPrice $value + * @psalm-param DiscountOnTotalPrice|stdClass $value + * @throws InvalidArgumentException + * + * @return DiscountOnTotalPriceCollection + */ + public function add($value) + { + if (!$value instanceof DiscountOnTotalPrice) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?DiscountOnTotalPrice + */ + protected function mapper() + { + return function (?int $index): ?DiscountOnTotalPrice { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var DiscountOnTotalPrice $data */ + $data = DiscountOnTotalPriceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountOnTotalPriceModel.php b/lib/commercetools-history/src/Models/Common/DiscountOnTotalPriceModel.php new file mode 100644 index 00000000000..69254e344cc --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountOnTotalPriceModel.php @@ -0,0 +1,187 @@ +discountedAmount = $discountedAmount; + $this->includedDiscounts = $includedDiscounts; + $this->discountedNetAmount = $discountedNetAmount; + $this->discountedGrossAmount = $discountedGrossAmount; + + } + + /** + *

                                                                                                                            Money value of the discount on the total price of the Cart or Order.

                                                                                                                            + * + * + * @return null|TypedMoney + */ + public function getDiscountedAmount() + { + if (is_null($this->discountedAmount)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DISCOUNTED_AMOUNT); + if (is_null($data)) { + return null; + } + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->discountedAmount = $className::of($data); + } + + return $this->discountedAmount; + } + + /** + *

                                                                                                                            Discounts that impact the total price of the Cart or Order.

                                                                                                                            + * + * + * @return null|DiscountedTotalPricePortionCollection + */ + public function getIncludedDiscounts() + { + if (is_null($this->includedDiscounts)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_INCLUDED_DISCOUNTS); + if (is_null($data)) { + return null; + } + $this->includedDiscounts = DiscountedTotalPricePortionCollection::fromArray($data); + } + + return $this->includedDiscounts; + } + + /** + *

                                                                                                                            Money value of the discount on the total net price of the Cart or Order.

                                                                                                                            + *

                                                                                                                            The same percentage of discount applies as on the discountedAmount. + * Present only when taxedPrice of the Cart or Order exists.

                                                                                                                            + * + * + * @return null|TypedMoney + */ + public function getDiscountedNetAmount() + { + if (is_null($this->discountedNetAmount)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DISCOUNTED_NET_AMOUNT); + if (is_null($data)) { + return null; + } + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->discountedNetAmount = $className::of($data); + } + + return $this->discountedNetAmount; + } + + /** + *

                                                                                                                            Money value of the discount on the total gross price of the Cart or Order.

                                                                                                                            + *

                                                                                                                            The same percentage of discount applies as on the discountedAmount. + * Present only when taxedPrice of the Cart or Order exists.

                                                                                                                            + * + * + * @return null|TypedMoney + */ + public function getDiscountedGrossAmount() + { + if (is_null($this->discountedGrossAmount)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DISCOUNTED_GROSS_AMOUNT); + if (is_null($data)) { + return null; + } + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->discountedGrossAmount = $className::of($data); + } + + return $this->discountedGrossAmount; + } + + + /** + * @param ?TypedMoney $discountedAmount + */ + public function setDiscountedAmount(?TypedMoney $discountedAmount): void + { + $this->discountedAmount = $discountedAmount; + } + + /** + * @param ?DiscountedTotalPricePortionCollection $includedDiscounts + */ + public function setIncludedDiscounts(?DiscountedTotalPricePortionCollection $includedDiscounts): void + { + $this->includedDiscounts = $includedDiscounts; + } + + /** + * @param ?TypedMoney $discountedNetAmount + */ + public function setDiscountedNetAmount(?TypedMoney $discountedNetAmount): void + { + $this->discountedNetAmount = $discountedNetAmount; + } + + /** + * @param ?TypedMoney $discountedGrossAmount + */ + public function setDiscountedGrossAmount(?TypedMoney $discountedGrossAmount): void + { + $this->discountedGrossAmount = $discountedGrossAmount; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortion.php b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortion.php index 9368c80476b..35596a4eefc 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortion.php +++ b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortion.php @@ -18,14 +18,18 @@ interface DiscountedLineItemPortion extends JsonObject public const FIELD_DISCOUNTED_AMOUNT = 'discountedAmount'; /** + *

                                                                                                                            A CartDiscountReference or DirectDiscountReference of the applicable discount on the Line Item.

                                                                                                                            + * * @return null|Reference */ public function getDiscount(); /** + *

                                                                                                                            Money value of the applicable discount.

                                                                                                                            + * - * @return null|Money + * @return null|TypedMoney */ public function getDiscountedAmount(); @@ -35,7 +39,7 @@ public function getDiscountedAmount(); public function setDiscount(?Reference $discount): void; /** - * @param ?Money $discountedAmount + * @param ?TypedMoney $discountedAmount */ - public function setDiscountedAmount(?Money $discountedAmount): void; + public function setDiscountedAmount(?TypedMoney $discountedAmount): void; } diff --git a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortionBuilder.php b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortionBuilder.php index 4b71bc061d2..22b25820296 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortionBuilder.php +++ b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortionBuilder.php @@ -28,11 +28,13 @@ final class DiscountedLineItemPortionBuilder implements Builder /** - * @var null|Money|MoneyBuilder + * @var null|TypedMoney|TypedMoneyBuilder */ private $discountedAmount; /** + *

                                                                                                                            A CartDiscountReference or DirectDiscountReference of the applicable discount on the Line Item.

                                                                                                                            + * * @return null|Reference */ @@ -42,12 +44,14 @@ public function getDiscount() } /** + *

                                                                                                                            Money value of the applicable discount.

                                                                                                                            + * - * @return null|Money + * @return null|TypedMoney */ public function getDiscountedAmount() { - return $this->discountedAmount instanceof MoneyBuilder ? $this->discountedAmount->build() : $this->discountedAmount; + return $this->discountedAmount instanceof TypedMoneyBuilder ? $this->discountedAmount->build() : $this->discountedAmount; } /** @@ -62,10 +66,10 @@ public function withDiscount(?Reference $discount) } /** - * @param ?Money $discountedAmount + * @param ?TypedMoney $discountedAmount * @return $this */ - public function withDiscountedAmount(?Money $discountedAmount) + public function withDiscountedAmount(?TypedMoney $discountedAmount) { $this->discountedAmount = $discountedAmount; @@ -87,7 +91,7 @@ public function withDiscountBuilder(?ReferenceBuilder $discount) * @deprecated use withDiscountedAmount() instead * @return $this */ - public function withDiscountedAmountBuilder(?MoneyBuilder $discountedAmount) + public function withDiscountedAmountBuilder(?TypedMoneyBuilder $discountedAmount) { $this->discountedAmount = $discountedAmount; @@ -98,7 +102,7 @@ public function build(): DiscountedLineItemPortion { return new DiscountedLineItemPortionModel( $this->discount instanceof ReferenceBuilder ? $this->discount->build() : $this->discount, - $this->discountedAmount instanceof MoneyBuilder ? $this->discountedAmount->build() : $this->discountedAmount + $this->discountedAmount instanceof TypedMoneyBuilder ? $this->discountedAmount->build() : $this->discountedAmount ); } diff --git a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortionModel.php b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortionModel.php index cb582256099..cd46bb2aac0 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortionModel.php +++ b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPortionModel.php @@ -29,7 +29,7 @@ final class DiscountedLineItemPortionModel extends JsonObjectModel implements Di /** * - * @var ?Money + * @var ?TypedMoney */ protected $discountedAmount; @@ -39,7 +39,7 @@ final class DiscountedLineItemPortionModel extends JsonObjectModel implements Di */ public function __construct( ?Reference $discount = null, - ?Money $discountedAmount = null + ?TypedMoney $discountedAmount = null ) { $this->discount = $discount; $this->discountedAmount = $discountedAmount; @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            A CartDiscountReference or DirectDiscountReference of the applicable discount on the Line Item.

                                                                                                                            + * * * @return null|Reference */ @@ -58,16 +60,18 @@ public function getDiscount() if (is_null($data)) { return null; } - - $this->discount = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->discount = $className::of($data); } return $this->discount; } /** + *

                                                                                                                            Money value of the applicable discount.

                                                                                                                            * - * @return null|Money + * + * @return null|TypedMoney */ public function getDiscountedAmount() { @@ -77,8 +81,8 @@ public function getDiscountedAmount() if (is_null($data)) { return null; } - - $this->discountedAmount = MoneyModel::of($data); + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->discountedAmount = $className::of($data); } return $this->discountedAmount; @@ -94,9 +98,9 @@ public function setDiscount(?Reference $discount): void } /** - * @param ?Money $discountedAmount + * @param ?TypedMoney $discountedAmount */ - public function setDiscountedAmount(?Money $discountedAmount): void + public function setDiscountedAmount(?TypedMoney $discountedAmount): void { $this->discountedAmount = $discountedAmount; } diff --git a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPrice.php b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPrice.php index 6096b6a69e4..670448e6cec 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPrice.php +++ b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPrice.php @@ -18,21 +18,25 @@ interface DiscountedLineItemPrice extends JsonObject public const FIELD_INCLUDED_DISCOUNTS = 'includedDiscounts'; /** + *

                                                                                                                            Money value of the discounted Line Item or Custom Line Item.

                                                                                                                            + * - * @return null|Money + * @return null|TypedMoney */ public function getValue(); /** + *

                                                                                                                            Discount applicable on the Line Item or Custom Line Item.

                                                                                                                            + * * @return null|DiscountedLineItemPortionCollection */ public function getIncludedDiscounts(); /** - * @param ?Money $value + * @param ?TypedMoney $value */ - public function setValue(?Money $value): void; + public function setValue(?TypedMoney $value): void; /** * @param ?DiscountedLineItemPortionCollection $includedDiscounts diff --git a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceBuilder.php b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceBuilder.php index 43fc83302cc..6580ab7cd83 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceBuilder.php +++ b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceBuilder.php @@ -22,7 +22,7 @@ final class DiscountedLineItemPriceBuilder implements Builder { /** - * @var null|Money|MoneyBuilder + * @var null|TypedMoney|TypedMoneyBuilder */ private $value; @@ -33,15 +33,19 @@ final class DiscountedLineItemPriceBuilder implements Builder private $includedDiscounts; /** + *

                                                                                                                            Money value of the discounted Line Item or Custom Line Item.

                                                                                                                            + * - * @return null|Money + * @return null|TypedMoney */ public function getValue() { - return $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value; + return $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value; } /** + *

                                                                                                                            Discount applicable on the Line Item or Custom Line Item.

                                                                                                                            + * * @return null|DiscountedLineItemPortionCollection */ @@ -51,10 +55,10 @@ public function getIncludedDiscounts() } /** - * @param ?Money $value + * @param ?TypedMoney $value * @return $this */ - public function withValue(?Money $value) + public function withValue(?TypedMoney $value) { $this->value = $value; @@ -76,7 +80,7 @@ public function withIncludedDiscounts(?DiscountedLineItemPortionCollection $incl * @deprecated use withValue() instead * @return $this */ - public function withValueBuilder(?MoneyBuilder $value) + public function withValueBuilder(?TypedMoneyBuilder $value) { $this->value = $value; @@ -86,7 +90,7 @@ public function withValueBuilder(?MoneyBuilder $value) public function build(): DiscountedLineItemPrice { return new DiscountedLineItemPriceModel( - $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value, + $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value, $this->includedDiscounts ); } diff --git a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantity.php b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantity.php index 72c99f24056..ea5cf0ad4a8 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantity.php +++ b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantity.php @@ -18,12 +18,16 @@ interface DiscountedLineItemPriceForQuantity extends JsonObject public const FIELD_DISCOUNTED_PRICE = 'discountedPrice'; /** + *

                                                                                                                            Number of Line Items or Custom Line Items in the Cart.

                                                                                                                            + * * @return null|int */ public function getQuantity(); /** + *

                                                                                                                            Discounted price of the Line Item or Custom Line Item.

                                                                                                                            + * * @return null|DiscountedLineItemPrice */ diff --git a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantityBuilder.php b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantityBuilder.php index 66ac488a12b..be2ae9f75ce 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantityBuilder.php +++ b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantityBuilder.php @@ -33,6 +33,8 @@ final class DiscountedLineItemPriceForQuantityBuilder implements Builder private $discountedPrice; /** + *

                                                                                                                            Number of Line Items or Custom Line Items in the Cart.

                                                                                                                            + * * @return null|int */ @@ -42,6 +44,8 @@ public function getQuantity() } /** + *

                                                                                                                            Discounted price of the Line Item or Custom Line Item.

                                                                                                                            + * * @return null|DiscountedLineItemPrice */ diff --git a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantityModel.php b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantityModel.php index 3d8c7bda4df..8bc11595563 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantityModel.php +++ b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceForQuantityModel.php @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            Number of Line Items or Custom Line Items in the Cart.

                                                                                                                            + * * * @return null|int */ @@ -65,6 +67,8 @@ public function getQuantity() } /** + *

                                                                                                                            Discounted price of the Line Item or Custom Line Item.

                                                                                                                            + * * * @return null|DiscountedLineItemPrice */ diff --git a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceModel.php b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceModel.php index 81e8de435ee..99e33ddb5ce 100644 --- a/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceModel.php +++ b/lib/commercetools-history/src/Models/Common/DiscountedLineItemPriceModel.php @@ -23,7 +23,7 @@ final class DiscountedLineItemPriceModel extends JsonObjectModel implements Disc /** * - * @var ?Money + * @var ?TypedMoney */ protected $value; @@ -38,7 +38,7 @@ final class DiscountedLineItemPriceModel extends JsonObjectModel implements Disc * @psalm-suppress MissingParamType */ public function __construct( - ?Money $value = null, + ?TypedMoney $value = null, ?DiscountedLineItemPortionCollection $includedDiscounts = null ) { $this->value = $value; @@ -47,8 +47,10 @@ public function __construct( } /** + *

                                                                                                                            Money value of the discounted Line Item or Custom Line Item.

                                                                                                                            * - * @return null|Money + * + * @return null|TypedMoney */ public function getValue() { @@ -58,14 +60,16 @@ public function getValue() if (is_null($data)) { return null; } - - $this->value = MoneyModel::of($data); + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->value = $className::of($data); } return $this->value; } /** + *

                                                                                                                            Discount applicable on the Line Item or Custom Line Item.

                                                                                                                            + * * * @return null|DiscountedLineItemPortionCollection */ @@ -85,9 +89,9 @@ public function getIncludedDiscounts() /** - * @param ?Money $value + * @param ?TypedMoney $value */ - public function setValue(?Money $value): void + public function setValue(?TypedMoney $value): void { $this->value = $value; } diff --git a/lib/commercetools-history/src/Models/Common/DiscountedPrice.php b/lib/commercetools-history/src/Models/Common/DiscountedPrice.php new file mode 100644 index 00000000000..40e433cc7bc --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountedPrice.php @@ -0,0 +1,45 @@ +Money value of the discounted price.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getValue(); + + /** + *

                                                                                                                            ProductDiscount related to the discounted price.

                                                                                                                            + * + + * @return null|ProductDiscountReference + */ + public function getDiscount(); + + /** + * @param ?TypedMoney $value + */ + public function setValue(?TypedMoney $value): void; + + /** + * @param ?ProductDiscountReference $discount + */ + public function setDiscount(?ProductDiscountReference $discount): void; +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountedPriceBuilder.php b/lib/commercetools-history/src/Models/Common/DiscountedPriceBuilder.php new file mode 100644 index 00000000000..592d4bb505e --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountedPriceBuilder.php @@ -0,0 +1,113 @@ + + */ +final class DiscountedPriceBuilder implements Builder +{ + /** + + * @var null|TypedMoney|TypedMoneyBuilder + */ + private $value; + + /** + + * @var null|ProductDiscountReference|ProductDiscountReferenceBuilder + */ + private $discount; + + /** + *

                                                                                                                            Money value of the discounted price.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getValue() + { + return $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value; + } + + /** + *

                                                                                                                            ProductDiscount related to the discounted price.

                                                                                                                            + * + + * @return null|ProductDiscountReference + */ + public function getDiscount() + { + return $this->discount instanceof ProductDiscountReferenceBuilder ? $this->discount->build() : $this->discount; + } + + /** + * @param ?TypedMoney $value + * @return $this + */ + public function withValue(?TypedMoney $value) + { + $this->value = $value; + + return $this; + } + + /** + * @param ?ProductDiscountReference $discount + * @return $this + */ + public function withDiscount(?ProductDiscountReference $discount) + { + $this->discount = $discount; + + return $this; + } + + /** + * @deprecated use withValue() instead + * @return $this + */ + public function withValueBuilder(?TypedMoneyBuilder $value) + { + $this->value = $value; + + return $this; + } + + /** + * @deprecated use withDiscount() instead + * @return $this + */ + public function withDiscountBuilder(?ProductDiscountReferenceBuilder $discount) + { + $this->discount = $discount; + + return $this; + } + + public function build(): DiscountedPrice + { + return new DiscountedPriceModel( + $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value, + $this->discount instanceof ProductDiscountReferenceBuilder ? $this->discount->build() : $this->discount + ); + } + + public static function of(): DiscountedPriceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountedPriceCollection.php b/lib/commercetools-history/src/Models/Common/DiscountedPriceCollection.php new file mode 100644 index 00000000000..edcee3cb70b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountedPriceCollection.php @@ -0,0 +1,56 @@ + + * @method DiscountedPrice current() + * @method DiscountedPrice end() + * @method DiscountedPrice at($offset) + */ +class DiscountedPriceCollection extends MapperSequence +{ + /** + * @psalm-assert DiscountedPrice $value + * @psalm-param DiscountedPrice|stdClass $value + * @throws InvalidArgumentException + * + * @return DiscountedPriceCollection + */ + public function add($value) + { + if (!$value instanceof DiscountedPrice) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?DiscountedPrice + */ + protected function mapper() + { + return function (?int $index): ?DiscountedPrice { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var DiscountedPrice $data */ + $data = DiscountedPriceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountedPriceModel.php b/lib/commercetools-history/src/Models/Common/DiscountedPriceModel.php new file mode 100644 index 00000000000..9388ae501f3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountedPriceModel.php @@ -0,0 +1,110 @@ +value = $value; + $this->discount = $discount; + + } + + /** + *

                                                                                                                            Money value of the discounted price.

                                                                                                                            + * + * + * @return null|TypedMoney + */ + public function getValue() + { + if (is_null($this->value)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_VALUE); + if (is_null($data)) { + return null; + } + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->value = $className::of($data); + } + + return $this->value; + } + + /** + *

                                                                                                                            ProductDiscount related to the discounted price.

                                                                                                                            + * + * + * @return null|ProductDiscountReference + */ + public function getDiscount() + { + if (is_null($this->discount)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DISCOUNT); + if (is_null($data)) { + return null; + } + + $this->discount = ProductDiscountReferenceModel::of($data); + } + + return $this->discount; + } + + + /** + * @param ?TypedMoney $value + */ + public function setValue(?TypedMoney $value): void + { + $this->value = $value; + } + + /** + * @param ?ProductDiscountReference $discount + */ + public function setDiscount(?ProductDiscountReference $discount): void + { + $this->discount = $discount; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortion.php b/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortion.php new file mode 100644 index 00000000000..4f52a7509e3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortion.php @@ -0,0 +1,45 @@ +A CartDiscountReference or DirectDiscountReference to the discount applied on the Cart totalPrice.

                                                                                                                            + * + + * @return null|Reference + */ + public function getDiscount(); + + /** + *

                                                                                                                            Money value of the discount.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getDiscountedAmount(); + + /** + * @param ?Reference $discount + */ + public function setDiscount(?Reference $discount): void; + + /** + * @param ?TypedMoney $discountedAmount + */ + public function setDiscountedAmount(?TypedMoney $discountedAmount): void; +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortionBuilder.php b/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortionBuilder.php new file mode 100644 index 00000000000..b403cca5b96 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortionBuilder.php @@ -0,0 +1,113 @@ + + */ +final class DiscountedTotalPricePortionBuilder implements Builder +{ + /** + + * @var null|Reference|ReferenceBuilder + */ + private $discount; + + /** + + * @var null|TypedMoney|TypedMoneyBuilder + */ + private $discountedAmount; + + /** + *

                                                                                                                            A CartDiscountReference or DirectDiscountReference to the discount applied on the Cart totalPrice.

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

                                                                                                                            Money value of the discount.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getDiscountedAmount() + { + return $this->discountedAmount instanceof TypedMoneyBuilder ? $this->discountedAmount->build() : $this->discountedAmount; + } + + /** + * @param ?Reference $discount + * @return $this + */ + public function withDiscount(?Reference $discount) + { + $this->discount = $discount; + + return $this; + } + + /** + * @param ?TypedMoney $discountedAmount + * @return $this + */ + public function withDiscountedAmount(?TypedMoney $discountedAmount) + { + $this->discountedAmount = $discountedAmount; + + return $this; + } + + /** + * @deprecated use withDiscount() instead + * @return $this + */ + public function withDiscountBuilder(?ReferenceBuilder $discount) + { + $this->discount = $discount; + + return $this; + } + + /** + * @deprecated use withDiscountedAmount() instead + * @return $this + */ + public function withDiscountedAmountBuilder(?TypedMoneyBuilder $discountedAmount) + { + $this->discountedAmount = $discountedAmount; + + return $this; + } + + public function build(): DiscountedTotalPricePortion + { + return new DiscountedTotalPricePortionModel( + $this->discount instanceof ReferenceBuilder ? $this->discount->build() : $this->discount, + $this->discountedAmount instanceof TypedMoneyBuilder ? $this->discountedAmount->build() : $this->discountedAmount + ); + } + + public static function of(): DiscountedTotalPricePortionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortionCollection.php b/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortionCollection.php new file mode 100644 index 00000000000..ec7ab20546c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortionCollection.php @@ -0,0 +1,56 @@ + + * @method DiscountedTotalPricePortion current() + * @method DiscountedTotalPricePortion end() + * @method DiscountedTotalPricePortion at($offset) + */ +class DiscountedTotalPricePortionCollection extends MapperSequence +{ + /** + * @psalm-assert DiscountedTotalPricePortion $value + * @psalm-param DiscountedTotalPricePortion|stdClass $value + * @throws InvalidArgumentException + * + * @return DiscountedTotalPricePortionCollection + */ + public function add($value) + { + if (!$value instanceof DiscountedTotalPricePortion) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?DiscountedTotalPricePortion + */ + protected function mapper() + { + return function (?int $index): ?DiscountedTotalPricePortion { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var DiscountedTotalPricePortion $data */ + $data = DiscountedTotalPricePortionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortionModel.php b/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortionModel.php new file mode 100644 index 00000000000..4ee36cc7d68 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/DiscountedTotalPricePortionModel.php @@ -0,0 +1,110 @@ +discount = $discount; + $this->discountedAmount = $discountedAmount; + + } + + /** + *

                                                                                                                            A CartDiscountReference or DirectDiscountReference to the discount applied on the Cart totalPrice.

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

                                                                                                                            Money value of the discount.

                                                                                                                            + * + * + * @return null|TypedMoney + */ + public function getDiscountedAmount() + { + if (is_null($this->discountedAmount)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DISCOUNTED_AMOUNT); + if (is_null($data)) { + return null; + } + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->discountedAmount = $className::of($data); + } + + return $this->discountedAmount; + } + + + /** + * @param ?Reference $discount + */ + public function setDiscount(?Reference $discount): void + { + $this->discount = $discount; + } + + /** + * @param ?TypedMoney $discountedAmount + */ + public function setDiscountedAmount(?TypedMoney $discountedAmount): void + { + $this->discountedAmount = $discountedAmount; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/FieldContainer.php b/lib/commercetools-history/src/Models/Common/FieldContainer.php new file mode 100644 index 00000000000..126e441ee9b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/FieldContainer.php @@ -0,0 +1,15 @@ + + * @extends MapperMap + */ +final class FieldContainerBuilder extends MapperMap implements Builder +{ + /** + * @psalm-return callable(string):?FieldContainer + */ + protected function mapper() + { + return + /** + * @psalm-return ?FieldContainer + */ + function(string $key) { + $data = $this->get($key); + if ($data instanceof stdClass) { + $data = FieldContainerModel::of($data); + } + return $data; + }; + } + + /** + * @return FieldContainer + */ + public function build() + { + return new FieldContainerModel($this->toArray()); + } +} diff --git a/lib/commercetools-history/src/Models/Common/FieldContainerCollection.php b/lib/commercetools-history/src/Models/Common/FieldContainerCollection.php new file mode 100644 index 00000000000..4321298046d --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/FieldContainerCollection.php @@ -0,0 +1,56 @@ + + * @method FieldContainer current() + * @method FieldContainer end() + * @method FieldContainer at($offset) + */ +class FieldContainerCollection extends MapperSequence +{ + /** + * @psalm-assert FieldContainer $value + * @psalm-param FieldContainer|stdClass $value + * @throws InvalidArgumentException + * + * @return FieldContainerCollection + */ + public function add($value) + { + if (!$value instanceof FieldContainer) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?FieldContainer + */ + protected function mapper() + { + return function (?int $index): ?FieldContainer { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var FieldContainer $data */ + $data = FieldContainerModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/FieldContainerModel.php b/lib/commercetools-history/src/Models/Common/FieldContainerModel.php new file mode 100644 index 00000000000..3babbe18a8a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/FieldContainerModel.php @@ -0,0 +1,31 @@ +get($key); + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/FieldDefinition.php b/lib/commercetools-history/src/Models/Common/FieldDefinition.php index 84d3217789f..8bb422f5914 100644 --- a/lib/commercetools-history/src/Models/Common/FieldDefinition.php +++ b/lib/commercetools-history/src/Models/Common/FieldDefinition.php @@ -17,16 +17,21 @@ interface FieldDefinition extends JsonObject public const FIELD_TYPE = 'type'; public const FIELD_NAME = 'name'; public const FIELD_LABEL = 'label'; + public const FIELD_REQUIRED = 'required'; public const FIELD_INPUT_HINT = 'inputHint'; /** + *

                                                                                                                            Data type of the Custom Field to define.

                                                                                                                            + * * @return null|FieldType */ public function getType(); /** - *

                                                                                                                            The name of the field. The name must be between two and 36 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (_) and the hyphen-minus (-). The name must be unique for a given resource type ID. In case there is a field with the same name in another type it has to have the same FieldType also.

                                                                                                                            + *

                                                                                                                            Name of the Custom Field to define. + * Must be unique for a given ResourceTypeId. + * In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type.

                                                                                                                            * * @return null|string @@ -34,12 +39,25 @@ public function getType(); public function getName(); /** + *

                                                                                                                            A human-readable label for the field.

                                                                                                                            + * * @return null|LocalizedString */ public function getLabel(); /** + *

                                                                                                                            Defines whether the field is required to have a value.

                                                                                                                            + * + + * @return null|bool + */ + public function getRequired(); + + /** + *

                                                                                                                            Defines the visual representation of the field in user interfaces like the Merchant Center. + * It is only relevant for string-based FieldTypes like CustomFieldStringType and CustomFieldLocalizedStringType.

                                                                                                                            + * * @return null|string */ @@ -60,6 +78,11 @@ public function setName(?string $name): void; */ public function setLabel(?LocalizedString $label): void; + /** + * @param ?bool $required + */ + public function setRequired(?bool $required): void; + /** * @param ?string $inputHint */ diff --git a/lib/commercetools-history/src/Models/Common/FieldDefinitionBuilder.php b/lib/commercetools-history/src/Models/Common/FieldDefinitionBuilder.php index d742a3deaf3..001bad68493 100644 --- a/lib/commercetools-history/src/Models/Common/FieldDefinitionBuilder.php +++ b/lib/commercetools-history/src/Models/Common/FieldDefinitionBuilder.php @@ -38,6 +38,12 @@ final class FieldDefinitionBuilder implements Builder */ private $label; + /** + + * @var ?bool + */ + private $required; + /** * @var ?string @@ -45,6 +51,8 @@ final class FieldDefinitionBuilder implements Builder private $inputHint; /** + *

                                                                                                                            Data type of the Custom Field to define.

                                                                                                                            + * * @return null|FieldType */ @@ -54,7 +62,9 @@ public function getType() } /** - *

                                                                                                                            The name of the field. The name must be between two and 36 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (_) and the hyphen-minus (-). The name must be unique for a given resource type ID. In case there is a field with the same name in another type it has to have the same FieldType also.

                                                                                                                            + *

                                                                                                                            Name of the Custom Field to define. + * Must be unique for a given ResourceTypeId. + * In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type.

                                                                                                                            * * @return null|string @@ -65,6 +75,8 @@ public function getName() } /** + *

                                                                                                                            A human-readable label for the field.

                                                                                                                            + * * @return null|LocalizedString */ @@ -74,6 +86,20 @@ public function getLabel() } /** + *

                                                                                                                            Defines whether the field is required to have a value.

                                                                                                                            + * + + * @return null|bool + */ + public function getRequired() + { + return $this->required; + } + + /** + *

                                                                                                                            Defines the visual representation of the field in user interfaces like the Merchant Center. + * It is only relevant for string-based FieldTypes like CustomFieldStringType and CustomFieldLocalizedStringType.

                                                                                                                            + * * @return null|string */ @@ -115,6 +141,17 @@ public function withLabel(?LocalizedString $label) return $this; } + /** + * @param ?bool $required + * @return $this + */ + public function withRequired(?bool $required) + { + $this->required = $required; + + return $this; + } + /** * @param ?string $inputHint * @return $this @@ -154,6 +191,7 @@ public function build(): FieldDefinition $this->type instanceof FieldTypeBuilder ? $this->type->build() : $this->type, $this->name, $this->label instanceof LocalizedStringBuilder ? $this->label->build() : $this->label, + $this->required, $this->inputHint ); } diff --git a/lib/commercetools-history/src/Models/Common/FieldDefinitionModel.php b/lib/commercetools-history/src/Models/Common/FieldDefinitionModel.php index 1634e0e0fea..3d494fd2f16 100644 --- a/lib/commercetools-history/src/Models/Common/FieldDefinitionModel.php +++ b/lib/commercetools-history/src/Models/Common/FieldDefinitionModel.php @@ -39,6 +39,12 @@ final class FieldDefinitionModel extends JsonObjectModel implements FieldDefinit */ protected $label; + /** + * + * @var ?bool + */ + protected $required; + /** * * @var ?string @@ -53,16 +59,20 @@ public function __construct( ?FieldType $type = null, ?string $name = null, ?LocalizedString $label = null, + ?bool $required = null, ?string $inputHint = null ) { $this->type = $type; $this->name = $name; $this->label = $label; + $this->required = $required; $this->inputHint = $inputHint; } /** + *

                                                                                                                            Data type of the Custom Field to define.

                                                                                                                            + * * * @return null|FieldType */ @@ -82,7 +92,9 @@ public function getType() } /** - *

                                                                                                                            The name of the field. The name must be between two and 36 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (_) and the hyphen-minus (-). The name must be unique for a given resource type ID. In case there is a field with the same name in another type it has to have the same FieldType also.

                                                                                                                            + *

                                                                                                                            Name of the Custom Field to define. + * Must be unique for a given ResourceTypeId. + * In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type.

                                                                                                                            * * * @return null|string @@ -102,6 +114,8 @@ public function getName() } /** + *

                                                                                                                            A human-readable label for the field.

                                                                                                                            + * * * @return null|LocalizedString */ @@ -121,6 +135,29 @@ public function getLabel() } /** + *

                                                                                                                            Defines whether the field is required to have a value.

                                                                                                                            + * + * + * @return null|bool + */ + public function getRequired() + { + if (is_null($this->required)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_REQUIRED); + if (is_null($data)) { + return null; + } + $this->required = (bool) $data; + } + + return $this->required; + } + + /** + *

                                                                                                                            Defines the visual representation of the field in user interfaces like the Merchant Center. + * It is only relevant for string-based FieldTypes like CustomFieldStringType and CustomFieldLocalizedStringType.

                                                                                                                            + * * * @return null|string */ @@ -163,6 +200,14 @@ public function setLabel(?LocalizedString $label): void $this->label = $label; } + /** + * @param ?bool $required + */ + public function setRequired(?bool $required): void + { + $this->required = $required; + } + /** * @param ?string $inputHint */ diff --git a/lib/commercetools-history/src/Models/Common/GeoJson.php b/lib/commercetools-history/src/Models/Common/GeoJson.php new file mode 100644 index 00000000000..40cd1ca97a4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/GeoJson.php @@ -0,0 +1,25 @@ + + */ +final class GeoJsonBuilder implements Builder +{ + + + + + public function build(): GeoJson + { + return new GeoJsonModel( + ); + } + + public static function of(): GeoJsonBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/GeoJsonCollection.php b/lib/commercetools-history/src/Models/Common/GeoJsonCollection.php new file mode 100644 index 00000000000..ebf5c0bafaf --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/GeoJsonCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method GeoJson current() + * @method GeoJson end() + * @method GeoJson at($offset) + */ +class GeoJsonCollection extends MapperSequence +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return GeoJsonCollection + */ + public function add($value) + { + if (!$value instanceof GeoJson) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?GeoJson { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = GeoJsonModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/GeoJsonModel.php b/lib/commercetools-history/src/Models/Common/GeoJsonModel.php new file mode 100644 index 00000000000..be385133480 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/GeoJsonModel.php @@ -0,0 +1,96 @@ + > + * + */ + private static $discriminatorClasses = [ + 'Point' => GeoLocationModel::class, + ]; + + /** + * @psalm-suppress MissingParamType + */ + public function __construct( + ?string $type = null + ) { + $this->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; + } + + + + + + /** + * @psalm-param stdClass|array $value + * @psalm-return class-string + */ + public static function resolveDiscriminatorClass($value): string + { + $fieldName = GeoJson::DISCRIMINATOR_FIELD; + if (is_object($value) && isset($value->$fieldName)) { + /** @psalm-var string $discriminatorValue */ + $discriminatorValue = $value->$fieldName; + if (isset(self::$discriminatorClasses[$discriminatorValue])) { + return self::$discriminatorClasses[$discriminatorValue]; + } + } + if (is_array($value) && isset($value[$fieldName])) { + /** @psalm-var string $discriminatorValue */ + $discriminatorValue = $value[$fieldName]; + if (isset(self::$discriminatorClasses[$discriminatorValue])) { + return self::$discriminatorClasses[$discriminatorValue]; + } + } + + /** @psalm-var class-string */ + $type = GeoJsonModel::class; + return $type; + } +} diff --git a/lib/commercetools-history/src/Models/Common/GeoLocation.php b/lib/commercetools-history/src/Models/Common/GeoLocation.php index b59d3989b79..550d20ecbd9 100644 --- a/lib/commercetools-history/src/Models/Common/GeoLocation.php +++ b/lib/commercetools-history/src/Models/Common/GeoLocation.php @@ -11,10 +11,9 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -interface GeoLocation extends JsonObject +interface GeoLocation extends GeoJson { - public const FIELD_TYPE = 'type'; public const FIELD_COORDINATES = 'coordinates'; /** @@ -29,11 +28,6 @@ public function getType(); */ public function getCoordinates(); - /** - * @param ?string $type - */ - public function setType(?string $type): void; - /** * @param ?array $coordinates */ diff --git a/lib/commercetools-history/src/Models/Common/GeoLocationBuilder.php b/lib/commercetools-history/src/Models/Common/GeoLocationBuilder.php index c3678e6e68e..8cfbfbbb16c 100644 --- a/lib/commercetools-history/src/Models/Common/GeoLocationBuilder.php +++ b/lib/commercetools-history/src/Models/Common/GeoLocationBuilder.php @@ -20,27 +20,12 @@ */ final class GeoLocationBuilder implements Builder { - /** - - * @var ?string - */ - private $type; - /** * @var ?array */ private $coordinates; - /** - - * @return null|string - */ - public function getType() - { - return $this->type; - } - /** * @return null|array @@ -50,17 +35,6 @@ public function getCoordinates() return $this->coordinates; } - /** - * @param ?string $type - * @return $this - */ - public function withType(?string $type) - { - $this->type = $type; - - return $this; - } - /** * @param ?array $coordinates * @return $this @@ -76,7 +50,6 @@ public function withCoordinates(?array $coordinates) public function build(): GeoLocation { return new GeoLocationModel( - $this->type, $this->coordinates ); } diff --git a/lib/commercetools-history/src/Models/Common/GeoLocationCollection.php b/lib/commercetools-history/src/Models/Common/GeoLocationCollection.php index 8379f742dbf..ee05b3e9b3c 100644 --- a/lib/commercetools-history/src/Models/Common/GeoLocationCollection.php +++ b/lib/commercetools-history/src/Models/Common/GeoLocationCollection.php @@ -8,17 +8,17 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\MapperSequence; +use Commercetools\History\Models\Common\GeoJsonCollection; use Commercetools\Exception\InvalidArgumentException; use stdClass; /** - * @extends MapperSequence + * @extends GeoJsonCollection * @method GeoLocation current() * @method GeoLocation end() * @method GeoLocation at($offset) */ -class GeoLocationCollection extends MapperSequence +class GeoLocationCollection extends GeoJsonCollection { /** * @psalm-assert GeoLocation $value diff --git a/lib/commercetools-history/src/Models/Common/GeoLocationModel.php b/lib/commercetools-history/src/Models/Common/GeoLocationModel.php index 7e694baf290..71ce8d691be 100644 --- a/lib/commercetools-history/src/Models/Common/GeoLocationModel.php +++ b/lib/commercetools-history/src/Models/Common/GeoLocationModel.php @@ -20,7 +20,7 @@ final class GeoLocationModel extends JsonObjectModel implements GeoLocation { - + public const DISCRIMINATOR_VALUE = 'Point'; /** * * @var ?string @@ -38,12 +38,11 @@ final class GeoLocationModel extends JsonObjectModel implements GeoLocation * @psalm-suppress MissingParamType */ public function __construct( - ?string $type = null, - ?array $coordinates = null + ?array $coordinates = null, + ?string $type = null ) { - $this->type = $type; $this->coordinates = $coordinates; - + $this->type = $type ?? self::DISCRIMINATOR_VALUE; } /** @@ -83,14 +82,6 @@ public function getCoordinates() } - /** - * @param ?string $type - */ - public function setType(?string $type): void - { - $this->type = $type; - } - /** * @param ?array $coordinates */ diff --git a/lib/commercetools-history/src/Models/Common/Image.php b/lib/commercetools-history/src/Models/Common/Image.php index 0fd7aff5ca0..b0275cd19a5 100644 --- a/lib/commercetools-history/src/Models/Common/Image.php +++ b/lib/commercetools-history/src/Models/Common/Image.php @@ -19,18 +19,24 @@ interface Image extends JsonObject public const FIELD_LABEL = 'label'; /** + *

                                                                                                                            URL of the image in its original size that must be unique within a single ProductVariant.

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

                                                                                                                            Dimensions of the original image.

                                                                                                                            + * * @return null|ImageDimensions */ public function getDimensions(); /** + *

                                                                                                                            Custom label for the image.

                                                                                                                            + * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/ImageBuilder.php b/lib/commercetools-history/src/Models/Common/ImageBuilder.php index 2007ad2e221..4261cbd29e8 100644 --- a/lib/commercetools-history/src/Models/Common/ImageBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ImageBuilder.php @@ -39,6 +39,8 @@ final class ImageBuilder implements Builder private $label; /** + *

                                                                                                                            URL of the image in its original size that must be unique within a single ProductVariant.

                                                                                                                            + * * @return null|string */ @@ -48,6 +50,8 @@ public function getUrl() } /** + *

                                                                                                                            Dimensions of the original image.

                                                                                                                            + * * @return null|ImageDimensions */ @@ -57,6 +61,8 @@ public function getDimensions() } /** + *

                                                                                                                            Custom label for the image.

                                                                                                                            + * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/ImageDimensions.php b/lib/commercetools-history/src/Models/Common/ImageDimensions.php index 9059408e259..eb006da4eba 100644 --- a/lib/commercetools-history/src/Models/Common/ImageDimensions.php +++ b/lib/commercetools-history/src/Models/Common/ImageDimensions.php @@ -18,12 +18,16 @@ interface ImageDimensions extends JsonObject public const FIELD_H = 'h'; /** + *

                                                                                                                            Width of the image.

                                                                                                                            + * * @return null|int */ public function getW(); /** + *

                                                                                                                            Height of the image.

                                                                                                                            + * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/ImageDimensionsBuilder.php b/lib/commercetools-history/src/Models/Common/ImageDimensionsBuilder.php index b2fe6b5a830..78bdf42b21d 100644 --- a/lib/commercetools-history/src/Models/Common/ImageDimensionsBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ImageDimensionsBuilder.php @@ -33,6 +33,8 @@ final class ImageDimensionsBuilder implements Builder private $h; /** + *

                                                                                                                            Width of the image.

                                                                                                                            + * * @return null|int */ @@ -42,6 +44,8 @@ public function getW() } /** + *

                                                                                                                            Height of the image.

                                                                                                                            + * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/ImageDimensionsModel.php b/lib/commercetools-history/src/Models/Common/ImageDimensionsModel.php index 996969e089d..74b09f3e0c7 100644 --- a/lib/commercetools-history/src/Models/Common/ImageDimensionsModel.php +++ b/lib/commercetools-history/src/Models/Common/ImageDimensionsModel.php @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            Width of the image.

                                                                                                                            + * * * @return null|int */ @@ -65,6 +67,8 @@ public function getW() } /** + *

                                                                                                                            Height of the image.

                                                                                                                            + * * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/ImageModel.php b/lib/commercetools-history/src/Models/Common/ImageModel.php index d77d8d0b0be..ba778597ed3 100644 --- a/lib/commercetools-history/src/Models/Common/ImageModel.php +++ b/lib/commercetools-history/src/Models/Common/ImageModel.php @@ -55,6 +55,8 @@ public function __construct( } /** + *

                                                                                                                            URL of the image in its original size that must be unique within a single ProductVariant.

                                                                                                                            + * * * @return null|string */ @@ -73,6 +75,8 @@ public function getUrl() } /** + *

                                                                                                                            Dimensions of the original image.

                                                                                                                            + * * * @return null|ImageDimensions */ @@ -92,6 +96,8 @@ public function getDimensions() } /** + *

                                                                                                                            Custom label for the image.

                                                                                                                            + * * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/InheritedAssociate.php b/lib/commercetools-history/src/Models/Common/InheritedAssociate.php index 7a10ebba356..31ea7d1ed21 100644 --- a/lib/commercetools-history/src/Models/Common/InheritedAssociate.php +++ b/lib/commercetools-history/src/Models/Common/InheritedAssociate.php @@ -18,14 +18,18 @@ interface InheritedAssociate extends JsonObject public const FIELD_CUSTOMER = 'customer'; /** + *

                                                                                                                            Inherited roles of the Associate within a Business Unit.

                                                                                                                            + * * @return null|InheritedAssociateRoleAssignmentCollection */ public function getAssociateRoleAssignments(); /** + *

                                                                                                                            The Customer that acts as an Associate in the Business Unit.

                                                                                                                            + * - * @return null|Reference + * @return null|CustomerReference */ public function getCustomer(); @@ -35,7 +39,7 @@ public function getCustomer(); public function setAssociateRoleAssignments(?InheritedAssociateRoleAssignmentCollection $associateRoleAssignments): void; /** - * @param ?Reference $customer + * @param ?CustomerReference $customer */ - public function setCustomer(?Reference $customer): void; + public function setCustomer(?CustomerReference $customer): void; } diff --git a/lib/commercetools-history/src/Models/Common/InheritedAssociateBuilder.php b/lib/commercetools-history/src/Models/Common/InheritedAssociateBuilder.php index 2fd89070972..cc728f6285e 100644 --- a/lib/commercetools-history/src/Models/Common/InheritedAssociateBuilder.php +++ b/lib/commercetools-history/src/Models/Common/InheritedAssociateBuilder.php @@ -28,11 +28,13 @@ final class InheritedAssociateBuilder implements Builder /** - * @var null|Reference|ReferenceBuilder + * @var null|CustomerReference|CustomerReferenceBuilder */ private $customer; /** + *

                                                                                                                            Inherited roles of the Associate within a Business Unit.

                                                                                                                            + * * @return null|InheritedAssociateRoleAssignmentCollection */ @@ -42,12 +44,14 @@ public function getAssociateRoleAssignments() } /** + *

                                                                                                                            The Customer that acts as an Associate in the Business Unit.

                                                                                                                            + * - * @return null|Reference + * @return null|CustomerReference */ public function getCustomer() { - return $this->customer instanceof ReferenceBuilder ? $this->customer->build() : $this->customer; + return $this->customer instanceof CustomerReferenceBuilder ? $this->customer->build() : $this->customer; } /** @@ -62,10 +66,10 @@ public function withAssociateRoleAssignments(?InheritedAssociateRoleAssignmentCo } /** - * @param ?Reference $customer + * @param ?CustomerReference $customer * @return $this */ - public function withCustomer(?Reference $customer) + public function withCustomer(?CustomerReference $customer) { $this->customer = $customer; @@ -76,7 +80,7 @@ public function withCustomer(?Reference $customer) * @deprecated use withCustomer() instead * @return $this */ - public function withCustomerBuilder(?ReferenceBuilder $customer) + public function withCustomerBuilder(?CustomerReferenceBuilder $customer) { $this->customer = $customer; @@ -87,7 +91,7 @@ public function build(): InheritedAssociate { return new InheritedAssociateModel( $this->associateRoleAssignments, - $this->customer instanceof ReferenceBuilder ? $this->customer->build() : $this->customer + $this->customer instanceof CustomerReferenceBuilder ? $this->customer->build() : $this->customer ); } diff --git a/lib/commercetools-history/src/Models/Common/InheritedAssociateModel.php b/lib/commercetools-history/src/Models/Common/InheritedAssociateModel.php index 4737059a675..1a2dc7fdf67 100644 --- a/lib/commercetools-history/src/Models/Common/InheritedAssociateModel.php +++ b/lib/commercetools-history/src/Models/Common/InheritedAssociateModel.php @@ -29,7 +29,7 @@ final class InheritedAssociateModel extends JsonObjectModel implements Inherited /** * - * @var ?Reference + * @var ?CustomerReference */ protected $customer; @@ -39,7 +39,7 @@ final class InheritedAssociateModel extends JsonObjectModel implements Inherited */ public function __construct( ?InheritedAssociateRoleAssignmentCollection $associateRoleAssignments = null, - ?Reference $customer = null + ?CustomerReference $customer = null ) { $this->associateRoleAssignments = $associateRoleAssignments; $this->customer = $customer; @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            Inherited roles of the Associate within a Business Unit.

                                                                                                                            + * * * @return null|InheritedAssociateRoleAssignmentCollection */ @@ -65,8 +67,10 @@ public function getAssociateRoleAssignments() } /** + *

                                                                                                                            The Customer that acts as an Associate in the Business Unit.

                                                                                                                            + * * - * @return null|Reference + * @return null|CustomerReference */ public function getCustomer() { @@ -77,7 +81,7 @@ public function getCustomer() return null; } - $this->customer = ReferenceModel::of($data); + $this->customer = CustomerReferenceModel::of($data); } return $this->customer; @@ -93,9 +97,9 @@ public function setAssociateRoleAssignments(?InheritedAssociateRoleAssignmentCol } /** - * @param ?Reference $customer + * @param ?CustomerReference $customer */ - public function setCustomer(?Reference $customer): void + public function setCustomer(?CustomerReference $customer): void { $this->customer = $customer; } diff --git a/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignment.php b/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignment.php index 76d85d30bf8..d56324ca8fa 100644 --- a/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignment.php +++ b/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignment.php @@ -18,24 +18,28 @@ interface InheritedAssociateRoleAssignment extends JsonObject public const FIELD_SOURCE = 'source'; /** + *

                                                                                                                            Inherited role the Associate holds within a Business Unit.

                                                                                                                            + * - * @return null|KeyReference + * @return null|AssociateRoleKeyReference */ public function getAssociateRole(); /** + *

                                                                                                                            Reference to the parent Business Unit where the assignment is defined explicitly.

                                                                                                                            + * - * @return null|KeyReference + * @return null|BusinessUnitKeyReference */ public function getSource(); /** - * @param ?KeyReference $associateRole + * @param ?AssociateRoleKeyReference $associateRole */ - public function setAssociateRole(?KeyReference $associateRole): void; + public function setAssociateRole(?AssociateRoleKeyReference $associateRole): void; /** - * @param ?KeyReference $source + * @param ?BusinessUnitKeyReference $source */ - public function setSource(?KeyReference $source): void; + public function setSource(?BusinessUnitKeyReference $source): void; } diff --git a/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignmentBuilder.php b/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignmentBuilder.php index 0767d4c4341..0dba7bae6d4 100644 --- a/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignmentBuilder.php +++ b/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignmentBuilder.php @@ -22,39 +22,43 @@ final class InheritedAssociateRoleAssignmentBuilder implements Builder { /** - * @var null|KeyReference|KeyReferenceBuilder + * @var null|AssociateRoleKeyReference|AssociateRoleKeyReferenceBuilder */ private $associateRole; /** - * @var null|KeyReference|KeyReferenceBuilder + * @var null|BusinessUnitKeyReference|BusinessUnitKeyReferenceBuilder */ private $source; /** + *

                                                                                                                            Inherited role the Associate holds within a Business Unit.

                                                                                                                            + * - * @return null|KeyReference + * @return null|AssociateRoleKeyReference */ public function getAssociateRole() { - return $this->associateRole instanceof KeyReferenceBuilder ? $this->associateRole->build() : $this->associateRole; + return $this->associateRole instanceof AssociateRoleKeyReferenceBuilder ? $this->associateRole->build() : $this->associateRole; } /** + *

                                                                                                                            Reference to the parent Business Unit where the assignment is defined explicitly.

                                                                                                                            + * - * @return null|KeyReference + * @return null|BusinessUnitKeyReference */ public function getSource() { - return $this->source instanceof KeyReferenceBuilder ? $this->source->build() : $this->source; + return $this->source instanceof BusinessUnitKeyReferenceBuilder ? $this->source->build() : $this->source; } /** - * @param ?KeyReference $associateRole + * @param ?AssociateRoleKeyReference $associateRole * @return $this */ - public function withAssociateRole(?KeyReference $associateRole) + public function withAssociateRole(?AssociateRoleKeyReference $associateRole) { $this->associateRole = $associateRole; @@ -62,10 +66,10 @@ public function withAssociateRole(?KeyReference $associateRole) } /** - * @param ?KeyReference $source + * @param ?BusinessUnitKeyReference $source * @return $this */ - public function withSource(?KeyReference $source) + public function withSource(?BusinessUnitKeyReference $source) { $this->source = $source; @@ -76,7 +80,7 @@ public function withSource(?KeyReference $source) * @deprecated use withAssociateRole() instead * @return $this */ - public function withAssociateRoleBuilder(?KeyReferenceBuilder $associateRole) + public function withAssociateRoleBuilder(?AssociateRoleKeyReferenceBuilder $associateRole) { $this->associateRole = $associateRole; @@ -87,7 +91,7 @@ public function withAssociateRoleBuilder(?KeyReferenceBuilder $associateRole) * @deprecated use withSource() instead * @return $this */ - public function withSourceBuilder(?KeyReferenceBuilder $source) + public function withSourceBuilder(?BusinessUnitKeyReferenceBuilder $source) { $this->source = $source; @@ -97,8 +101,8 @@ public function withSourceBuilder(?KeyReferenceBuilder $source) public function build(): InheritedAssociateRoleAssignment { return new InheritedAssociateRoleAssignmentModel( - $this->associateRole instanceof KeyReferenceBuilder ? $this->associateRole->build() : $this->associateRole, - $this->source instanceof KeyReferenceBuilder ? $this->source->build() : $this->source + $this->associateRole instanceof AssociateRoleKeyReferenceBuilder ? $this->associateRole->build() : $this->associateRole, + $this->source instanceof BusinessUnitKeyReferenceBuilder ? $this->source->build() : $this->source ); } diff --git a/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignmentModel.php b/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignmentModel.php index 2939ce39e01..c8ccf3521b8 100644 --- a/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignmentModel.php +++ b/lib/commercetools-history/src/Models/Common/InheritedAssociateRoleAssignmentModel.php @@ -23,13 +23,13 @@ final class InheritedAssociateRoleAssignmentModel extends JsonObjectModel implem /** * - * @var ?KeyReference + * @var ?AssociateRoleKeyReference */ protected $associateRole; /** * - * @var ?KeyReference + * @var ?BusinessUnitKeyReference */ protected $source; @@ -38,8 +38,8 @@ final class InheritedAssociateRoleAssignmentModel extends JsonObjectModel implem * @psalm-suppress MissingParamType */ public function __construct( - ?KeyReference $associateRole = null, - ?KeyReference $source = null + ?AssociateRoleKeyReference $associateRole = null, + ?BusinessUnitKeyReference $source = null ) { $this->associateRole = $associateRole; $this->source = $source; @@ -47,8 +47,10 @@ public function __construct( } /** + *

                                                                                                                            Inherited role the Associate holds within a Business Unit.

                                                                                                                            * - * @return null|KeyReference + * + * @return null|AssociateRoleKeyReference */ public function getAssociateRole() { @@ -59,15 +61,17 @@ public function getAssociateRole() return null; } - $this->associateRole = KeyReferenceModel::of($data); + $this->associateRole = AssociateRoleKeyReferenceModel::of($data); } return $this->associateRole; } /** + *

                                                                                                                            Reference to the parent Business Unit where the assignment is defined explicitly.

                                                                                                                            + * * - * @return null|KeyReference + * @return null|BusinessUnitKeyReference */ public function getSource() { @@ -78,7 +82,7 @@ public function getSource() return null; } - $this->source = KeyReferenceModel::of($data); + $this->source = BusinessUnitKeyReferenceModel::of($data); } return $this->source; @@ -86,17 +90,17 @@ public function getSource() /** - * @param ?KeyReference $associateRole + * @param ?AssociateRoleKeyReference $associateRole */ - public function setAssociateRole(?KeyReference $associateRole): void + public function setAssociateRole(?AssociateRoleKeyReference $associateRole): void { $this->associateRole = $associateRole; } /** - * @param ?KeyReference $source + * @param ?BusinessUnitKeyReference $source */ - public function setSource(?KeyReference $source): void + public function setSource(?BusinessUnitKeyReference $source): void { $this->source = $source; } diff --git a/lib/commercetools-history/src/Models/Common/ItemShippingDetails.php b/lib/commercetools-history/src/Models/Common/ItemShippingDetails.php index 0dcee422051..959508d6e67 100644 --- a/lib/commercetools-history/src/Models/Common/ItemShippingDetails.php +++ b/lib/commercetools-history/src/Models/Common/ItemShippingDetails.php @@ -18,13 +18,19 @@ interface ItemShippingDetails extends JsonObject public const FIELD_VALID = 'valid'; /** + *

                                                                                                                            Holds information on the quantity of Line Items or Custom Line Items and the address it is shipped.

                                                                                                                            + * * @return null|ItemShippingTargetCollection */ public function getTargets(); /** - *

                                                                                                                            true if the quantity of the (custom) line item is equal to the sum of the sub-quantities in targets, false otherwise. A cart cannot be ordered when the value is false. The error InvalidItemShippingDetails will be triggered.

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • true if the quantity of Line Items or Custom Line Items is equal to the sum of sub-quantities defined in targets.
                                                                                                                            • + *
                                                                                                                            • false if the quantity of Line Items or Custom Line Items is not equal to the sum of sub-quantities defined in targets. + * Ordering a Cart when the value is false returns an InvalidItemShippingDetails error.
                                                                                                                            • + *
                                                                                                                            * * @return null|bool diff --git a/lib/commercetools-history/src/Models/Common/ItemShippingDetailsBuilder.php b/lib/commercetools-history/src/Models/Common/ItemShippingDetailsBuilder.php index 77ae80ac615..a4a5e0a2e21 100644 --- a/lib/commercetools-history/src/Models/Common/ItemShippingDetailsBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ItemShippingDetailsBuilder.php @@ -33,6 +33,8 @@ final class ItemShippingDetailsBuilder implements Builder private $valid; /** + *

                                                                                                                            Holds information on the quantity of Line Items or Custom Line Items and the address it is shipped.

                                                                                                                            + * * @return null|ItemShippingTargetCollection */ @@ -42,7 +44,11 @@ public function getTargets() } /** - *

                                                                                                                            true if the quantity of the (custom) line item is equal to the sum of the sub-quantities in targets, false otherwise. A cart cannot be ordered when the value is false. The error InvalidItemShippingDetails will be triggered.

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • true if the quantity of Line Items or Custom Line Items is equal to the sum of sub-quantities defined in targets.
                                                                                                                            • + *
                                                                                                                            • false if the quantity of Line Items or Custom Line Items is not equal to the sum of sub-quantities defined in targets. + * Ordering a Cart when the value is false returns an InvalidItemShippingDetails error.
                                                                                                                            • + *
                                                                                                                            * * @return null|bool diff --git a/lib/commercetools-history/src/Models/Common/ItemShippingDetailsModel.php b/lib/commercetools-history/src/Models/Common/ItemShippingDetailsModel.php index f0c5af5d792..4308933f282 100644 --- a/lib/commercetools-history/src/Models/Common/ItemShippingDetailsModel.php +++ b/lib/commercetools-history/src/Models/Common/ItemShippingDetailsModel.php @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            Holds information on the quantity of Line Items or Custom Line Items and the address it is shipped.

                                                                                                                            + * * * @return null|ItemShippingTargetCollection */ @@ -65,7 +67,11 @@ public function getTargets() } /** - *

                                                                                                                            true if the quantity of the (custom) line item is equal to the sum of the sub-quantities in targets, false otherwise. A cart cannot be ordered when the value is false. The error InvalidItemShippingDetails will be triggered.

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • true if the quantity of Line Items or Custom Line Items is equal to the sum of sub-quantities defined in targets.
                                                                                                                            • + *
                                                                                                                            • false if the quantity of Line Items or Custom Line Items is not equal to the sum of sub-quantities defined in targets. + * Ordering a Cart when the value is false returns an InvalidItemShippingDetails error.
                                                                                                                            • + *
                                                                                                                            * * * @return null|bool diff --git a/lib/commercetools-history/src/Models/Common/ItemShippingTarget.php b/lib/commercetools-history/src/Models/Common/ItemShippingTarget.php index 76fde52a2d0..1d3fcaa1d85 100644 --- a/lib/commercetools-history/src/Models/Common/ItemShippingTarget.php +++ b/lib/commercetools-history/src/Models/Common/ItemShippingTarget.php @@ -16,9 +16,11 @@ interface ItemShippingTarget extends JsonObject public const FIELD_ADDRESS_KEY = 'addressKey'; public const FIELD_QUANTITY = 'quantity'; + public const FIELD_SHIPPING_METHOD_KEY = 'shippingMethodKey'; /** - *

                                                                                                                            The key of the address in the cart's itemShippingAddresses

                                                                                                                            + *

                                                                                                                            Key of the address in the Cart itemShippingAddresses. + * Duplicate address keys are not allowed.

                                                                                                                            * * @return null|string @@ -26,13 +28,23 @@ interface ItemShippingTarget extends JsonObject public function getAddressKey(); /** - *

                                                                                                                            The quantity of items that should go to the address with the specified addressKey. Only positive values are allowed. Using 0 as quantity is also possible in a draft object, but the element will not be present in the resulting ItemShippingDetails.

                                                                                                                            + *

                                                                                                                            Quantity of Line Items or Custom Line Items shipped to the address with the specified addressKey.

                                                                                                                            + *

                                                                                                                            If a quantity is updated to 0 when defining ItemShippingDetailsDraft, the targets are removed from a Line Item or Custom Line Item in the resulting ItemShippingDetails.

                                                                                                                            * * @return null|int */ public function getQuantity(); + /** + *

                                                                                                                            User-defined unique identifier of the Shipping Method in a Cart with Multiple ShippingMode.

                                                                                                                            + *

                                                                                                                            It connects Line Item or Custom Line Item quantities with individual Shipping Methods.

                                                                                                                            + * + + * @return null|string + */ + public function getShippingMethodKey(); + /** * @param ?string $addressKey */ @@ -42,4 +54,9 @@ public function setAddressKey(?string $addressKey): void; * @param ?int $quantity */ public function setQuantity(?int $quantity): void; + + /** + * @param ?string $shippingMethodKey + */ + public function setShippingMethodKey(?string $shippingMethodKey): void; } diff --git a/lib/commercetools-history/src/Models/Common/ItemShippingTargetBuilder.php b/lib/commercetools-history/src/Models/Common/ItemShippingTargetBuilder.php index d07329a6c3b..771c9248996 100644 --- a/lib/commercetools-history/src/Models/Common/ItemShippingTargetBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ItemShippingTargetBuilder.php @@ -33,7 +33,14 @@ final class ItemShippingTargetBuilder implements Builder private $quantity; /** - *

                                                                                                                            The key of the address in the cart's itemShippingAddresses

                                                                                                                            + + * @var ?string + */ + private $shippingMethodKey; + + /** + *

                                                                                                                            Key of the address in the Cart itemShippingAddresses. + * Duplicate address keys are not allowed.

                                                                                                                            * * @return null|string @@ -44,7 +51,8 @@ public function getAddressKey() } /** - *

                                                                                                                            The quantity of items that should go to the address with the specified addressKey. Only positive values are allowed. Using 0 as quantity is also possible in a draft object, but the element will not be present in the resulting ItemShippingDetails.

                                                                                                                            + *

                                                                                                                            Quantity of Line Items or Custom Line Items shipped to the address with the specified addressKey.

                                                                                                                            + *

                                                                                                                            If a quantity is updated to 0 when defining ItemShippingDetailsDraft, the targets are removed from a Line Item or Custom Line Item in the resulting ItemShippingDetails.

                                                                                                                            * * @return null|int @@ -54,6 +62,18 @@ public function getQuantity() return $this->quantity; } + /** + *

                                                                                                                            User-defined unique identifier of the Shipping Method in a Cart with Multiple ShippingMode.

                                                                                                                            + *

                                                                                                                            It connects Line Item or Custom Line Item quantities with individual Shipping Methods.

                                                                                                                            + * + + * @return null|string + */ + public function getShippingMethodKey() + { + return $this->shippingMethodKey; + } + /** * @param ?string $addressKey * @return $this @@ -76,12 +96,24 @@ public function withQuantity(?int $quantity) return $this; } + /** + * @param ?string $shippingMethodKey + * @return $this + */ + public function withShippingMethodKey(?string $shippingMethodKey) + { + $this->shippingMethodKey = $shippingMethodKey; + + return $this; + } + public function build(): ItemShippingTarget { return new ItemShippingTargetModel( $this->addressKey, - $this->quantity + $this->quantity, + $this->shippingMethodKey ); } diff --git a/lib/commercetools-history/src/Models/Common/ItemShippingTargetModel.php b/lib/commercetools-history/src/Models/Common/ItemShippingTargetModel.php index 85b3cb7ce87..acf4aef3922 100644 --- a/lib/commercetools-history/src/Models/Common/ItemShippingTargetModel.php +++ b/lib/commercetools-history/src/Models/Common/ItemShippingTargetModel.php @@ -33,21 +33,30 @@ final class ItemShippingTargetModel extends JsonObjectModel implements ItemShipp */ protected $quantity; + /** + * + * @var ?string + */ + protected $shippingMethodKey; + /** * @psalm-suppress MissingParamType */ public function __construct( ?string $addressKey = null, - ?int $quantity = null + ?int $quantity = null, + ?string $shippingMethodKey = null ) { $this->addressKey = $addressKey; $this->quantity = $quantity; + $this->shippingMethodKey = $shippingMethodKey; } /** - *

                                                                                                                            The key of the address in the cart's itemShippingAddresses

                                                                                                                            + *

                                                                                                                            Key of the address in the Cart itemShippingAddresses. + * Duplicate address keys are not allowed.

                                                                                                                            * * * @return null|string @@ -67,7 +76,8 @@ public function getAddressKey() } /** - *

                                                                                                                            The quantity of items that should go to the address with the specified addressKey. Only positive values are allowed. Using 0 as quantity is also possible in a draft object, but the element will not be present in the resulting ItemShippingDetails.

                                                                                                                            + *

                                                                                                                            Quantity of Line Items or Custom Line Items shipped to the address with the specified addressKey.

                                                                                                                            + *

                                                                                                                            If a quantity is updated to 0 when defining ItemShippingDetailsDraft, the targets are removed from a Line Item or Custom Line Item in the resulting ItemShippingDetails.

                                                                                                                            * * * @return null|int @@ -86,6 +96,27 @@ public function getQuantity() return $this->quantity; } + /** + *

                                                                                                                            User-defined unique identifier of the Shipping Method in a Cart with Multiple ShippingMode.

                                                                                                                            + *

                                                                                                                            It connects Line Item or Custom Line Item quantities with individual Shipping Methods.

                                                                                                                            + * + * + * @return null|string + */ + public function getShippingMethodKey() + { + if (is_null($this->shippingMethodKey)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_SHIPPING_METHOD_KEY); + if (is_null($data)) { + return null; + } + $this->shippingMethodKey = (string) $data; + } + + return $this->shippingMethodKey; + } + /** * @param ?string $addressKey @@ -103,6 +134,14 @@ public function setQuantity(?int $quantity): void $this->quantity = $quantity; } + /** + * @param ?string $shippingMethodKey + */ + public function setShippingMethodKey(?string $shippingMethodKey): void + { + $this->shippingMethodKey = $shippingMethodKey; + } + } diff --git a/lib/commercetools-history/src/Models/Common/ItemState.php b/lib/commercetools-history/src/Models/Common/ItemState.php index 434cdc061d5..8dc937dd158 100644 --- a/lib/commercetools-history/src/Models/Common/ItemState.php +++ b/lib/commercetools-history/src/Models/Common/ItemState.php @@ -18,14 +18,18 @@ interface ItemState extends JsonObject public const FIELD_STATE = 'state'; /** + *

                                                                                                                            Number of Line Items or Custom Line Items in this State.

                                                                                                                            + * * @return null|int */ public function getQuantity(); /** + *

                                                                                                                            State of the Line Items or Custom Line Items in a custom workflow.

                                                                                                                            + * - * @return null|Reference + * @return null|StateReference */ public function getState(); @@ -35,7 +39,7 @@ public function getState(); public function setQuantity(?int $quantity): void; /** - * @param ?Reference $state + * @param ?StateReference $state */ - public function setState(?Reference $state): void; + public function setState(?StateReference $state): void; } diff --git a/lib/commercetools-history/src/Models/Common/ItemStateBuilder.php b/lib/commercetools-history/src/Models/Common/ItemStateBuilder.php index 5e3076b210b..bd69d7e7124 100644 --- a/lib/commercetools-history/src/Models/Common/ItemStateBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ItemStateBuilder.php @@ -28,11 +28,13 @@ final class ItemStateBuilder implements Builder /** - * @var null|Reference|ReferenceBuilder + * @var null|StateReference|StateReferenceBuilder */ private $state; /** + *

                                                                                                                            Number of Line Items or Custom Line Items in this State.

                                                                                                                            + * * @return null|int */ @@ -42,12 +44,14 @@ public function getQuantity() } /** + *

                                                                                                                            State of the Line Items or Custom Line Items in a custom workflow.

                                                                                                                            + * - * @return null|Reference + * @return null|StateReference */ public function getState() { - return $this->state instanceof ReferenceBuilder ? $this->state->build() : $this->state; + return $this->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state; } /** @@ -62,10 +66,10 @@ public function withQuantity(?int $quantity) } /** - * @param ?Reference $state + * @param ?StateReference $state * @return $this */ - public function withState(?Reference $state) + public function withState(?StateReference $state) { $this->state = $state; @@ -76,7 +80,7 @@ public function withState(?Reference $state) * @deprecated use withState() instead * @return $this */ - public function withStateBuilder(?ReferenceBuilder $state) + public function withStateBuilder(?StateReferenceBuilder $state) { $this->state = $state; @@ -87,7 +91,7 @@ public function build(): ItemState { return new ItemStateModel( $this->quantity, - $this->state instanceof ReferenceBuilder ? $this->state->build() : $this->state + $this->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state ); } diff --git a/lib/commercetools-history/src/Models/Common/ItemStateModel.php b/lib/commercetools-history/src/Models/Common/ItemStateModel.php index f958127a752..f0cb3054bfe 100644 --- a/lib/commercetools-history/src/Models/Common/ItemStateModel.php +++ b/lib/commercetools-history/src/Models/Common/ItemStateModel.php @@ -29,7 +29,7 @@ final class ItemStateModel extends JsonObjectModel implements ItemState /** * - * @var ?Reference + * @var ?StateReference */ protected $state; @@ -39,7 +39,7 @@ final class ItemStateModel extends JsonObjectModel implements ItemState */ public function __construct( ?int $quantity = null, - ?Reference $state = null + ?StateReference $state = null ) { $this->quantity = $quantity; $this->state = $state; @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            Number of Line Items or Custom Line Items in this State.

                                                                                                                            + * * * @return null|int */ @@ -65,8 +67,10 @@ public function getQuantity() } /** + *

                                                                                                                            State of the Line Items or Custom Line Items in a custom workflow.

                                                                                                                            + * * - * @return null|Reference + * @return null|StateReference */ public function getState() { @@ -77,7 +81,7 @@ public function getState() return null; } - $this->state = ReferenceModel::of($data); + $this->state = StateReferenceModel::of($data); } return $this->state; @@ -93,9 +97,9 @@ public function setQuantity(?int $quantity): void } /** - * @param ?Reference $state + * @param ?StateReference $state */ - public function setState(?Reference $state): void + public function setState(?StateReference $state): void { $this->state = $state; } diff --git a/lib/commercetools-history/src/Models/Common/KeyReference.php b/lib/commercetools-history/src/Models/Common/KeyReference.php index 1b1cd7da533..bc100b79cc7 100644 --- a/lib/commercetools-history/src/Models/Common/KeyReference.php +++ b/lib/commercetools-history/src/Models/Common/KeyReference.php @@ -13,29 +13,28 @@ interface KeyReference extends JsonObject { - - public const FIELD_KEY = 'key'; + public const DISCRIMINATOR_FIELD = 'typeId'; public const FIELD_TYPE_ID = 'typeId'; + public const FIELD_KEY = 'key'; /** + *

                                                                                                                            Type of referenced resource.

                                                                                                                            + * * @return null|string */ - public function getKey(); + public function getTypeId(); /** + *

                                                                                                                            User-defined unique and immutable key of the referenced resource.

                                                                                                                            + * * @return null|string */ - public function getTypeId(); + public function getKey(); /** * @param ?string $key */ public function setKey(?string $key): void; - - /** - * @param ?string $typeId - */ - public function setTypeId(?string $typeId): void; } diff --git a/lib/commercetools-history/src/Models/Common/KeyReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/KeyReferenceBuilder.php index 5edad50266c..d149c3d2299 100644 --- a/lib/commercetools-history/src/Models/Common/KeyReferenceBuilder.php +++ b/lib/commercetools-history/src/Models/Common/KeyReferenceBuilder.php @@ -27,12 +27,8 @@ final class KeyReferenceBuilder implements Builder private $key; /** - - * @var ?string - */ - private $typeId; - - /** + *

                                                                                                                            User-defined unique and immutable key of the referenced resource.

                                                                                                                            + * * @return null|string */ @@ -41,15 +37,6 @@ public function getKey() return $this->key; } - /** - - * @return null|string - */ - public function getTypeId() - { - return $this->typeId; - } - /** * @param ?string $key * @return $this @@ -61,23 +48,11 @@ public function withKey(?string $key) return $this; } - /** - * @param ?string $typeId - * @return $this - */ - public function withTypeId(?string $typeId) - { - $this->typeId = $typeId; - - return $this; - } - public function build(): KeyReference { return new KeyReferenceModel( - $this->key, - $this->typeId + $this->key ); } diff --git a/lib/commercetools-history/src/Models/Common/KeyReferenceCollection.php b/lib/commercetools-history/src/Models/Common/KeyReferenceCollection.php index a826083ccd1..e28e03e29e1 100644 --- a/lib/commercetools-history/src/Models/Common/KeyReferenceCollection.php +++ b/lib/commercetools-history/src/Models/Common/KeyReferenceCollection.php @@ -13,7 +13,11 @@ use stdClass; /** - * @extends MapperSequence + * @template T of KeyReference + * @extends MapperSequence + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) * @method KeyReference current() * @method KeyReference end() * @method KeyReference at($offset) @@ -21,8 +25,8 @@ class KeyReferenceCollection extends MapperSequence { /** - * @psalm-assert KeyReference $value - * @psalm-param KeyReference|stdClass $value + * @psalm-assert T $value + * @psalm-param T|stdClass $value * @throws InvalidArgumentException * * @return KeyReferenceCollection @@ -38,14 +42,14 @@ public function add($value) } /** - * @psalm-return callable(int):?KeyReference + * @psalm-return callable(int):?T */ protected function mapper() { return function (?int $index): ?KeyReference { $data = $this->get($index); if ($data instanceof stdClass) { - /** @var KeyReference $data */ + /** @var T $data */ $data = KeyReferenceModel::of($data); $this->set($data, $index); } diff --git a/lib/commercetools-history/src/Models/Common/KeyReferenceModel.php b/lib/commercetools-history/src/Models/Common/KeyReferenceModel.php index 4628bc762e8..6d6613bc6b1 100644 --- a/lib/commercetools-history/src/Models/Common/KeyReferenceModel.php +++ b/lib/commercetools-history/src/Models/Common/KeyReferenceModel.php @@ -20,19 +20,28 @@ final class KeyReferenceModel extends JsonObjectModel implements KeyReference { - + public const DISCRIMINATOR_VALUE = ''; /** * * @var ?string */ - protected $key; + protected $typeId; /** * * @var ?string */ - protected $typeId; + protected $key; + /** + * @psalm-var array > + * + */ + private static $discriminatorClasses = [ + 'associate-role' => AssociateRoleKeyReferenceModel::class, + 'business-unit' => BusinessUnitKeyReferenceModel::class, + 'store' => StoreKeyReferenceModel::class, + ]; /** * @psalm-suppress MissingParamType @@ -47,39 +56,43 @@ public function __construct( } /** + *

                                                                                                                            Type of referenced resource.

                                                                                                                            + * * * @return null|string */ - public function getKey() + public function getTypeId() { - if (is_null($this->key)) { + if (is_null($this->typeId)) { /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_KEY); + $data = $this->raw(self::FIELD_TYPE_ID); if (is_null($data)) { return null; } - $this->key = (string) $data; + $this->typeId = (string) $data; } - return $this->key; + return $this->typeId; } /** + *

                                                                                                                            User-defined unique and immutable key of the referenced resource.

                                                                                                                            + * * * @return null|string */ - public function getTypeId() + public function getKey() { - if (is_null($this->typeId)) { + if (is_null($this->key)) { /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_TYPE_ID); + $data = $this->raw(self::FIELD_KEY); if (is_null($data)) { return null; } - $this->typeId = (string) $data; + $this->key = (string) $data; } - return $this->typeId; + return $this->key; } @@ -91,14 +104,32 @@ public function setKey(?string $key): void $this->key = $key; } + + /** - * @param ?string $typeId + * @psalm-param stdClass|array $value + * @psalm-return class-string */ - public function setTypeId(?string $typeId): void + public static function resolveDiscriminatorClass($value): string { - $this->typeId = $typeId; + $fieldName = KeyReference::DISCRIMINATOR_FIELD; + if (is_object($value) && isset($value->$fieldName)) { + /** @psalm-var string $discriminatorValue */ + $discriminatorValue = $value->$fieldName; + if (isset(self::$discriminatorClasses[$discriminatorValue])) { + return self::$discriminatorClasses[$discriminatorValue]; + } + } + if (is_array($value) && isset($value[$fieldName])) { + /** @psalm-var string $discriminatorValue */ + $discriminatorValue = $value[$fieldName]; + if (isset(self::$discriminatorClasses[$discriminatorValue])) { + return self::$discriminatorClasses[$discriminatorValue]; + } + } + + /** @psalm-var class-string */ + $type = KeyReferenceModel::class; + return $type; } - - - } diff --git a/lib/commercetools-history/src/Models/Common/LineItem.php b/lib/commercetools-history/src/Models/Common/LineItem.php index 4688f6fa8ec..27e841d1254 100644 --- a/lib/commercetools-history/src/Models/Common/LineItem.php +++ b/lib/commercetools-history/src/Models/Common/LineItem.php @@ -10,90 +10,271 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use DateTimeImmutable; interface LineItem extends JsonObject { - public const FIELD_ADDED_AT = 'addedAt'; - public const FIELD_CUSTOM = 'custom'; public const FIELD_ID = 'id'; - public const FIELD_NAME = 'name'; + public const FIELD_KEY = 'key'; public const FIELD_PRODUCT_ID = 'productId'; + public const FIELD_PRODUCT_KEY = 'productKey'; + public const FIELD_NAME = 'name'; public const FIELD_PRODUCT_SLUG = 'productSlug'; public const FIELD_PRODUCT_TYPE = 'productType'; - public const FIELD_QUANTITY = 'quantity'; public const FIELD_VARIANT = 'variant'; - public const FIELD_VARIANT_ID = 'variantId'; + public const FIELD_PRICE = 'price'; + public const FIELD_QUANTITY = 'quantity'; + public const FIELD_TOTAL_PRICE = 'totalPrice'; + public const FIELD_DISCOUNTED_PRICE_PER_QUANTITY = 'discountedPricePerQuantity'; + public const FIELD_TAXED_PRICE = 'taxedPrice'; + public const FIELD_TAXED_PRICE_PORTIONS = 'taxedPricePortions'; + public const FIELD_STATE = 'state'; + public const FIELD_TAX_RATE = 'taxRate'; + public const FIELD_PER_METHOD_TAX_RATE = 'perMethodTaxRate'; + public const FIELD_SUPPLY_CHANNEL = 'supplyChannel'; + public const FIELD_DISTRIBUTION_CHANNEL = 'distributionChannel'; + public const FIELD_PRICE_MODE = 'priceMode'; + public const FIELD_LINE_ITEM_MODE = 'lineItemMode'; + public const FIELD_INVENTORY_MODE = 'inventoryMode'; + public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; + public const FIELD_CUSTOM = 'custom'; + public const FIELD_ADDED_AT = 'addedAt'; + public const FIELD_LAST_MODIFIED_AT = 'lastModifiedAt'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; /** + *

                                                                                                                            Unique identifier of the LineItem.

                                                                                                                            + * * @return null|string */ - public function getAddedAt(); + public function getId(); /** + *

                                                                                                                            User-defined unique identifier of the LineItem.

                                                                                                                            + * - * @return null|CustomFields + * @return null|string */ - public function getCustom(); + public function getKey(); /** + *

                                                                                                                            id of the Product the Line Item is based on.

                                                                                                                            + * * @return null|string */ - public function getId(); + public function getProductId(); /** + *

                                                                                                                            key of the Product.

                                                                                                                            + *

                                                                                                                            This field is only present on:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Line Items in a Cart when the key is available on that specific Product at the time the LineItem was created or updated on the Cart.
                                                                                                                            • + *
                                                                                                                            • Line Items in an Order when the key is available on the specific Product at the time the Order was created from the Cart.
                                                                                                                            • + *
                                                                                                                            + *

                                                                                                                            Present on resources created or updated after 3 December 2021.

                                                                                                                            + * - * @return null|LocalizedString + * @return null|string */ - public function getName(); + public function getProductKey(); /** + *

                                                                                                                            Name of the Product.

                                                                                                                            + * - * @return null|string + * @return null|LocalizedString */ - public function getProductId(); + public function getName(); /** + *

                                                                                                                            slug of the current version of the Product. Updated automatically if the slug changes. Empty if the Product has been deleted. + * The productSlug field of LineItem is not expanded when using Reference Expansion.

                                                                                                                            + * * @return null|LocalizedString */ public function getProductSlug(); /** + *

                                                                                                                            Product Type of the Product.

                                                                                                                            + * - * @return null|Reference + * @return null|ProductTypeReference */ public function getProductType(); /** + *

                                                                                                                            Holds the data of the Product Variant added to the Cart.

                                                                                                                            + *

                                                                                                                            The data is saved at the time the Product Variant is added to the Cart and is not updated automatically when Product Variant data changes. + * Must be updated using the Recalculate update action.

                                                                                                                            + * + + * @return null|ProductVariant + */ + public function getVariant(); + + /** + *

                                                                                                                            Price of a Line Item selected from the Product Variant according to the Product priceMode. If the priceMode is Embedded ProductPriceMode and the variant field hasn't been updated, the price may not correspond to a price in variant.prices.

                                                                                                                            + * + + * @return null|Price + */ + public function getPrice(); + + /** + *

                                                                                                                            Number of Line Items of the given Product Variant present in the Cart or Order.

                                                                                                                            + * * @return null|int */ public function getQuantity(); /** + *

                                                                                                                            Total price of this Line Item equalling price multiplied by quantity. If the Line Item is discounted, the total price is the discountedPricePerQuantity multiplied by quantity. + * Includes taxes if the TaxRate includedInPrice is true.

                                                                                                                            + *

                                                                                                                            If ExternalPrice LineItemPriceMode is used with high-precision money, then the total price is rounded by using the HalfEven rounding mode.

                                                                                                                            + * - * @return null|Variant + * @return null|CentPrecisionMoney */ - public function getVariant(); + public function getTotalPrice(); /** + *

                                                                                                                            Discounted price of a single quantity of the Line Item.

                                                                                                                            + * - * @return null|int + * @return null|DiscountedLineItemPriceForQuantityCollection */ - public function getVariantId(); + public function getDiscountedPricePerQuantity(); /** - * @param ?string $addedAt + *

                                                                                                                            Automatically set after taxRate is set.

                                                                                                                            + * + + * @return null|TaxedItemPrice */ - public function setAddedAt(?string $addedAt): void; + public function getTaxedPrice(); /** - * @param ?CustomFields $custom + *

                                                                                                                            Total taxed prices based on the quantity of Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. + * Automatically set after perMethodTaxRate is set.

                                                                                                                            + * + + * @return null|MethodTaxedPriceCollection */ - public function setCustom(?CustomFields $custom): void; + public function getTaxedPricePortions(); + + /** + *

                                                                                                                            Tracks specific quantities of the Line Item within a given State. When a Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Line Items are managed on the Order.

                                                                                                                            + * + + * @return null|ItemStateCollection + */ + public function getState(); + + /** + *
                                                                                                                              + *
                                                                                                                            • For a Cart with Platform TaxMode, the taxRate of Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
                                                                                                                            • + *
                                                                                                                            • For a Cart with External TaxMode, the taxRate of Line Items can be set using ExternalTaxRateDraft.
                                                                                                                            • + *
                                                                                                                            + * + + * @return null|TaxRate + */ + public function getTaxRate(); + + /** + *

                                                                                                                            Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. + * For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

                                                                                                                            + * + + * @return null|MethodTaxRateCollection + */ + public function getPerMethodTaxRate(); + + /** + *

                                                                                                                            Identifies Inventory entries that are reserved. The referenced Channel has the InventorySupply ChannelRoleEnum.

                                                                                                                            + * + + * @return null|ChannelReference + */ + public function getSupplyChannel(); + + /** + *

                                                                                                                            Used to select a Product Price. The referenced Channel has the ProductDistribution ChannelRoleEnum.

                                                                                                                            + * + + * @return null|ChannelReference + */ + public function getDistributionChannel(); + + /** + *

                                                                                                                            Indicates how the Price for the Line Item is set.

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

                                                                                                                            Indicates how the Line Item is added to the Cart.

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

                                                                                                                            Inventory mode specific to this Line Item only, and valid for the entire quantity of the Line Item. + * Only present if the inventory mode is different from the inventoryMode specified on the Cart.

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

                                                                                                                            Container for Line Item-specific addresses.

                                                                                                                            + * + + * @return null|ItemShippingDetails + */ + public function getShippingDetails(); + + /** + *

                                                                                                                            Custom Fields of the Line Item.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom(); + + /** + *

                                                                                                                            Date and time (UTC) the Line Item was added to the Cart.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ + public function getAddedAt(); + + /** + *

                                                                                                                            Date and time (UTC) the Line Item was last updated.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ + public function getLastModifiedAt(); + + /** + *

                                                                                                                            Recurring Order and frequency data.

                                                                                                                            + * + + * @return null|LineItemRecurrenceInfo + */ + public function getRecurrenceInfo(); /** * @param ?string $id @@ -101,24 +282,44 @@ public function setCustom(?CustomFields $custom): void; public function setId(?string $id): void; /** - * @param ?LocalizedString $name + * @param ?string $key */ - public function setName(?LocalizedString $name): void; + public function setKey(?string $key): void; /** * @param ?string $productId */ public function setProductId(?string $productId): void; + /** + * @param ?string $productKey + */ + public function setProductKey(?string $productKey): void; + + /** + * @param ?LocalizedString $name + */ + public function setName(?LocalizedString $name): void; + /** * @param ?LocalizedString $productSlug */ public function setProductSlug(?LocalizedString $productSlug): void; /** - * @param ?Reference $productType + * @param ?ProductTypeReference $productType + */ + public function setProductType(?ProductTypeReference $productType): void; + + /** + * @param ?ProductVariant $variant + */ + public function setVariant(?ProductVariant $variant): void; + + /** + * @param ?Price $price */ - public function setProductType(?Reference $productType): void; + public function setPrice(?Price $price): void; /** * @param ?int $quantity @@ -126,12 +327,87 @@ public function setProductType(?Reference $productType): void; public function setQuantity(?int $quantity): void; /** - * @param ?Variant $variant + * @param ?CentPrecisionMoney $totalPrice + */ + public function setTotalPrice(?CentPrecisionMoney $totalPrice): void; + + /** + * @param ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity + */ + public function setDiscountedPricePerQuantity(?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity): void; + + /** + * @param ?TaxedItemPrice $taxedPrice + */ + public function setTaxedPrice(?TaxedItemPrice $taxedPrice): void; + + /** + * @param ?MethodTaxedPriceCollection $taxedPricePortions + */ + public function setTaxedPricePortions(?MethodTaxedPriceCollection $taxedPricePortions): void; + + /** + * @param ?ItemStateCollection $state + */ + public function setState(?ItemStateCollection $state): void; + + /** + * @param ?TaxRate $taxRate + */ + public function setTaxRate(?TaxRate $taxRate): void; + + /** + * @param ?MethodTaxRateCollection $perMethodTaxRate + */ + public function setPerMethodTaxRate(?MethodTaxRateCollection $perMethodTaxRate): void; + + /** + * @param ?ChannelReference $supplyChannel + */ + public function setSupplyChannel(?ChannelReference $supplyChannel): void; + + /** + * @param ?ChannelReference $distributionChannel + */ + public function setDistributionChannel(?ChannelReference $distributionChannel): void; + + /** + * @param ?string $priceMode + */ + public function setPriceMode(?string $priceMode): void; + + /** + * @param ?string $lineItemMode + */ + public function setLineItemMode(?string $lineItemMode): void; + + /** + * @param ?string $inventoryMode + */ + public function setInventoryMode(?string $inventoryMode): void; + + /** + * @param ?ItemShippingDetails $shippingDetails + */ + public function setShippingDetails(?ItemShippingDetails $shippingDetails): void; + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void; + + /** + * @param ?DateTimeImmutable $addedAt + */ + public function setAddedAt(?DateTimeImmutable $addedAt): void; + + /** + * @param ?DateTimeImmutable $lastModifiedAt */ - public function setVariant(?Variant $variant): void; + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void; /** - * @param ?int $variantId + * @param ?LineItemRecurrenceInfo $recurrenceInfo */ - public function setVariantId(?int $variantId): void; + public function setRecurrenceInfo(?LineItemRecurrenceInfo $recurrenceInfo): void; } diff --git a/lib/commercetools-history/src/Models/Common/LineItemBuilder.php b/lib/commercetools-history/src/Models/Common/LineItemBuilder.php index 3e79b30807d..7d5a28aa2e5 100644 --- a/lib/commercetools-history/src/Models/Common/LineItemBuilder.php +++ b/lib/commercetools-history/src/Models/Common/LineItemBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @implements Builder @@ -24,31 +25,31 @@ final class LineItemBuilder implements Builder * @var ?string */ - private $addedAt; + private $id; /** - * @var null|CustomFields|CustomFieldsBuilder + * @var ?string */ - private $custom; + private $key; /** * @var ?string */ - private $id; + private $productId; /** - * @var null|LocalizedString|LocalizedStringBuilder + * @var ?string */ - private $name; + private $productKey; /** - * @var ?string + * @var null|LocalizedString|LocalizedStringBuilder */ - private $productId; + private $name; /** @@ -58,10 +59,22 @@ final class LineItemBuilder implements Builder /** - * @var null|Reference|ReferenceBuilder + * @var null|ProductTypeReference|ProductTypeReferenceBuilder */ private $productType; + /** + + * @var null|ProductVariant|ProductVariantBuilder + */ + private $variant; + + /** + + * @var null|Price|PriceBuilder + */ + private $price; + /** * @var ?int @@ -70,36 +83,110 @@ final class LineItemBuilder implements Builder /** - * @var null|Variant|VariantBuilder + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder */ - private $variant; + private $totalPrice; /** - * @var ?int + * @var ?DiscountedLineItemPriceForQuantityCollection */ - private $variantId; + private $discountedPricePerQuantity; /** - * @return null|string + * @var null|TaxedItemPrice|TaxedItemPriceBuilder */ - public function getAddedAt() - { - return $this->addedAt; - } + private $taxedPrice; /** - * @return null|CustomFields + * @var ?MethodTaxedPriceCollection */ - public function getCustom() - { - return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; - } + private $taxedPricePortions; /** + * @var ?ItemStateCollection + */ + private $state; + + /** + + * @var null|TaxRate|TaxRateBuilder + */ + private $taxRate; + + /** + + * @var ?MethodTaxRateCollection + */ + private $perMethodTaxRate; + + /** + + * @var null|ChannelReference|ChannelReferenceBuilder + */ + private $supplyChannel; + + /** + + * @var null|ChannelReference|ChannelReferenceBuilder + */ + private $distributionChannel; + + /** + + * @var ?string + */ + private $priceMode; + + /** + + * @var ?string + */ + private $lineItemMode; + + /** + + * @var ?string + */ + private $inventoryMode; + + /** + + * @var null|ItemShippingDetails|ItemShippingDetailsBuilder + */ + private $shippingDetails; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + + /** + + * @var ?DateTimeImmutable + */ + private $addedAt; + + /** + + * @var ?DateTimeImmutable + */ + private $lastModifiedAt; + + /** + + * @var null|LineItemRecurrenceInfo|LineItemRecurrenceInfoBuilder + */ + private $recurrenceInfo; + + /** + *

                                                                                                                            Unique identifier of the LineItem.

                                                                                                                            + * + * @return null|string */ public function getId() @@ -108,15 +195,19 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the LineItem.

                                                                                                                            + * - * @return null|LocalizedString + * @return null|string */ - public function getName() + public function getKey() { - return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name; + return $this->key; } /** + *

                                                                                                                            id of the Product the Line Item is based on.

                                                                                                                            + * * @return null|string */ @@ -126,6 +217,37 @@ public function getProductId() } /** + *

                                                                                                                            key of the Product.

                                                                                                                            + *

                                                                                                                            This field is only present on:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Line Items in a Cart when the key is available on that specific Product at the time the LineItem was created or updated on the Cart.
                                                                                                                            • + *
                                                                                                                            • Line Items in an Order when the key is available on the specific Product at the time the Order was created from the Cart.
                                                                                                                            • + *
                                                                                                                            + *

                                                                                                                            Present on resources created or updated after 3 December 2021.

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

                                                                                                                            Name of the Product.

                                                                                                                            + * + + * @return null|LocalizedString + */ + public function getName() + { + return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name; + } + + /** + *

                                                                                                                            slug of the current version of the Product. Updated automatically if the slug changes. Empty if the Product has been deleted. + * The productSlug field of LineItem is not expanded when using Reference Expansion.

                                                                                                                            + * * @return null|LocalizedString */ @@ -135,15 +257,43 @@ public function getProductSlug() } /** + *

                                                                                                                            Product Type of the Product.

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

                                                                                                                            Holds the data of the Product Variant added to the Cart.

                                                                                                                            + *

                                                                                                                            The data is saved at the time the Product Variant is added to the Cart and is not updated automatically when Product Variant data changes. + * Must be updated using the Recalculate update action.

                                                                                                                            + * + + * @return null|ProductVariant + */ + public function getVariant() + { + return $this->variant instanceof ProductVariantBuilder ? $this->variant->build() : $this->variant; } /** + *

                                                                                                                            Price of a Line Item selected from the Product Variant according to the Product priceMode. If the priceMode is Embedded ProductPriceMode and the variant field hasn't been updated, the price may not correspond to a price in variant.prices.

                                                                                                                            + * + + * @return null|Price + */ + public function getPrice() + { + return $this->price instanceof PriceBuilder ? $this->price->build() : $this->price; + } + + /** + *

                                                                                                                            Number of Line Items of the given Product Variant present in the Cart or Order.

                                                                                                                            + * * @return null|int */ @@ -153,43 +303,198 @@ public function getQuantity() } /** + *

                                                                                                                            Total price of this Line Item equalling price multiplied by quantity. If the Line Item is discounted, the total price is the discountedPricePerQuantity multiplied by quantity. + * Includes taxes if the TaxRate includedInPrice is true.

                                                                                                                            + *

                                                                                                                            If ExternalPrice LineItemPriceMode is used with high-precision money, then the total price is rounded by using the HalfEven rounding mode.

                                                                                                                            + * - * @return null|Variant + * @return null|CentPrecisionMoney */ - public function getVariant() + public function getTotalPrice() { - return $this->variant instanceof VariantBuilder ? $this->variant->build() : $this->variant; + return $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice; } /** + *

                                                                                                                            Discounted price of a single quantity of the Line Item.

                                                                                                                            + * - * @return null|int + * @return null|DiscountedLineItemPriceForQuantityCollection */ - public function getVariantId() + public function getDiscountedPricePerQuantity() { - return $this->variantId; + return $this->discountedPricePerQuantity; } /** - * @param ?string $addedAt - * @return $this + *

                                                                                                                            Automatically set after taxRate is set.

                                                                                                                            + * + + * @return null|TaxedItemPrice */ - public function withAddedAt(?string $addedAt) + public function getTaxedPrice() { - $this->addedAt = $addedAt; + return $this->taxedPrice instanceof TaxedItemPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice; + } - return $this; + /** + *

                                                                                                                            Total taxed prices based on the quantity of Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. + * Automatically set after perMethodTaxRate is set.

                                                                                                                            + * + + * @return null|MethodTaxedPriceCollection + */ + public function getTaxedPricePortions() + { + return $this->taxedPricePortions; } /** - * @param ?CustomFields $custom - * @return $this + *

                                                                                                                            Tracks specific quantities of the Line Item within a given State. When a Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Line Items are managed on the Order.

                                                                                                                            + * + + * @return null|ItemStateCollection */ - public function withCustom(?CustomFields $custom) + public function getState() { - $this->custom = $custom; + return $this->state; + } - return $this; + /** + *
                                                                                                                              + *
                                                                                                                            • For a Cart with Platform TaxMode, the taxRate of Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
                                                                                                                            • + *
                                                                                                                            • For a Cart with External TaxMode, the taxRate of Line Items can be set using ExternalTaxRateDraft.
                                                                                                                            • + *
                                                                                                                            + * + + * @return null|TaxRate + */ + public function getTaxRate() + { + return $this->taxRate instanceof TaxRateBuilder ? $this->taxRate->build() : $this->taxRate; + } + + /** + *

                                                                                                                            Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. + * For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

                                                                                                                            + * + + * @return null|MethodTaxRateCollection + */ + public function getPerMethodTaxRate() + { + return $this->perMethodTaxRate; + } + + /** + *

                                                                                                                            Identifies Inventory entries that are reserved. The referenced Channel has the InventorySupply ChannelRoleEnum.

                                                                                                                            + * + + * @return null|ChannelReference + */ + public function getSupplyChannel() + { + return $this->supplyChannel instanceof ChannelReferenceBuilder ? $this->supplyChannel->build() : $this->supplyChannel; + } + + /** + *

                                                                                                                            Used to select a Product Price. The referenced Channel has the ProductDistribution ChannelRoleEnum.

                                                                                                                            + * + + * @return null|ChannelReference + */ + public function getDistributionChannel() + { + return $this->distributionChannel instanceof ChannelReferenceBuilder ? $this->distributionChannel->build() : $this->distributionChannel; + } + + /** + *

                                                                                                                            Indicates how the Price for the Line Item is set.

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

                                                                                                                            Indicates how the Line Item is added to the Cart.

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

                                                                                                                            Inventory mode specific to this Line Item only, and valid for the entire quantity of the Line Item. + * Only present if the inventory mode is different from the inventoryMode specified on the Cart.

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

                                                                                                                            Container for Line Item-specific addresses.

                                                                                                                            + * + + * @return null|ItemShippingDetails + */ + public function getShippingDetails() + { + return $this->shippingDetails instanceof ItemShippingDetailsBuilder ? $this->shippingDetails->build() : $this->shippingDetails; + } + + /** + *

                                                                                                                            Custom Fields of the Line Item.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; + } + + /** + *

                                                                                                                            Date and time (UTC) the Line Item was added to the Cart.

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

                                                                                                                            Date and time (UTC) the Line Item was last updated.

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

                                                                                                                            Recurring Order and frequency data.

                                                                                                                            + * + + * @return null|LineItemRecurrenceInfo + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof LineItemRecurrenceInfoBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; } /** @@ -204,12 +509,12 @@ public function withId(?string $id) } /** - * @param ?LocalizedString $name + * @param ?string $key * @return $this */ - public function withName(?LocalizedString $name) + public function withKey(?string $key) { - $this->name = $name; + $this->key = $key; return $this; } @@ -225,6 +530,28 @@ public function withProductId(?string $productId) return $this; } + /** + * @param ?string $productKey + * @return $this + */ + public function withProductKey(?string $productKey) + { + $this->productKey = $productKey; + + return $this; + } + + /** + * @param ?LocalizedString $name + * @return $this + */ + public function withName(?LocalizedString $name) + { + $this->name = $name; + + return $this; + } + /** * @param ?LocalizedString $productSlug * @return $this @@ -237,16 +564,38 @@ public function withProductSlug(?LocalizedString $productSlug) } /** - * @param ?Reference $productType + * @param ?ProductTypeReference $productType * @return $this */ - public function withProductType(?Reference $productType) + public function withProductType(?ProductTypeReference $productType) { $this->productType = $productType; return $this; } + /** + * @param ?ProductVariant $variant + * @return $this + */ + public function withVariant(?ProductVariant $variant) + { + $this->variant = $variant; + + return $this; + } + + /** + * @param ?Price $price + * @return $this + */ + public function withPrice(?Price $price) + { + $this->price = $price; + + return $this; + } + /** * @param ?int $quantity * @return $this @@ -259,38 +608,192 @@ public function withQuantity(?int $quantity) } /** - * @param ?Variant $variant + * @param ?CentPrecisionMoney $totalPrice * @return $this */ - public function withVariant(?Variant $variant) + public function withTotalPrice(?CentPrecisionMoney $totalPrice) { - $this->variant = $variant; + $this->totalPrice = $totalPrice; return $this; } /** - * @param ?int $variantId + * @param ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity * @return $this */ - public function withVariantId(?int $variantId) + public function withDiscountedPricePerQuantity(?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity) { - $this->variantId = $variantId; + $this->discountedPricePerQuantity = $discountedPricePerQuantity; return $this; } /** - * @deprecated use withCustom() instead + * @param ?TaxedItemPrice $taxedPrice * @return $this */ - public function withCustomBuilder(?CustomFieldsBuilder $custom) + public function withTaxedPrice(?TaxedItemPrice $taxedPrice) + { + $this->taxedPrice = $taxedPrice; + + return $this; + } + + /** + * @param ?MethodTaxedPriceCollection $taxedPricePortions + * @return $this + */ + public function withTaxedPricePortions(?MethodTaxedPriceCollection $taxedPricePortions) + { + $this->taxedPricePortions = $taxedPricePortions; + + return $this; + } + + /** + * @param ?ItemStateCollection $state + * @return $this + */ + public function withState(?ItemStateCollection $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?TaxRate $taxRate + * @return $this + */ + public function withTaxRate(?TaxRate $taxRate) + { + $this->taxRate = $taxRate; + + return $this; + } + + /** + * @param ?MethodTaxRateCollection $perMethodTaxRate + * @return $this + */ + public function withPerMethodTaxRate(?MethodTaxRateCollection $perMethodTaxRate) + { + $this->perMethodTaxRate = $perMethodTaxRate; + + return $this; + } + + /** + * @param ?ChannelReference $supplyChannel + * @return $this + */ + public function withSupplyChannel(?ChannelReference $supplyChannel) + { + $this->supplyChannel = $supplyChannel; + + return $this; + } + + /** + * @param ?ChannelReference $distributionChannel + * @return $this + */ + public function withDistributionChannel(?ChannelReference $distributionChannel) + { + $this->distributionChannel = $distributionChannel; + + return $this; + } + + /** + * @param ?string $priceMode + * @return $this + */ + public function withPriceMode(?string $priceMode) + { + $this->priceMode = $priceMode; + + return $this; + } + + /** + * @param ?string $lineItemMode + * @return $this + */ + public function withLineItemMode(?string $lineItemMode) + { + $this->lineItemMode = $lineItemMode; + + return $this; + } + + /** + * @param ?string $inventoryMode + * @return $this + */ + public function withInventoryMode(?string $inventoryMode) + { + $this->inventoryMode = $inventoryMode; + + return $this; + } + + /** + * @param ?ItemShippingDetails $shippingDetails + * @return $this + */ + public function withShippingDetails(?ItemShippingDetails $shippingDetails) + { + $this->shippingDetails = $shippingDetails; + + return $this; + } + + /** + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) { $this->custom = $custom; return $this; } + /** + * @param ?DateTimeImmutable $addedAt + * @return $this + */ + public function withAddedAt(?DateTimeImmutable $addedAt) + { + $this->addedAt = $addedAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + * @return $this + */ + public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt) + { + $this->lastModifiedAt = $lastModifiedAt; + + return $this; + } + + /** + * @param ?LineItemRecurrenceInfo $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?LineItemRecurrenceInfo $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withName() instead * @return $this @@ -317,7 +820,7 @@ public function withProductSlugBuilder(?LocalizedStringBuilder $productSlug) * @deprecated use withProductType() instead * @return $this */ - public function withProductTypeBuilder(?ReferenceBuilder $productType) + public function withProductTypeBuilder(?ProductTypeReferenceBuilder $productType) { $this->productType = $productType; @@ -328,26 +831,142 @@ public function withProductTypeBuilder(?ReferenceBuilder $productType) * @deprecated use withVariant() instead * @return $this */ - public function withVariantBuilder(?VariantBuilder $variant) + public function withVariantBuilder(?ProductVariantBuilder $variant) { $this->variant = $variant; return $this; } + /** + * @deprecated use withPrice() instead + * @return $this + */ + public function withPriceBuilder(?PriceBuilder $price) + { + $this->price = $price; + + return $this; + } + + /** + * @deprecated use withTotalPrice() instead + * @return $this + */ + public function withTotalPriceBuilder(?CentPrecisionMoneyBuilder $totalPrice) + { + $this->totalPrice = $totalPrice; + + return $this; + } + + /** + * @deprecated use withTaxedPrice() instead + * @return $this + */ + public function withTaxedPriceBuilder(?TaxedItemPriceBuilder $taxedPrice) + { + $this->taxedPrice = $taxedPrice; + + return $this; + } + + /** + * @deprecated use withTaxRate() instead + * @return $this + */ + public function withTaxRateBuilder(?TaxRateBuilder $taxRate) + { + $this->taxRate = $taxRate; + + return $this; + } + + /** + * @deprecated use withSupplyChannel() instead + * @return $this + */ + public function withSupplyChannelBuilder(?ChannelReferenceBuilder $supplyChannel) + { + $this->supplyChannel = $supplyChannel; + + return $this; + } + + /** + * @deprecated use withDistributionChannel() instead + * @return $this + */ + public function withDistributionChannelBuilder(?ChannelReferenceBuilder $distributionChannel) + { + $this->distributionChannel = $distributionChannel; + + return $this; + } + + /** + * @deprecated use withShippingDetails() instead + * @return $this + */ + public function withShippingDetailsBuilder(?ItemShippingDetailsBuilder $shippingDetails) + { + $this->shippingDetails = $shippingDetails; + + return $this; + } + + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?LineItemRecurrenceInfoBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + public function build(): LineItem { return new LineItemModel( - $this->addedAt, - $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, $this->id, - $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name, + $this->key, $this->productId, + $this->productKey, + $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name, $this->productSlug instanceof LocalizedStringBuilder ? $this->productSlug->build() : $this->productSlug, - $this->productType instanceof ReferenceBuilder ? $this->productType->build() : $this->productType, + $this->productType instanceof ProductTypeReferenceBuilder ? $this->productType->build() : $this->productType, + $this->variant instanceof ProductVariantBuilder ? $this->variant->build() : $this->variant, + $this->price instanceof PriceBuilder ? $this->price->build() : $this->price, $this->quantity, - $this->variant instanceof VariantBuilder ? $this->variant->build() : $this->variant, - $this->variantId + $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice, + $this->discountedPricePerQuantity, + $this->taxedPrice instanceof TaxedItemPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice, + $this->taxedPricePortions, + $this->state, + $this->taxRate instanceof TaxRateBuilder ? $this->taxRate->build() : $this->taxRate, + $this->perMethodTaxRate, + $this->supplyChannel instanceof ChannelReferenceBuilder ? $this->supplyChannel->build() : $this->supplyChannel, + $this->distributionChannel instanceof ChannelReferenceBuilder ? $this->distributionChannel->build() : $this->distributionChannel, + $this->priceMode, + $this->lineItemMode, + $this->inventoryMode, + $this->shippingDetails instanceof ItemShippingDetailsBuilder ? $this->shippingDetails->build() : $this->shippingDetails, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, + $this->addedAt, + $this->lastModifiedAt, + $this->recurrenceInfo instanceof LineItemRecurrenceInfoBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo ); } diff --git a/lib/commercetools-history/src/Models/Common/LineItemModel.php b/lib/commercetools-history/src/Models/Common/LineItemModel.php index 5db57ac92e2..f85d840ec09 100644 --- a/lib/commercetools-history/src/Models/Common/LineItemModel.php +++ b/lib/commercetools-history/src/Models/Common/LineItemModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @internal @@ -25,31 +26,31 @@ final class LineItemModel extends JsonObjectModel implements LineItem * * @var ?string */ - protected $addedAt; + protected $id; /** * - * @var ?CustomFields + * @var ?string */ - protected $custom; + protected $key; /** * * @var ?string */ - protected $id; + protected $productId; /** * - * @var ?LocalizedString + * @var ?string */ - protected $name; + protected $productKey; /** * - * @var ?string + * @var ?LocalizedString */ - protected $productId; + protected $name; /** * @@ -59,10 +60,22 @@ final class LineItemModel extends JsonObjectModel implements LineItem /** * - * @var ?Reference + * @var ?ProductTypeReference */ protected $productType; + /** + * + * @var ?ProductVariant + */ + protected $variant; + + /** + * + * @var ?Price + */ + protected $price; + /** * * @var ?int @@ -71,138 +84,280 @@ final class LineItemModel extends JsonObjectModel implements LineItem /** * - * @var ?Variant + * @var ?CentPrecisionMoney */ - protected $variant; + protected $totalPrice; /** * - * @var ?int + * @var ?DiscountedLineItemPriceForQuantityCollection + */ + protected $discountedPricePerQuantity; + + /** + * + * @var ?TaxedItemPrice + */ + protected $taxedPrice; + + /** + * + * @var ?MethodTaxedPriceCollection + */ + protected $taxedPricePortions; + + /** + * + * @var ?ItemStateCollection + */ + protected $state; + + /** + * + * @var ?TaxRate + */ + protected $taxRate; + + /** + * + * @var ?MethodTaxRateCollection + */ + protected $perMethodTaxRate; + + /** + * + * @var ?ChannelReference + */ + protected $supplyChannel; + + /** + * + * @var ?ChannelReference + */ + protected $distributionChannel; + + /** + * + * @var ?string + */ + protected $priceMode; + + /** + * + * @var ?string + */ + protected $lineItemMode; + + /** + * + * @var ?string + */ + protected $inventoryMode; + + /** + * + * @var ?ItemShippingDetails + */ + protected $shippingDetails; + + /** + * + * @var ?CustomFields + */ + protected $custom; + + /** + * + * @var ?DateTimeImmutable + */ + protected $addedAt; + + /** + * + * @var ?DateTimeImmutable + */ + protected $lastModifiedAt; + + /** + * + * @var ?LineItemRecurrenceInfo */ - protected $variantId; + protected $recurrenceInfo; /** * @psalm-suppress MissingParamType */ public function __construct( - ?string $addedAt = null, - ?CustomFields $custom = null, ?string $id = null, - ?LocalizedString $name = null, + ?string $key = null, ?string $productId = null, + ?string $productKey = null, + ?LocalizedString $name = null, ?LocalizedString $productSlug = null, - ?Reference $productType = null, + ?ProductTypeReference $productType = null, + ?ProductVariant $variant = null, + ?Price $price = null, ?int $quantity = null, - ?Variant $variant = null, - ?int $variantId = null + ?CentPrecisionMoney $totalPrice = null, + ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity = null, + ?TaxedItemPrice $taxedPrice = null, + ?MethodTaxedPriceCollection $taxedPricePortions = null, + ?ItemStateCollection $state = null, + ?TaxRate $taxRate = null, + ?MethodTaxRateCollection $perMethodTaxRate = null, + ?ChannelReference $supplyChannel = null, + ?ChannelReference $distributionChannel = null, + ?string $priceMode = null, + ?string $lineItemMode = null, + ?string $inventoryMode = null, + ?ItemShippingDetails $shippingDetails = null, + ?CustomFields $custom = null, + ?DateTimeImmutable $addedAt = null, + ?DateTimeImmutable $lastModifiedAt = null, + ?LineItemRecurrenceInfo $recurrenceInfo = null ) { - $this->addedAt = $addedAt; - $this->custom = $custom; $this->id = $id; - $this->name = $name; + $this->key = $key; $this->productId = $productId; + $this->productKey = $productKey; + $this->name = $name; $this->productSlug = $productSlug; $this->productType = $productType; - $this->quantity = $quantity; $this->variant = $variant; - $this->variantId = $variantId; + $this->price = $price; + $this->quantity = $quantity; + $this->totalPrice = $totalPrice; + $this->discountedPricePerQuantity = $discountedPricePerQuantity; + $this->taxedPrice = $taxedPrice; + $this->taxedPricePortions = $taxedPricePortions; + $this->state = $state; + $this->taxRate = $taxRate; + $this->perMethodTaxRate = $perMethodTaxRate; + $this->supplyChannel = $supplyChannel; + $this->distributionChannel = $distributionChannel; + $this->priceMode = $priceMode; + $this->lineItemMode = $lineItemMode; + $this->inventoryMode = $inventoryMode; + $this->shippingDetails = $shippingDetails; + $this->custom = $custom; + $this->addedAt = $addedAt; + $this->lastModifiedAt = $lastModifiedAt; + $this->recurrenceInfo = $recurrenceInfo; } /** + *

                                                                                                                            Unique identifier of the LineItem.

                                                                                                                            + * * * @return null|string */ - public function getAddedAt() + public function getId() { - if (is_null($this->addedAt)) { + if (is_null($this->id)) { /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_ADDED_AT); + $data = $this->raw(self::FIELD_ID); if (is_null($data)) { return null; } - $this->addedAt = (string) $data; + $this->id = (string) $data; } - return $this->addedAt; + return $this->id; } /** + *

                                                                                                                            User-defined unique identifier of the LineItem.

                                                                                                                            * - * @return null|CustomFields + * + * @return null|string */ - public function getCustom() + public function getKey() { - if (is_null($this->custom)) { - /** @psalm-var stdClass|array|null $data */ - $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($this->key)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_KEY); if (is_null($data)) { return null; } - - $this->custom = CustomFieldsModel::of($data); + $this->key = (string) $data; } - return $this->custom; + return $this->key; } /** + *

                                                                                                                            id of the Product the Line Item is based on.

                                                                                                                            + * * * @return null|string */ - public function getId() + public function getProductId() { - if (is_null($this->id)) { + if (is_null($this->productId)) { /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_ID); + $data = $this->raw(self::FIELD_PRODUCT_ID); if (is_null($data)) { return null; } - $this->id = (string) $data; + $this->productId = (string) $data; } - return $this->id; + return $this->productId; } /** + *

                                                                                                                            key of the Product.

                                                                                                                            + *

                                                                                                                            This field is only present on:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Line Items in a Cart when the key is available on that specific Product at the time the LineItem was created or updated on the Cart.
                                                                                                                            • + *
                                                                                                                            • Line Items in an Order when the key is available on the specific Product at the time the Order was created from the Cart.
                                                                                                                            • + *
                                                                                                                            + *

                                                                                                                            Present on resources created or updated after 3 December 2021.

                                                                                                                            * - * @return null|LocalizedString + * + * @return null|string */ - public function getName() + public function getProductKey() { - if (is_null($this->name)) { - /** @psalm-var stdClass|array|null $data */ - $data = $this->raw(self::FIELD_NAME); + if (is_null($this->productKey)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_PRODUCT_KEY); if (is_null($data)) { return null; } - - $this->name = LocalizedStringModel::of($data); + $this->productKey = (string) $data; } - return $this->name; + return $this->productKey; } /** + *

                                                                                                                            Name of the Product.

                                                                                                                            * - * @return null|string + * + * @return null|LocalizedString */ - public function getProductId() + public function getName() { - if (is_null($this->productId)) { - /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_PRODUCT_ID); + if (is_null($this->name)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NAME); if (is_null($data)) { return null; } - $this->productId = (string) $data; + + $this->name = LocalizedStringModel::of($data); } - return $this->productId; + return $this->name; } /** + *

                                                                                                                            slug of the current version of the Product. Updated automatically if the slug changes. Empty if the Product has been deleted. + * The productSlug field of LineItem is not expanded when using Reference Expansion.

                                                                                                                            + * * * @return null|LocalizedString */ @@ -222,8 +377,10 @@ public function getProductSlug() } /** + *

                                                                                                                            Product Type of the Product.

                                                                                                                            + * * - * @return null|Reference + * @return null|ProductTypeReference */ public function getProductType() { @@ -234,124 +391,513 @@ public function getProductType() return null; } - $this->productType = ReferenceModel::of($data); + $this->productType = ProductTypeReferenceModel::of($data); } return $this->productType; } /** + *

                                                                                                                            Holds the data of the Product Variant added to the Cart.

                                                                                                                            + *

                                                                                                                            The data is saved at the time the Product Variant is added to the Cart and is not updated automatically when Product Variant data changes. + * Must be updated using the Recalculate update action.

                                                                                                                            * - * @return null|int + * + * @return null|ProductVariant */ - public function getQuantity() + public function getVariant() { - if (is_null($this->quantity)) { - /** @psalm-var ?int $data */ - $data = $this->raw(self::FIELD_QUANTITY); + if (is_null($this->variant)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_VARIANT); if (is_null($data)) { return null; } - $this->quantity = (int) $data; + + $this->variant = ProductVariantModel::of($data); } - return $this->quantity; + return $this->variant; } /** + *

                                                                                                                            Price of a Line Item selected from the Product Variant according to the Product priceMode. If the priceMode is Embedded ProductPriceMode and the variant field hasn't been updated, the price may not correspond to a price in variant.prices.

                                                                                                                            * - * @return null|Variant + * + * @return null|Price */ - public function getVariant() + public function getPrice() { - if (is_null($this->variant)) { + if (is_null($this->price)) { /** @psalm-var stdClass|array|null $data */ - $data = $this->raw(self::FIELD_VARIANT); + $data = $this->raw(self::FIELD_PRICE); if (is_null($data)) { return null; } - $this->variant = VariantModel::of($data); + $this->price = PriceModel::of($data); } - return $this->variant; + return $this->price; } /** + *

                                                                                                                            Number of Line Items of the given Product Variant present in the Cart or Order.

                                                                                                                            + * * * @return null|int */ - public function getVariantId() + public function getQuantity() { - if (is_null($this->variantId)) { + if (is_null($this->quantity)) { /** @psalm-var ?int $data */ - $data = $this->raw(self::FIELD_VARIANT_ID); + $data = $this->raw(self::FIELD_QUANTITY); if (is_null($data)) { return null; } - $this->variantId = (int) $data; + $this->quantity = (int) $data; } - return $this->variantId; + return $this->quantity; } - /** - * @param ?string $addedAt + *

                                                                                                                            Total price of this Line Item equalling price multiplied by quantity. If the Line Item is discounted, the total price is the discountedPricePerQuantity multiplied by quantity. + * Includes taxes if the TaxRate includedInPrice is true.

                                                                                                                            + *

                                                                                                                            If ExternalPrice LineItemPriceMode is used with high-precision money, then the total price is rounded by using the HalfEven rounding mode.

                                                                                                                            + * + * + * @return null|CentPrecisionMoney */ - public function setAddedAt(?string $addedAt): void + public function getTotalPrice() { - $this->addedAt = $addedAt; + if (is_null($this->totalPrice)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TOTAL_PRICE); + if (is_null($data)) { + return null; + } + + $this->totalPrice = CentPrecisionMoneyModel::of($data); + } + + return $this->totalPrice; } /** - * @param ?CustomFields $custom + *

                                                                                                                            Discounted price of a single quantity of the Line Item.

                                                                                                                            + * + * + * @return null|DiscountedLineItemPriceForQuantityCollection */ - public function setCustom(?CustomFields $custom): void + public function getDiscountedPricePerQuantity() { - $this->custom = $custom; + if (is_null($this->discountedPricePerQuantity)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_DISCOUNTED_PRICE_PER_QUANTITY); + if (is_null($data)) { + return null; + } + $this->discountedPricePerQuantity = DiscountedLineItemPriceForQuantityCollection::fromArray($data); + } + + return $this->discountedPricePerQuantity; } /** - * @param ?string $id + *

                                                                                                                            Automatically set after taxRate is set.

                                                                                                                            + * + * + * @return null|TaxedItemPrice */ - public function setId(?string $id): void + public function getTaxedPrice() { - $this->id = $id; + if (is_null($this->taxedPrice)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TAXED_PRICE); + if (is_null($data)) { + return null; + } + + $this->taxedPrice = TaxedItemPriceModel::of($data); + } + + return $this->taxedPrice; } /** - * @param ?LocalizedString $name + *

                                                                                                                            Total taxed prices based on the quantity of Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. + * Automatically set after perMethodTaxRate is set.

                                                                                                                            + * + * + * @return null|MethodTaxedPriceCollection */ - public function setName(?LocalizedString $name): void + public function getTaxedPricePortions() { - $this->name = $name; + if (is_null($this->taxedPricePortions)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_TAXED_PRICE_PORTIONS); + if (is_null($data)) { + return null; + } + $this->taxedPricePortions = MethodTaxedPriceCollection::fromArray($data); + } + + return $this->taxedPricePortions; } /** - * @param ?string $productId + *

                                                                                                                            Tracks specific quantities of the Line Item within a given State. When a Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Line Items are managed on the Order.

                                                                                                                            + * + * + * @return null|ItemStateCollection */ - public function setProductId(?string $productId): void + public function getState() { - $this->productId = $productId; + if (is_null($this->state)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_STATE); + if (is_null($data)) { + return null; + } + $this->state = ItemStateCollection::fromArray($data); + } + + return $this->state; } /** - * @param ?LocalizedString $productSlug + *
                                                                                                                              + *
                                                                                                                            • For a Cart with Platform TaxMode, the taxRate of Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
                                                                                                                            • + *
                                                                                                                            • For a Cart with External TaxMode, the taxRate of Line Items can be set using ExternalTaxRateDraft.
                                                                                                                            • + *
                                                                                                                            + * + * + * @return null|TaxRate */ - public function setProductSlug(?LocalizedString $productSlug): void + public function getTaxRate() { - $this->productSlug = $productSlug; + if (is_null($this->taxRate)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TAX_RATE); + if (is_null($data)) { + return null; + } + + $this->taxRate = TaxRateModel::of($data); + } + + return $this->taxRate; } /** - * @param ?Reference $productType + *

                                                                                                                            Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. + * For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

                                                                                                                            + * + * + * @return null|MethodTaxRateCollection */ - public function setProductType(?Reference $productType): void + public function getPerMethodTaxRate() + { + if (is_null($this->perMethodTaxRate)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_PER_METHOD_TAX_RATE); + if (is_null($data)) { + return null; + } + $this->perMethodTaxRate = MethodTaxRateCollection::fromArray($data); + } + + return $this->perMethodTaxRate; + } + + /** + *

                                                                                                                            Identifies Inventory entries that are reserved. The referenced Channel has the InventorySupply ChannelRoleEnum.

                                                                                                                            + * + * + * @return null|ChannelReference + */ + public function getSupplyChannel() + { + if (is_null($this->supplyChannel)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SUPPLY_CHANNEL); + if (is_null($data)) { + return null; + } + + $this->supplyChannel = ChannelReferenceModel::of($data); + } + + return $this->supplyChannel; + } + + /** + *

                                                                                                                            Used to select a Product Price. The referenced Channel has the ProductDistribution ChannelRoleEnum.

                                                                                                                            + * + * + * @return null|ChannelReference + */ + public function getDistributionChannel() + { + if (is_null($this->distributionChannel)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DISTRIBUTION_CHANNEL); + if (is_null($data)) { + return null; + } + + $this->distributionChannel = ChannelReferenceModel::of($data); + } + + return $this->distributionChannel; + } + + /** + *

                                                                                                                            Indicates how the Price for the Line Item is set.

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

                                                                                                                            Indicates how the Line Item is added to the Cart.

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

                                                                                                                            Inventory mode specific to this Line Item only, and valid for the entire quantity of the Line Item. + * Only present if the inventory mode is different from the inventoryMode specified on the Cart.

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

                                                                                                                            Container for Line Item-specific addresses.

                                                                                                                            + * + * + * @return null|ItemShippingDetails + */ + public function getShippingDetails() + { + if (is_null($this->shippingDetails)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SHIPPING_DETAILS); + if (is_null($data)) { + return null; + } + + $this->shippingDetails = ItemShippingDetailsModel::of($data); + } + + return $this->shippingDetails; + } + + /** + *

                                                                                                                            Custom Fields of the Line Item.

                                                                                                                            + * + * + * @return null|CustomFields + */ + public function getCustom() + { + if (is_null($this->custom)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($data)) { + return null; + } + + $this->custom = CustomFieldsModel::of($data); + } + + return $this->custom; + } + + /** + *

                                                                                                                            Date and time (UTC) the Line Item was added to the Cart.

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

                                                                                                                            Date and time (UTC) the Line Item was last updated.

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

                                                                                                                            Recurring Order and frequency data.

                                                                                                                            + * + * + * @return null|LineItemRecurrenceInfo + */ + public function getRecurrenceInfo() + { + if (is_null($this->recurrenceInfo)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRENCE_INFO); + if (is_null($data)) { + return null; + } + + $this->recurrenceInfo = LineItemRecurrenceInfoModel::of($data); + } + + return $this->recurrenceInfo; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?string $productId + */ + public function setProductId(?string $productId): void + { + $this->productId = $productId; + } + + /** + * @param ?string $productKey + */ + public function setProductKey(?string $productKey): void + { + $this->productKey = $productKey; + } + + /** + * @param ?LocalizedString $name + */ + public function setName(?LocalizedString $name): void + { + $this->name = $name; + } + + /** + * @param ?LocalizedString $productSlug + */ + public function setProductSlug(?LocalizedString $productSlug): void + { + $this->productSlug = $productSlug; + } + + /** + * @param ?ProductTypeReference $productType + */ + public function setProductType(?ProductTypeReference $productType): void { $this->productType = $productType; } + /** + * @param ?ProductVariant $variant + */ + public function setVariant(?ProductVariant $variant): void + { + $this->variant = $variant; + } + + /** + * @param ?Price $price + */ + public function setPrice(?Price $price): void + { + $this->price = $price; + } + /** * @param ?int $quantity */ @@ -361,21 +907,154 @@ public function setQuantity(?int $quantity): void } /** - * @param ?Variant $variant + * @param ?CentPrecisionMoney $totalPrice */ - public function setVariant(?Variant $variant): void + public function setTotalPrice(?CentPrecisionMoney $totalPrice): void { - $this->variant = $variant; + $this->totalPrice = $totalPrice; + } + + /** + * @param ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity + */ + public function setDiscountedPricePerQuantity(?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity): void + { + $this->discountedPricePerQuantity = $discountedPricePerQuantity; + } + + /** + * @param ?TaxedItemPrice $taxedPrice + */ + public function setTaxedPrice(?TaxedItemPrice $taxedPrice): void + { + $this->taxedPrice = $taxedPrice; + } + + /** + * @param ?MethodTaxedPriceCollection $taxedPricePortions + */ + public function setTaxedPricePortions(?MethodTaxedPriceCollection $taxedPricePortions): void + { + $this->taxedPricePortions = $taxedPricePortions; + } + + /** + * @param ?ItemStateCollection $state + */ + public function setState(?ItemStateCollection $state): void + { + $this->state = $state; + } + + /** + * @param ?TaxRate $taxRate + */ + public function setTaxRate(?TaxRate $taxRate): void + { + $this->taxRate = $taxRate; + } + + /** + * @param ?MethodTaxRateCollection $perMethodTaxRate + */ + public function setPerMethodTaxRate(?MethodTaxRateCollection $perMethodTaxRate): void + { + $this->perMethodTaxRate = $perMethodTaxRate; } /** - * @param ?int $variantId + * @param ?ChannelReference $supplyChannel */ - public function setVariantId(?int $variantId): void + public function setSupplyChannel(?ChannelReference $supplyChannel): void { - $this->variantId = $variantId; + $this->supplyChannel = $supplyChannel; } + /** + * @param ?ChannelReference $distributionChannel + */ + public function setDistributionChannel(?ChannelReference $distributionChannel): void + { + $this->distributionChannel = $distributionChannel; + } + /** + * @param ?string $priceMode + */ + public function setPriceMode(?string $priceMode): void + { + $this->priceMode = $priceMode; + } + + /** + * @param ?string $lineItemMode + */ + public function setLineItemMode(?string $lineItemMode): void + { + $this->lineItemMode = $lineItemMode; + } + + /** + * @param ?string $inventoryMode + */ + public function setInventoryMode(?string $inventoryMode): void + { + $this->inventoryMode = $inventoryMode; + } + + /** + * @param ?ItemShippingDetails $shippingDetails + */ + public function setShippingDetails(?ItemShippingDetails $shippingDetails): void + { + $this->shippingDetails = $shippingDetails; + } + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + + /** + * @param ?DateTimeImmutable $addedAt + */ + public function setAddedAt(?DateTimeImmutable $addedAt): void + { + $this->addedAt = $addedAt; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + */ + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void + { + $this->lastModifiedAt = $lastModifiedAt; + } + + /** + * @param ?LineItemRecurrenceInfo $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfo $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[LineItem::FIELD_ADDED_AT]) && $data[LineItem::FIELD_ADDED_AT] instanceof \DateTimeImmutable) { + $data[LineItem::FIELD_ADDED_AT] = $data[LineItem::FIELD_ADDED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[LineItem::FIELD_LAST_MODIFIED_AT]) && $data[LineItem::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) { + $data[LineItem::FIELD_LAST_MODIFIED_AT] = $data[LineItem::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } } diff --git a/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfo.php b/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfo.php new file mode 100644 index 00000000000..12abb21fcaa --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfo.php @@ -0,0 +1,45 @@ +Reference to a RecurrencePolicy.

                                                                                                                            + * + + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy(); + + /** + *

                                                                                                                            Indicates how the price of a line item will be selected during order creation.

                                                                                                                            + * + + * @return null|string + */ + public function getPriceSelectionMode(); + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy): void; + + /** + * @param ?string $priceSelectionMode + */ + public function setPriceSelectionMode(?string $priceSelectionMode): void; +} diff --git a/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfoBuilder.php b/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfoBuilder.php new file mode 100644 index 00000000000..790ae939146 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfoBuilder.php @@ -0,0 +1,102 @@ + + */ +final class LineItemRecurrenceInfoBuilder implements Builder +{ + /** + + * @var null|RecurrencePolicyReference|RecurrencePolicyReferenceBuilder + */ + private $recurrencePolicy; + + /** + + * @var ?string + */ + private $priceSelectionMode; + + /** + *

                                                                                                                            Reference to a RecurrencePolicy.

                                                                                                                            + * + + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy() + { + return $this->recurrencePolicy instanceof RecurrencePolicyReferenceBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy; + } + + /** + *

                                                                                                                            Indicates how the price of a line item will be selected during order creation.

                                                                                                                            + * + + * @return null|string + */ + public function getPriceSelectionMode() + { + return $this->priceSelectionMode; + } + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + + /** + * @param ?string $priceSelectionMode + * @return $this + */ + public function withPriceSelectionMode(?string $priceSelectionMode) + { + $this->priceSelectionMode = $priceSelectionMode; + + return $this; + } + + /** + * @deprecated use withRecurrencePolicy() instead + * @return $this + */ + public function withRecurrencePolicyBuilder(?RecurrencePolicyReferenceBuilder $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + + public function build(): LineItemRecurrenceInfo + { + return new LineItemRecurrenceInfoModel( + $this->recurrencePolicy instanceof RecurrencePolicyReferenceBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy, + $this->priceSelectionMode + ); + } + + public static function of(): LineItemRecurrenceInfoBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfoCollection.php b/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfoCollection.php new file mode 100644 index 00000000000..cf2f5fe1d39 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfoCollection.php @@ -0,0 +1,56 @@ + + * @method LineItemRecurrenceInfo current() + * @method LineItemRecurrenceInfo end() + * @method LineItemRecurrenceInfo at($offset) + */ +class LineItemRecurrenceInfoCollection extends MapperSequence +{ + /** + * @psalm-assert LineItemRecurrenceInfo $value + * @psalm-param LineItemRecurrenceInfo|stdClass $value + * @throws InvalidArgumentException + * + * @return LineItemRecurrenceInfoCollection + */ + public function add($value) + { + if (!$value instanceof LineItemRecurrenceInfo) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?LineItemRecurrenceInfo + */ + protected function mapper() + { + return function (?int $index): ?LineItemRecurrenceInfo { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var LineItemRecurrenceInfo $data */ + $data = LineItemRecurrenceInfoModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfoModel.php b/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfoModel.php new file mode 100644 index 00000000000..d2dd46069b2 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/LineItemRecurrenceInfoModel.php @@ -0,0 +1,109 @@ +recurrencePolicy = $recurrencePolicy; + $this->priceSelectionMode = $priceSelectionMode; + + } + + /** + *

                                                                                                                            Reference to a RecurrencePolicy.

                                                                                                                            + * + * + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy() + { + if (is_null($this->recurrencePolicy)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRENCE_POLICY); + if (is_null($data)) { + return null; + } + + $this->recurrencePolicy = RecurrencePolicyReferenceModel::of($data); + } + + return $this->recurrencePolicy; + } + + /** + *

                                                                                                                            Indicates how the price of a line item will be selected during order creation.

                                                                                                                            + * + * + * @return null|string + */ + public function getPriceSelectionMode() + { + if (is_null($this->priceSelectionMode)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_PRICE_SELECTION_MODE); + if (is_null($data)) { + return null; + } + $this->priceSelectionMode = (string) $data; + } + + return $this->priceSelectionMode; + } + + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy): void + { + $this->recurrencePolicy = $recurrencePolicy; + } + + /** + * @param ?string $priceSelectionMode + */ + public function setPriceSelectionMode(?string $priceSelectionMode): void + { + $this->priceSelectionMode = $priceSelectionMode; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/Location.php b/lib/commercetools-history/src/Models/Common/Location.php index 9419857bbd6..03252ecf4f6 100644 --- a/lib/commercetools-history/src/Models/Common/Location.php +++ b/lib/commercetools-history/src/Models/Common/Location.php @@ -18,7 +18,7 @@ interface Location extends JsonObject public const FIELD_STATE = 'state'; /** - *

                                                                                                                            Two-digit country code as per ISO 3166-1 alpha-2.

                                                                                                                            + *

                                                                                                                            Country code of the geographic location.

                                                                                                                            * * @return null|string @@ -26,6 +26,8 @@ interface Location extends JsonObject public function getCountry(); /** + *

                                                                                                                            State within the country.

                                                                                                                            + * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/LocationBuilder.php b/lib/commercetools-history/src/Models/Common/LocationBuilder.php index 49207eaf8b7..a569a5b3a47 100644 --- a/lib/commercetools-history/src/Models/Common/LocationBuilder.php +++ b/lib/commercetools-history/src/Models/Common/LocationBuilder.php @@ -33,7 +33,7 @@ final class LocationBuilder implements Builder private $state; /** - *

                                                                                                                            Two-digit country code as per ISO 3166-1 alpha-2.

                                                                                                                            + *

                                                                                                                            Country code of the geographic location.

                                                                                                                            * * @return null|string @@ -44,6 +44,8 @@ public function getCountry() } /** + *

                                                                                                                            State within the country.

                                                                                                                            + * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/LocationModel.php b/lib/commercetools-history/src/Models/Common/LocationModel.php index 8610a32d77d..92a88d5a92e 100644 --- a/lib/commercetools-history/src/Models/Common/LocationModel.php +++ b/lib/commercetools-history/src/Models/Common/LocationModel.php @@ -47,7 +47,7 @@ public function __construct( } /** - *

                                                                                                                            Two-digit country code as per ISO 3166-1 alpha-2.

                                                                                                                            + *

                                                                                                                            Country code of the geographic location.

                                                                                                                            * * * @return null|string @@ -67,6 +67,8 @@ public function getCountry() } /** + *

                                                                                                                            State within the country.

                                                                                                                            + * * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/MethodTaxRate.php b/lib/commercetools-history/src/Models/Common/MethodTaxRate.php new file mode 100644 index 00000000000..2459dd67339 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/MethodTaxRate.php @@ -0,0 +1,45 @@ +User-defined unique identifier of the Shipping Method in a Cart with Multiple ShippingMode.

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

                                                                                                                            Tax Rate for the Shipping Method.

                                                                                                                            + * + + * @return null|TaxRate + */ + public function getTaxRate(); + + /** + * @param ?string $shippingMethodKey + */ + public function setShippingMethodKey(?string $shippingMethodKey): void; + + /** + * @param ?TaxRate $taxRate + */ + public function setTaxRate(?TaxRate $taxRate): void; +} diff --git a/lib/commercetools-history/src/Models/Common/MethodTaxRateBuilder.php b/lib/commercetools-history/src/Models/Common/MethodTaxRateBuilder.php new file mode 100644 index 00000000000..bba7daf3f1f --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/MethodTaxRateBuilder.php @@ -0,0 +1,102 @@ + + */ +final class MethodTaxRateBuilder implements Builder +{ + /** + + * @var ?string + */ + private $shippingMethodKey; + + /** + + * @var null|TaxRate|TaxRateBuilder + */ + private $taxRate; + + /** + *

                                                                                                                            User-defined unique identifier of the Shipping Method in a Cart with Multiple ShippingMode.

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

                                                                                                                            Tax Rate for the Shipping Method.

                                                                                                                            + * + + * @return null|TaxRate + */ + public function getTaxRate() + { + return $this->taxRate instanceof TaxRateBuilder ? $this->taxRate->build() : $this->taxRate; + } + + /** + * @param ?string $shippingMethodKey + * @return $this + */ + public function withShippingMethodKey(?string $shippingMethodKey) + { + $this->shippingMethodKey = $shippingMethodKey; + + return $this; + } + + /** + * @param ?TaxRate $taxRate + * @return $this + */ + public function withTaxRate(?TaxRate $taxRate) + { + $this->taxRate = $taxRate; + + return $this; + } + + /** + * @deprecated use withTaxRate() instead + * @return $this + */ + public function withTaxRateBuilder(?TaxRateBuilder $taxRate) + { + $this->taxRate = $taxRate; + + return $this; + } + + public function build(): MethodTaxRate + { + return new MethodTaxRateModel( + $this->shippingMethodKey, + $this->taxRate instanceof TaxRateBuilder ? $this->taxRate->build() : $this->taxRate + ); + } + + public static function of(): MethodTaxRateBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/MethodTaxRateCollection.php b/lib/commercetools-history/src/Models/Common/MethodTaxRateCollection.php new file mode 100644 index 00000000000..3e56511ee1a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/MethodTaxRateCollection.php @@ -0,0 +1,56 @@ + + * @method MethodTaxRate current() + * @method MethodTaxRate end() + * @method MethodTaxRate at($offset) + */ +class MethodTaxRateCollection extends MapperSequence +{ + /** + * @psalm-assert MethodTaxRate $value + * @psalm-param MethodTaxRate|stdClass $value + * @throws InvalidArgumentException + * + * @return MethodTaxRateCollection + */ + public function add($value) + { + if (!$value instanceof MethodTaxRate) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?MethodTaxRate + */ + protected function mapper() + { + return function (?int $index): ?MethodTaxRate { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var MethodTaxRate $data */ + $data = MethodTaxRateModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/MethodTaxRateModel.php b/lib/commercetools-history/src/Models/Common/MethodTaxRateModel.php new file mode 100644 index 00000000000..5b7ede16536 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/MethodTaxRateModel.php @@ -0,0 +1,109 @@ +shippingMethodKey = $shippingMethodKey; + $this->taxRate = $taxRate; + + } + + /** + *

                                                                                                                            User-defined unique identifier of the Shipping Method in a Cart with Multiple ShippingMode.

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

                                                                                                                            Tax Rate for the Shipping Method.

                                                                                                                            + * + * + * @return null|TaxRate + */ + public function getTaxRate() + { + if (is_null($this->taxRate)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TAX_RATE); + if (is_null($data)) { + return null; + } + + $this->taxRate = TaxRateModel::of($data); + } + + return $this->taxRate; + } + + + /** + * @param ?string $shippingMethodKey + */ + public function setShippingMethodKey(?string $shippingMethodKey): void + { + $this->shippingMethodKey = $shippingMethodKey; + } + + /** + * @param ?TaxRate $taxRate + */ + public function setTaxRate(?TaxRate $taxRate): void + { + $this->taxRate = $taxRate; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/MethodTaxedPrice.php b/lib/commercetools-history/src/Models/Common/MethodTaxedPrice.php new file mode 100644 index 00000000000..684d5bee703 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/MethodTaxedPrice.php @@ -0,0 +1,45 @@ +User-defined unique identifier of the Shipping Method in a Cart with Multiple ShippingMode.

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

                                                                                                                            Total taxed price based on the quantity of the Line Item or Custom Line Item assigned to the Shipping Method identified by shippingMethodKey.

                                                                                                                            + * + + * @return null|TaxedItemPrice + */ + public function getTaxedPrice(); + + /** + * @param ?string $shippingMethodKey + */ + public function setShippingMethodKey(?string $shippingMethodKey): void; + + /** + * @param ?TaxedItemPrice $taxedPrice + */ + public function setTaxedPrice(?TaxedItemPrice $taxedPrice): void; +} diff --git a/lib/commercetools-history/src/Models/Common/MethodTaxedPriceBuilder.php b/lib/commercetools-history/src/Models/Common/MethodTaxedPriceBuilder.php new file mode 100644 index 00000000000..7def38684cf --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/MethodTaxedPriceBuilder.php @@ -0,0 +1,102 @@ + + */ +final class MethodTaxedPriceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $shippingMethodKey; + + /** + + * @var null|TaxedItemPrice|TaxedItemPriceBuilder + */ + private $taxedPrice; + + /** + *

                                                                                                                            User-defined unique identifier of the Shipping Method in a Cart with Multiple ShippingMode.

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

                                                                                                                            Total taxed price based on the quantity of the Line Item or Custom Line Item assigned to the Shipping Method identified by shippingMethodKey.

                                                                                                                            + * + + * @return null|TaxedItemPrice + */ + public function getTaxedPrice() + { + return $this->taxedPrice instanceof TaxedItemPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice; + } + + /** + * @param ?string $shippingMethodKey + * @return $this + */ + public function withShippingMethodKey(?string $shippingMethodKey) + { + $this->shippingMethodKey = $shippingMethodKey; + + return $this; + } + + /** + * @param ?TaxedItemPrice $taxedPrice + * @return $this + */ + public function withTaxedPrice(?TaxedItemPrice $taxedPrice) + { + $this->taxedPrice = $taxedPrice; + + return $this; + } + + /** + * @deprecated use withTaxedPrice() instead + * @return $this + */ + public function withTaxedPriceBuilder(?TaxedItemPriceBuilder $taxedPrice) + { + $this->taxedPrice = $taxedPrice; + + return $this; + } + + public function build(): MethodTaxedPrice + { + return new MethodTaxedPriceModel( + $this->shippingMethodKey, + $this->taxedPrice instanceof TaxedItemPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice + ); + } + + public static function of(): MethodTaxedPriceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/MethodTaxedPriceCollection.php b/lib/commercetools-history/src/Models/Common/MethodTaxedPriceCollection.php new file mode 100644 index 00000000000..2e587a96697 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/MethodTaxedPriceCollection.php @@ -0,0 +1,56 @@ + + * @method MethodTaxedPrice current() + * @method MethodTaxedPrice end() + * @method MethodTaxedPrice at($offset) + */ +class MethodTaxedPriceCollection extends MapperSequence +{ + /** + * @psalm-assert MethodTaxedPrice $value + * @psalm-param MethodTaxedPrice|stdClass $value + * @throws InvalidArgumentException + * + * @return MethodTaxedPriceCollection + */ + public function add($value) + { + if (!$value instanceof MethodTaxedPrice) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?MethodTaxedPrice + */ + protected function mapper() + { + return function (?int $index): ?MethodTaxedPrice { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var MethodTaxedPrice $data */ + $data = MethodTaxedPriceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/MethodTaxedPriceModel.php b/lib/commercetools-history/src/Models/Common/MethodTaxedPriceModel.php new file mode 100644 index 00000000000..b5fc0f68a1b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/MethodTaxedPriceModel.php @@ -0,0 +1,109 @@ +shippingMethodKey = $shippingMethodKey; + $this->taxedPrice = $taxedPrice; + + } + + /** + *

                                                                                                                            User-defined unique identifier of the Shipping Method in a Cart with Multiple ShippingMode.

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

                                                                                                                            Total taxed price based on the quantity of the Line Item or Custom Line Item assigned to the Shipping Method identified by shippingMethodKey.

                                                                                                                            + * + * + * @return null|TaxedItemPrice + */ + public function getTaxedPrice() + { + if (is_null($this->taxedPrice)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TAXED_PRICE); + if (is_null($data)) { + return null; + } + + $this->taxedPrice = TaxedItemPriceModel::of($data); + } + + return $this->taxedPrice; + } + + + /** + * @param ?string $shippingMethodKey + */ + public function setShippingMethodKey(?string $shippingMethodKey): void + { + $this->shippingMethodKey = $shippingMethodKey; + } + + /** + * @param ?TaxedItemPrice $taxedPrice + */ + public function setTaxedPrice(?TaxedItemPrice $taxedPrice): void + { + $this->taxedPrice = $taxedPrice; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/Money.php b/lib/commercetools-history/src/Models/Common/Money.php index 25298abdfc9..1de8db020e0 100644 --- a/lib/commercetools-history/src/Models/Common/Money.php +++ b/lib/commercetools-history/src/Models/Common/Money.php @@ -14,41 +14,28 @@ interface Money extends JsonObject { - public const FIELD_CURRENCY_CODE = 'currencyCode'; public const FIELD_CENT_AMOUNT = 'centAmount'; - public const FIELD_FRACTION_DIGITS = 'fractionDigits'; - public const FIELD_TYPE = 'type'; + public const FIELD_CURRENCY_CODE = 'currencyCode'; /** - *

                                                                                                                            Currency code compliant to ISO 4217.

                                                                                                                            + *

                                                                                                                            Amount in the smallest indivisible unit of a currency, such as:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as 500).
                                                                                                                            • + *
                                                                                                                            • The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as 5).
                                                                                                                            • + *
                                                                                                                            * - * @return null|string - */ - public function getCurrencyCode(); - - /** - * @return null|int */ public function getCentAmount(); /** - - * @return null|int - */ - public function getFractionDigits(); - - /** + *

                                                                                                                            Currency code compliant to ISO 4217.

                                                                                                                            + * * @return null|string */ - public function getType(); - - /** - * @param ?string $currencyCode - */ - public function setCurrencyCode(?string $currencyCode): void; + public function getCurrencyCode(); /** * @param ?int $centAmount @@ -56,12 +43,7 @@ public function setCurrencyCode(?string $currencyCode): void; public function setCentAmount(?int $centAmount): void; /** - * @param ?int $fractionDigits - */ - public function setFractionDigits(?int $fractionDigits): void; - - /** - * @param ?string $type + * @param ?string $currencyCode */ - public function setType(?string $type): void; + public function setCurrencyCode(?string $currencyCode): void; } diff --git a/lib/commercetools-history/src/Models/Common/MoneyBuilder.php b/lib/commercetools-history/src/Models/Common/MoneyBuilder.php index 8a75da8588d..32da95ea588 100644 --- a/lib/commercetools-history/src/Models/Common/MoneyBuilder.php +++ b/lib/commercetools-history/src/Models/Common/MoneyBuilder.php @@ -20,43 +20,26 @@ */ final class MoneyBuilder implements Builder { - /** - - * @var ?string - */ - private $currencyCode; - /** * @var ?int */ private $centAmount; - /** - - * @var ?int - */ - private $fractionDigits; - /** * @var ?string */ - private $type; + private $currencyCode; /** - *

                                                                                                                            Currency code compliant to ISO 4217.

                                                                                                                            + *

                                                                                                                            Amount in the smallest indivisible unit of a currency, such as:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as 500).
                                                                                                                            • + *
                                                                                                                            • The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as 5).
                                                                                                                            • + *
                                                                                                                            * - * @return null|string - */ - public function getCurrencyCode() - { - return $this->currencyCode; - } - - /** - * @return null|int */ public function getCentAmount() @@ -65,32 +48,14 @@ public function getCentAmount() } /** - - * @return null|int - */ - public function getFractionDigits() - { - return $this->fractionDigits; - } - - /** + *

                                                                                                                            Currency code compliant to ISO 4217.

                                                                                                                            + * * @return null|string */ - public function getType() - { - return $this->type; - } - - /** - * @param ?string $currencyCode - * @return $this - */ - public function withCurrencyCode(?string $currencyCode) + public function getCurrencyCode() { - $this->currencyCode = $currencyCode; - - return $this; + return $this->currencyCode; } /** @@ -105,23 +70,12 @@ public function withCentAmount(?int $centAmount) } /** - * @param ?int $fractionDigits - * @return $this - */ - public function withFractionDigits(?int $fractionDigits) - { - $this->fractionDigits = $fractionDigits; - - return $this; - } - - /** - * @param ?string $type + * @param ?string $currencyCode * @return $this */ - public function withType(?string $type) + public function withCurrencyCode(?string $currencyCode) { - $this->type = $type; + $this->currencyCode = $currencyCode; return $this; } @@ -130,10 +84,8 @@ public function withType(?string $type) public function build(): Money { return new MoneyModel( - $this->currencyCode, $this->centAmount, - $this->fractionDigits, - $this->type + $this->currencyCode ); } diff --git a/lib/commercetools-history/src/Models/Common/MoneyCollection.php b/lib/commercetools-history/src/Models/Common/MoneyCollection.php index bfdddc38885..44d4fdc982c 100644 --- a/lib/commercetools-history/src/Models/Common/MoneyCollection.php +++ b/lib/commercetools-history/src/Models/Common/MoneyCollection.php @@ -13,7 +13,11 @@ use stdClass; /** - * @extends MapperSequence + * @template T of Money + * @extends MapperSequence + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) * @method Money current() * @method Money end() * @method Money at($offset) @@ -21,8 +25,8 @@ class MoneyCollection extends MapperSequence { /** - * @psalm-assert Money $value - * @psalm-param Money|stdClass $value + * @psalm-assert T $value + * @psalm-param T|stdClass $value * @throws InvalidArgumentException * * @return MoneyCollection @@ -38,14 +42,14 @@ public function add($value) } /** - * @psalm-return callable(int):?Money + * @psalm-return callable(int):?T */ protected function mapper() { return function (?int $index): ?Money { $data = $this->get($index); if ($data instanceof stdClass) { - /** @var Money $data */ + /** @var T $data */ $data = MoneyModel::of($data); $this->set($data, $index); } diff --git a/lib/commercetools-history/src/Models/Common/MoneyModel.php b/lib/commercetools-history/src/Models/Common/MoneyModel.php index 21ac514edc4..6afe861dfe3 100644 --- a/lib/commercetools-history/src/Models/Common/MoneyModel.php +++ b/lib/commercetools-history/src/Models/Common/MoneyModel.php @@ -21,68 +21,38 @@ final class MoneyModel extends JsonObjectModel implements Money { - /** - * - * @var ?string - */ - protected $currencyCode; - /** * * @var ?int */ protected $centAmount; - /** - * - * @var ?int - */ - protected $fractionDigits; - /** * * @var ?string */ - protected $type; + protected $currencyCode; /** * @psalm-suppress MissingParamType */ public function __construct( - ?string $currencyCode = null, ?int $centAmount = null, - ?int $fractionDigits = null, - ?string $type = null + ?string $currencyCode = null ) { - $this->currencyCode = $currencyCode; $this->centAmount = $centAmount; - $this->fractionDigits = $fractionDigits; - $this->type = $type; + $this->currencyCode = $currencyCode; } /** - *

                                                                                                                            Currency code compliant to ISO 4217.

                                                                                                                            + *

                                                                                                                            Amount in the smallest indivisible unit of a currency, such as:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as 500).
                                                                                                                            • + *
                                                                                                                            • The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as 5).
                                                                                                                            • + *
                                                                                                                            * - * - * @return null|string - */ - public function getCurrencyCode() - { - if (is_null($this->currencyCode)) { - /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_CURRENCY_CODE); - if (is_null($data)) { - return null; - } - $this->currencyCode = (string) $data; - } - - return $this->currencyCode; - } - - /** * * @return null|int */ @@ -101,50 +71,26 @@ public function getCentAmount() } /** + *

                                                                                                                            Currency code compliant to ISO 4217.

                                                                                                                            * - * @return null|int - */ - public function getFractionDigits() - { - if (is_null($this->fractionDigits)) { - /** @psalm-var ?int $data */ - $data = $this->raw(self::FIELD_FRACTION_DIGITS); - if (is_null($data)) { - return null; - } - $this->fractionDigits = (int) $data; - } - - return $this->fractionDigits; - } - - /** * * @return null|string */ - public function getType() + public function getCurrencyCode() { - if (is_null($this->type)) { + if (is_null($this->currencyCode)) { /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_TYPE); + $data = $this->raw(self::FIELD_CURRENCY_CODE); if (is_null($data)) { return null; } - $this->type = (string) $data; + $this->currencyCode = (string) $data; } - return $this->type; + return $this->currencyCode; } - /** - * @param ?string $currencyCode - */ - public function setCurrencyCode(?string $currencyCode): void - { - $this->currencyCode = $currencyCode; - } - /** * @param ?int $centAmount */ @@ -154,19 +100,11 @@ public function setCentAmount(?int $centAmount): void } /** - * @param ?int $fractionDigits - */ - public function setFractionDigits(?int $fractionDigits): void - { - $this->fractionDigits = $fractionDigits; - } - - /** - * @param ?string $type + * @param ?string $currencyCode */ - public function setType(?string $type): void + public function setCurrencyCode(?string $currencyCode): void { - $this->type = $type; + $this->currencyCode = $currencyCode; } diff --git a/lib/commercetools-history/src/Models/Common/Parcel.php b/lib/commercetools-history/src/Models/Common/Parcel.php index 623217f1f64..16e09df5e5d 100644 --- a/lib/commercetools-history/src/Models/Common/Parcel.php +++ b/lib/commercetools-history/src/Models/Common/Parcel.php @@ -10,55 +10,89 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use DateTimeImmutable; interface Parcel extends JsonObject { public const FIELD_ID = 'id'; + public const FIELD_KEY = 'key'; public const FIELD_CREATED_AT = 'createdAt'; public const FIELD_MEASUREMENTS = 'measurements'; public const FIELD_TRACKING_DATA = 'trackingData'; public const FIELD_ITEMS = 'items'; + public const FIELD_CUSTOM = 'custom'; /** + *

                                                                                                                            Unique identifier of the Parcel.

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

                                                                                                                            User-defined unique identifier of the Parcel.

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

                                                                                                                            Date and time (UTC) the Parcel was created.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ public function getCreatedAt(); /** + *

                                                                                                                            Information about the dimensions of the Parcel.

                                                                                                                            + * * @return null|ParcelMeasurements */ public function getMeasurements(); /** + *

                                                                                                                            Shipment tracking information of the Parcel.

                                                                                                                            + * * @return null|TrackingData */ public function getTrackingData(); /** + *

                                                                                                                            Line Items or Custom Line Items delivered in this Parcel.

                                                                                                                            + * * @return null|DeliveryItemCollection */ public function getItems(); + /** + *

                                                                                                                            Custom Fields of the Parcel.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom(); + /** * @param ?string $id */ public function setId(?string $id): void; /** - * @param ?string $createdAt + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?DateTimeImmutable $createdAt */ - public function setCreatedAt(?string $createdAt): void; + public function setCreatedAt(?DateTimeImmutable $createdAt): void; /** * @param ?ParcelMeasurements $measurements @@ -74,4 +108,9 @@ public function setTrackingData(?TrackingData $trackingData): void; * @param ?DeliveryItemCollection $items */ public function setItems(?DeliveryItemCollection $items): void; + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void; } diff --git a/lib/commercetools-history/src/Models/Common/ParcelBuilder.php b/lib/commercetools-history/src/Models/Common/ParcelBuilder.php index e61c7fe4812..a3a46d177fe 100644 --- a/lib/commercetools-history/src/Models/Common/ParcelBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ParcelBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @implements Builder @@ -30,6 +31,12 @@ final class ParcelBuilder implements Builder * @var ?string */ + private $key; + + /** + + * @var ?DateTimeImmutable + */ private $createdAt; /** @@ -52,6 +59,14 @@ final class ParcelBuilder implements Builder /** + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + + /** + *

                                                                                                                            Unique identifier of the Parcel.

                                                                                                                            + * + * @return null|string */ public function getId() @@ -60,15 +75,30 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the Parcel.

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

                                                                                                                            Date and time (UTC) the Parcel was created.

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

                                                                                                                            Information about the dimensions of the Parcel.

                                                                                                                            + * * @return null|ParcelMeasurements */ @@ -78,6 +108,8 @@ public function getMeasurements() } /** + *

                                                                                                                            Shipment tracking information of the Parcel.

                                                                                                                            + * * @return null|TrackingData */ @@ -87,6 +119,8 @@ public function getTrackingData() } /** + *

                                                                                                                            Line Items or Custom Line Items delivered in this Parcel.

                                                                                                                            + * * @return null|DeliveryItemCollection */ @@ -95,6 +129,17 @@ public function getItems() return $this->items; } + /** + *

                                                                                                                            Custom Fields of the Parcel.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; + } + /** * @param ?string $id * @return $this @@ -107,10 +152,21 @@ public function withId(?string $id) } /** - * @param ?string $createdAt + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?DateTimeImmutable $createdAt * @return $this */ - public function withCreatedAt(?string $createdAt) + public function withCreatedAt(?DateTimeImmutable $createdAt) { $this->createdAt = $createdAt; @@ -150,6 +206,17 @@ public function withItems(?DeliveryItemCollection $items) return $this; } + /** + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) + { + $this->custom = $custom; + + return $this; + } + /** * @deprecated use withMeasurements() instead * @return $this @@ -172,14 +239,27 @@ public function withTrackingDataBuilder(?TrackingDataBuilder $trackingData) return $this; } + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + return $this; + } + public function build(): Parcel { return new ParcelModel( $this->id, + $this->key, $this->createdAt, $this->measurements instanceof ParcelMeasurementsBuilder ? $this->measurements->build() : $this->measurements, $this->trackingData instanceof TrackingDataBuilder ? $this->trackingData->build() : $this->trackingData, - $this->items + $this->items, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom ); } diff --git a/lib/commercetools-history/src/Models/Common/ParcelMeasurements.php b/lib/commercetools-history/src/Models/Common/ParcelMeasurements.php index 58aa265da85..a7b208af2d4 100644 --- a/lib/commercetools-history/src/Models/Common/ParcelMeasurements.php +++ b/lib/commercetools-history/src/Models/Common/ParcelMeasurements.php @@ -20,24 +20,32 @@ interface ParcelMeasurements extends JsonObject public const FIELD_WEIGHT_IN_GRAM = 'weightInGram'; /** + *

                                                                                                                            Height of the Parcel.

                                                                                                                            + * * @return null|int */ public function getHeightInMillimeter(); /** + *

                                                                                                                            Length of the Parcel.

                                                                                                                            + * * @return null|int */ public function getLengthInMillimeter(); /** + *

                                                                                                                            Width of the Parcel.

                                                                                                                            + * * @return null|int */ public function getWidthInMillimeter(); /** + *

                                                                                                                            Weight of the Parcel.

                                                                                                                            + * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/ParcelMeasurementsBuilder.php b/lib/commercetools-history/src/Models/Common/ParcelMeasurementsBuilder.php index f6082981c69..86c1eaec907 100644 --- a/lib/commercetools-history/src/Models/Common/ParcelMeasurementsBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ParcelMeasurementsBuilder.php @@ -45,6 +45,8 @@ final class ParcelMeasurementsBuilder implements Builder private $weightInGram; /** + *

                                                                                                                            Height of the Parcel.

                                                                                                                            + * * @return null|int */ @@ -54,6 +56,8 @@ public function getHeightInMillimeter() } /** + *

                                                                                                                            Length of the Parcel.

                                                                                                                            + * * @return null|int */ @@ -63,6 +67,8 @@ public function getLengthInMillimeter() } /** + *

                                                                                                                            Width of the Parcel.

                                                                                                                            + * * @return null|int */ @@ -72,6 +78,8 @@ public function getWidthInMillimeter() } /** + *

                                                                                                                            Weight of the Parcel.

                                                                                                                            + * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/ParcelMeasurementsModel.php b/lib/commercetools-history/src/Models/Common/ParcelMeasurementsModel.php index cc49a8c2e10..6546a6f3361 100644 --- a/lib/commercetools-history/src/Models/Common/ParcelMeasurementsModel.php +++ b/lib/commercetools-history/src/Models/Common/ParcelMeasurementsModel.php @@ -63,6 +63,8 @@ public function __construct( } /** + *

                                                                                                                            Height of the Parcel.

                                                                                                                            + * * * @return null|int */ @@ -81,6 +83,8 @@ public function getHeightInMillimeter() } /** + *

                                                                                                                            Length of the Parcel.

                                                                                                                            + * * * @return null|int */ @@ -99,6 +103,8 @@ public function getLengthInMillimeter() } /** + *

                                                                                                                            Width of the Parcel.

                                                                                                                            + * * * @return null|int */ @@ -117,6 +123,8 @@ public function getWidthInMillimeter() } /** + *

                                                                                                                            Weight of the Parcel.

                                                                                                                            + * * * @return null|int */ diff --git a/lib/commercetools-history/src/Models/Common/ParcelModel.php b/lib/commercetools-history/src/Models/Common/ParcelModel.php index 571aaf15492..cf7691069c4 100644 --- a/lib/commercetools-history/src/Models/Common/ParcelModel.php +++ b/lib/commercetools-history/src/Models/Common/ParcelModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @internal @@ -31,6 +32,12 @@ final class ParcelModel extends JsonObjectModel implements Parcel * * @var ?string */ + protected $key; + + /** + * + * @var ?DateTimeImmutable + */ protected $createdAt; /** @@ -51,26 +58,38 @@ final class ParcelModel extends JsonObjectModel implements Parcel */ protected $items; + /** + * + * @var ?CustomFields + */ + protected $custom; + /** * @psalm-suppress MissingParamType */ public function __construct( ?string $id = null, - ?string $createdAt = null, + ?string $key = null, + ?DateTimeImmutable $createdAt = null, ?ParcelMeasurements $measurements = null, ?TrackingData $trackingData = null, - ?DeliveryItemCollection $items = null + ?DeliveryItemCollection $items = null, + ?CustomFields $custom = null ) { $this->id = $id; + $this->key = $key; $this->createdAt = $createdAt; $this->measurements = $measurements; $this->trackingData = $trackingData; $this->items = $items; + $this->custom = $custom; } /** + *

                                                                                                                            Unique identifier of the Parcel.

                                                                                                                            + * * * @return null|string */ @@ -89,9 +108,31 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the Parcel.

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

                                                                                                                            Date and time (UTC) the Parcel was created.

                                                                                                                            + * + * + * @return null|DateTimeImmutable + */ public function getCreatedAt() { if (is_null($this->createdAt)) { @@ -100,13 +141,19 @@ public function getCreatedAt() if (is_null($data)) { return null; } - $this->createdAt = (string) $data; + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; } return $this->createdAt; } /** + *

                                                                                                                            Information about the dimensions of the Parcel.

                                                                                                                            + * * * @return null|ParcelMeasurements */ @@ -126,6 +173,8 @@ public function getMeasurements() } /** + *

                                                                                                                            Shipment tracking information of the Parcel.

                                                                                                                            + * * * @return null|TrackingData */ @@ -145,6 +194,8 @@ public function getTrackingData() } /** + *

                                                                                                                            Line Items or Custom Line Items delivered in this Parcel.

                                                                                                                            + * * * @return null|DeliveryItemCollection */ @@ -162,6 +213,27 @@ public function getItems() return $this->items; } + /** + *

                                                                                                                            Custom Fields of the Parcel.

                                                                                                                            + * + * + * @return null|CustomFields + */ + public function getCustom() + { + if (is_null($this->custom)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($data)) { + return null; + } + + $this->custom = CustomFieldsModel::of($data); + } + + return $this->custom; + } + /** * @param ?string $id @@ -172,9 +244,17 @@ public function setId(?string $id): void } /** - * @param ?string $createdAt + * @param ?string $key */ - public function setCreatedAt(?string $createdAt): void + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void { $this->createdAt = $createdAt; } @@ -203,6 +283,23 @@ public function setItems(?DeliveryItemCollection $items): void $this->items = $items; } + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Parcel::FIELD_CREATED_AT]) && $data[Parcel::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[Parcel::FIELD_CREATED_AT] = $data[Parcel::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } } diff --git a/lib/commercetools-history/src/Models/Common/PaymentInfo.php b/lib/commercetools-history/src/Models/Common/PaymentInfo.php index 067e9564149..e27907f6591 100644 --- a/lib/commercetools-history/src/Models/Common/PaymentInfo.php +++ b/lib/commercetools-history/src/Models/Common/PaymentInfo.php @@ -17,13 +17,15 @@ interface PaymentInfo extends JsonObject public const FIELD_PAYMENTS = 'payments'; /** + *

                                                                                                                            References to the Payments associated with the Order.

                                                                                                                            + * - * @return null|ReferenceCollection + * @return null|PaymentReferenceCollection */ public function getPayments(); /** - * @param ?ReferenceCollection $payments + * @param ?PaymentReferenceCollection $payments */ - public function setPayments(?ReferenceCollection $payments): void; + public function setPayments(?PaymentReferenceCollection $payments): void; } diff --git a/lib/commercetools-history/src/Models/Common/PaymentInfoBuilder.php b/lib/commercetools-history/src/Models/Common/PaymentInfoBuilder.php index 7f27db76c45..d1d8cb5994e 100644 --- a/lib/commercetools-history/src/Models/Common/PaymentInfoBuilder.php +++ b/lib/commercetools-history/src/Models/Common/PaymentInfoBuilder.php @@ -22,13 +22,15 @@ final class PaymentInfoBuilder implements Builder { /** - * @var ?ReferenceCollection + * @var ?PaymentReferenceCollection */ private $payments; /** + *

                                                                                                                            References to the Payments associated with the Order.

                                                                                                                            + * - * @return null|ReferenceCollection + * @return null|PaymentReferenceCollection */ public function getPayments() { @@ -36,10 +38,10 @@ public function getPayments() } /** - * @param ?ReferenceCollection $payments + * @param ?PaymentReferenceCollection $payments * @return $this */ - public function withPayments(?ReferenceCollection $payments) + public function withPayments(?PaymentReferenceCollection $payments) { $this->payments = $payments; diff --git a/lib/commercetools-history/src/Models/Common/PaymentInfoModel.php b/lib/commercetools-history/src/Models/Common/PaymentInfoModel.php index 90b89bf4f8f..f18b63f2d3a 100644 --- a/lib/commercetools-history/src/Models/Common/PaymentInfoModel.php +++ b/lib/commercetools-history/src/Models/Common/PaymentInfoModel.php @@ -23,7 +23,7 @@ final class PaymentInfoModel extends JsonObjectModel implements PaymentInfo /** * - * @var ?ReferenceCollection + * @var ?PaymentReferenceCollection */ protected $payments; @@ -32,15 +32,17 @@ final class PaymentInfoModel extends JsonObjectModel implements PaymentInfo * @psalm-suppress MissingParamType */ public function __construct( - ?ReferenceCollection $payments = null + ?PaymentReferenceCollection $payments = null ) { $this->payments = $payments; } /** + *

                                                                                                                            References to the Payments associated with the Order.

                                                                                                                            * - * @return null|ReferenceCollection + * + * @return null|PaymentReferenceCollection */ public function getPayments() { @@ -50,7 +52,7 @@ public function getPayments() if (is_null($data)) { return null; } - $this->payments = ReferenceCollection::fromArray($data); + $this->payments = PaymentReferenceCollection::fromArray($data); } return $this->payments; @@ -58,9 +60,9 @@ public function getPayments() /** - * @param ?ReferenceCollection $payments + * @param ?PaymentReferenceCollection $payments */ - public function setPayments(?ReferenceCollection $payments): void + public function setPayments(?PaymentReferenceCollection $payments): void { $this->payments = $payments; } diff --git a/lib/commercetools-history/src/Models/Common/PaymentReference.php b/lib/commercetools-history/src/Models/Common/PaymentReference.php new file mode 100644 index 00000000000..dff3333a61f --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/PaymentReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced Payment.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/PaymentReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/PaymentReferenceBuilder.php new file mode 100644 index 00000000000..873f50e4317 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/PaymentReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class PaymentReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced Payment.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): PaymentReference + { + return new PaymentReferenceModel( + $this->id + ); + } + + public static function of(): PaymentReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/PaymentReferenceCollection.php b/lib/commercetools-history/src/Models/Common/PaymentReferenceCollection.php new file mode 100644 index 00000000000..ab4020bfda4 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/PaymentReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method PaymentReference current() + * @method PaymentReference end() + * @method PaymentReference at($offset) + */ +class PaymentReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert PaymentReference $value + * @psalm-param PaymentReference|stdClass $value + * @throws InvalidArgumentException + * + * @return PaymentReferenceCollection + */ + public function add($value) + { + if (!$value instanceof PaymentReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?PaymentReference + */ + protected function mapper() + { + return function (?int $index): ?PaymentReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var PaymentReference $data */ + $data = PaymentReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/PaymentReferenceModel.php b/lib/commercetools-history/src/Models/Common/PaymentReferenceModel.php new file mode 100644 index 00000000000..bf93bc7c294 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/PaymentReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced Payment.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/Price.php b/lib/commercetools-history/src/Models/Common/Price.php index c9cd4eb1e93..95b5bda1c40 100644 --- a/lib/commercetools-history/src/Models/Common/Price.php +++ b/lib/commercetools-history/src/Models/Common/Price.php @@ -10,32 +10,180 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use DateTimeImmutable; interface Price extends JsonObject { public const FIELD_ID = 'id'; + public const FIELD_KEY = 'key'; public const FIELD_VALUE = 'value'; + public const FIELD_COUNTRY = 'country'; + public const FIELD_CUSTOMER_GROUP = 'customerGroup'; + public const FIELD_CHANNEL = 'channel'; + public const FIELD_VALID_FROM = 'validFrom'; + public const FIELD_VALID_UNTIL = 'validUntil'; + public const FIELD_DISCOUNTED = 'discounted'; + public const FIELD_TIERS = 'tiers'; + public const FIELD_CUSTOM = 'custom'; + public const FIELD_RECURRENCE_POLICY = 'recurrencePolicy'; /** + *

                                                                                                                            Unique identifier of this Price.

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

                                                                                                                            User-defined identifier of the Price. It is unique per ProductVariant.

                                                                                                                            + * - * @return null|Money + * @return null|string + */ + public function getKey(); + + /** + *

                                                                                                                            Money value of this Price.

                                                                                                                            + * + + * @return null|TypedMoney */ public function getValue(); + /** + *

                                                                                                                            Country for which this Price is valid.

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

                                                                                                                            CustomerGroup for which this Price is valid.

                                                                                                                            + * + + * @return null|CustomerGroupReference + */ + public function getCustomerGroup(); + + /** + *

                                                                                                                            ProductDistribution Channel for which this Price is valid.

                                                                                                                            + * + + * @return null|ChannelReference + */ + public function getChannel(); + + /** + *

                                                                                                                            Date and time from which this Price is valid.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ + public function getValidFrom(); + + /** + *

                                                                                                                            Date and time until this Price is valid. Prices that are no longer valid are not automatically removed, but they can be removed if necessary.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ + public function getValidUntil(); + + /** + *

                                                                                                                            Is set if a ProductDiscount has been applied. + * If set, the API uses the DiscountedPrice value for the Line Item price selection. + * When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

                                                                                                                            + * + + * @return null|DiscountedPrice + */ + public function getDiscounted(); + + /** + *

                                                                                                                            Present if different Prices for certain LineItem quantities have been specified.

                                                                                                                            + *

                                                                                                                            If discounted is present, the tiered Price is ignored for a Product Variant.

                                                                                                                            + * + + * @return null|PriceTierCollection + */ + public function getTiers(); + + /** + *

                                                                                                                            Custom Fields defined for the Price.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom(); + + /** + *

                                                                                                                            Recurrence Policy for which this Price is valid.

                                                                                                                            + * + + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy(); + /** * @param ?string $id */ public function setId(?string $id): void; /** - * @param ?Money $value + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?TypedMoney $value + */ + public function setValue(?TypedMoney $value): void; + + /** + * @param ?string $country + */ + public function setCountry(?string $country): void; + + /** + * @param ?CustomerGroupReference $customerGroup + */ + public function setCustomerGroup(?CustomerGroupReference $customerGroup): void; + + /** + * @param ?ChannelReference $channel + */ + public function setChannel(?ChannelReference $channel): void; + + /** + * @param ?DateTimeImmutable $validFrom + */ + public function setValidFrom(?DateTimeImmutable $validFrom): void; + + /** + * @param ?DateTimeImmutable $validUntil + */ + public function setValidUntil(?DateTimeImmutable $validUntil): void; + + /** + * @param ?DiscountedPrice $discounted + */ + public function setDiscounted(?DiscountedPrice $discounted): void; + + /** + * @param ?PriceTierCollection $tiers + */ + public function setTiers(?PriceTierCollection $tiers): void; + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void; + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy */ - public function setValue(?Money $value): void; + public function setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy): void; } diff --git a/lib/commercetools-history/src/Models/Common/PriceBuilder.php b/lib/commercetools-history/src/Models/Common/PriceBuilder.php index 961bd9ce68f..3f2dc401265 100644 --- a/lib/commercetools-history/src/Models/Common/PriceBuilder.php +++ b/lib/commercetools-history/src/Models/Common/PriceBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @implements Builder @@ -28,12 +29,74 @@ final class PriceBuilder implements Builder /** - * @var null|Money|MoneyBuilder + * @var ?string + */ + private $key; + + /** + + * @var null|TypedMoney|TypedMoneyBuilder */ private $value; /** + * @var ?string + */ + private $country; + + /** + + * @var null|CustomerGroupReference|CustomerGroupReferenceBuilder + */ + private $customerGroup; + + /** + + * @var null|ChannelReference|ChannelReferenceBuilder + */ + private $channel; + + /** + + * @var ?DateTimeImmutable + */ + private $validFrom; + + /** + + * @var ?DateTimeImmutable + */ + private $validUntil; + + /** + + * @var null|DiscountedPrice|DiscountedPriceBuilder + */ + private $discounted; + + /** + + * @var ?PriceTierCollection + */ + private $tiers; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + + /** + + * @var null|RecurrencePolicyReference|RecurrencePolicyReferenceBuilder + */ + private $recurrencePolicy; + + /** + *

                                                                                                                            Unique identifier of this Price.

                                                                                                                            + * + * @return null|string */ public function getId() @@ -42,12 +105,127 @@ public function getId() } /** + *

                                                                                                                            User-defined identifier of the Price. It is unique per ProductVariant.

                                                                                                                            + * - * @return null|Money + * @return null|string + */ + public function getKey() + { + return $this->key; + } + + /** + *

                                                                                                                            Money value of this Price.

                                                                                                                            + * + + * @return null|TypedMoney */ public function getValue() { - return $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value; + return $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value; + } + + /** + *

                                                                                                                            Country for which this Price is valid.

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

                                                                                                                            CustomerGroup for which this Price is valid.

                                                                                                                            + * + + * @return null|CustomerGroupReference + */ + public function getCustomerGroup() + { + return $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup; + } + + /** + *

                                                                                                                            ProductDistribution Channel for which this Price is valid.

                                                                                                                            + * + + * @return null|ChannelReference + */ + public function getChannel() + { + return $this->channel instanceof ChannelReferenceBuilder ? $this->channel->build() : $this->channel; + } + + /** + *

                                                                                                                            Date and time from which this Price is valid.

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

                                                                                                                            Date and time until this Price is valid. Prices that are no longer valid are not automatically removed, but they can be removed if necessary.

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

                                                                                                                            Is set if a ProductDiscount has been applied. + * If set, the API uses the DiscountedPrice value for the Line Item price selection. + * When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

                                                                                                                            + * + + * @return null|DiscountedPrice + */ + public function getDiscounted() + { + return $this->discounted instanceof DiscountedPriceBuilder ? $this->discounted->build() : $this->discounted; + } + + /** + *

                                                                                                                            Present if different Prices for certain LineItem quantities have been specified.

                                                                                                                            + *

                                                                                                                            If discounted is present, the tiered Price is ignored for a Product Variant.

                                                                                                                            + * + + * @return null|PriceTierCollection + */ + public function getTiers() + { + return $this->tiers; + } + + /** + *

                                                                                                                            Custom Fields defined for the Price.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; + } + + /** + *

                                                                                                                            Recurrence Policy for which this Price is valid.

                                                                                                                            + * + + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy() + { + return $this->recurrencePolicy instanceof RecurrencePolicyReferenceBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy; } /** @@ -62,32 +240,207 @@ public function withId(?string $id) } /** - * @param ?Money $value + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?TypedMoney $value * @return $this */ - public function withValue(?Money $value) + public function withValue(?TypedMoney $value) { $this->value = $value; return $this; } + /** + * @param ?string $country + * @return $this + */ + public function withCountry(?string $country) + { + $this->country = $country; + + return $this; + } + + /** + * @param ?CustomerGroupReference $customerGroup + * @return $this + */ + public function withCustomerGroup(?CustomerGroupReference $customerGroup) + { + $this->customerGroup = $customerGroup; + + return $this; + } + + /** + * @param ?ChannelReference $channel + * @return $this + */ + public function withChannel(?ChannelReference $channel) + { + $this->channel = $channel; + + return $this; + } + + /** + * @param ?DateTimeImmutable $validFrom + * @return $this + */ + public function withValidFrom(?DateTimeImmutable $validFrom) + { + $this->validFrom = $validFrom; + + return $this; + } + + /** + * @param ?DateTimeImmutable $validUntil + * @return $this + */ + public function withValidUntil(?DateTimeImmutable $validUntil) + { + $this->validUntil = $validUntil; + + return $this; + } + + /** + * @param ?DiscountedPrice $discounted + * @return $this + */ + public function withDiscounted(?DiscountedPrice $discounted) + { + $this->discounted = $discounted; + + return $this; + } + + /** + * @param ?PriceTierCollection $tiers + * @return $this + */ + public function withTiers(?PriceTierCollection $tiers) + { + $this->tiers = $tiers; + + return $this; + } + + /** + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + /** * @deprecated use withValue() instead * @return $this */ - public function withValueBuilder(?MoneyBuilder $value) + public function withValueBuilder(?TypedMoneyBuilder $value) { $this->value = $value; return $this; } + /** + * @deprecated use withCustomerGroup() instead + * @return $this + */ + public function withCustomerGroupBuilder(?CustomerGroupReferenceBuilder $customerGroup) + { + $this->customerGroup = $customerGroup; + + return $this; + } + + /** + * @deprecated use withChannel() instead + * @return $this + */ + public function withChannelBuilder(?ChannelReferenceBuilder $channel) + { + $this->channel = $channel; + + return $this; + } + + /** + * @deprecated use withDiscounted() instead + * @return $this + */ + public function withDiscountedBuilder(?DiscountedPriceBuilder $discounted) + { + $this->discounted = $discounted; + + return $this; + } + + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @deprecated use withRecurrencePolicy() instead + * @return $this + */ + public function withRecurrencePolicyBuilder(?RecurrencePolicyReferenceBuilder $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + public function build(): Price { return new PriceModel( $this->id, - $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value + $this->key, + $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value, + $this->country, + $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup, + $this->channel instanceof ChannelReferenceBuilder ? $this->channel->build() : $this->channel, + $this->validFrom, + $this->validUntil, + $this->discounted instanceof DiscountedPriceBuilder ? $this->discounted->build() : $this->discounted, + $this->tiers, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, + $this->recurrencePolicy instanceof RecurrencePolicyReferenceBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy ); } diff --git a/lib/commercetools-history/src/Models/Common/PriceModel.php b/lib/commercetools-history/src/Models/Common/PriceModel.php index 3561bd0f9f7..1f49b2d045b 100644 --- a/lib/commercetools-history/src/Models/Common/PriceModel.php +++ b/lib/commercetools-history/src/Models/Common/PriceModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @internal @@ -29,24 +30,106 @@ final class PriceModel extends JsonObjectModel implements Price /** * - * @var ?Money + * @var ?string + */ + protected $key; + + /** + * + * @var ?TypedMoney */ protected $value; + /** + * + * @var ?string + */ + protected $country; + + /** + * + * @var ?CustomerGroupReference + */ + protected $customerGroup; + + /** + * + * @var ?ChannelReference + */ + protected $channel; + + /** + * + * @var ?DateTimeImmutable + */ + protected $validFrom; + + /** + * + * @var ?DateTimeImmutable + */ + protected $validUntil; + + /** + * + * @var ?DiscountedPrice + */ + protected $discounted; + + /** + * + * @var ?PriceTierCollection + */ + protected $tiers; + + /** + * + * @var ?CustomFields + */ + protected $custom; + + /** + * + * @var ?RecurrencePolicyReference + */ + protected $recurrencePolicy; + /** * @psalm-suppress MissingParamType */ public function __construct( ?string $id = null, - ?Money $value = null + ?string $key = null, + ?TypedMoney $value = null, + ?string $country = null, + ?CustomerGroupReference $customerGroup = null, + ?ChannelReference $channel = null, + ?DateTimeImmutable $validFrom = null, + ?DateTimeImmutable $validUntil = null, + ?DiscountedPrice $discounted = null, + ?PriceTierCollection $tiers = null, + ?CustomFields $custom = null, + ?RecurrencePolicyReference $recurrencePolicy = null ) { $this->id = $id; + $this->key = $key; $this->value = $value; + $this->country = $country; + $this->customerGroup = $customerGroup; + $this->channel = $channel; + $this->validFrom = $validFrom; + $this->validUntil = $validUntil; + $this->discounted = $discounted; + $this->tiers = $tiers; + $this->custom = $custom; + $this->recurrencePolicy = $recurrencePolicy; } /** + *

                                                                                                                            Unique identifier of this Price.

                                                                                                                            + * * * @return null|string */ @@ -65,8 +148,30 @@ public function getId() } /** + *

                                                                                                                            User-defined identifier of the Price. It is unique per ProductVariant.

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

                                                                                                                            Money value of this Price.

                                                                                                                            * - * @return null|Money + * + * @return null|TypedMoney */ public function getValue() { @@ -76,13 +181,209 @@ public function getValue() if (is_null($data)) { return null; } - - $this->value = MoneyModel::of($data); + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->value = $className::of($data); } return $this->value; } + /** + *

                                                                                                                            Country for which this Price is valid.

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

                                                                                                                            CustomerGroup for which this Price is valid.

                                                                                                                            + * + * + * @return null|CustomerGroupReference + */ + public function getCustomerGroup() + { + if (is_null($this->customerGroup)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOMER_GROUP); + if (is_null($data)) { + return null; + } + + $this->customerGroup = CustomerGroupReferenceModel::of($data); + } + + return $this->customerGroup; + } + + /** + *

                                                                                                                            ProductDistribution Channel for which this Price is valid.

                                                                                                                            + * + * + * @return null|ChannelReference + */ + public function getChannel() + { + if (is_null($this->channel)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CHANNEL); + if (is_null($data)) { + return null; + } + + $this->channel = ChannelReferenceModel::of($data); + } + + return $this->channel; + } + + /** + *

                                                                                                                            Date and time from which this Price is valid.

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

                                                                                                                            Date and time until this Price is valid. Prices that are no longer valid are not automatically removed, but they can be removed if necessary.

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

                                                                                                                            Is set if a ProductDiscount has been applied. + * If set, the API uses the DiscountedPrice value for the Line Item price selection. + * When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

                                                                                                                            + * + * + * @return null|DiscountedPrice + */ + public function getDiscounted() + { + if (is_null($this->discounted)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DISCOUNTED); + if (is_null($data)) { + return null; + } + + $this->discounted = DiscountedPriceModel::of($data); + } + + return $this->discounted; + } + + /** + *

                                                                                                                            Present if different Prices for certain LineItem quantities have been specified.

                                                                                                                            + *

                                                                                                                            If discounted is present, the tiered Price is ignored for a Product Variant.

                                                                                                                            + * + * + * @return null|PriceTierCollection + */ + public function getTiers() + { + if (is_null($this->tiers)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_TIERS); + if (is_null($data)) { + return null; + } + $this->tiers = PriceTierCollection::fromArray($data); + } + + return $this->tiers; + } + + /** + *

                                                                                                                            Custom Fields defined for the Price.

                                                                                                                            + * + * + * @return null|CustomFields + */ + public function getCustom() + { + if (is_null($this->custom)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($data)) { + return null; + } + + $this->custom = CustomFieldsModel::of($data); + } + + return $this->custom; + } + + /** + *

                                                                                                                            Recurrence Policy for which this Price is valid.

                                                                                                                            + * + * + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy() + { + if (is_null($this->recurrencePolicy)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRENCE_POLICY); + if (is_null($data)) { + return null; + } + + $this->recurrencePolicy = RecurrencePolicyReferenceModel::of($data); + } + + return $this->recurrencePolicy; + } + /** * @param ?string $id @@ -93,13 +394,106 @@ public function setId(?string $id): void } /** - * @param ?Money $value + * @param ?string $key */ - public function setValue(?Money $value): void + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?TypedMoney $value + */ + public function setValue(?TypedMoney $value): void { $this->value = $value; } + /** + * @param ?string $country + */ + public function setCountry(?string $country): void + { + $this->country = $country; + } + + /** + * @param ?CustomerGroupReference $customerGroup + */ + public function setCustomerGroup(?CustomerGroupReference $customerGroup): void + { + $this->customerGroup = $customerGroup; + } + + /** + * @param ?ChannelReference $channel + */ + public function setChannel(?ChannelReference $channel): void + { + $this->channel = $channel; + } + + /** + * @param ?DateTimeImmutable $validFrom + */ + public function setValidFrom(?DateTimeImmutable $validFrom): void + { + $this->validFrom = $validFrom; + } + + /** + * @param ?DateTimeImmutable $validUntil + */ + public function setValidUntil(?DateTimeImmutable $validUntil): void + { + $this->validUntil = $validUntil; + } + + /** + * @param ?DiscountedPrice $discounted + */ + public function setDiscounted(?DiscountedPrice $discounted): void + { + $this->discounted = $discounted; + } + + /** + * @param ?PriceTierCollection $tiers + */ + public function setTiers(?PriceTierCollection $tiers): void + { + $this->tiers = $tiers; + } + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy): void + { + $this->recurrencePolicy = $recurrencePolicy; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Price::FIELD_VALID_FROM]) && $data[Price::FIELD_VALID_FROM] instanceof \DateTimeImmutable) { + $data[Price::FIELD_VALID_FROM] = $data[Price::FIELD_VALID_FROM]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[Price::FIELD_VALID_UNTIL]) && $data[Price::FIELD_VALID_UNTIL] instanceof \DateTimeImmutable) { + $data[Price::FIELD_VALID_UNTIL] = $data[Price::FIELD_VALID_UNTIL]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } } diff --git a/lib/commercetools-history/src/Models/Common/PriceTier.php b/lib/commercetools-history/src/Models/Common/PriceTier.php new file mode 100644 index 00000000000..acdc3624c4b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/PriceTier.php @@ -0,0 +1,48 @@ +Minimum quantity this Price tier is valid for.

                                                                                                                            + *

                                                                                                                            The minimum quantity is always greater than or equal to 2. The base Price is interpreted as valid for a minimum quantity equal to 1. + * A Price or StandalonePrice cannot contain more than one tier with the same minimumQuantity.

                                                                                                                            + * + + * @return null|int + */ + public function getMinimumQuantity(); + + /** + *

                                                                                                                            Money value that applies when the minimumQuantity is greater than or equal to the LineItem quantity.

                                                                                                                            + *

                                                                                                                            The currencyCode of a Price tier is always the same as the currencyCode in the value of the related Price.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getValue(); + + /** + * @param ?int $minimumQuantity + */ + public function setMinimumQuantity(?int $minimumQuantity): void; + + /** + * @param ?TypedMoney $value + */ + public function setValue(?TypedMoney $value): void; +} diff --git a/lib/commercetools-history/src/Models/Common/PriceTierBuilder.php b/lib/commercetools-history/src/Models/Common/PriceTierBuilder.php new file mode 100644 index 00000000000..1b78d004415 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/PriceTierBuilder.php @@ -0,0 +1,105 @@ + + */ +final class PriceTierBuilder implements Builder +{ + /** + + * @var ?int + */ + private $minimumQuantity; + + /** + + * @var null|TypedMoney|TypedMoneyBuilder + */ + private $value; + + /** + *

                                                                                                                            Minimum quantity this Price tier is valid for.

                                                                                                                            + *

                                                                                                                            The minimum quantity is always greater than or equal to 2. The base Price is interpreted as valid for a minimum quantity equal to 1. + * A Price or StandalonePrice cannot contain more than one tier with the same minimumQuantity.

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

                                                                                                                            Money value that applies when the minimumQuantity is greater than or equal to the LineItem quantity.

                                                                                                                            + *

                                                                                                                            The currencyCode of a Price tier is always the same as the currencyCode in the value of the related Price.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getValue() + { + return $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value; + } + + /** + * @param ?int $minimumQuantity + * @return $this + */ + public function withMinimumQuantity(?int $minimumQuantity) + { + $this->minimumQuantity = $minimumQuantity; + + return $this; + } + + /** + * @param ?TypedMoney $value + * @return $this + */ + public function withValue(?TypedMoney $value) + { + $this->value = $value; + + return $this; + } + + /** + * @deprecated use withValue() instead + * @return $this + */ + public function withValueBuilder(?TypedMoneyBuilder $value) + { + $this->value = $value; + + return $this; + } + + public function build(): PriceTier + { + return new PriceTierModel( + $this->minimumQuantity, + $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value + ); + } + + public static function of(): PriceTierBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/PriceTierCollection.php b/lib/commercetools-history/src/Models/Common/PriceTierCollection.php new file mode 100644 index 00000000000..e64c7123bc8 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/PriceTierCollection.php @@ -0,0 +1,56 @@ + + * @method PriceTier current() + * @method PriceTier end() + * @method PriceTier at($offset) + */ +class PriceTierCollection extends MapperSequence +{ + /** + * @psalm-assert PriceTier $value + * @psalm-param PriceTier|stdClass $value + * @throws InvalidArgumentException + * + * @return PriceTierCollection + */ + public function add($value) + { + if (!$value instanceof PriceTier) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?PriceTier + */ + protected function mapper() + { + return function (?int $index): ?PriceTier { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var PriceTier $data */ + $data = PriceTierModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/PriceTierModel.php b/lib/commercetools-history/src/Models/Common/PriceTierModel.php new file mode 100644 index 00000000000..a5e18f3775c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/PriceTierModel.php @@ -0,0 +1,112 @@ +minimumQuantity = $minimumQuantity; + $this->value = $value; + + } + + /** + *

                                                                                                                            Minimum quantity this Price tier is valid for.

                                                                                                                            + *

                                                                                                                            The minimum quantity is always greater than or equal to 2. The base Price is interpreted as valid for a minimum quantity equal to 1. + * A Price or StandalonePrice cannot contain more than one tier with the same minimumQuantity.

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

                                                                                                                            Money value that applies when the minimumQuantity is greater than or equal to the LineItem quantity.

                                                                                                                            + *

                                                                                                                            The currencyCode of a Price tier is always the same as the currencyCode in the value of the related Price.

                                                                                                                            + * + * + * @return null|TypedMoney + */ + public function getValue() + { + if (is_null($this->value)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_VALUE); + if (is_null($data)) { + return null; + } + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->value = $className::of($data); + } + + return $this->value; + } + + + /** + * @param ?int $minimumQuantity + */ + public function setMinimumQuantity(?int $minimumQuantity): void + { + $this->minimumQuantity = $minimumQuantity; + } + + /** + * @param ?TypedMoney $value + */ + public function setValue(?TypedMoney $value): void + { + $this->value = $value; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ProductDiscountReference.php b/lib/commercetools-history/src/Models/Common/ProductDiscountReference.php new file mode 100644 index 00000000000..2a250fc308e --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductDiscountReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced ProductDiscount.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ProductDiscountReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/ProductDiscountReferenceBuilder.php new file mode 100644 index 00000000000..1e921947ae3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductDiscountReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class ProductDiscountReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced ProductDiscount.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): ProductDiscountReference + { + return new ProductDiscountReferenceModel( + $this->id + ); + } + + public static function of(): ProductDiscountReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductDiscountReferenceCollection.php b/lib/commercetools-history/src/Models/Common/ProductDiscountReferenceCollection.php new file mode 100644 index 00000000000..ed72ff4829f --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductDiscountReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method ProductDiscountReference current() + * @method ProductDiscountReference end() + * @method ProductDiscountReference at($offset) + */ +class ProductDiscountReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert ProductDiscountReference $value + * @psalm-param ProductDiscountReference|stdClass $value + * @throws InvalidArgumentException + * + * @return ProductDiscountReferenceCollection + */ + public function add($value) + { + if (!$value instanceof ProductDiscountReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ProductDiscountReference + */ + protected function mapper() + { + return function (?int $index): ?ProductDiscountReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ProductDiscountReference $data */ + $data = ProductDiscountReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductDiscountReferenceModel.php b/lib/commercetools-history/src/Models/Common/ProductDiscountReferenceModel.php new file mode 100644 index 00000000000..cbd237bd81b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductDiscountReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced ProductDiscount.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ProductDiscountValue.php b/lib/commercetools-history/src/Models/Common/ProductDiscountValue.php new file mode 100644 index 00000000000..f82e7d6b4ae --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductDiscountValue.php @@ -0,0 +1,29 @@ + + */ +final class ProductDiscountValueBuilder implements Builder +{ + /** + + * @var ?string + */ + private $type; + + /** + + * @return null|string + */ + public function getType() + { + return $this->type; + } + + /** + * @param ?string $type + * @return $this + */ + public function withType(?string $type) + { + $this->type = $type; + + return $this; + } + + + public function build(): ProductDiscountValue + { + return new ProductDiscountValueModel( + $this->type + ); + } + + public static function of(): ProductDiscountValueBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductDiscountValueCollection.php b/lib/commercetools-history/src/Models/Common/ProductDiscountValueCollection.php new file mode 100644 index 00000000000..eebc3d5675e --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductDiscountValueCollection.php @@ -0,0 +1,56 @@ + + * @method ProductDiscountValue current() + * @method ProductDiscountValue end() + * @method ProductDiscountValue at($offset) + */ +class ProductDiscountValueCollection extends MapperSequence +{ + /** + * @psalm-assert ProductDiscountValue $value + * @psalm-param ProductDiscountValue|stdClass $value + * @throws InvalidArgumentException + * + * @return ProductDiscountValueCollection + */ + public function add($value) + { + if (!$value instanceof ProductDiscountValue) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ProductDiscountValue + */ + protected function mapper() + { + return function (?int $index): ?ProductDiscountValue { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ProductDiscountValue $data */ + $data = ProductDiscountValueModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductDiscountValueModel.php b/lib/commercetools-history/src/Models/Common/ProductDiscountValueModel.php new file mode 100644 index 00000000000..6b63b923af2 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductDiscountValueModel.php @@ -0,0 +1,70 @@ +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; + } + + + /** + * @param ?string $type + */ + public function setType(?string $type): void + { + $this->type = $type; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ProductReference.php b/lib/commercetools-history/src/Models/Common/ProductReference.php new file mode 100644 index 00000000000..da7ae0c0a01 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced Product.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ProductReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/ProductReferenceBuilder.php new file mode 100644 index 00000000000..9a68b1f2d33 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class ProductReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced Product.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): ProductReference + { + return new ProductReferenceModel( + $this->id + ); + } + + public static function of(): ProductReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductReferenceCollection.php b/lib/commercetools-history/src/Models/Common/ProductReferenceCollection.php new file mode 100644 index 00000000000..0e98170f23c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method ProductReference current() + * @method ProductReference end() + * @method ProductReference at($offset) + */ +class ProductReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert ProductReference $value + * @psalm-param ProductReference|stdClass $value + * @throws InvalidArgumentException + * + * @return ProductReferenceCollection + */ + public function add($value) + { + if (!$value instanceof ProductReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ProductReference + */ + protected function mapper() + { + return function (?int $index): ?ProductReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ProductReference $data */ + $data = ProductReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductReferenceModel.php b/lib/commercetools-history/src/Models/Common/ProductReferenceModel.php new file mode 100644 index 00000000000..e970208e834 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced Product.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ProductSelectionReference.php b/lib/commercetools-history/src/Models/Common/ProductSelectionReference.php new file mode 100644 index 00000000000..c6c14b95b39 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductSelectionReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced ProductSelection.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ProductSelectionReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/ProductSelectionReferenceBuilder.php new file mode 100644 index 00000000000..41ca2cbcdcc --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductSelectionReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class ProductSelectionReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced ProductSelection.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): ProductSelectionReference + { + return new ProductSelectionReferenceModel( + $this->id + ); + } + + public static function of(): ProductSelectionReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductSelectionReferenceCollection.php b/lib/commercetools-history/src/Models/Common/ProductSelectionReferenceCollection.php new file mode 100644 index 00000000000..e54180908ce --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductSelectionReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method ProductSelectionReference current() + * @method ProductSelectionReference end() + * @method ProductSelectionReference at($offset) + */ +class ProductSelectionReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert ProductSelectionReference $value + * @psalm-param ProductSelectionReference|stdClass $value + * @throws InvalidArgumentException + * + * @return ProductSelectionReferenceCollection + */ + public function add($value) + { + if (!$value instanceof ProductSelectionReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ProductSelectionReference + */ + protected function mapper() + { + return function (?int $index): ?ProductSelectionReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ProductSelectionReference $data */ + $data = ProductSelectionReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductSelectionReferenceModel.php b/lib/commercetools-history/src/Models/Common/ProductSelectionReferenceModel.php new file mode 100644 index 00000000000..f5cbc2b1773 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductSelectionReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced ProductSelection.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ProductSelectionSetting.php b/lib/commercetools-history/src/Models/Common/ProductSelectionSetting.php index 865804064a5..03db84ddb07 100644 --- a/lib/commercetools-history/src/Models/Common/ProductSelectionSetting.php +++ b/lib/commercetools-history/src/Models/Common/ProductSelectionSetting.php @@ -18,21 +18,25 @@ interface ProductSelectionSetting extends JsonObject public const FIELD_ACTIVE = 'active'; /** + *

                                                                                                                            Reference to a ProductSelection.

                                                                                                                            + * - * @return null|Reference + * @return null|ProductSelectionReference */ public function getProductSelection(); /** + *

                                                                                                                            If true, all Products assigned to this Product Selection are part of the Store's assortment.

                                                                                                                            + * * @return null|bool */ public function getActive(); /** - * @param ?Reference $productSelection + * @param ?ProductSelectionReference $productSelection */ - public function setProductSelection(?Reference $productSelection): void; + public function setProductSelection(?ProductSelectionReference $productSelection): void; /** * @param ?bool $active diff --git a/lib/commercetools-history/src/Models/Common/ProductSelectionSettingBuilder.php b/lib/commercetools-history/src/Models/Common/ProductSelectionSettingBuilder.php index 7af21482248..c55c36b7a3c 100644 --- a/lib/commercetools-history/src/Models/Common/ProductSelectionSettingBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ProductSelectionSettingBuilder.php @@ -22,7 +22,7 @@ final class ProductSelectionSettingBuilder implements Builder { /** - * @var null|Reference|ReferenceBuilder + * @var null|ProductSelectionReference|ProductSelectionReferenceBuilder */ private $productSelection; @@ -33,15 +33,19 @@ final class ProductSelectionSettingBuilder implements Builder private $active; /** + *

                                                                                                                            Reference to a ProductSelection.

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

                                                                                                                            If true, all Products assigned to this Product Selection are part of the Store's assortment.

                                                                                                                            + * * @return null|bool */ @@ -51,10 +55,10 @@ public function getActive() } /** - * @param ?Reference $productSelection + * @param ?ProductSelectionReference $productSelection * @return $this */ - public function withProductSelection(?Reference $productSelection) + public function withProductSelection(?ProductSelectionReference $productSelection) { $this->productSelection = $productSelection; @@ -76,7 +80,7 @@ public function withActive(?bool $active) * @deprecated use withProductSelection() instead * @return $this */ - public function withProductSelectionBuilder(?ReferenceBuilder $productSelection) + public function withProductSelectionBuilder(?ProductSelectionReferenceBuilder $productSelection) { $this->productSelection = $productSelection; @@ -86,7 +90,7 @@ public function withProductSelectionBuilder(?ReferenceBuilder $productSelection) public function build(): ProductSelectionSetting { return new ProductSelectionSettingModel( - $this->productSelection instanceof ReferenceBuilder ? $this->productSelection->build() : $this->productSelection, + $this->productSelection instanceof ProductSelectionReferenceBuilder ? $this->productSelection->build() : $this->productSelection, $this->active ); } diff --git a/lib/commercetools-history/src/Models/Common/ProductSelectionSettingModel.php b/lib/commercetools-history/src/Models/Common/ProductSelectionSettingModel.php index dcd446b3a2c..60e6b04e8a1 100644 --- a/lib/commercetools-history/src/Models/Common/ProductSelectionSettingModel.php +++ b/lib/commercetools-history/src/Models/Common/ProductSelectionSettingModel.php @@ -23,7 +23,7 @@ final class ProductSelectionSettingModel extends JsonObjectModel implements Prod /** * - * @var ?Reference + * @var ?ProductSelectionReference */ protected $productSelection; @@ -38,7 +38,7 @@ final class ProductSelectionSettingModel extends JsonObjectModel implements Prod * @psalm-suppress MissingParamType */ public function __construct( - ?Reference $productSelection = null, + ?ProductSelectionReference $productSelection = null, ?bool $active = null ) { $this->productSelection = $productSelection; @@ -47,8 +47,10 @@ public function __construct( } /** + *

                                                                                                                            Reference to a ProductSelection.

                                                                                                                            * - * @return null|Reference + * + * @return null|ProductSelectionReference */ public function getProductSelection() { @@ -59,13 +61,15 @@ public function getProductSelection() return null; } - $this->productSelection = ReferenceModel::of($data); + $this->productSelection = ProductSelectionReferenceModel::of($data); } return $this->productSelection; } /** + *

                                                                                                                            If true, all Products assigned to this Product Selection are part of the Store's assortment.

                                                                                                                            + * * * @return null|bool */ @@ -85,9 +89,9 @@ public function getActive() /** - * @param ?Reference $productSelection + * @param ?ProductSelectionReference $productSelection */ - public function setProductSelection(?Reference $productSelection): void + public function setProductSelection(?ProductSelectionReference $productSelection): void { $this->productSelection = $productSelection; } diff --git a/lib/commercetools-history/src/Models/Common/ProductTypeReference.php b/lib/commercetools-history/src/Models/Common/ProductTypeReference.php new file mode 100644 index 00000000000..8a926e3cbcc --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductTypeReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced ProductType.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ProductTypeReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/ProductTypeReferenceBuilder.php new file mode 100644 index 00000000000..642fd7b5806 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductTypeReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class ProductTypeReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced ProductType.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): ProductTypeReference + { + return new ProductTypeReferenceModel( + $this->id + ); + } + + public static function of(): ProductTypeReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductTypeReferenceCollection.php b/lib/commercetools-history/src/Models/Common/ProductTypeReferenceCollection.php new file mode 100644 index 00000000000..92d7323555b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductTypeReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method ProductTypeReference current() + * @method ProductTypeReference end() + * @method ProductTypeReference at($offset) + */ +class ProductTypeReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert ProductTypeReference $value + * @psalm-param ProductTypeReference|stdClass $value + * @throws InvalidArgumentException + * + * @return ProductTypeReferenceCollection + */ + public function add($value) + { + if (!$value instanceof ProductTypeReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ProductTypeReference + */ + protected function mapper() + { + return function (?int $index): ?ProductTypeReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ProductTypeReference $data */ + $data = ProductTypeReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductTypeReferenceModel.php b/lib/commercetools-history/src/Models/Common/ProductTypeReferenceModel.php new file mode 100644 index 00000000000..82c5872529e --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductTypeReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced ProductType.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ProductVariant.php b/lib/commercetools-history/src/Models/Common/ProductVariant.php new file mode 100644 index 00000000000..7c6c1b6c516 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductVariant.php @@ -0,0 +1,209 @@ +A unique, sequential identifier of the Product Variant within the Product.

                                                                                                                            + * + + * @return null|int + */ + public function getId(); + + /** + *

                                                                                                                            User-defined unique SKU of the Product Variant.

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

                                                                                                                            User-defined unique identifier of the ProductVariant.

                                                                                                                            + *

                                                                                                                            This is different from Product key.

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

                                                                                                                            The Embedded Prices of the Product Variant. + * Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

                                                                                                                            + * + + * @return null|PriceCollection + */ + public function getPrices(); + + /** + *

                                                                                                                            Variant Attributes according to the respective AttributeDefinition.

                                                                                                                            + * + + * @return null|AttributeCollection + */ + public function getAttributes(); + + /** + *

                                                                                                                            Only available when price selection is used. + * Cannot be used in a Query Predicate.

                                                                                                                            + * + + * @return null|Price + */ + public function getPrice(); + + /** + *

                                                                                                                            Images of the Product Variant.

                                                                                                                            + * + + * @return null|ImageCollection + */ + public function getImages(); + + /** + *

                                                                                                                            Media assets of the Product Variant.

                                                                                                                            + * + + * @return null|AssetCollection + */ + public function getAssets(); + + /** + *

                                                                                                                            Set if the Product Variant is tracked by Inventory. + * Can be used as an optimization to reduce calls to the Inventory service. + * May not contain the latest Inventory State (it is eventually consistent).

                                                                                                                            + * + + * @return null|ProductVariantAvailability + */ + public function getAvailability(); + + /** + *

                                                                                                                            true if the Product Variant matches the search query. + * Only available in response to a Product Projection Search request.

                                                                                                                            + * + + * @return null|bool + */ + public function getIsMatchingVariant(); + + /** + *

                                                                                                                            Only available in response to a Product Projection Search request + * with Product price selection. + * Can be used to sort, filter, and facet.

                                                                                                                            + * + + * @return null|ScopedPrice + */ + public function getScopedPrice(); + + /** + *

                                                                                                                            Only available in response to a Product Projection Search request + * with Product price selection.

                                                                                                                            + * + + * @return null|bool + */ + public function getScopedPriceDiscounted(); + + /** + *

                                                                                                                            Only available when Product price selection is used. + * Cannot be used in a Query Predicate.

                                                                                                                            + * + + * @return null|PriceCollection + */ + public function getRecurrencePrices(); + + /** + * @param ?int $id + */ + public function setId(?int $id): void; + + /** + * @param ?string $sku + */ + public function setSku(?string $sku): void; + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?PriceCollection $prices + */ + public function setPrices(?PriceCollection $prices): void; + + /** + * @param ?AttributeCollection $attributes + */ + public function setAttributes(?AttributeCollection $attributes): void; + + /** + * @param ?Price $price + */ + public function setPrice(?Price $price): void; + + /** + * @param ?ImageCollection $images + */ + public function setImages(?ImageCollection $images): void; + + /** + * @param ?AssetCollection $assets + */ + public function setAssets(?AssetCollection $assets): void; + + /** + * @param ?ProductVariantAvailability $availability + */ + public function setAvailability(?ProductVariantAvailability $availability): void; + + /** + * @param ?bool $isMatchingVariant + */ + public function setIsMatchingVariant(?bool $isMatchingVariant): void; + + /** + * @param ?ScopedPrice $scopedPrice + */ + public function setScopedPrice(?ScopedPrice $scopedPrice): void; + + /** + * @param ?bool $scopedPriceDiscounted + */ + public function setScopedPriceDiscounted(?bool $scopedPriceDiscounted): void; + + /** + * @param ?PriceCollection $recurrencePrices + */ + public function setRecurrencePrices(?PriceCollection $recurrencePrices): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantAvailability.php b/lib/commercetools-history/src/Models/Common/ProductVariantAvailability.php index 6edf4bac201..8e9e487150d 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantAvailability.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantAvailability.php @@ -14,34 +14,65 @@ interface ProductVariantAvailability extends JsonObject { + public const FIELD_CHANNELS = 'channels'; public const FIELD_IS_ON_STOCK = 'isOnStock'; public const FIELD_RESTOCKABLE_IN_DAYS = 'restockableInDays'; public const FIELD_AVAILABLE_QUANTITY = 'availableQuantity'; - public const FIELD_CHANNELS = 'channels'; + public const FIELD_ID = 'id'; + public const FIELD_VERSION = 'version'; /** + *

                                                                                                                            For each InventoryEntry with a supply Channel, an entry is added to channels.

                                                                                                                            + * + + * @return null|ProductVariantChannelAvailabilityMap + */ + public function getChannels(); + + /** + *

                                                                                                                            Indicates whether a Product Variant is in stock.

                                                                                                                            + * * @return null|bool */ public function getIsOnStock(); /** + *

                                                                                                                            Number of days to restock a Product Variant once it is out of stock.

                                                                                                                            + * * @return null|int */ public function getRestockableInDays(); /** + *

                                                                                                                            Number of items of the Product Variant that are in stock.

                                                                                                                            + * * @return null|int */ public function getAvailableQuantity(); /** + *

                                                                                                                            Unique identifier of the InventoryEntry.

                                                                                                                            + * - * @return null|ProductVariantChannelAvailabilityMap + * @return null|string */ - public function getChannels(); + public function getId(); + + /** + *

                                                                                                                            Current version of the InventoryEntry.

                                                                                                                            + * + + * @return null|int + */ + public function getVersion(); + + /** + * @param ?ProductVariantChannelAvailabilityMap $channels + */ + public function setChannels(?ProductVariantChannelAvailabilityMap $channels): void; /** * @param ?bool $isOnStock @@ -59,7 +90,12 @@ public function setRestockableInDays(?int $restockableInDays): void; public function setAvailableQuantity(?int $availableQuantity): void; /** - * @param ?ProductVariantChannelAvailabilityMap $channels + * @param ?string $id */ - public function setChannels(?ProductVariantChannelAvailabilityMap $channels): void; + public function setId(?string $id): void; + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void; } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantAvailabilityBuilder.php b/lib/commercetools-history/src/Models/Common/ProductVariantAvailabilityBuilder.php index b47e5925d7b..6675f5154fc 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantAvailabilityBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantAvailabilityBuilder.php @@ -20,6 +20,12 @@ */ final class ProductVariantAvailabilityBuilder implements Builder { + /** + + * @var null|ProductVariantChannelAvailabilityMap|ProductVariantChannelAvailabilityMapBuilder + */ + private $channels; + /** * @var ?bool @@ -40,12 +46,31 @@ final class ProductVariantAvailabilityBuilder implements Builder /** - * @var null|ProductVariantChannelAvailabilityMap|ProductVariantChannelAvailabilityMapBuilder + * @var ?string */ - private $channels; + private $id; /** + * @var ?int + */ + private $version; + + /** + *

                                                                                                                            For each InventoryEntry with a supply Channel, an entry is added to channels.

                                                                                                                            + * + + * @return null|ProductVariantChannelAvailabilityMap + */ + public function getChannels() + { + return $this->channels instanceof ProductVariantChannelAvailabilityMapBuilder ? $this->channels->build() : $this->channels; + } + + /** + *

                                                                                                                            Indicates whether a Product Variant is in stock.

                                                                                                                            + * + * @return null|bool */ public function getIsOnStock() @@ -54,6 +79,8 @@ public function getIsOnStock() } /** + *

                                                                                                                            Number of days to restock a Product Variant once it is out of stock.

                                                                                                                            + * * @return null|int */ @@ -63,6 +90,8 @@ public function getRestockableInDays() } /** + *

                                                                                                                            Number of items of the Product Variant that are in stock.

                                                                                                                            + * * @return null|int */ @@ -72,12 +101,36 @@ public function getAvailableQuantity() } /** + *

                                                                                                                            Unique identifier of the InventoryEntry.

                                                                                                                            + * - * @return null|ProductVariantChannelAvailabilityMap + * @return null|string */ - public function getChannels() + public function getId() { - return $this->channels instanceof ProductVariantChannelAvailabilityMapBuilder ? $this->channels->build() : $this->channels; + return $this->id; + } + + /** + *

                                                                                                                            Current version of the InventoryEntry.

                                                                                                                            + * + + * @return null|int + */ + public function getVersion() + { + return $this->version; + } + + /** + * @param ?ProductVariantChannelAvailabilityMap $channels + * @return $this + */ + public function withChannels(?ProductVariantChannelAvailabilityMap $channels) + { + $this->channels = $channels; + + return $this; } /** @@ -114,12 +167,23 @@ public function withAvailableQuantity(?int $availableQuantity) } /** - * @param ?ProductVariantChannelAvailabilityMap $channels + * @param ?string $id * @return $this */ - public function withChannels(?ProductVariantChannelAvailabilityMap $channels) + public function withId(?string $id) { - $this->channels = $channels; + $this->id = $id; + + return $this; + } + + /** + * @param ?int $version + * @return $this + */ + public function withVersion(?int $version) + { + $this->version = $version; return $this; } @@ -138,10 +202,12 @@ public function withChannelsBuilder(?ProductVariantChannelAvailabilityMapBuilder public function build(): ProductVariantAvailability { return new ProductVariantAvailabilityModel( + $this->channels instanceof ProductVariantChannelAvailabilityMapBuilder ? $this->channels->build() : $this->channels, $this->isOnStock, $this->restockableInDays, $this->availableQuantity, - $this->channels instanceof ProductVariantChannelAvailabilityMapBuilder ? $this->channels->build() : $this->channels + $this->id, + $this->version ); } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantAvailabilityModel.php b/lib/commercetools-history/src/Models/Common/ProductVariantAvailabilityModel.php index cfb84e0bff3..51f2b66112c 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantAvailabilityModel.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantAvailabilityModel.php @@ -21,6 +21,12 @@ final class ProductVariantAvailabilityModel extends JsonObjectModel implements P { + /** + * + * @var ?ProductVariantChannelAvailabilityMap + */ + protected $channels; + /** * * @var ?bool @@ -41,28 +47,61 @@ final class ProductVariantAvailabilityModel extends JsonObjectModel implements P /** * - * @var ?ProductVariantChannelAvailabilityMap + * @var ?string */ - protected $channels; + protected $id; + + /** + * + * @var ?int + */ + protected $version; /** * @psalm-suppress MissingParamType */ public function __construct( + ?ProductVariantChannelAvailabilityMap $channels = null, ?bool $isOnStock = null, ?int $restockableInDays = null, ?int $availableQuantity = null, - ?ProductVariantChannelAvailabilityMap $channels = null + ?string $id = null, + ?int $version = null ) { + $this->channels = $channels; $this->isOnStock = $isOnStock; $this->restockableInDays = $restockableInDays; $this->availableQuantity = $availableQuantity; - $this->channels = $channels; + $this->id = $id; + $this->version = $version; + + } + + /** + *

                                                                                                                            For each InventoryEntry with a supply Channel, an entry is added to channels.

                                                                                                                            + * + * + * @return null|ProductVariantChannelAvailabilityMap + */ + public function getChannels() + { + if (is_null($this->channels)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CHANNELS); + if (is_null($data)) { + return null; + } + + $this->channels = ProductVariantChannelAvailabilityMapModel::of($data); + } + return $this->channels; } /** + *

                                                                                                                            Indicates whether a Product Variant is in stock.

                                                                                                                            + * * * @return null|bool */ @@ -81,6 +120,8 @@ public function getIsOnStock() } /** + *

                                                                                                                            Number of days to restock a Product Variant once it is out of stock.

                                                                                                                            + * * * @return null|int */ @@ -99,6 +140,8 @@ public function getRestockableInDays() } /** + *

                                                                                                                            Number of items of the Product Variant that are in stock.

                                                                                                                            + * * * @return null|int */ @@ -117,25 +160,54 @@ public function getAvailableQuantity() } /** + *

                                                                                                                            Unique identifier of the InventoryEntry.

                                                                                                                            * - * @return null|ProductVariantChannelAvailabilityMap + * + * @return null|string */ - public function getChannels() + public function getId() { - if (is_null($this->channels)) { - /** @psalm-var stdClass|array|null $data */ - $data = $this->raw(self::FIELD_CHANNELS); + 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; + } - $this->channels = ProductVariantChannelAvailabilityMapModel::of($data); + return $this->id; + } + + /** + *

                                                                                                                            Current version of the InventoryEntry.

                                                                                                                            + * + * + * @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->channels; + return $this->version; } + /** + * @param ?ProductVariantChannelAvailabilityMap $channels + */ + public function setChannels(?ProductVariantChannelAvailabilityMap $channels): void + { + $this->channels = $channels; + } + /** * @param ?bool $isOnStock */ @@ -161,11 +233,19 @@ public function setAvailableQuantity(?int $availableQuantity): void } /** - * @param ?ProductVariantChannelAvailabilityMap $channels + * @param ?string $id */ - public function setChannels(?ProductVariantChannelAvailabilityMap $channels): void + public function setId(?string $id): void { - $this->channels = $channels; + $this->id = $id; + } + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void + { + $this->version = $version; } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantBuilder.php b/lib/commercetools-history/src/Models/Common/ProductVariantBuilder.php new file mode 100644 index 00000000000..6aefa5741d5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductVariantBuilder.php @@ -0,0 +1,453 @@ + + */ +final class ProductVariantBuilder implements Builder +{ + /** + + * @var ?int + */ + private $id; + + /** + + * @var ?string + */ + private $sku; + + /** + + * @var ?string + */ + private $key; + + /** + + * @var ?PriceCollection + */ + private $prices; + + /** + + * @var ?AttributeCollection + */ + private $attributes; + + /** + + * @var null|Price|PriceBuilder + */ + private $price; + + /** + + * @var ?ImageCollection + */ + private $images; + + /** + + * @var ?AssetCollection + */ + private $assets; + + /** + + * @var null|ProductVariantAvailability|ProductVariantAvailabilityBuilder + */ + private $availability; + + /** + + * @var ?bool + */ + private $isMatchingVariant; + + /** + + * @var null|ScopedPrice|ScopedPriceBuilder + */ + private $scopedPrice; + + /** + + * @var ?bool + */ + private $scopedPriceDiscounted; + + /** + + * @var ?PriceCollection + */ + private $recurrencePrices; + + /** + *

                                                                                                                            A unique, sequential identifier of the Product Variant within the Product.

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

                                                                                                                            User-defined unique SKU of the Product Variant.

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

                                                                                                                            User-defined unique identifier of the ProductVariant.

                                                                                                                            + *

                                                                                                                            This is different from Product key.

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

                                                                                                                            The Embedded Prices of the Product Variant. + * Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

                                                                                                                            + * + + * @return null|PriceCollection + */ + public function getPrices() + { + return $this->prices; + } + + /** + *

                                                                                                                            Variant Attributes according to the respective AttributeDefinition.

                                                                                                                            + * + + * @return null|AttributeCollection + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + *

                                                                                                                            Only available when price selection is used. + * Cannot be used in a Query Predicate.

                                                                                                                            + * + + * @return null|Price + */ + public function getPrice() + { + return $this->price instanceof PriceBuilder ? $this->price->build() : $this->price; + } + + /** + *

                                                                                                                            Images of the Product Variant.

                                                                                                                            + * + + * @return null|ImageCollection + */ + public function getImages() + { + return $this->images; + } + + /** + *

                                                                                                                            Media assets of the Product Variant.

                                                                                                                            + * + + * @return null|AssetCollection + */ + public function getAssets() + { + return $this->assets; + } + + /** + *

                                                                                                                            Set if the Product Variant is tracked by Inventory. + * Can be used as an optimization to reduce calls to the Inventory service. + * May not contain the latest Inventory State (it is eventually consistent).

                                                                                                                            + * + + * @return null|ProductVariantAvailability + */ + public function getAvailability() + { + return $this->availability instanceof ProductVariantAvailabilityBuilder ? $this->availability->build() : $this->availability; + } + + /** + *

                                                                                                                            true if the Product Variant matches the search query. + * Only available in response to a Product Projection Search request.

                                                                                                                            + * + + * @return null|bool + */ + public function getIsMatchingVariant() + { + return $this->isMatchingVariant; + } + + /** + *

                                                                                                                            Only available in response to a Product Projection Search request + * with Product price selection. + * Can be used to sort, filter, and facet.

                                                                                                                            + * + + * @return null|ScopedPrice + */ + public function getScopedPrice() + { + return $this->scopedPrice instanceof ScopedPriceBuilder ? $this->scopedPrice->build() : $this->scopedPrice; + } + + /** + *

                                                                                                                            Only available in response to a Product Projection Search request + * with Product price selection.

                                                                                                                            + * + + * @return null|bool + */ + public function getScopedPriceDiscounted() + { + return $this->scopedPriceDiscounted; + } + + /** + *

                                                                                                                            Only available when Product price selection is used. + * Cannot be used in a Query Predicate.

                                                                                                                            + * + + * @return null|PriceCollection + */ + public function getRecurrencePrices() + { + return $this->recurrencePrices; + } + + /** + * @param ?int $id + * @return $this + */ + public function withId(?int $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $sku + * @return $this + */ + public function withSku(?string $sku) + { + $this->sku = $sku; + + return $this; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?PriceCollection $prices + * @return $this + */ + public function withPrices(?PriceCollection $prices) + { + $this->prices = $prices; + + return $this; + } + + /** + * @param ?AttributeCollection $attributes + * @return $this + */ + public function withAttributes(?AttributeCollection $attributes) + { + $this->attributes = $attributes; + + return $this; + } + + /** + * @param ?Price $price + * @return $this + */ + public function withPrice(?Price $price) + { + $this->price = $price; + + return $this; + } + + /** + * @param ?ImageCollection $images + * @return $this + */ + public function withImages(?ImageCollection $images) + { + $this->images = $images; + + return $this; + } + + /** + * @param ?AssetCollection $assets + * @return $this + */ + public function withAssets(?AssetCollection $assets) + { + $this->assets = $assets; + + return $this; + } + + /** + * @param ?ProductVariantAvailability $availability + * @return $this + */ + public function withAvailability(?ProductVariantAvailability $availability) + { + $this->availability = $availability; + + return $this; + } + + /** + * @param ?bool $isMatchingVariant + * @return $this + */ + public function withIsMatchingVariant(?bool $isMatchingVariant) + { + $this->isMatchingVariant = $isMatchingVariant; + + return $this; + } + + /** + * @param ?ScopedPrice $scopedPrice + * @return $this + */ + public function withScopedPrice(?ScopedPrice $scopedPrice) + { + $this->scopedPrice = $scopedPrice; + + return $this; + } + + /** + * @param ?bool $scopedPriceDiscounted + * @return $this + */ + public function withScopedPriceDiscounted(?bool $scopedPriceDiscounted) + { + $this->scopedPriceDiscounted = $scopedPriceDiscounted; + + return $this; + } + + /** + * @param ?PriceCollection $recurrencePrices + * @return $this + */ + public function withRecurrencePrices(?PriceCollection $recurrencePrices) + { + $this->recurrencePrices = $recurrencePrices; + + return $this; + } + + /** + * @deprecated use withPrice() instead + * @return $this + */ + public function withPriceBuilder(?PriceBuilder $price) + { + $this->price = $price; + + return $this; + } + + /** + * @deprecated use withAvailability() instead + * @return $this + */ + public function withAvailabilityBuilder(?ProductVariantAvailabilityBuilder $availability) + { + $this->availability = $availability; + + return $this; + } + + /** + * @deprecated use withScopedPrice() instead + * @return $this + */ + public function withScopedPriceBuilder(?ScopedPriceBuilder $scopedPrice) + { + $this->scopedPrice = $scopedPrice; + + return $this; + } + + public function build(): ProductVariant + { + return new ProductVariantModel( + $this->id, + $this->sku, + $this->key, + $this->prices, + $this->attributes, + $this->price instanceof PriceBuilder ? $this->price->build() : $this->price, + $this->images, + $this->assets, + $this->availability instanceof ProductVariantAvailabilityBuilder ? $this->availability->build() : $this->availability, + $this->isMatchingVariant, + $this->scopedPrice instanceof ScopedPriceBuilder ? $this->scopedPrice->build() : $this->scopedPrice, + $this->scopedPriceDiscounted, + $this->recurrencePrices + ); + } + + public static function of(): ProductVariantBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailability.php b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailability.php index 6272d7f3f6c..51c85be2d12 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailability.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailability.php @@ -17,25 +17,49 @@ interface ProductVariantChannelAvailability extends JsonObject public const FIELD_IS_ON_STOCK = 'isOnStock'; public const FIELD_RESTOCKABLE_IN_DAYS = 'restockableInDays'; public const FIELD_AVAILABLE_QUANTITY = 'availableQuantity'; + public const FIELD_ID = 'id'; + public const FIELD_VERSION = 'version'; /** + *

                                                                                                                            Indicates whether a Product Variant is in stock in a specified Channel.

                                                                                                                            + * * @return null|bool */ public function getIsOnStock(); /** + *

                                                                                                                            Number of days to restock a Product Variant once it is out of stock in a specified Channel.

                                                                                                                            + * * @return null|int */ public function getRestockableInDays(); /** + *

                                                                                                                            Number of items of this Product Variant that are in stock in a specified Channel.

                                                                                                                            + * * @return null|int */ public function getAvailableQuantity(); + /** + *

                                                                                                                            Unique identifier of the InventoryEntry.

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

                                                                                                                            Current version of the InventoryEntry.

                                                                                                                            + * + + * @return null|int + */ + public function getVersion(); + /** * @param ?bool $isOnStock */ @@ -50,4 +74,14 @@ public function setRestockableInDays(?int $restockableInDays): void; * @param ?int $availableQuantity */ public function setAvailableQuantity(?int $availableQuantity): void; + + /** + * @param ?string $id + */ + public function setId(?string $id): void; + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void; } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityBuilder.php b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityBuilder.php index f62eb1a945a..36c15140fed 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityBuilder.php @@ -40,6 +40,20 @@ final class ProductVariantChannelAvailabilityBuilder implements Builder /** + * @var ?string + */ + private $id; + + /** + + * @var ?int + */ + private $version; + + /** + *

                                                                                                                            Indicates whether a Product Variant is in stock in a specified Channel.

                                                                                                                            + * + * @return null|bool */ public function getIsOnStock() @@ -48,6 +62,8 @@ public function getIsOnStock() } /** + *

                                                                                                                            Number of days to restock a Product Variant once it is out of stock in a specified Channel.

                                                                                                                            + * * @return null|int */ @@ -57,6 +73,8 @@ public function getRestockableInDays() } /** + *

                                                                                                                            Number of items of this Product Variant that are in stock in a specified Channel.

                                                                                                                            + * * @return null|int */ @@ -65,6 +83,28 @@ public function getAvailableQuantity() return $this->availableQuantity; } + /** + *

                                                                                                                            Unique identifier of the InventoryEntry.

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

                                                                                                                            Current version of the InventoryEntry.

                                                                                                                            + * + + * @return null|int + */ + public function getVersion() + { + return $this->version; + } + /** * @param ?bool $isOnStock * @return $this @@ -98,13 +138,37 @@ public function withAvailableQuantity(?int $availableQuantity) return $this; } + /** + * @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; + } + public function build(): ProductVariantChannelAvailability { return new ProductVariantChannelAvailabilityModel( $this->isOnStock, $this->restockableInDays, - $this->availableQuantity + $this->availableQuantity, + $this->id, + $this->version ); } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMap.php b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMap.php index bde55bec75b..f243b78e09c 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMap.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMap.php @@ -8,13 +8,8 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\JsonObject; -use Commercetools\Base\DateTimeImmutableCollection; +use Commercetools\Base\CMap; -interface ProductVariantChannelAvailabilityMap extends JsonObject +interface ProductVariantChannelAvailabilityMap extends CMap { - - public const FIELD_PATTERN0 = '//'; - - } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMapBuilder.php b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMapBuilder.php index 34835c316aa..71da921c144 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMapBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMapBuilder.php @@ -8,30 +8,39 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\Builder; -use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\Base\JsonObject; -use Commercetools\Base\JsonObjectModel; -use Commercetools\Base\MapperFactory; use stdClass; +use Commercetools\Base\MapperMap; +use Commercetools\Base\Builder; /** * @implements Builder + * @extends MapperMap */ -final class ProductVariantChannelAvailabilityMapBuilder implements Builder +final class ProductVariantChannelAvailabilityMapBuilder extends MapperMap implements Builder { - - - - - public function build(): ProductVariantChannelAvailabilityMap + /** + * @psalm-return callable(string):?ProductVariantChannelAvailabilityMap + */ + protected function mapper() { - return new ProductVariantChannelAvailabilityMapModel( - ); + return + /** + * @psalm-return ?ProductVariantChannelAvailabilityMap + */ + function(string $key) { + $data = $this->get($key); + if ($data instanceof stdClass) { + $data = ProductVariantChannelAvailabilityMapModel::of($data); + } + return $data; + }; } - public static function of(): ProductVariantChannelAvailabilityMapBuilder + /** + * @return ProductVariantChannelAvailabilityMap + */ + public function build() { - return new self(); + return new ProductVariantChannelAvailabilityMapModel($this->toArray()); } } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMapModel.php b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMapModel.php index eaaec8fbd28..8fc6a9125db 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMapModel.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityMapModel.php @@ -8,49 +8,24 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\Base\JsonObject; -use Commercetools\Base\JsonObjectModel; -use Commercetools\Base\MapperFactory; -use stdClass; +use Commercetools\Base\MapperMap; /** * @internal */ -final class ProductVariantChannelAvailabilityMapModel extends JsonObjectModel implements ProductVariantChannelAvailabilityMap +final class ProductVariantChannelAvailabilityMapModel extends MapperMap implements ProductVariantChannelAvailabilityMap { - - - - - /** - * @psalm-suppress MissingParamType - */ - public function __construct( - ) { - - } - - - - /** - * @return mixed + * @psalm-return callable(string):?mixed */ - public function by(string $key) + protected function mapper() { - $data = $this->raw($key); - if (is_null($data)) { - return null; - } - if (preg_match(ProductVariantChannelAvailabilityMap::FIELD_PATTERN0, $key) === 1) { - /** @psalm-var stdClass|array $data */ - - return ProductVariantChannelAvailabilityModel::of($data); - } - - return $data; + return + /** + * @psalm-return ?mixed + */ + function(string $key) { + return $this->get($key); + }; } - - } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityModel.php b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityModel.php index c7af59c26ac..607e7c69279 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityModel.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantChannelAvailabilityModel.php @@ -39,6 +39,18 @@ final class ProductVariantChannelAvailabilityModel extends JsonObjectModel imple */ protected $availableQuantity; + /** + * + * @var ?string + */ + protected $id; + + /** + * + * @var ?int + */ + protected $version; + /** * @psalm-suppress MissingParamType @@ -46,15 +58,21 @@ final class ProductVariantChannelAvailabilityModel extends JsonObjectModel imple public function __construct( ?bool $isOnStock = null, ?int $restockableInDays = null, - ?int $availableQuantity = null + ?int $availableQuantity = null, + ?string $id = null, + ?int $version = null ) { $this->isOnStock = $isOnStock; $this->restockableInDays = $restockableInDays; $this->availableQuantity = $availableQuantity; + $this->id = $id; + $this->version = $version; } /** + *

                                                                                                                            Indicates whether a Product Variant is in stock in a specified Channel.

                                                                                                                            + * * * @return null|bool */ @@ -73,6 +91,8 @@ public function getIsOnStock() } /** + *

                                                                                                                            Number of days to restock a Product Variant once it is out of stock in a specified Channel.

                                                                                                                            + * * * @return null|int */ @@ -91,6 +111,8 @@ public function getRestockableInDays() } /** + *

                                                                                                                            Number of items of this Product Variant that are in stock in a specified Channel.

                                                                                                                            + * * * @return null|int */ @@ -108,6 +130,46 @@ public function getAvailableQuantity() return $this->availableQuantity; } + /** + *

                                                                                                                            Unique identifier of the InventoryEntry.

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

                                                                                                                            Current version of the InventoryEntry.

                                                                                                                            + * + * + * @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; + } + /** * @param ?bool $isOnStock @@ -133,6 +195,22 @@ public function setAvailableQuantity(?int $availableQuantity): void $this->availableQuantity = $availableQuantity; } + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void + { + $this->version = $version; + } + } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantCollection.php b/lib/commercetools-history/src/Models/Common/ProductVariantCollection.php new file mode 100644 index 00000000000..5f0827f8cff --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductVariantCollection.php @@ -0,0 +1,56 @@ + + * @method ProductVariant current() + * @method ProductVariant end() + * @method ProductVariant at($offset) + */ +class ProductVariantCollection extends MapperSequence +{ + /** + * @psalm-assert ProductVariant $value + * @psalm-param ProductVariant|stdClass $value + * @throws InvalidArgumentException + * + * @return ProductVariantCollection + */ + public function add($value) + { + if (!$value instanceof ProductVariant) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ProductVariant + */ + protected function mapper() + { + return function (?int $index): ?ProductVariant { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ProductVariant $data */ + $data = ProductVariantModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantExclusion.php b/lib/commercetools-history/src/Models/Common/ProductVariantExclusion.php new file mode 100644 index 00000000000..52689d1154a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductVariantExclusion.php @@ -0,0 +1,31 @@ +Non-empty array of SKUs representing Product Variants to be included in the Product Selection with IndividualExclusion ProductSelectionMode.

                                                                                                                            + * + + * @return null|array + */ + public function getSkus(); + + /** + * @param ?array $skus + */ + public function setSkus(?array $skus): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantExclusionBuilder.php b/lib/commercetools-history/src/Models/Common/ProductVariantExclusionBuilder.php new file mode 100644 index 00000000000..b28341e2286 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductVariantExclusionBuilder.php @@ -0,0 +1,63 @@ + + */ +final class ProductVariantExclusionBuilder implements Builder +{ + /** + + * @var ?array + */ + private $skus; + + /** + *

                                                                                                                            Non-empty array of SKUs representing Product Variants to be included in the Product Selection with IndividualExclusion ProductSelectionMode.

                                                                                                                            + * + + * @return null|array + */ + public function getSkus() + { + return $this->skus; + } + + /** + * @param ?array $skus + * @return $this + */ + public function withSkus(?array $skus) + { + $this->skus = $skus; + + return $this; + } + + + public function build(): ProductVariantExclusion + { + return new ProductVariantExclusionModel( + $this->skus + ); + } + + public static function of(): ProductVariantExclusionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantExclusionCollection.php b/lib/commercetools-history/src/Models/Common/ProductVariantExclusionCollection.php new file mode 100644 index 00000000000..1588d9faa5d --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductVariantExclusionCollection.php @@ -0,0 +1,56 @@ + + * @method ProductVariantExclusion current() + * @method ProductVariantExclusion end() + * @method ProductVariantExclusion at($offset) + */ +class ProductVariantExclusionCollection extends MapperSequence +{ + /** + * @psalm-assert ProductVariantExclusion $value + * @psalm-param ProductVariantExclusion|stdClass $value + * @throws InvalidArgumentException + * + * @return ProductVariantExclusionCollection + */ + public function add($value) + { + if (!$value instanceof ProductVariantExclusion) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ProductVariantExclusion + */ + protected function mapper() + { + return function (?int $index): ?ProductVariantExclusion { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ProductVariantExclusion $data */ + $data = ProductVariantExclusionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantExclusionModel.php b/lib/commercetools-history/src/Models/Common/ProductVariantExclusionModel.php new file mode 100644 index 00000000000..42212bb0bd5 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductVariantExclusionModel.php @@ -0,0 +1,72 @@ +skus = $skus; + + } + + /** + *

                                                                                                                            Non-empty array of SKUs representing Product Variants to be included in the Product Selection with IndividualExclusion ProductSelectionMode.

                                                                                                                            + * + * + * @return null|array + */ + public function getSkus() + { + if (is_null($this->skus)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_SKUS); + if (is_null($data)) { + return null; + } + $this->skus = $data; + } + + return $this->skus; + } + + + /** + * @param ?array $skus + */ + public function setSkus(?array $skus): void + { + $this->skus = $skus; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantModel.php b/lib/commercetools-history/src/Models/Common/ProductVariantModel.php new file mode 100644 index 00000000000..bce7c0d0f28 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ProductVariantModel.php @@ -0,0 +1,517 @@ +id = $id; + $this->sku = $sku; + $this->key = $key; + $this->prices = $prices; + $this->attributes = $attributes; + $this->price = $price; + $this->images = $images; + $this->assets = $assets; + $this->availability = $availability; + $this->isMatchingVariant = $isMatchingVariant; + $this->scopedPrice = $scopedPrice; + $this->scopedPriceDiscounted = $scopedPriceDiscounted; + $this->recurrencePrices = $recurrencePrices; + + } + + /** + *

                                                                                                                            A unique, sequential identifier of the Product Variant within the Product.

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

                                                                                                                            User-defined unique SKU of the Product Variant.

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

                                                                                                                            User-defined unique identifier of the ProductVariant.

                                                                                                                            + *

                                                                                                                            This is different from Product key.

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

                                                                                                                            The Embedded Prices of the Product Variant. + * Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

                                                                                                                            + * + * + * @return null|PriceCollection + */ + public function getPrices() + { + if (is_null($this->prices)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_PRICES); + if (is_null($data)) { + return null; + } + $this->prices = PriceCollection::fromArray($data); + } + + return $this->prices; + } + + /** + *

                                                                                                                            Variant Attributes according to the respective AttributeDefinition.

                                                                                                                            + * + * + * @return null|AttributeCollection + */ + public function getAttributes() + { + if (is_null($this->attributes)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ATTRIBUTES); + if (is_null($data)) { + return null; + } + $this->attributes = AttributeCollection::fromArray($data); + } + + return $this->attributes; + } + + /** + *

                                                                                                                            Only available when price selection is used. + * Cannot be used in a Query Predicate.

                                                                                                                            + * + * + * @return null|Price + */ + public function getPrice() + { + if (is_null($this->price)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PRICE); + if (is_null($data)) { + return null; + } + + $this->price = PriceModel::of($data); + } + + return $this->price; + } + + /** + *

                                                                                                                            Images of the Product Variant.

                                                                                                                            + * + * + * @return null|ImageCollection + */ + public function getImages() + { + if (is_null($this->images)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_IMAGES); + if (is_null($data)) { + return null; + } + $this->images = ImageCollection::fromArray($data); + } + + return $this->images; + } + + /** + *

                                                                                                                            Media assets of the Product Variant.

                                                                                                                            + * + * + * @return null|AssetCollection + */ + public function getAssets() + { + if (is_null($this->assets)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ASSETS); + if (is_null($data)) { + return null; + } + $this->assets = AssetCollection::fromArray($data); + } + + return $this->assets; + } + + /** + *

                                                                                                                            Set if the Product Variant is tracked by Inventory. + * Can be used as an optimization to reduce calls to the Inventory service. + * May not contain the latest Inventory State (it is eventually consistent).

                                                                                                                            + * + * + * @return null|ProductVariantAvailability + */ + public function getAvailability() + { + if (is_null($this->availability)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_AVAILABILITY); + if (is_null($data)) { + return null; + } + + $this->availability = ProductVariantAvailabilityModel::of($data); + } + + return $this->availability; + } + + /** + *

                                                                                                                            true if the Product Variant matches the search query. + * Only available in response to a Product Projection Search request.

                                                                                                                            + * + * + * @return null|bool + */ + public function getIsMatchingVariant() + { + if (is_null($this->isMatchingVariant)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_IS_MATCHING_VARIANT); + if (is_null($data)) { + return null; + } + $this->isMatchingVariant = (bool) $data; + } + + return $this->isMatchingVariant; + } + + /** + *

                                                                                                                            Only available in response to a Product Projection Search request + * with Product price selection. + * Can be used to sort, filter, and facet.

                                                                                                                            + * + * + * @return null|ScopedPrice + */ + public function getScopedPrice() + { + if (is_null($this->scopedPrice)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SCOPED_PRICE); + if (is_null($data)) { + return null; + } + + $this->scopedPrice = ScopedPriceModel::of($data); + } + + return $this->scopedPrice; + } + + /** + *

                                                                                                                            Only available in response to a Product Projection Search request + * with Product price selection.

                                                                                                                            + * + * + * @return null|bool + */ + public function getScopedPriceDiscounted() + { + if (is_null($this->scopedPriceDiscounted)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_SCOPED_PRICE_DISCOUNTED); + if (is_null($data)) { + return null; + } + $this->scopedPriceDiscounted = (bool) $data; + } + + return $this->scopedPriceDiscounted; + } + + /** + *

                                                                                                                            Only available when Product price selection is used. + * Cannot be used in a Query Predicate.

                                                                                                                            + * + * + * @return null|PriceCollection + */ + public function getRecurrencePrices() + { + if (is_null($this->recurrencePrices)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_RECURRENCE_PRICES); + if (is_null($data)) { + return null; + } + $this->recurrencePrices = PriceCollection::fromArray($data); + } + + return $this->recurrencePrices; + } + + + /** + * @param ?int $id + */ + public function setId(?int $id): void + { + $this->id = $id; + } + + /** + * @param ?string $sku + */ + public function setSku(?string $sku): void + { + $this->sku = $sku; + } + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?PriceCollection $prices + */ + public function setPrices(?PriceCollection $prices): void + { + $this->prices = $prices; + } + + /** + * @param ?AttributeCollection $attributes + */ + public function setAttributes(?AttributeCollection $attributes): void + { + $this->attributes = $attributes; + } + + /** + * @param ?Price $price + */ + public function setPrice(?Price $price): void + { + $this->price = $price; + } + + /** + * @param ?ImageCollection $images + */ + public function setImages(?ImageCollection $images): void + { + $this->images = $images; + } + + /** + * @param ?AssetCollection $assets + */ + public function setAssets(?AssetCollection $assets): void + { + $this->assets = $assets; + } + + /** + * @param ?ProductVariantAvailability $availability + */ + public function setAvailability(?ProductVariantAvailability $availability): void + { + $this->availability = $availability; + } + + /** + * @param ?bool $isMatchingVariant + */ + public function setIsMatchingVariant(?bool $isMatchingVariant): void + { + $this->isMatchingVariant = $isMatchingVariant; + } + + /** + * @param ?ScopedPrice $scopedPrice + */ + public function setScopedPrice(?ScopedPrice $scopedPrice): void + { + $this->scopedPrice = $scopedPrice; + } + + /** + * @param ?bool $scopedPriceDiscounted + */ + public function setScopedPriceDiscounted(?bool $scopedPriceDiscounted): void + { + $this->scopedPriceDiscounted = $scopedPriceDiscounted; + } + + /** + * @param ?PriceCollection $recurrencePrices + */ + public function setRecurrencePrices(?PriceCollection $recurrencePrices): void + { + $this->recurrencePrices = $recurrencePrices; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantSelection.php b/lib/commercetools-history/src/Models/Common/ProductVariantSelection.php index bf651f2c67c..ee27f016b66 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantSelection.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantSelection.php @@ -15,27 +15,17 @@ interface ProductVariantSelection extends JsonObject { public const FIELD_TYPE = 'type'; - public const FIELD_SKUS = 'skus'; /** + *

                                                                                                                            Determines whether the SKUs are to be included in, or excluded from, the Product Selection.

                                                                                                                            + * * @return null|string */ public function getType(); - /** - - * @return null|array - */ - public function getSkus(); - /** * @param ?string $type */ public function setType(?string $type): void; - - /** - * @param ?array $skus - */ - public function setSkus(?array $skus): void; } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantSelectionBuilder.php b/lib/commercetools-history/src/Models/Common/ProductVariantSelectionBuilder.php index 2feb26d1de8..0759661920c 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantSelectionBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantSelectionBuilder.php @@ -27,12 +27,8 @@ final class ProductVariantSelectionBuilder implements Builder private $type; /** - - * @var ?array - */ - private $skus; - - /** + *

                                                                                                                            Determines whether the SKUs are to be included in, or excluded from, the Product Selection.

                                                                                                                            + * * @return null|string */ @@ -41,15 +37,6 @@ public function getType() return $this->type; } - /** - - * @return null|array - */ - public function getSkus() - { - return $this->skus; - } - /** * @param ?string $type * @return $this @@ -61,23 +48,11 @@ public function withType(?string $type) return $this; } - /** - * @param ?array $skus - * @return $this - */ - public function withSkus(?array $skus) - { - $this->skus = $skus; - - return $this; - } - public function build(): ProductVariantSelection { return new ProductVariantSelectionModel( - $this->type, - $this->skus + $this->type ); } diff --git a/lib/commercetools-history/src/Models/Common/ProductVariantSelectionModel.php b/lib/commercetools-history/src/Models/Common/ProductVariantSelectionModel.php index 103205d6003..2866cf91bbd 100644 --- a/lib/commercetools-history/src/Models/Common/ProductVariantSelectionModel.php +++ b/lib/commercetools-history/src/Models/Common/ProductVariantSelectionModel.php @@ -27,26 +27,20 @@ final class ProductVariantSelectionModel extends JsonObjectModel implements Prod */ protected $type; - /** - * - * @var ?array - */ - protected $skus; - /** * @psalm-suppress MissingParamType */ public function __construct( - ?string $type = null, - ?array $skus = null + ?string $type = null ) { $this->type = $type; - $this->skus = $skus; } /** + *

                                                                                                                            Determines whether the SKUs are to be included in, or excluded from, the Product Selection.

                                                                                                                            + * * * @return null|string */ @@ -64,24 +58,6 @@ public function getType() return $this->type; } - /** - * - * @return null|array - */ - public function getSkus() - { - if (is_null($this->skus)) { - /** @psalm-var ?list $data */ - $data = $this->raw(self::FIELD_SKUS); - if (is_null($data)) { - return null; - } - $this->skus = $data; - } - - return $this->skus; - } - /** * @param ?string $type @@ -91,14 +67,6 @@ public function setType(?string $type): void $this->type = $type; } - /** - * @param ?array $skus - */ - public function setSkus(?array $skus): void - { - $this->skus = $skus; - } - } diff --git a/lib/commercetools-history/src/Models/Common/RecurrencePolicyReference.php b/lib/commercetools-history/src/Models/Common/RecurrencePolicyReference.php new file mode 100644 index 00000000000..1c5ac5a2213 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/RecurrencePolicyReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced RecurrencePolicy.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/RecurrencePolicyReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/RecurrencePolicyReferenceBuilder.php new file mode 100644 index 00000000000..72497305e9c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/RecurrencePolicyReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class RecurrencePolicyReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced RecurrencePolicy.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): RecurrencePolicyReference + { + return new RecurrencePolicyReferenceModel( + $this->id + ); + } + + public static function of(): RecurrencePolicyReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/RecurrencePolicyReferenceCollection.php b/lib/commercetools-history/src/Models/Common/RecurrencePolicyReferenceCollection.php new file mode 100644 index 00000000000..5c0e27a7a99 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/RecurrencePolicyReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicyReference current() + * @method RecurrencePolicyReference end() + * @method RecurrencePolicyReference at($offset) + */ +class RecurrencePolicyReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert RecurrencePolicyReference $value + * @psalm-param RecurrencePolicyReference|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicyReferenceCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicyReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicyReference + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicyReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicyReference $data */ + $data = RecurrencePolicyReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/RecurrencePolicyReferenceModel.php b/lib/commercetools-history/src/Models/Common/RecurrencePolicyReferenceModel.php new file mode 100644 index 00000000000..089f3fe30dd --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/RecurrencePolicyReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced RecurrencePolicy.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/Reference.php b/lib/commercetools-history/src/Models/Common/Reference.php index 38ed3ee6e27..044964e4b93 100644 --- a/lib/commercetools-history/src/Models/Common/Reference.php +++ b/lib/commercetools-history/src/Models/Common/Reference.php @@ -13,29 +13,28 @@ interface Reference extends JsonObject { - - public const FIELD_ID = 'id'; + public const DISCRIMINATOR_FIELD = 'typeId'; public const FIELD_TYPE_ID = 'typeId'; + public const FIELD_ID = 'id'; /** + *

                                                                                                                            Type of referenced resource.

                                                                                                                            + * * @return null|string */ - public function getId(); + public function getTypeId(); /** + *

                                                                                                                            Unique ID of the referenced resource.

                                                                                                                            + * * @return null|string */ - public function getTypeId(); + public function getId(); /** * @param ?string $id */ public function setId(?string $id): void; - - /** - * @param ?string $typeId - */ - public function setTypeId(?string $typeId): void; } diff --git a/lib/commercetools-history/src/Models/Common/ReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/ReferenceBuilder.php index 8c5ef208760..8797411a9e5 100644 --- a/lib/commercetools-history/src/Models/Common/ReferenceBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ReferenceBuilder.php @@ -27,12 +27,8 @@ final class ReferenceBuilder implements Builder private $id; /** - - * @var ?string - */ - private $typeId; - - /** + *

                                                                                                                            Unique ID of the referenced resource.

                                                                                                                            + * * @return null|string */ @@ -41,15 +37,6 @@ public function getId() return $this->id; } - /** - - * @return null|string - */ - public function getTypeId() - { - return $this->typeId; - } - /** * @param ?string $id * @return $this @@ -61,23 +48,11 @@ public function withId(?string $id) return $this; } - /** - * @param ?string $typeId - * @return $this - */ - public function withTypeId(?string $typeId) - { - $this->typeId = $typeId; - - return $this; - } - public function build(): Reference { return new ReferenceModel( - $this->id, - $this->typeId + $this->id ); } diff --git a/lib/commercetools-history/src/Models/Common/ReferenceCollection.php b/lib/commercetools-history/src/Models/Common/ReferenceCollection.php index 8af97b3c0be..591411fb745 100644 --- a/lib/commercetools-history/src/Models/Common/ReferenceCollection.php +++ b/lib/commercetools-history/src/Models/Common/ReferenceCollection.php @@ -13,7 +13,11 @@ use stdClass; /** - * @extends MapperSequence + * @template T of Reference + * @extends MapperSequence + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) * @method Reference current() * @method Reference end() * @method Reference at($offset) @@ -21,8 +25,8 @@ class ReferenceCollection extends MapperSequence { /** - * @psalm-assert Reference $value - * @psalm-param Reference|stdClass $value + * @psalm-assert T $value + * @psalm-param T|stdClass $value * @throws InvalidArgumentException * * @return ReferenceCollection @@ -38,14 +42,14 @@ public function add($value) } /** - * @psalm-return callable(int):?Reference + * @psalm-return callable(int):?T */ protected function mapper() { return function (?int $index): ?Reference { $data = $this->get($index); if ($data instanceof stdClass) { - /** @var Reference $data */ + /** @var T $data */ $data = ReferenceModel::of($data); $this->set($data, $index); } diff --git a/lib/commercetools-history/src/Models/Common/ReferenceModel.php b/lib/commercetools-history/src/Models/Common/ReferenceModel.php index 47e205628e0..cf795f8185e 100644 --- a/lib/commercetools-history/src/Models/Common/ReferenceModel.php +++ b/lib/commercetools-history/src/Models/Common/ReferenceModel.php @@ -20,19 +20,41 @@ final class ReferenceModel extends JsonObjectModel implements Reference { - + public const DISCRIMINATOR_VALUE = ''; /** * * @var ?string */ - protected $id; + protected $typeId; /** * * @var ?string */ - protected $typeId; + protected $id; + /** + * @psalm-var array > + * + */ + private static $discriminatorClasses = [ + 'cart-discount' => CartDiscountReferenceModel::class, + 'category' => CategoryReferenceModel::class, + 'channel' => ChannelReferenceModel::class, + 'customer' => CustomerReferenceModel::class, + 'customer-group' => CustomerGroupReferenceModel::class, + 'discount-code' => DiscountCodeReferenceModel::class, + 'payment' => PaymentReferenceModel::class, + 'product' => ProductReferenceModel::class, + 'product-discount' => ProductDiscountReferenceModel::class, + 'product-selection' => ProductSelectionReferenceModel::class, + 'product-type' => ProductTypeReferenceModel::class, + 'recurrence-policy' => RecurrencePolicyReferenceModel::class, + 'shipping-method' => ShippingMethodReferenceModel::class, + 'state' => StateReferenceModel::class, + 'tax-category' => TaxCategoryReferenceModel::class, + 'type' => TypeReferenceModel::class, + ]; /** * @psalm-suppress MissingParamType @@ -47,39 +69,43 @@ public function __construct( } /** + *

                                                                                                                            Type of referenced resource.

                                                                                                                            + * * * @return null|string */ - public function getId() + public function getTypeId() { - if (is_null($this->id)) { + if (is_null($this->typeId)) { /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_ID); + $data = $this->raw(self::FIELD_TYPE_ID); if (is_null($data)) { return null; } - $this->id = (string) $data; + $this->typeId = (string) $data; } - return $this->id; + return $this->typeId; } /** + *

                                                                                                                            Unique ID of the referenced resource.

                                                                                                                            + * * * @return null|string */ - public function getTypeId() + public function getId() { - if (is_null($this->typeId)) { + if (is_null($this->id)) { /** @psalm-var ?string $data */ - $data = $this->raw(self::FIELD_TYPE_ID); + $data = $this->raw(self::FIELD_ID); if (is_null($data)) { return null; } - $this->typeId = (string) $data; + $this->id = (string) $data; } - return $this->typeId; + return $this->id; } @@ -91,14 +117,32 @@ public function setId(?string $id): void $this->id = $id; } + + /** - * @param ?string $typeId + * @psalm-param stdClass|array $value + * @psalm-return class-string */ - public function setTypeId(?string $typeId): void + public static function resolveDiscriminatorClass($value): string { - $this->typeId = $typeId; + $fieldName = Reference::DISCRIMINATOR_FIELD; + if (is_object($value) && isset($value->$fieldName)) { + /** @psalm-var string $discriminatorValue */ + $discriminatorValue = $value->$fieldName; + if (isset(self::$discriminatorClasses[$discriminatorValue])) { + return self::$discriminatorClasses[$discriminatorValue]; + } + } + if (is_array($value) && isset($value[$fieldName])) { + /** @psalm-var string $discriminatorValue */ + $discriminatorValue = $value[$fieldName]; + if (isset(self::$discriminatorClasses[$discriminatorValue])) { + return self::$discriminatorClasses[$discriminatorValue]; + } + } + + /** @psalm-var class-string */ + $type = ReferenceModel::class; + return $type; } - - - } diff --git a/lib/commercetools-history/src/Models/Common/Reservation.php b/lib/commercetools-history/src/Models/Common/Reservation.php index 7351fa30725..eee9fd336fd 100644 --- a/lib/commercetools-history/src/Models/Common/Reservation.php +++ b/lib/commercetools-history/src/Models/Common/Reservation.php @@ -26,6 +26,8 @@ interface Reservation extends JsonObject public function getQuantity(); /** + *

                                                                                                                            A Reference represents a loose reference to another resource in the same Project identified by its id. The typeId indicates the type of the referenced resource. Each resource type has its corresponding Reference type, like ChannelReference. A referenced resource can be embedded through Reference Expansion. The expanded reference is the value of an additional obj field then.

                                                                                                                            + * * @return null|Reference */ diff --git a/lib/commercetools-history/src/Models/Common/ReservationBuilder.php b/lib/commercetools-history/src/Models/Common/ReservationBuilder.php index b7c3fb221f2..b41e852d98a 100644 --- a/lib/commercetools-history/src/Models/Common/ReservationBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ReservationBuilder.php @@ -54,6 +54,8 @@ public function getQuantity() } /** + *

                                                                                                                            A Reference represents a loose reference to another resource in the same Project identified by its id. The typeId indicates the type of the referenced resource. Each resource type has its corresponding Reference type, like ChannelReference. A referenced resource can be embedded through Reference Expansion. The expanded reference is the value of an additional obj field then.

                                                                                                                            + * * @return null|Reference */ diff --git a/lib/commercetools-history/src/Models/Common/ReservationModel.php b/lib/commercetools-history/src/Models/Common/ReservationModel.php index 50f0d10f883..7278daabdd2 100644 --- a/lib/commercetools-history/src/Models/Common/ReservationModel.php +++ b/lib/commercetools-history/src/Models/Common/ReservationModel.php @@ -81,6 +81,8 @@ public function getQuantity() } /** + *

                                                                                                                            A Reference represents a loose reference to another resource in the same Project identified by its id. The typeId indicates the type of the referenced resource. Each resource type has its corresponding Reference type, like ChannelReference. A referenced resource can be embedded through Reference Expansion. The expanded reference is the value of an additional obj field then.

                                                                                                                            + * * * @return null|Reference */ @@ -92,8 +94,8 @@ public function getOwner() if (is_null($data)) { return null; } - - $this->owner = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->owner = $className::of($data); } return $this->owner; diff --git a/lib/commercetools-history/src/Models/Common/ResourceIdentifier.php b/lib/commercetools-history/src/Models/Common/ResourceIdentifier.php index f45f18d41b1..9976d6698de 100644 --- a/lib/commercetools-history/src/Models/Common/ResourceIdentifier.php +++ b/lib/commercetools-history/src/Models/Common/ResourceIdentifier.php @@ -31,6 +31,8 @@ public function getId(); public function getKey(); /** + *

                                                                                                                            Type of resource the value should reference. Supported resource type identifiers are:

                                                                                                                            + * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/ResourceIdentifierBuilder.php b/lib/commercetools-history/src/Models/Common/ResourceIdentifierBuilder.php index 3954a6e14ae..e6cbeff806c 100644 --- a/lib/commercetools-history/src/Models/Common/ResourceIdentifierBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ResourceIdentifierBuilder.php @@ -57,6 +57,8 @@ public function getKey() } /** + *

                                                                                                                            Type of resource the value should reference. Supported resource type identifiers are:

                                                                                                                            + * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/ResourceIdentifierCollection.php b/lib/commercetools-history/src/Models/Common/ResourceIdentifierCollection.php index 930e7501e69..d3963c27549 100644 --- a/lib/commercetools-history/src/Models/Common/ResourceIdentifierCollection.php +++ b/lib/commercetools-history/src/Models/Common/ResourceIdentifierCollection.php @@ -13,7 +13,11 @@ use stdClass; /** - * @extends MapperSequence + * @template T of ResourceIdentifier + * @extends MapperSequence + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) * @method ResourceIdentifier current() * @method ResourceIdentifier end() * @method ResourceIdentifier at($offset) @@ -21,8 +25,8 @@ class ResourceIdentifierCollection extends MapperSequence { /** - * @psalm-assert ResourceIdentifier $value - * @psalm-param ResourceIdentifier|stdClass $value + * @psalm-assert T $value + * @psalm-param T|stdClass $value * @throws InvalidArgumentException * * @return ResourceIdentifierCollection @@ -38,14 +42,14 @@ public function add($value) } /** - * @psalm-return callable(int):?ResourceIdentifier + * @psalm-return callable(int):?T */ protected function mapper() { return function (?int $index): ?ResourceIdentifier { $data = $this->get($index); if ($data instanceof stdClass) { - /** @var ResourceIdentifier $data */ + /** @var T $data */ $data = ResourceIdentifierModel::of($data); $this->set($data, $index); } diff --git a/lib/commercetools-history/src/Models/Common/ResourceIdentifierModel.php b/lib/commercetools-history/src/Models/Common/ResourceIdentifierModel.php index dc4842a5ed2..d0f4a3cbe69 100644 --- a/lib/commercetools-history/src/Models/Common/ResourceIdentifierModel.php +++ b/lib/commercetools-history/src/Models/Common/ResourceIdentifierModel.php @@ -91,6 +91,8 @@ public function getKey() } /** + *

                                                                                                                            Type of resource the value should reference. Supported resource type identifiers are:

                                                                                                                            + * * * @return null|string */ diff --git a/lib/commercetools-history/src/Models/Common/ReturnInfo.php b/lib/commercetools-history/src/Models/Common/ReturnInfo.php index adbefb3207a..57ce3cca376 100644 --- a/lib/commercetools-history/src/Models/Common/ReturnInfo.php +++ b/lib/commercetools-history/src/Models/Common/ReturnInfo.php @@ -10,6 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use DateTimeImmutable; interface ReturnInfo extends JsonObject { @@ -19,13 +20,15 @@ interface ReturnInfo extends JsonObject public const FIELD_RETURN_DATE = 'returnDate'; /** + *

                                                                                                                            Information on the Line Items or Custom Line Items returned.

                                                                                                                            + * * @return null|ReturnItemCollection */ public function getItems(); /** - *

                                                                                                                            Identifies, which return tracking ID is connected to this particular return.

                                                                                                                            + *

                                                                                                                            User-defined identifier to track the return.

                                                                                                                            * * @return null|string @@ -33,8 +36,10 @@ public function getItems(); public function getReturnTrackingId(); /** + *

                                                                                                                            Date and time (UTC) the return is initiated.

                                                                                                                            + * - * @return null|string + * @return null|DateTimeImmutable */ public function getReturnDate(); @@ -49,7 +54,7 @@ public function setItems(?ReturnItemCollection $items): void; public function setReturnTrackingId(?string $returnTrackingId): void; /** - * @param ?string $returnDate + * @param ?DateTimeImmutable $returnDate */ - public function setReturnDate(?string $returnDate): void; + public function setReturnDate(?DateTimeImmutable $returnDate): void; } diff --git a/lib/commercetools-history/src/Models/Common/ReturnInfoBuilder.php b/lib/commercetools-history/src/Models/Common/ReturnInfoBuilder.php index f5ce70ed382..2a6db2e6295 100644 --- a/lib/commercetools-history/src/Models/Common/ReturnInfoBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ReturnInfoBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @implements Builder @@ -34,11 +35,13 @@ final class ReturnInfoBuilder implements Builder /** - * @var ?string + * @var ?DateTimeImmutable */ private $returnDate; /** + *

                                                                                                                            Information on the Line Items or Custom Line Items returned.

                                                                                                                            + * * @return null|ReturnItemCollection */ @@ -48,7 +51,7 @@ public function getItems() } /** - *

                                                                                                                            Identifies, which return tracking ID is connected to this particular return.

                                                                                                                            + *

                                                                                                                            User-defined identifier to track the return.

                                                                                                                            * * @return null|string @@ -59,8 +62,10 @@ public function getReturnTrackingId() } /** + *

                                                                                                                            Date and time (UTC) the return is initiated.

                                                                                                                            + * - * @return null|string + * @return null|DateTimeImmutable */ public function getReturnDate() { @@ -90,10 +95,10 @@ public function withReturnTrackingId(?string $returnTrackingId) } /** - * @param ?string $returnDate + * @param ?DateTimeImmutable $returnDate * @return $this */ - public function withReturnDate(?string $returnDate) + public function withReturnDate(?DateTimeImmutable $returnDate) { $this->returnDate = $returnDate; diff --git a/lib/commercetools-history/src/Models/Common/ReturnInfoModel.php b/lib/commercetools-history/src/Models/Common/ReturnInfoModel.php index cf360d012cb..d42e70bf46b 100644 --- a/lib/commercetools-history/src/Models/Common/ReturnInfoModel.php +++ b/lib/commercetools-history/src/Models/Common/ReturnInfoModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @internal @@ -35,7 +36,7 @@ final class ReturnInfoModel extends JsonObjectModel implements ReturnInfo /** * - * @var ?string + * @var ?DateTimeImmutable */ protected $returnDate; @@ -46,7 +47,7 @@ final class ReturnInfoModel extends JsonObjectModel implements ReturnInfo public function __construct( ?ReturnItemCollection $items = null, ?string $returnTrackingId = null, - ?string $returnDate = null + ?DateTimeImmutable $returnDate = null ) { $this->items = $items; $this->returnTrackingId = $returnTrackingId; @@ -55,6 +56,8 @@ public function __construct( } /** + *

                                                                                                                            Information on the Line Items or Custom Line Items returned.

                                                                                                                            + * * * @return null|ReturnItemCollection */ @@ -73,7 +76,7 @@ public function getItems() } /** - *

                                                                                                                            Identifies, which return tracking ID is connected to this particular return.

                                                                                                                            + *

                                                                                                                            User-defined identifier to track the return.

                                                                                                                            * * * @return null|string @@ -93,8 +96,10 @@ public function getReturnTrackingId() } /** + *

                                                                                                                            Date and time (UTC) the return is initiated.

                                                                                                                            * - * @return null|string + * + * @return null|DateTimeImmutable */ public function getReturnDate() { @@ -104,7 +109,11 @@ public function getReturnDate() if (is_null($data)) { return null; } - $this->returnDate = (string) $data; + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->returnDate = $data; } return $this->returnDate; @@ -128,13 +137,22 @@ public function setReturnTrackingId(?string $returnTrackingId): void } /** - * @param ?string $returnDate + * @param ?DateTimeImmutable $returnDate */ - public function setReturnDate(?string $returnDate): void + public function setReturnDate(?DateTimeImmutable $returnDate): void { $this->returnDate = $returnDate; } + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[ReturnInfo::FIELD_RETURN_DATE]) && $data[ReturnInfo::FIELD_RETURN_DATE] instanceof \DateTimeImmutable) { + $data[ReturnInfo::FIELD_RETURN_DATE] = $data[ReturnInfo::FIELD_RETURN_DATE]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } } diff --git a/lib/commercetools-history/src/Models/Common/ReturnItem.php b/lib/commercetools-history/src/Models/Common/ReturnItem.php index 20f29907d41..639e05cdb54 100644 --- a/lib/commercetools-history/src/Models/Common/ReturnItem.php +++ b/lib/commercetools-history/src/Models/Common/ReturnItem.php @@ -10,26 +10,41 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use DateTimeImmutable; interface ReturnItem extends JsonObject { public const FIELD_ID = 'id'; + public const FIELD_KEY = 'key'; public const FIELD_QUANTITY = 'quantity'; public const FIELD_TYPE = 'type'; public const FIELD_COMMENT = 'comment'; public const FIELD_SHIPMENT_STATE = 'shipmentState'; public const FIELD_PAYMENT_STATE = 'paymentState'; + public const FIELD_CUSTOM = 'custom'; public const FIELD_LAST_MODIFIED_AT = 'lastModifiedAt'; public const FIELD_CREATED_AT = 'createdAt'; /** + *

                                                                                                                            Unique identifier of the Return Item.

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

                                                                                                                            User-defined unique identifier of the Return Item.

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

                                                                                                                            Number of Line Items or Custom Line Items returned.

                                                                                                                            + * * @return null|int */ @@ -42,32 +57,54 @@ public function getQuantity(); public function getType(); /** + *

                                                                                                                            User-defined description for the return.

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

                                                                                                                            Shipment status of the Return Item.

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

                                                                                                                            Payment status of the Return Item:

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

                                                                                                                            Custom Fields of the Return Item.

                                                                                                                            + * - * @return null|string + * @return null|CustomFields + */ + public function getCustom(); + + /** + *

                                                                                                                            Date and time (UTC) the Return Item was last updated.

                                                                                                                            + * + + * @return null|DateTimeImmutable */ public function getLastModifiedAt(); /** + *

                                                                                                                            Date and time (UTC) the Return Item was initially created.

                                                                                                                            + * - * @return null|string + * @return null|DateTimeImmutable */ public function getCreatedAt(); @@ -76,6 +113,11 @@ public function getCreatedAt(); */ public function setId(?string $id): void; + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + /** * @param ?int $quantity */ @@ -102,12 +144,17 @@ public function setShipmentState(?string $shipmentState): void; public function setPaymentState(?string $paymentState): void; /** - * @param ?string $lastModifiedAt + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void; + + /** + * @param ?DateTimeImmutable $lastModifiedAt */ - public function setLastModifiedAt(?string $lastModifiedAt): void; + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void; /** - * @param ?string $createdAt + * @param ?DateTimeImmutable $createdAt */ - public function setCreatedAt(?string $createdAt): void; + public function setCreatedAt(?DateTimeImmutable $createdAt): void; } diff --git a/lib/commercetools-history/src/Models/Common/ReturnItemBuilder.php b/lib/commercetools-history/src/Models/Common/ReturnItemBuilder.php index 4ddf48d935a..93f27c7e073 100644 --- a/lib/commercetools-history/src/Models/Common/ReturnItemBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ReturnItemBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @implements Builder @@ -26,6 +27,12 @@ final class ReturnItemBuilder implements Builder */ private $id; + /** + + * @var ?string + */ + private $key; + /** * @var ?int @@ -58,17 +65,25 @@ final class ReturnItemBuilder implements Builder /** - * @var ?string + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + + /** + + * @var ?DateTimeImmutable */ private $lastModifiedAt; /** - * @var ?string + * @var ?DateTimeImmutable */ private $createdAt; /** + *

                                                                                                                            Unique identifier of the Return Item.

                                                                                                                            + * * @return null|string */ @@ -78,6 +93,19 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the Return Item.

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

                                                                                                                            Number of Line Items or Custom Line Items returned.

                                                                                                                            + * * @return null|int */ @@ -96,6 +124,8 @@ public function getType() } /** + *

                                                                                                                            User-defined description for the return.

                                                                                                                            + * * @return null|string */ @@ -105,6 +135,8 @@ public function getComment() } /** + *

                                                                                                                            Shipment status of the Return Item.

                                                                                                                            + * * @return null|string */ @@ -114,6 +146,12 @@ public function getShipmentState() } /** + *

                                                                                                                            Payment status of the Return Item:

                                                                                                                            + * + * * @return null|string */ @@ -123,8 +161,21 @@ public function getPaymentState() } /** + *

                                                                                                                            Custom Fields of the Return Item.

                                                                                                                            + * - * @return null|string + * @return null|CustomFields + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; + } + + /** + *

                                                                                                                            Date and time (UTC) the Return Item was last updated.

                                                                                                                            + * + + * @return null|DateTimeImmutable */ public function getLastModifiedAt() { @@ -132,8 +183,10 @@ public function getLastModifiedAt() } /** + *

                                                                                                                            Date and time (UTC) the Return Item was initially created.

                                                                                                                            + * - * @return null|string + * @return null|DateTimeImmutable */ public function getCreatedAt() { @@ -151,6 +204,17 @@ public function withId(?string $id) return $this; } + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + /** * @param ?int $quantity * @return $this @@ -207,10 +271,21 @@ public function withPaymentState(?string $paymentState) } /** - * @param ?string $lastModifiedAt + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt * @return $this */ - public function withLastModifiedAt(?string $lastModifiedAt) + public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt) { $this->lastModifiedAt = $lastModifiedAt; @@ -218,26 +293,38 @@ public function withLastModifiedAt(?string $lastModifiedAt) } /** - * @param ?string $createdAt + * @param ?DateTimeImmutable $createdAt * @return $this */ - public function withCreatedAt(?string $createdAt) + public function withCreatedAt(?DateTimeImmutable $createdAt) { $this->createdAt = $createdAt; return $this; } + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + return $this; + } public function build(): ReturnItem { return new ReturnItemModel( $this->id, + $this->key, $this->quantity, $this->type, $this->comment, $this->shipmentState, $this->paymentState, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, $this->lastModifiedAt, $this->createdAt ); diff --git a/lib/commercetools-history/src/Models/Common/ReturnItemModel.php b/lib/commercetools-history/src/Models/Common/ReturnItemModel.php index 562e9c0320e..7c25e850c05 100644 --- a/lib/commercetools-history/src/Models/Common/ReturnItemModel.php +++ b/lib/commercetools-history/src/Models/Common/ReturnItemModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @internal @@ -27,6 +28,12 @@ final class ReturnItemModel extends JsonObjectModel implements ReturnItem */ protected $id; + /** + * + * @var ?string + */ + protected $key; + /** * * @var ?int @@ -59,13 +66,19 @@ final class ReturnItemModel extends JsonObjectModel implements ReturnItem /** * - * @var ?string + * @var ?CustomFields + */ + protected $custom; + + /** + * + * @var ?DateTimeImmutable */ protected $lastModifiedAt; /** * - * @var ?string + * @var ?DateTimeImmutable */ protected $createdAt; @@ -75,26 +88,32 @@ final class ReturnItemModel extends JsonObjectModel implements ReturnItem */ public function __construct( ?string $id = null, + ?string $key = null, ?int $quantity = null, ?string $type = null, ?string $comment = null, ?string $shipmentState = null, ?string $paymentState = null, - ?string $lastModifiedAt = null, - ?string $createdAt = null + ?CustomFields $custom = null, + ?DateTimeImmutable $lastModifiedAt = null, + ?DateTimeImmutable $createdAt = null ) { $this->id = $id; + $this->key = $key; $this->quantity = $quantity; $this->type = $type; $this->comment = $comment; $this->shipmentState = $shipmentState; $this->paymentState = $paymentState; + $this->custom = $custom; $this->lastModifiedAt = $lastModifiedAt; $this->createdAt = $createdAt; } /** + *

                                                                                                                            Unique identifier of the Return Item.

                                                                                                                            + * * * @return null|string */ @@ -113,6 +132,28 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the Return Item.

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

                                                                                                                            Number of Line Items or Custom Line Items returned.

                                                                                                                            + * * * @return null|int */ @@ -149,6 +190,8 @@ public function getType() } /** + *

                                                                                                                            User-defined description for the return.

                                                                                                                            + * * * @return null|string */ @@ -167,6 +210,8 @@ public function getComment() } /** + *

                                                                                                                            Shipment status of the Return Item.

                                                                                                                            + * * * @return null|string */ @@ -185,6 +230,12 @@ public function getShipmentState() } /** + *

                                                                                                                            Payment status of the Return Item:

                                                                                                                            + * + * * * @return null|string */ @@ -203,8 +254,31 @@ public function getPaymentState() } /** + *

                                                                                                                            Custom Fields of the Return Item.

                                                                                                                            * - * @return null|string + * + * @return null|CustomFields + */ + public function getCustom() + { + if (is_null($this->custom)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($data)) { + return null; + } + + $this->custom = CustomFieldsModel::of($data); + } + + return $this->custom; + } + + /** + *

                                                                                                                            Date and time (UTC) the Return Item was last updated.

                                                                                                                            + * + * + * @return null|DateTimeImmutable */ public function getLastModifiedAt() { @@ -214,15 +288,21 @@ public function getLastModifiedAt() if (is_null($data)) { return null; } - $this->lastModifiedAt = (string) $data; + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->lastModifiedAt = $data; } return $this->lastModifiedAt; } /** + *

                                                                                                                            Date and time (UTC) the Return Item was initially created.

                                                                                                                            * - * @return null|string + * + * @return null|DateTimeImmutable */ public function getCreatedAt() { @@ -232,7 +312,11 @@ public function getCreatedAt() if (is_null($data)) { return null; } - $this->createdAt = (string) $data; + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->createdAt = $data; } return $this->createdAt; @@ -247,6 +331,14 @@ public function setId(?string $id): void $this->id = $id; } + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + /** * @param ?int $quantity */ @@ -288,21 +380,42 @@ public function setPaymentState(?string $paymentState): void } /** - * @param ?string $lastModifiedAt + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt */ - public function setLastModifiedAt(?string $lastModifiedAt): void + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void { $this->lastModifiedAt = $lastModifiedAt; } /** - * @param ?string $createdAt + * @param ?DateTimeImmutable $createdAt */ - public function setCreatedAt(?string $createdAt): void + public function setCreatedAt(?DateTimeImmutable $createdAt): void { $this->createdAt = $createdAt; } + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[ReturnItem::FIELD_LAST_MODIFIED_AT]) && $data[ReturnItem::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) { + $data[ReturnItem::FIELD_LAST_MODIFIED_AT] = $data[ReturnItem::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[ReturnItem::FIELD_CREATED_AT]) && $data[ReturnItem::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[ReturnItem::FIELD_CREATED_AT] = $data[ReturnItem::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } } diff --git a/lib/commercetools-history/src/Models/Common/ReviewRatingStatistics.php b/lib/commercetools-history/src/Models/Common/ReviewRatingStatistics.php index 37412dae131..15b677edb74 100644 --- a/lib/commercetools-history/src/Models/Common/ReviewRatingStatistics.php +++ b/lib/commercetools-history/src/Models/Common/ReviewRatingStatistics.php @@ -21,10 +21,11 @@ interface ReviewRatingStatistics extends JsonObject public const FIELD_RATINGS_DISTRIBUTION = 'ratingsDistribution'; /** - *

                                                                                                                            Average rating of one target This number is rounded with 5 decimals.

                                                                                                                            + *

                                                                                                                            Average rating of one target + * This number is rounded with 5 decimals.

                                                                                                                            * - * @return null|int + * @return null|float */ public function getAverageRating(); @@ -32,7 +33,7 @@ public function getAverageRating(); *

                                                                                                                            Highest rating of one target

                                                                                                                            * - * @return null|int + * @return null|float */ public function getHighestRating(); @@ -40,7 +41,7 @@ public function getHighestRating(); *

                                                                                                                            Lowest rating of one target

                                                                                                                            * - * @return null|int + * @return null|float */ public function getLowestRating(); @@ -53,7 +54,9 @@ public function getLowestRating(); public function getCount(); /** - *

                                                                                                                            The full distribution of the ratings. The keys are the different ratings and the values are the count of reviews having this rating. Only the used ratings appear in this object.

                                                                                                                            + *

                                                                                                                            Full distribution of the ratings. + * The keys are the different ratings and the values are the count of reviews having this rating. + * Only the used ratings appear in this object.

                                                                                                                            * * @return null|mixed @@ -61,19 +64,19 @@ public function getCount(); public function getRatingsDistribution(); /** - * @param ?int $averageRating + * @param ?float $averageRating */ - public function setAverageRating(?int $averageRating): void; + public function setAverageRating(?float $averageRating): void; /** - * @param ?int $highestRating + * @param ?float $highestRating */ - public function setHighestRating(?int $highestRating): void; + public function setHighestRating(?float $highestRating): void; /** - * @param ?int $lowestRating + * @param ?float $lowestRating */ - public function setLowestRating(?int $lowestRating): void; + public function setLowestRating(?float $lowestRating): void; /** * @param ?int $count diff --git a/lib/commercetools-history/src/Models/Common/ReviewRatingStatisticsBuilder.php b/lib/commercetools-history/src/Models/Common/ReviewRatingStatisticsBuilder.php index 4b31e26a6a4..382cf6ecb31 100644 --- a/lib/commercetools-history/src/Models/Common/ReviewRatingStatisticsBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ReviewRatingStatisticsBuilder.php @@ -22,19 +22,19 @@ final class ReviewRatingStatisticsBuilder implements Builder { /** - * @var ?int + * @var ?float */ private $averageRating; /** - * @var ?int + * @var ?float */ private $highestRating; /** - * @var ?int + * @var ?float */ private $lowestRating; @@ -51,10 +51,11 @@ final class ReviewRatingStatisticsBuilder implements Builder private $ratingsDistribution; /** - *

                                                                                                                            Average rating of one target This number is rounded with 5 decimals.

                                                                                                                            + *

                                                                                                                            Average rating of one target + * This number is rounded with 5 decimals.

                                                                                                                            * - * @return null|int + * @return null|float */ public function getAverageRating() { @@ -65,7 +66,7 @@ public function getAverageRating() *

                                                                                                                            Highest rating of one target

                                                                                                                            * - * @return null|int + * @return null|float */ public function getHighestRating() { @@ -76,7 +77,7 @@ public function getHighestRating() *

                                                                                                                            Lowest rating of one target

                                                                                                                            * - * @return null|int + * @return null|float */ public function getLowestRating() { @@ -95,7 +96,9 @@ public function getCount() } /** - *

                                                                                                                            The full distribution of the ratings. The keys are the different ratings and the values are the count of reviews having this rating. Only the used ratings appear in this object.

                                                                                                                            + *

                                                                                                                            Full distribution of the ratings. + * The keys are the different ratings and the values are the count of reviews having this rating. + * Only the used ratings appear in this object.

                                                                                                                            * * @return null|JsonObject @@ -106,10 +109,10 @@ public function getRatingsDistribution() } /** - * @param ?int $averageRating + * @param ?float $averageRating * @return $this */ - public function withAverageRating(?int $averageRating) + public function withAverageRating(?float $averageRating) { $this->averageRating = $averageRating; @@ -117,10 +120,10 @@ public function withAverageRating(?int $averageRating) } /** - * @param ?int $highestRating + * @param ?float $highestRating * @return $this */ - public function withHighestRating(?int $highestRating) + public function withHighestRating(?float $highestRating) { $this->highestRating = $highestRating; @@ -128,10 +131,10 @@ public function withHighestRating(?int $highestRating) } /** - * @param ?int $lowestRating + * @param ?float $lowestRating * @return $this */ - public function withLowestRating(?int $lowestRating) + public function withLowestRating(?float $lowestRating) { $this->lowestRating = $lowestRating; diff --git a/lib/commercetools-history/src/Models/Common/ReviewRatingStatisticsModel.php b/lib/commercetools-history/src/Models/Common/ReviewRatingStatisticsModel.php index ddc9ffc1821..021da60f202 100644 --- a/lib/commercetools-history/src/Models/Common/ReviewRatingStatisticsModel.php +++ b/lib/commercetools-history/src/Models/Common/ReviewRatingStatisticsModel.php @@ -23,19 +23,19 @@ final class ReviewRatingStatisticsModel extends JsonObjectModel implements Revie /** * - * @var ?int + * @var ?float */ protected $averageRating; /** * - * @var ?int + * @var ?float */ protected $highestRating; /** * - * @var ?int + * @var ?float */ protected $lowestRating; @@ -56,9 +56,9 @@ final class ReviewRatingStatisticsModel extends JsonObjectModel implements Revie * @psalm-suppress MissingParamType */ public function __construct( - ?int $averageRating = null, - ?int $highestRating = null, - ?int $lowestRating = null, + ?float $averageRating = null, + ?float $highestRating = null, + ?float $lowestRating = null, ?int $count = null, ?JsonObject $ratingsDistribution = null ) { @@ -71,20 +71,21 @@ public function __construct( } /** - *

                                                                                                                            Average rating of one target This number is rounded with 5 decimals.

                                                                                                                            + *

                                                                                                                            Average rating of one target + * This number is rounded with 5 decimals.

                                                                                                                            * * - * @return null|int + * @return null|float */ public function getAverageRating() { if (is_null($this->averageRating)) { - /** @psalm-var ?int $data */ + /** @psalm-var ?float $data */ $data = $this->raw(self::FIELD_AVERAGE_RATING); if (is_null($data)) { return null; } - $this->averageRating = (int) $data; + $this->averageRating = (float) $data; } return $this->averageRating; @@ -94,17 +95,17 @@ public function getAverageRating() *

                                                                                                                            Highest rating of one target

                                                                                                                            * * - * @return null|int + * @return null|float */ public function getHighestRating() { if (is_null($this->highestRating)) { - /** @psalm-var ?int $data */ + /** @psalm-var ?float $data */ $data = $this->raw(self::FIELD_HIGHEST_RATING); if (is_null($data)) { return null; } - $this->highestRating = (int) $data; + $this->highestRating = (float) $data; } return $this->highestRating; @@ -114,17 +115,17 @@ public function getHighestRating() *

                                                                                                                            Lowest rating of one target

                                                                                                                            * * - * @return null|int + * @return null|float */ public function getLowestRating() { if (is_null($this->lowestRating)) { - /** @psalm-var ?int $data */ + /** @psalm-var ?float $data */ $data = $this->raw(self::FIELD_LOWEST_RATING); if (is_null($data)) { return null; } - $this->lowestRating = (int) $data; + $this->lowestRating = (float) $data; } return $this->lowestRating; @@ -151,7 +152,9 @@ public function getCount() } /** - *

                                                                                                                            The full distribution of the ratings. The keys are the different ratings and the values are the count of reviews having this rating. Only the used ratings appear in this object.

                                                                                                                            + *

                                                                                                                            Full distribution of the ratings. + * The keys are the different ratings and the values are the count of reviews having this rating. + * Only the used ratings appear in this object.

                                                                                                                            * * * @return null|mixed @@ -172,25 +175,25 @@ public function getRatingsDistribution() /** - * @param ?int $averageRating + * @param ?float $averageRating */ - public function setAverageRating(?int $averageRating): void + public function setAverageRating(?float $averageRating): void { $this->averageRating = $averageRating; } /** - * @param ?int $highestRating + * @param ?float $highestRating */ - public function setHighestRating(?int $highestRating): void + public function setHighestRating(?float $highestRating): void { $this->highestRating = $highestRating; } /** - * @param ?int $lowestRating + * @param ?float $lowestRating */ - public function setLowestRating(?int $lowestRating): void + public function setLowestRating(?float $lowestRating): void { $this->lowestRating = $lowestRating; } diff --git a/lib/commercetools-history/src/Models/Common/ScopedPrice.php b/lib/commercetools-history/src/Models/Common/ScopedPrice.php new file mode 100644 index 00000000000..ea65315d0cd --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ScopedPrice.php @@ -0,0 +1,159 @@ +Platform-generated unique identifier of the Price.

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

                                                                                                                            Original value of the Price.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getValue(); + + /** + *

                                                                                                                            If available, either the original price value or discounted value.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getCurrentValue(); + + /** + *

                                                                                                                            Country code of the geographic location.

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

                                                                                                                            Reference to a CustomerGroup.

                                                                                                                            + * + + * @return null|CustomerGroupReference + */ + public function getCustomerGroup(); + + /** + *

                                                                                                                            Reference to a Channel.

                                                                                                                            + * + + * @return null|ChannelReference + */ + public function getChannel(); + + /** + *

                                                                                                                            Date and time from which the Price is valid.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ + public function getValidFrom(); + + /** + *

                                                                                                                            Date and time until which the Price is valid.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ + public function getValidUntil(); + + /** + *

                                                                                                                            Is set when a matching ProductDiscount exists. If set, the Cart uses the discounted value for the Cart Price calculation.

                                                                                                                            + *

                                                                                                                            When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

                                                                                                                            + * + + * @return null|DiscountedPrice + */ + public function getDiscounted(); + + /** + *

                                                                                                                            Custom Fields for the Price.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; + + /** + * @param ?TypedMoney $value + */ + public function setValue(?TypedMoney $value): void; + + /** + * @param ?TypedMoney $currentValue + */ + public function setCurrentValue(?TypedMoney $currentValue): void; + + /** + * @param ?string $country + */ + public function setCountry(?string $country): void; + + /** + * @param ?CustomerGroupReference $customerGroup + */ + public function setCustomerGroup(?CustomerGroupReference $customerGroup): void; + + /** + * @param ?ChannelReference $channel + */ + public function setChannel(?ChannelReference $channel): void; + + /** + * @param ?DateTimeImmutable $validFrom + */ + public function setValidFrom(?DateTimeImmutable $validFrom): void; + + /** + * @param ?DateTimeImmutable $validUntil + */ + public function setValidUntil(?DateTimeImmutable $validUntil): void; + + /** + * @param ?DiscountedPrice $discounted + */ + public function setDiscounted(?DiscountedPrice $discounted): void; + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ScopedPriceBuilder.php b/lib/commercetools-history/src/Models/Common/ScopedPriceBuilder.php new file mode 100644 index 00000000000..7a3486d7aa2 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ScopedPriceBuilder.php @@ -0,0 +1,391 @@ + + */ +final class ScopedPriceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var null|TypedMoney|TypedMoneyBuilder + */ + private $value; + + /** + + * @var null|TypedMoney|TypedMoneyBuilder + */ + private $currentValue; + + /** + + * @var ?string + */ + private $country; + + /** + + * @var null|CustomerGroupReference|CustomerGroupReferenceBuilder + */ + private $customerGroup; + + /** + + * @var null|ChannelReference|ChannelReferenceBuilder + */ + private $channel; + + /** + + * @var ?DateTimeImmutable + */ + private $validFrom; + + /** + + * @var ?DateTimeImmutable + */ + private $validUntil; + + /** + + * @var null|DiscountedPrice|DiscountedPriceBuilder + */ + private $discounted; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + + /** + *

                                                                                                                            Platform-generated unique identifier of the Price.

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

                                                                                                                            Original value of the Price.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getValue() + { + return $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value; + } + + /** + *

                                                                                                                            If available, either the original price value or discounted value.

                                                                                                                            + * + + * @return null|TypedMoney + */ + public function getCurrentValue() + { + return $this->currentValue instanceof TypedMoneyBuilder ? $this->currentValue->build() : $this->currentValue; + } + + /** + *

                                                                                                                            Country code of the geographic location.

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

                                                                                                                            Reference to a CustomerGroup.

                                                                                                                            + * + + * @return null|CustomerGroupReference + */ + public function getCustomerGroup() + { + return $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup; + } + + /** + *

                                                                                                                            Reference to a Channel.

                                                                                                                            + * + + * @return null|ChannelReference + */ + public function getChannel() + { + return $this->channel instanceof ChannelReferenceBuilder ? $this->channel->build() : $this->channel; + } + + /** + *

                                                                                                                            Date and time from which the Price is valid.

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

                                                                                                                            Date and time until which the Price is valid.

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

                                                                                                                            Is set when a matching ProductDiscount exists. If set, the Cart uses the discounted value for the Cart Price calculation.

                                                                                                                            + *

                                                                                                                            When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

                                                                                                                            + * + + * @return null|DiscountedPrice + */ + public function getDiscounted() + { + return $this->discounted instanceof DiscountedPriceBuilder ? $this->discounted->build() : $this->discounted; + } + + /** + *

                                                                                                                            Custom Fields for the Price.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?TypedMoney $value + * @return $this + */ + public function withValue(?TypedMoney $value) + { + $this->value = $value; + + return $this; + } + + /** + * @param ?TypedMoney $currentValue + * @return $this + */ + public function withCurrentValue(?TypedMoney $currentValue) + { + $this->currentValue = $currentValue; + + return $this; + } + + /** + * @param ?string $country + * @return $this + */ + public function withCountry(?string $country) + { + $this->country = $country; + + return $this; + } + + /** + * @param ?CustomerGroupReference $customerGroup + * @return $this + */ + public function withCustomerGroup(?CustomerGroupReference $customerGroup) + { + $this->customerGroup = $customerGroup; + + return $this; + } + + /** + * @param ?ChannelReference $channel + * @return $this + */ + public function withChannel(?ChannelReference $channel) + { + $this->channel = $channel; + + return $this; + } + + /** + * @param ?DateTimeImmutable $validFrom + * @return $this + */ + public function withValidFrom(?DateTimeImmutable $validFrom) + { + $this->validFrom = $validFrom; + + return $this; + } + + /** + * @param ?DateTimeImmutable $validUntil + * @return $this + */ + public function withValidUntil(?DateTimeImmutable $validUntil) + { + $this->validUntil = $validUntil; + + return $this; + } + + /** + * @param ?DiscountedPrice $discounted + * @return $this + */ + public function withDiscounted(?DiscountedPrice $discounted) + { + $this->discounted = $discounted; + + return $this; + } + + /** + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @deprecated use withValue() instead + * @return $this + */ + public function withValueBuilder(?TypedMoneyBuilder $value) + { + $this->value = $value; + + return $this; + } + + /** + * @deprecated use withCurrentValue() instead + * @return $this + */ + public function withCurrentValueBuilder(?TypedMoneyBuilder $currentValue) + { + $this->currentValue = $currentValue; + + return $this; + } + + /** + * @deprecated use withCustomerGroup() instead + * @return $this + */ + public function withCustomerGroupBuilder(?CustomerGroupReferenceBuilder $customerGroup) + { + $this->customerGroup = $customerGroup; + + return $this; + } + + /** + * @deprecated use withChannel() instead + * @return $this + */ + public function withChannelBuilder(?ChannelReferenceBuilder $channel) + { + $this->channel = $channel; + + return $this; + } + + /** + * @deprecated use withDiscounted() instead + * @return $this + */ + public function withDiscountedBuilder(?DiscountedPriceBuilder $discounted) + { + $this->discounted = $discounted; + + return $this; + } + + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + return $this; + } + + public function build(): ScopedPrice + { + return new ScopedPriceModel( + $this->id, + $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value, + $this->currentValue instanceof TypedMoneyBuilder ? $this->currentValue->build() : $this->currentValue, + $this->country, + $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup, + $this->channel instanceof ChannelReferenceBuilder ? $this->channel->build() : $this->channel, + $this->validFrom, + $this->validUntil, + $this->discounted instanceof DiscountedPriceBuilder ? $this->discounted->build() : $this->discounted, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom + ); + } + + public static function of(): ScopedPriceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ScopedPriceCollection.php b/lib/commercetools-history/src/Models/Common/ScopedPriceCollection.php new file mode 100644 index 00000000000..925157aeb01 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ScopedPriceCollection.php @@ -0,0 +1,56 @@ + + * @method ScopedPrice current() + * @method ScopedPrice end() + * @method ScopedPrice at($offset) + */ +class ScopedPriceCollection extends MapperSequence +{ + /** + * @psalm-assert ScopedPrice $value + * @psalm-param ScopedPrice|stdClass $value + * @throws InvalidArgumentException + * + * @return ScopedPriceCollection + */ + public function add($value) + { + if (!$value instanceof ScopedPrice) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ScopedPrice + */ + protected function mapper() + { + return function (?int $index): ?ScopedPrice { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ScopedPrice $data */ + $data = ScopedPriceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ScopedPriceModel.php b/lib/commercetools-history/src/Models/Common/ScopedPriceModel.php new file mode 100644 index 00000000000..3bd7602cdb1 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ScopedPriceModel.php @@ -0,0 +1,425 @@ +id = $id; + $this->value = $value; + $this->currentValue = $currentValue; + $this->country = $country; + $this->customerGroup = $customerGroup; + $this->channel = $channel; + $this->validFrom = $validFrom; + $this->validUntil = $validUntil; + $this->discounted = $discounted; + $this->custom = $custom; + + } + + /** + *

                                                                                                                            Platform-generated unique identifier of the Price.

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

                                                                                                                            Original value of the Price.

                                                                                                                            + * + * + * @return null|TypedMoney + */ + public function getValue() + { + if (is_null($this->value)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_VALUE); + if (is_null($data)) { + return null; + } + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->value = $className::of($data); + } + + return $this->value; + } + + /** + *

                                                                                                                            If available, either the original price value or discounted value.

                                                                                                                            + * + * + * @return null|TypedMoney + */ + public function getCurrentValue() + { + if (is_null($this->currentValue)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CURRENT_VALUE); + if (is_null($data)) { + return null; + } + $className = TypedMoneyModel::resolveDiscriminatorClass($data); + $this->currentValue = $className::of($data); + } + + return $this->currentValue; + } + + /** + *

                                                                                                                            Country code of the geographic location.

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

                                                                                                                            Reference to a CustomerGroup.

                                                                                                                            + * + * + * @return null|CustomerGroupReference + */ + public function getCustomerGroup() + { + if (is_null($this->customerGroup)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOMER_GROUP); + if (is_null($data)) { + return null; + } + + $this->customerGroup = CustomerGroupReferenceModel::of($data); + } + + return $this->customerGroup; + } + + /** + *

                                                                                                                            Reference to a Channel.

                                                                                                                            + * + * + * @return null|ChannelReference + */ + public function getChannel() + { + if (is_null($this->channel)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CHANNEL); + if (is_null($data)) { + return null; + } + + $this->channel = ChannelReferenceModel::of($data); + } + + return $this->channel; + } + + /** + *

                                                                                                                            Date and time from which the Price is valid.

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

                                                                                                                            Date and time until which the Price is valid.

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

                                                                                                                            Is set when a matching ProductDiscount exists. If set, the Cart uses the discounted value for the Cart Price calculation.

                                                                                                                            + *

                                                                                                                            When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.

                                                                                                                            + * + * + * @return null|DiscountedPrice + */ + public function getDiscounted() + { + if (is_null($this->discounted)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DISCOUNTED); + if (is_null($data)) { + return null; + } + + $this->discounted = DiscountedPriceModel::of($data); + } + + return $this->discounted; + } + + /** + *

                                                                                                                            Custom Fields for the Price.

                                                                                                                            + * + * + * @return null|CustomFields + */ + public function getCustom() + { + if (is_null($this->custom)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($data)) { + return null; + } + + $this->custom = CustomFieldsModel::of($data); + } + + return $this->custom; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?TypedMoney $value + */ + public function setValue(?TypedMoney $value): void + { + $this->value = $value; + } + + /** + * @param ?TypedMoney $currentValue + */ + public function setCurrentValue(?TypedMoney $currentValue): void + { + $this->currentValue = $currentValue; + } + + /** + * @param ?string $country + */ + public function setCountry(?string $country): void + { + $this->country = $country; + } + + /** + * @param ?CustomerGroupReference $customerGroup + */ + public function setCustomerGroup(?CustomerGroupReference $customerGroup): void + { + $this->customerGroup = $customerGroup; + } + + /** + * @param ?ChannelReference $channel + */ + public function setChannel(?ChannelReference $channel): void + { + $this->channel = $channel; + } + + /** + * @param ?DateTimeImmutable $validFrom + */ + public function setValidFrom(?DateTimeImmutable $validFrom): void + { + $this->validFrom = $validFrom; + } + + /** + * @param ?DateTimeImmutable $validUntil + */ + public function setValidUntil(?DateTimeImmutable $validUntil): void + { + $this->validUntil = $validUntil; + } + + /** + * @param ?DiscountedPrice $discounted + */ + public function setDiscounted(?DiscountedPrice $discounted): void + { + $this->discounted = $discounted; + } + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[ScopedPrice::FIELD_VALID_FROM]) && $data[ScopedPrice::FIELD_VALID_FROM] instanceof \DateTimeImmutable) { + $data[ScopedPrice::FIELD_VALID_FROM] = $data[ScopedPrice::FIELD_VALID_FROM]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[ScopedPrice::FIELD_VALID_UNTIL]) && $data[ScopedPrice::FIELD_VALID_UNTIL] instanceof \DateTimeImmutable) { + $data[ScopedPrice::FIELD_VALID_UNTIL] = $data[ScopedPrice::FIELD_VALID_UNTIL]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } + +} diff --git a/lib/commercetools-history/src/Models/Common/SearchKeyword.php b/lib/commercetools-history/src/Models/Common/SearchKeyword.php index eaca48b4111..c85de1591b6 100644 --- a/lib/commercetools-history/src/Models/Common/SearchKeyword.php +++ b/lib/commercetools-history/src/Models/Common/SearchKeyword.php @@ -18,12 +18,16 @@ interface SearchKeyword extends JsonObject public const FIELD_SUGGEST_TOKENIZER = 'suggestTokenizer'; /** + *

                                                                                                                            Text to return in the SuggestionResult.

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

                                                                                                                            If no tokenizer is defined, the text is used as a single token.

                                                                                                                            + * * @return null|SuggestTokenizer */ diff --git a/lib/commercetools-history/src/Models/Common/SearchKeywordBuilder.php b/lib/commercetools-history/src/Models/Common/SearchKeywordBuilder.php index 248cdd32bb1..b9fc5e3e0a2 100644 --- a/lib/commercetools-history/src/Models/Common/SearchKeywordBuilder.php +++ b/lib/commercetools-history/src/Models/Common/SearchKeywordBuilder.php @@ -33,6 +33,8 @@ final class SearchKeywordBuilder implements Builder private $suggestTokenizer; /** + *

                                                                                                                            Text to return in the SuggestionResult.

                                                                                                                            + * * @return null|string */ @@ -42,6 +44,8 @@ public function getText() } /** + *

                                                                                                                            If no tokenizer is defined, the text is used as a single token.

                                                                                                                            + * * @return null|SuggestTokenizer */ diff --git a/lib/commercetools-history/src/Models/Common/SearchKeywordModel.php b/lib/commercetools-history/src/Models/Common/SearchKeywordModel.php index 9daff681814..bad4f7d96c2 100644 --- a/lib/commercetools-history/src/Models/Common/SearchKeywordModel.php +++ b/lib/commercetools-history/src/Models/Common/SearchKeywordModel.php @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            Text to return in the SuggestionResult.

                                                                                                                            + * * * @return null|string */ @@ -65,6 +67,8 @@ public function getText() } /** + *

                                                                                                                            If no tokenizer is defined, the text is used as a single token.

                                                                                                                            + * * * @return null|SuggestTokenizer */ diff --git a/lib/commercetools-history/src/Models/Common/SearchKeywords.php b/lib/commercetools-history/src/Models/Common/SearchKeywords.php index ecaa4a61020..50dd19daf7d 100644 --- a/lib/commercetools-history/src/Models/Common/SearchKeywords.php +++ b/lib/commercetools-history/src/Models/Common/SearchKeywords.php @@ -8,13 +8,8 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\JsonObject; -use Commercetools\Base\DateTimeImmutableCollection; +use Commercetools\Base\CMap; -interface SearchKeywords extends JsonObject +interface SearchKeywords extends CMap { - - public const FIELD_PATTERN0 = '/^[a-z]{2}(-[A-Z]{2})?$/'; - - } diff --git a/lib/commercetools-history/src/Models/Common/SearchKeywordsBuilder.php b/lib/commercetools-history/src/Models/Common/SearchKeywordsBuilder.php index faef0254adf..00e4ccaa43c 100644 --- a/lib/commercetools-history/src/Models/Common/SearchKeywordsBuilder.php +++ b/lib/commercetools-history/src/Models/Common/SearchKeywordsBuilder.php @@ -8,30 +8,39 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\Builder; -use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\Base\JsonObject; -use Commercetools\Base\JsonObjectModel; -use Commercetools\Base\MapperFactory; use stdClass; +use Commercetools\Base\MapperMap; +use Commercetools\Base\Builder; /** * @implements Builder + * @extends MapperMap */ -final class SearchKeywordsBuilder implements Builder +final class SearchKeywordsBuilder extends MapperMap implements Builder { - - - - - public function build(): SearchKeywords + /** + * @psalm-return callable(string):?SearchKeywords + */ + protected function mapper() { - return new SearchKeywordsModel( - ); + return + /** + * @psalm-return ?SearchKeywords + */ + function(string $key) { + $data = $this->get($key); + if ($data instanceof stdClass) { + $data = SearchKeywordsModel::of($data); + } + return $data; + }; } - public static function of(): SearchKeywordsBuilder + /** + * @return SearchKeywords + */ + public function build() { - return new self(); + return new SearchKeywordsModel($this->toArray()); } } diff --git a/lib/commercetools-history/src/Models/Common/SearchKeywordsModel.php b/lib/commercetools-history/src/Models/Common/SearchKeywordsModel.php index 4aa1b4a96a2..933d12a3bc3 100644 --- a/lib/commercetools-history/src/Models/Common/SearchKeywordsModel.php +++ b/lib/commercetools-history/src/Models/Common/SearchKeywordsModel.php @@ -8,48 +8,24 @@ namespace Commercetools\History\Models\Common; -use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\Base\JsonObject; -use Commercetools\Base\JsonObjectModel; -use Commercetools\Base\MapperFactory; -use stdClass; +use Commercetools\Base\MapperMap; /** * @internal */ -final class SearchKeywordsModel extends JsonObjectModel implements SearchKeywords +final class SearchKeywordsModel extends MapperMap implements SearchKeywords { - - - - /** - * @psalm-suppress MissingParamType + * @psalm-return callable(string):?mixed */ - public function __construct( - ) { - - } - - - - - /** - * @return mixed - */ - public function by(string $key) + protected function mapper() { - $data = $this->raw($key); - if (is_null($data)) { - return null; - } - if (preg_match(SearchKeywords::FIELD_PATTERN0, $key) === 1) { - /** @psalm-var list $data */ - return new SearchKeywordCollection($data); - } - - return $data; + return + /** + * @psalm-return ?mixed + */ + function(string $key) { + return $this->get($key); + }; } - - } diff --git a/lib/commercetools-history/src/Models/Common/Shipping.php b/lib/commercetools-history/src/Models/Common/Shipping.php new file mode 100644 index 00000000000..9543f3f290c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/Shipping.php @@ -0,0 +1,93 @@ +User-defined unique identifier of the Shipping in a Cart with Multiple ShippingMode.

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

                                                                                                                            Automatically set when the Shipping Method is added.

                                                                                                                            + * + + * @return null|ShippingInfo + */ + public function getShippingInfo(); + + /** + *

                                                                                                                            Determines the shipping rates and Tax Rates of associated Line Items.

                                                                                                                            + * + + * @return null|Address + */ + public function getShippingAddress(); + + /** + *

                                                                                                                            Used as an input to select a ShippingRatePriceTier. + * The data type of this field depends on the shippingRateInputType.type configured in the Project:

                                                                                                                            + * + * + + * @return null|ShippingRateInput + */ + public function getShippingRateInput(); + + /** + *

                                                                                                                            Custom Fields of Shipping with Multiple ShippingMode.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getShippingCustomFields(); + + /** + * @param ?string $shippingKey + */ + public function setShippingKey(?string $shippingKey): void; + + /** + * @param ?ShippingInfo $shippingInfo + */ + public function setShippingInfo(?ShippingInfo $shippingInfo): void; + + /** + * @param ?Address $shippingAddress + */ + public function setShippingAddress(?Address $shippingAddress): void; + + /** + * @param ?ShippingRateInput $shippingRateInput + */ + public function setShippingRateInput(?ShippingRateInput $shippingRateInput): void; + + /** + * @param ?CustomFields $shippingCustomFields + */ + public function setShippingCustomFields(?CustomFields $shippingCustomFields): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingBuilder.php b/lib/commercetools-history/src/Models/Common/ShippingBuilder.php new file mode 100644 index 00000000000..f3ef814b752 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingBuilder.php @@ -0,0 +1,228 @@ + + */ +final class ShippingBuilder implements Builder +{ + /** + + * @var ?string + */ + private $shippingKey; + + /** + + * @var null|ShippingInfo|ShippingInfoBuilder + */ + private $shippingInfo; + + /** + + * @var null|Address|AddressBuilder + */ + private $shippingAddress; + + /** + + * @var null|ShippingRateInput|ShippingRateInputBuilder + */ + private $shippingRateInput; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $shippingCustomFields; + + /** + *

                                                                                                                            User-defined unique identifier of the Shipping in a Cart with Multiple ShippingMode.

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

                                                                                                                            Automatically set when the Shipping Method is added.

                                                                                                                            + * + + * @return null|ShippingInfo + */ + public function getShippingInfo() + { + return $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo; + } + + /** + *

                                                                                                                            Determines the shipping rates and Tax Rates of associated Line Items.

                                                                                                                            + * + + * @return null|Address + */ + public function getShippingAddress() + { + return $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress; + } + + /** + *

                                                                                                                            Used as an input to select a ShippingRatePriceTier. + * The data type of this field depends on the shippingRateInputType.type configured in the Project:

                                                                                                                            + * + * + + * @return null|ShippingRateInput + */ + public function getShippingRateInput() + { + return $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput; + } + + /** + *

                                                                                                                            Custom Fields of Shipping with Multiple ShippingMode.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getShippingCustomFields() + { + return $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields; + } + + /** + * @param ?string $shippingKey + * @return $this + */ + public function withShippingKey(?string $shippingKey) + { + $this->shippingKey = $shippingKey; + + return $this; + } + + /** + * @param ?ShippingInfo $shippingInfo + * @return $this + */ + public function withShippingInfo(?ShippingInfo $shippingInfo) + { + $this->shippingInfo = $shippingInfo; + + return $this; + } + + /** + * @param ?Address $shippingAddress + * @return $this + */ + public function withShippingAddress(?Address $shippingAddress) + { + $this->shippingAddress = $shippingAddress; + + return $this; + } + + /** + * @param ?ShippingRateInput $shippingRateInput + * @return $this + */ + public function withShippingRateInput(?ShippingRateInput $shippingRateInput) + { + $this->shippingRateInput = $shippingRateInput; + + return $this; + } + + /** + * @param ?CustomFields $shippingCustomFields + * @return $this + */ + public function withShippingCustomFields(?CustomFields $shippingCustomFields) + { + $this->shippingCustomFields = $shippingCustomFields; + + return $this; + } + + /** + * @deprecated use withShippingInfo() instead + * @return $this + */ + public function withShippingInfoBuilder(?ShippingInfoBuilder $shippingInfo) + { + $this->shippingInfo = $shippingInfo; + + return $this; + } + + /** + * @deprecated use withShippingAddress() instead + * @return $this + */ + public function withShippingAddressBuilder(?AddressBuilder $shippingAddress) + { + $this->shippingAddress = $shippingAddress; + + return $this; + } + + /** + * @deprecated use withShippingRateInput() instead + * @return $this + */ + public function withShippingRateInputBuilder(?ShippingRateInputBuilder $shippingRateInput) + { + $this->shippingRateInput = $shippingRateInput; + + return $this; + } + + /** + * @deprecated use withShippingCustomFields() instead + * @return $this + */ + public function withShippingCustomFieldsBuilder(?CustomFieldsBuilder $shippingCustomFields) + { + $this->shippingCustomFields = $shippingCustomFields; + + return $this; + } + + public function build(): Shipping + { + return new ShippingModel( + $this->shippingKey, + $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo, + $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress, + $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput, + $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields + ); + } + + public static function of(): ShippingBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingCollection.php b/lib/commercetools-history/src/Models/Common/ShippingCollection.php new file mode 100644 index 00000000000..a769f5e684a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingCollection.php @@ -0,0 +1,56 @@ + + * @method Shipping current() + * @method Shipping end() + * @method Shipping at($offset) + */ +class ShippingCollection extends MapperSequence +{ + /** + * @psalm-assert Shipping $value + * @psalm-param Shipping|stdClass $value + * @throws InvalidArgumentException + * + * @return ShippingCollection + */ + public function add($value) + { + if (!$value instanceof Shipping) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?Shipping + */ + protected function mapper() + { + return function (?int $index): ?Shipping { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var Shipping $data */ + $data = ShippingModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingInfo.php b/lib/commercetools-history/src/Models/Common/ShippingInfo.php new file mode 100644 index 00000000000..1bda5bb6f5d --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingInfo.php @@ -0,0 +1,158 @@ +Name of the Shipping Method.

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

                                                                                                                            Determined based on the ShippingRate and its tiered prices, and either the sum of LineItem prices or the shippingRateInput field.

                                                                                                                            + * + + * @return null|CentPrecisionMoney + */ + public function getPrice(); + + /** + *

                                                                                                                            Used to determine the price.

                                                                                                                            + * + + * @return null|ShippingRate + */ + public function getShippingRate(); + + /** + *

                                                                                                                            Automatically set after the taxRate is set.

                                                                                                                            + * + + * @return null|TaxedItemPrice + */ + public function getTaxedPrice(); + + /** + *

                                                                                                                            Automatically set in the Platform TaxMode after the shipping address is set.

                                                                                                                            + *

                                                                                                                            For the External TaxMode the Tax Rate must be set explicitly with the ExternalTaxRateDraft.

                                                                                                                            + * + + * @return null|TaxRate + */ + public function getTaxRate(); + + /** + *

                                                                                                                            Used to select a Tax Rate when a Cart has the Platform TaxMode.

                                                                                                                            + * + + * @return null|TaxCategoryReference + */ + public function getTaxCategory(); + + /** + *

                                                                                                                            Not set if a custom Shipping Method is used.

                                                                                                                            + * + + * @return null|ShippingMethodReference + */ + public function getShippingMethod(); + + /** + *

                                                                                                                            Information on how items are delivered to customers.

                                                                                                                            + * + + * @return null|DeliveryCollection + */ + public function getDeliveries(); + + /** + *

                                                                                                                            Discounted price of the Shipping Method.

                                                                                                                            + * + + * @return null|DiscountedLineItemPrice + */ + public function getDiscountedPrice(); + + /** + *

                                                                                                                            Indicates whether the ShippingMethod referenced in this ShippingInfo is allowed for the Cart.

                                                                                                                            + * + + * @return null|string + */ + public function getShippingMethodState(); + + /** + * @param ?string $shippingMethodName + */ + public function setShippingMethodName(?string $shippingMethodName): void; + + /** + * @param ?CentPrecisionMoney $price + */ + public function setPrice(?CentPrecisionMoney $price): void; + + /** + * @param ?ShippingRate $shippingRate + */ + public function setShippingRate(?ShippingRate $shippingRate): void; + + /** + * @param ?TaxedItemPrice $taxedPrice + */ + public function setTaxedPrice(?TaxedItemPrice $taxedPrice): void; + + /** + * @param ?TaxRate $taxRate + */ + public function setTaxRate(?TaxRate $taxRate): void; + + /** + * @param ?TaxCategoryReference $taxCategory + */ + public function setTaxCategory(?TaxCategoryReference $taxCategory): void; + + /** + * @param ?ShippingMethodReference $shippingMethod + */ + public function setShippingMethod(?ShippingMethodReference $shippingMethod): void; + + /** + * @param ?DeliveryCollection $deliveries + */ + public function setDeliveries(?DeliveryCollection $deliveries): void; + + /** + * @param ?DiscountedLineItemPrice $discountedPrice + */ + public function setDiscountedPrice(?DiscountedLineItemPrice $discountedPrice): void; + + /** + * @param ?string $shippingMethodState + */ + public function setShippingMethodState(?string $shippingMethodState): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingInfoBuilder.php b/lib/commercetools-history/src/Models/Common/ShippingInfoBuilder.php new file mode 100644 index 00000000000..98bf872d1af --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingInfoBuilder.php @@ -0,0 +1,401 @@ + + */ +final class ShippingInfoBuilder implements Builder +{ + /** + + * @var ?string + */ + private $shippingMethodName; + + /** + + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder + */ + private $price; + + /** + + * @var null|ShippingRate|ShippingRateBuilder + */ + private $shippingRate; + + /** + + * @var null|TaxedItemPrice|TaxedItemPriceBuilder + */ + private $taxedPrice; + + /** + + * @var null|TaxRate|TaxRateBuilder + */ + private $taxRate; + + /** + + * @var null|TaxCategoryReference|TaxCategoryReferenceBuilder + */ + private $taxCategory; + + /** + + * @var null|ShippingMethodReference|ShippingMethodReferenceBuilder + */ + private $shippingMethod; + + /** + + * @var ?DeliveryCollection + */ + private $deliveries; + + /** + + * @var null|DiscountedLineItemPrice|DiscountedLineItemPriceBuilder + */ + private $discountedPrice; + + /** + + * @var ?string + */ + private $shippingMethodState; + + /** + *

                                                                                                                            Name of the Shipping Method.

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

                                                                                                                            Determined based on the ShippingRate and its tiered prices, and either the sum of LineItem prices or the shippingRateInput field.

                                                                                                                            + * + + * @return null|CentPrecisionMoney + */ + public function getPrice() + { + return $this->price instanceof CentPrecisionMoneyBuilder ? $this->price->build() : $this->price; + } + + /** + *

                                                                                                                            Used to determine the price.

                                                                                                                            + * + + * @return null|ShippingRate + */ + public function getShippingRate() + { + return $this->shippingRate instanceof ShippingRateBuilder ? $this->shippingRate->build() : $this->shippingRate; + } + + /** + *

                                                                                                                            Automatically set after the taxRate is set.

                                                                                                                            + * + + * @return null|TaxedItemPrice + */ + public function getTaxedPrice() + { + return $this->taxedPrice instanceof TaxedItemPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice; + } + + /** + *

                                                                                                                            Automatically set in the Platform TaxMode after the shipping address is set.

                                                                                                                            + *

                                                                                                                            For the External TaxMode the Tax Rate must be set explicitly with the ExternalTaxRateDraft.

                                                                                                                            + * + + * @return null|TaxRate + */ + public function getTaxRate() + { + return $this->taxRate instanceof TaxRateBuilder ? $this->taxRate->build() : $this->taxRate; + } + + /** + *

                                                                                                                            Used to select a Tax Rate when a Cart has the Platform TaxMode.

                                                                                                                            + * + + * @return null|TaxCategoryReference + */ + public function getTaxCategory() + { + return $this->taxCategory instanceof TaxCategoryReferenceBuilder ? $this->taxCategory->build() : $this->taxCategory; + } + + /** + *

                                                                                                                            Not set if a custom Shipping Method is used.

                                                                                                                            + * + + * @return null|ShippingMethodReference + */ + public function getShippingMethod() + { + return $this->shippingMethod instanceof ShippingMethodReferenceBuilder ? $this->shippingMethod->build() : $this->shippingMethod; + } + + /** + *

                                                                                                                            Information on how items are delivered to customers.

                                                                                                                            + * + + * @return null|DeliveryCollection + */ + public function getDeliveries() + { + return $this->deliveries; + } + + /** + *

                                                                                                                            Discounted price of the Shipping Method.

                                                                                                                            + * + + * @return null|DiscountedLineItemPrice + */ + public function getDiscountedPrice() + { + return $this->discountedPrice instanceof DiscountedLineItemPriceBuilder ? $this->discountedPrice->build() : $this->discountedPrice; + } + + /** + *

                                                                                                                            Indicates whether the ShippingMethod referenced in this ShippingInfo is allowed for the Cart.

                                                                                                                            + * + + * @return null|string + */ + public function getShippingMethodState() + { + return $this->shippingMethodState; + } + + /** + * @param ?string $shippingMethodName + * @return $this + */ + public function withShippingMethodName(?string $shippingMethodName) + { + $this->shippingMethodName = $shippingMethodName; + + return $this; + } + + /** + * @param ?CentPrecisionMoney $price + * @return $this + */ + public function withPrice(?CentPrecisionMoney $price) + { + $this->price = $price; + + return $this; + } + + /** + * @param ?ShippingRate $shippingRate + * @return $this + */ + public function withShippingRate(?ShippingRate $shippingRate) + { + $this->shippingRate = $shippingRate; + + return $this; + } + + /** + * @param ?TaxedItemPrice $taxedPrice + * @return $this + */ + public function withTaxedPrice(?TaxedItemPrice $taxedPrice) + { + $this->taxedPrice = $taxedPrice; + + return $this; + } + + /** + * @param ?TaxRate $taxRate + * @return $this + */ + public function withTaxRate(?TaxRate $taxRate) + { + $this->taxRate = $taxRate; + + return $this; + } + + /** + * @param ?TaxCategoryReference $taxCategory + * @return $this + */ + public function withTaxCategory(?TaxCategoryReference $taxCategory) + { + $this->taxCategory = $taxCategory; + + return $this; + } + + /** + * @param ?ShippingMethodReference $shippingMethod + * @return $this + */ + public function withShippingMethod(?ShippingMethodReference $shippingMethod) + { + $this->shippingMethod = $shippingMethod; + + return $this; + } + + /** + * @param ?DeliveryCollection $deliveries + * @return $this + */ + public function withDeliveries(?DeliveryCollection $deliveries) + { + $this->deliveries = $deliveries; + + return $this; + } + + /** + * @param ?DiscountedLineItemPrice $discountedPrice + * @return $this + */ + public function withDiscountedPrice(?DiscountedLineItemPrice $discountedPrice) + { + $this->discountedPrice = $discountedPrice; + + return $this; + } + + /** + * @param ?string $shippingMethodState + * @return $this + */ + public function withShippingMethodState(?string $shippingMethodState) + { + $this->shippingMethodState = $shippingMethodState; + + return $this; + } + + /** + * @deprecated use withPrice() instead + * @return $this + */ + public function withPriceBuilder(?CentPrecisionMoneyBuilder $price) + { + $this->price = $price; + + return $this; + } + + /** + * @deprecated use withShippingRate() instead + * @return $this + */ + public function withShippingRateBuilder(?ShippingRateBuilder $shippingRate) + { + $this->shippingRate = $shippingRate; + + return $this; + } + + /** + * @deprecated use withTaxedPrice() instead + * @return $this + */ + public function withTaxedPriceBuilder(?TaxedItemPriceBuilder $taxedPrice) + { + $this->taxedPrice = $taxedPrice; + + return $this; + } + + /** + * @deprecated use withTaxRate() instead + * @return $this + */ + public function withTaxRateBuilder(?TaxRateBuilder $taxRate) + { + $this->taxRate = $taxRate; + + return $this; + } + + /** + * @deprecated use withTaxCategory() instead + * @return $this + */ + public function withTaxCategoryBuilder(?TaxCategoryReferenceBuilder $taxCategory) + { + $this->taxCategory = $taxCategory; + + return $this; + } + + /** + * @deprecated use withShippingMethod() instead + * @return $this + */ + public function withShippingMethodBuilder(?ShippingMethodReferenceBuilder $shippingMethod) + { + $this->shippingMethod = $shippingMethod; + + return $this; + } + + /** + * @deprecated use withDiscountedPrice() instead + * @return $this + */ + public function withDiscountedPriceBuilder(?DiscountedLineItemPriceBuilder $discountedPrice) + { + $this->discountedPrice = $discountedPrice; + + return $this; + } + + public function build(): ShippingInfo + { + return new ShippingInfoModel( + $this->shippingMethodName, + $this->price instanceof CentPrecisionMoneyBuilder ? $this->price->build() : $this->price, + $this->shippingRate instanceof ShippingRateBuilder ? $this->shippingRate->build() : $this->shippingRate, + $this->taxedPrice instanceof TaxedItemPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice, + $this->taxRate instanceof TaxRateBuilder ? $this->taxRate->build() : $this->taxRate, + $this->taxCategory instanceof TaxCategoryReferenceBuilder ? $this->taxCategory->build() : $this->taxCategory, + $this->shippingMethod instanceof ShippingMethodReferenceBuilder ? $this->shippingMethod->build() : $this->shippingMethod, + $this->deliveries, + $this->discountedPrice instanceof DiscountedLineItemPriceBuilder ? $this->discountedPrice->build() : $this->discountedPrice, + $this->shippingMethodState + ); + } + + public static function of(): ShippingInfoBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingInfoCollection.php b/lib/commercetools-history/src/Models/Common/ShippingInfoCollection.php new file mode 100644 index 00000000000..c5e8e8ede5c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingInfoCollection.php @@ -0,0 +1,56 @@ + + * @method ShippingInfo current() + * @method ShippingInfo end() + * @method ShippingInfo at($offset) + */ +class ShippingInfoCollection extends MapperSequence +{ + /** + * @psalm-assert ShippingInfo $value + * @psalm-param ShippingInfo|stdClass $value + * @throws InvalidArgumentException + * + * @return ShippingInfoCollection + */ + public function add($value) + { + if (!$value instanceof ShippingInfo) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ShippingInfo + */ + protected function mapper() + { + return function (?int $index): ?ShippingInfo { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ShippingInfo $data */ + $data = ShippingInfoModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingInfoModel.php b/lib/commercetools-history/src/Models/Common/ShippingInfoModel.php new file mode 100644 index 00000000000..e2e7e64731b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingInfoModel.php @@ -0,0 +1,404 @@ +shippingMethodName = $shippingMethodName; + $this->price = $price; + $this->shippingRate = $shippingRate; + $this->taxedPrice = $taxedPrice; + $this->taxRate = $taxRate; + $this->taxCategory = $taxCategory; + $this->shippingMethod = $shippingMethod; + $this->deliveries = $deliveries; + $this->discountedPrice = $discountedPrice; + $this->shippingMethodState = $shippingMethodState; + + } + + /** + *

                                                                                                                            Name of the Shipping Method.

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

                                                                                                                            Determined based on the ShippingRate and its tiered prices, and either the sum of LineItem prices or the shippingRateInput field.

                                                                                                                            + * + * + * @return null|CentPrecisionMoney + */ + public function getPrice() + { + if (is_null($this->price)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PRICE); + if (is_null($data)) { + return null; + } + + $this->price = CentPrecisionMoneyModel::of($data); + } + + return $this->price; + } + + /** + *

                                                                                                                            Used to determine the price.

                                                                                                                            + * + * + * @return null|ShippingRate + */ + public function getShippingRate() + { + if (is_null($this->shippingRate)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SHIPPING_RATE); + if (is_null($data)) { + return null; + } + + $this->shippingRate = ShippingRateModel::of($data); + } + + return $this->shippingRate; + } + + /** + *

                                                                                                                            Automatically set after the taxRate is set.

                                                                                                                            + * + * + * @return null|TaxedItemPrice + */ + public function getTaxedPrice() + { + if (is_null($this->taxedPrice)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TAXED_PRICE); + if (is_null($data)) { + return null; + } + + $this->taxedPrice = TaxedItemPriceModel::of($data); + } + + return $this->taxedPrice; + } + + /** + *

                                                                                                                            Automatically set in the Platform TaxMode after the shipping address is set.

                                                                                                                            + *

                                                                                                                            For the External TaxMode the Tax Rate must be set explicitly with the ExternalTaxRateDraft.

                                                                                                                            + * + * + * @return null|TaxRate + */ + public function getTaxRate() + { + if (is_null($this->taxRate)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TAX_RATE); + if (is_null($data)) { + return null; + } + + $this->taxRate = TaxRateModel::of($data); + } + + return $this->taxRate; + } + + /** + *

                                                                                                                            Used to select a Tax Rate when a Cart has the Platform TaxMode.

                                                                                                                            + * + * + * @return null|TaxCategoryReference + */ + public function getTaxCategory() + { + if (is_null($this->taxCategory)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TAX_CATEGORY); + if (is_null($data)) { + return null; + } + + $this->taxCategory = TaxCategoryReferenceModel::of($data); + } + + return $this->taxCategory; + } + + /** + *

                                                                                                                            Not set if a custom Shipping Method is used.

                                                                                                                            + * + * + * @return null|ShippingMethodReference + */ + public function getShippingMethod() + { + if (is_null($this->shippingMethod)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SHIPPING_METHOD); + if (is_null($data)) { + return null; + } + + $this->shippingMethod = ShippingMethodReferenceModel::of($data); + } + + return $this->shippingMethod; + } + + /** + *

                                                                                                                            Information on how items are delivered to customers.

                                                                                                                            + * + * + * @return null|DeliveryCollection + */ + public function getDeliveries() + { + if (is_null($this->deliveries)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_DELIVERIES); + if (is_null($data)) { + return null; + } + $this->deliveries = DeliveryCollection::fromArray($data); + } + + return $this->deliveries; + } + + /** + *

                                                                                                                            Discounted price of the Shipping Method.

                                                                                                                            + * + * + * @return null|DiscountedLineItemPrice + */ + public function getDiscountedPrice() + { + if (is_null($this->discountedPrice)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DISCOUNTED_PRICE); + if (is_null($data)) { + return null; + } + + $this->discountedPrice = DiscountedLineItemPriceModel::of($data); + } + + return $this->discountedPrice; + } + + /** + *

                                                                                                                            Indicates whether the ShippingMethod referenced in this ShippingInfo is allowed for the Cart.

                                                                                                                            + * + * + * @return null|string + */ + public function getShippingMethodState() + { + if (is_null($this->shippingMethodState)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_SHIPPING_METHOD_STATE); + if (is_null($data)) { + return null; + } + $this->shippingMethodState = (string) $data; + } + + return $this->shippingMethodState; + } + + + /** + * @param ?string $shippingMethodName + */ + public function setShippingMethodName(?string $shippingMethodName): void + { + $this->shippingMethodName = $shippingMethodName; + } + + /** + * @param ?CentPrecisionMoney $price + */ + public function setPrice(?CentPrecisionMoney $price): void + { + $this->price = $price; + } + + /** + * @param ?ShippingRate $shippingRate + */ + public function setShippingRate(?ShippingRate $shippingRate): void + { + $this->shippingRate = $shippingRate; + } + + /** + * @param ?TaxedItemPrice $taxedPrice + */ + public function setTaxedPrice(?TaxedItemPrice $taxedPrice): void + { + $this->taxedPrice = $taxedPrice; + } + + /** + * @param ?TaxRate $taxRate + */ + public function setTaxRate(?TaxRate $taxRate): void + { + $this->taxRate = $taxRate; + } + + /** + * @param ?TaxCategoryReference $taxCategory + */ + public function setTaxCategory(?TaxCategoryReference $taxCategory): void + { + $this->taxCategory = $taxCategory; + } + + /** + * @param ?ShippingMethodReference $shippingMethod + */ + public function setShippingMethod(?ShippingMethodReference $shippingMethod): void + { + $this->shippingMethod = $shippingMethod; + } + + /** + * @param ?DeliveryCollection $deliveries + */ + public function setDeliveries(?DeliveryCollection $deliveries): void + { + $this->deliveries = $deliveries; + } + + /** + * @param ?DiscountedLineItemPrice $discountedPrice + */ + public function setDiscountedPrice(?DiscountedLineItemPrice $discountedPrice): void + { + $this->discountedPrice = $discountedPrice; + } + + /** + * @param ?string $shippingMethodState + */ + public function setShippingMethodState(?string $shippingMethodState): void + { + $this->shippingMethodState = $shippingMethodState; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingMethodReference.php b/lib/commercetools-history/src/Models/Common/ShippingMethodReference.php new file mode 100644 index 00000000000..33e3a162609 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingMethodReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced ShippingMethod.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingMethodReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/ShippingMethodReferenceBuilder.php new file mode 100644 index 00000000000..d3cb0fc439b --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingMethodReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class ShippingMethodReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced ShippingMethod.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): ShippingMethodReference + { + return new ShippingMethodReferenceModel( + $this->id + ); + } + + public static function of(): ShippingMethodReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingMethodReferenceCollection.php b/lib/commercetools-history/src/Models/Common/ShippingMethodReferenceCollection.php new file mode 100644 index 00000000000..a86da40e93c --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingMethodReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method ShippingMethodReference current() + * @method ShippingMethodReference end() + * @method ShippingMethodReference at($offset) + */ +class ShippingMethodReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert ShippingMethodReference $value + * @psalm-param ShippingMethodReference|stdClass $value + * @throws InvalidArgumentException + * + * @return ShippingMethodReferenceCollection + */ + public function add($value) + { + if (!$value instanceof ShippingMethodReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ShippingMethodReference + */ + protected function mapper() + { + return function (?int $index): ?ShippingMethodReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ShippingMethodReference $data */ + $data = ShippingMethodReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingMethodReferenceModel.php b/lib/commercetools-history/src/Models/Common/ShippingMethodReferenceModel.php new file mode 100644 index 00000000000..46b2f1ca3c8 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingMethodReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced ShippingMethod.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingModel.php b/lib/commercetools-history/src/Models/Common/ShippingModel.php new file mode 100644 index 00000000000..7ab72aade80 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingModel.php @@ -0,0 +1,226 @@ +shippingKey = $shippingKey; + $this->shippingInfo = $shippingInfo; + $this->shippingAddress = $shippingAddress; + $this->shippingRateInput = $shippingRateInput; + $this->shippingCustomFields = $shippingCustomFields; + + } + + /** + *

                                                                                                                            User-defined unique identifier of the Shipping in a Cart with Multiple ShippingMode.

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

                                                                                                                            Automatically set when the Shipping Method is added.

                                                                                                                            + * + * + * @return null|ShippingInfo + */ + public function getShippingInfo() + { + if (is_null($this->shippingInfo)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SHIPPING_INFO); + if (is_null($data)) { + return null; + } + + $this->shippingInfo = ShippingInfoModel::of($data); + } + + return $this->shippingInfo; + } + + /** + *

                                                                                                                            Determines the shipping rates and Tax Rates of associated Line Items.

                                                                                                                            + * + * + * @return null|Address + */ + public function getShippingAddress() + { + if (is_null($this->shippingAddress)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SHIPPING_ADDRESS); + if (is_null($data)) { + return null; + } + + $this->shippingAddress = AddressModel::of($data); + } + + return $this->shippingAddress; + } + + /** + *

                                                                                                                            Used as an input to select a ShippingRatePriceTier. + * The data type of this field depends on the shippingRateInputType.type configured in the Project:

                                                                                                                            + * + * + * + * @return null|ShippingRateInput + */ + public function getShippingRateInput() + { + if (is_null($this->shippingRateInput)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SHIPPING_RATE_INPUT); + if (is_null($data)) { + return null; + } + + $this->shippingRateInput = ShippingRateInputModel::of($data); + } + + return $this->shippingRateInput; + } + + /** + *

                                                                                                                            Custom Fields of Shipping with Multiple ShippingMode.

                                                                                                                            + * + * + * @return null|CustomFields + */ + public function getShippingCustomFields() + { + if (is_null($this->shippingCustomFields)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SHIPPING_CUSTOM_FIELDS); + if (is_null($data)) { + return null; + } + + $this->shippingCustomFields = CustomFieldsModel::of($data); + } + + return $this->shippingCustomFields; + } + + + /** + * @param ?string $shippingKey + */ + public function setShippingKey(?string $shippingKey): void + { + $this->shippingKey = $shippingKey; + } + + /** + * @param ?ShippingInfo $shippingInfo + */ + public function setShippingInfo(?ShippingInfo $shippingInfo): void + { + $this->shippingInfo = $shippingInfo; + } + + /** + * @param ?Address $shippingAddress + */ + public function setShippingAddress(?Address $shippingAddress): void + { + $this->shippingAddress = $shippingAddress; + } + + /** + * @param ?ShippingRateInput $shippingRateInput + */ + public function setShippingRateInput(?ShippingRateInput $shippingRateInput): void + { + $this->shippingRateInput = $shippingRateInput; + } + + /** + * @param ?CustomFields $shippingCustomFields + */ + public function setShippingCustomFields(?CustomFields $shippingCustomFields): void + { + $this->shippingCustomFields = $shippingCustomFields; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingRate.php b/lib/commercetools-history/src/Models/Common/ShippingRate.php index fcacb694f7b..21b2e53bc79 100644 --- a/lib/commercetools-history/src/Models/Common/ShippingRate.php +++ b/lib/commercetools-history/src/Models/Common/ShippingRate.php @@ -20,19 +20,25 @@ interface ShippingRate extends JsonObject public const FIELD_TIERS = 'tiers'; /** + *

                                                                                                                            Currency amount of the ShippingRate.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getPrice(); /** + *

                                                                                                                            Free shipping is applied if the sum of the (Custom) Line Item Prices reaches the specified value.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getFreeAbove(); /** - *

                                                                                                                            Only appears in response to requests for ShippingMethods by Cart or location to mark this shipping rate as one that matches the Cart or location.

                                                                                                                            + *

                                                                                                                            true if the ShippingRate matches given Cart or Location. + * Only appears in response to requests for Get ShippingMethods for a Cart or + * Get ShippingMethods for a Location.

                                                                                                                            * * @return null|bool @@ -40,20 +46,22 @@ public function getFreeAbove(); public function getIsMatching(); /** + *

                                                                                                                            Price tiers for the ShippingRate.

                                                                                                                            + * * @return null|ShippingRatePriceTierCollection */ public function getTiers(); /** - * @param ?Money $price + * @param ?CentPrecisionMoney $price */ - public function setPrice(?Money $price): void; + public function setPrice(?CentPrecisionMoney $price): void; /** - * @param ?Money $freeAbove + * @param ?CentPrecisionMoney $freeAbove */ - public function setFreeAbove(?Money $freeAbove): void; + public function setFreeAbove(?CentPrecisionMoney $freeAbove): void; /** * @param ?bool $isMatching diff --git a/lib/commercetools-history/src/Models/Common/ShippingRateBuilder.php b/lib/commercetools-history/src/Models/Common/ShippingRateBuilder.php index 23767bd15a9..5a46c67f555 100644 --- a/lib/commercetools-history/src/Models/Common/ShippingRateBuilder.php +++ b/lib/commercetools-history/src/Models/Common/ShippingRateBuilder.php @@ -22,13 +22,13 @@ final class ShippingRateBuilder implements Builder { /** - * @var null|Money|MoneyBuilder + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder */ private $price; /** - * @var null|Money|MoneyBuilder + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder */ private $freeAbove; @@ -45,25 +45,31 @@ final class ShippingRateBuilder implements Builder private $tiers; /** + *

                                                                                                                            Currency amount of the ShippingRate.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getPrice() { - return $this->price instanceof MoneyBuilder ? $this->price->build() : $this->price; + return $this->price instanceof CentPrecisionMoneyBuilder ? $this->price->build() : $this->price; } /** + *

                                                                                                                            Free shipping is applied if the sum of the (Custom) Line Item Prices reaches the specified value.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getFreeAbove() { - return $this->freeAbove instanceof MoneyBuilder ? $this->freeAbove->build() : $this->freeAbove; + return $this->freeAbove instanceof CentPrecisionMoneyBuilder ? $this->freeAbove->build() : $this->freeAbove; } /** - *

                                                                                                                            Only appears in response to requests for ShippingMethods by Cart or location to mark this shipping rate as one that matches the Cart or location.

                                                                                                                            + *

                                                                                                                            true if the ShippingRate matches given Cart or Location. + * Only appears in response to requests for Get ShippingMethods for a Cart or + * Get ShippingMethods for a Location.

                                                                                                                            * * @return null|bool @@ -74,6 +80,8 @@ public function getIsMatching() } /** + *

                                                                                                                            Price tiers for the ShippingRate.

                                                                                                                            + * * @return null|ShippingRatePriceTierCollection */ @@ -83,10 +91,10 @@ public function getTiers() } /** - * @param ?Money $price + * @param ?CentPrecisionMoney $price * @return $this */ - public function withPrice(?Money $price) + public function withPrice(?CentPrecisionMoney $price) { $this->price = $price; @@ -94,10 +102,10 @@ public function withPrice(?Money $price) } /** - * @param ?Money $freeAbove + * @param ?CentPrecisionMoney $freeAbove * @return $this */ - public function withFreeAbove(?Money $freeAbove) + public function withFreeAbove(?CentPrecisionMoney $freeAbove) { $this->freeAbove = $freeAbove; @@ -130,7 +138,7 @@ public function withTiers(?ShippingRatePriceTierCollection $tiers) * @deprecated use withPrice() instead * @return $this */ - public function withPriceBuilder(?MoneyBuilder $price) + public function withPriceBuilder(?CentPrecisionMoneyBuilder $price) { $this->price = $price; @@ -141,7 +149,7 @@ public function withPriceBuilder(?MoneyBuilder $price) * @deprecated use withFreeAbove() instead * @return $this */ - public function withFreeAboveBuilder(?MoneyBuilder $freeAbove) + public function withFreeAboveBuilder(?CentPrecisionMoneyBuilder $freeAbove) { $this->freeAbove = $freeAbove; @@ -151,8 +159,8 @@ public function withFreeAboveBuilder(?MoneyBuilder $freeAbove) public function build(): ShippingRate { return new ShippingRateModel( - $this->price instanceof MoneyBuilder ? $this->price->build() : $this->price, - $this->freeAbove instanceof MoneyBuilder ? $this->freeAbove->build() : $this->freeAbove, + $this->price instanceof CentPrecisionMoneyBuilder ? $this->price->build() : $this->price, + $this->freeAbove instanceof CentPrecisionMoneyBuilder ? $this->freeAbove->build() : $this->freeAbove, $this->isMatching, $this->tiers ); diff --git a/lib/commercetools-history/src/Models/Common/ShippingRateInput.php b/lib/commercetools-history/src/Models/Common/ShippingRateInput.php new file mode 100644 index 00000000000..0e155cc215d --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingRateInput.php @@ -0,0 +1,29 @@ + + */ +final class ShippingRateInputBuilder implements Builder +{ + /** + + * @var ?string + */ + private $type; + + /** + + * @return null|string + */ + public function getType() + { + return $this->type; + } + + /** + * @param ?string $type + * @return $this + */ + public function withType(?string $type) + { + $this->type = $type; + + return $this; + } + + + public function build(): ShippingRateInput + { + return new ShippingRateInputModel( + $this->type + ); + } + + public static function of(): ShippingRateInputBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingRateInputCollection.php b/lib/commercetools-history/src/Models/Common/ShippingRateInputCollection.php new file mode 100644 index 00000000000..4877077e51a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingRateInputCollection.php @@ -0,0 +1,56 @@ + + * @method ShippingRateInput current() + * @method ShippingRateInput end() + * @method ShippingRateInput at($offset) + */ +class ShippingRateInputCollection extends MapperSequence +{ + /** + * @psalm-assert ShippingRateInput $value + * @psalm-param ShippingRateInput|stdClass $value + * @throws InvalidArgumentException + * + * @return ShippingRateInputCollection + */ + public function add($value) + { + if (!$value instanceof ShippingRateInput) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ShippingRateInput + */ + protected function mapper() + { + return function (?int $index): ?ShippingRateInput { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ShippingRateInput $data */ + $data = ShippingRateInputModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingRateInputModel.php b/lib/commercetools-history/src/Models/Common/ShippingRateInputModel.php new file mode 100644 index 00000000000..4d49851e8b7 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShippingRateInputModel.php @@ -0,0 +1,70 @@ +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; + } + + + /** + * @param ?string $type + */ + public function setType(?string $type): void + { + $this->type = $type; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/ShippingRateModel.php b/lib/commercetools-history/src/Models/Common/ShippingRateModel.php index 9aa814fbb5a..33d60f4d10d 100644 --- a/lib/commercetools-history/src/Models/Common/ShippingRateModel.php +++ b/lib/commercetools-history/src/Models/Common/ShippingRateModel.php @@ -23,13 +23,13 @@ final class ShippingRateModel extends JsonObjectModel implements ShippingRate /** * - * @var ?Money + * @var ?CentPrecisionMoney */ protected $price; /** * - * @var ?Money + * @var ?CentPrecisionMoney */ protected $freeAbove; @@ -50,8 +50,8 @@ final class ShippingRateModel extends JsonObjectModel implements ShippingRate * @psalm-suppress MissingParamType */ public function __construct( - ?Money $price = null, - ?Money $freeAbove = null, + ?CentPrecisionMoney $price = null, + ?CentPrecisionMoney $freeAbove = null, ?bool $isMatching = null, ?ShippingRatePriceTierCollection $tiers = null ) { @@ -63,8 +63,10 @@ public function __construct( } /** + *

                                                                                                                            Currency amount of the ShippingRate.

                                                                                                                            * - * @return null|Money + * + * @return null|CentPrecisionMoney */ public function getPrice() { @@ -75,15 +77,17 @@ public function getPrice() return null; } - $this->price = MoneyModel::of($data); + $this->price = CentPrecisionMoneyModel::of($data); } return $this->price; } /** + *

                                                                                                                            Free shipping is applied if the sum of the (Custom) Line Item Prices reaches the specified value.

                                                                                                                            + * * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getFreeAbove() { @@ -94,14 +98,16 @@ public function getFreeAbove() return null; } - $this->freeAbove = MoneyModel::of($data); + $this->freeAbove = CentPrecisionMoneyModel::of($data); } return $this->freeAbove; } /** - *

                                                                                                                            Only appears in response to requests for ShippingMethods by Cart or location to mark this shipping rate as one that matches the Cart or location.

                                                                                                                            + *

                                                                                                                            true if the ShippingRate matches given Cart or Location. + * Only appears in response to requests for Get ShippingMethods for a Cart or + * Get ShippingMethods for a Location.

                                                                                                                            * * * @return null|bool @@ -121,6 +127,8 @@ public function getIsMatching() } /** + *

                                                                                                                            Price tiers for the ShippingRate.

                                                                                                                            + * * * @return null|ShippingRatePriceTierCollection */ @@ -140,17 +148,17 @@ public function getTiers() /** - * @param ?Money $price + * @param ?CentPrecisionMoney $price */ - public function setPrice(?Money $price): void + public function setPrice(?CentPrecisionMoney $price): void { $this->price = $price; } /** - * @param ?Money $freeAbove + * @param ?CentPrecisionMoney $freeAbove */ - public function setFreeAbove(?Money $freeAbove): void + public function setFreeAbove(?CentPrecisionMoney $freeAbove): void { $this->freeAbove = $freeAbove; } diff --git a/lib/commercetools-history/src/Models/Common/ShoppingListLineItem.php b/lib/commercetools-history/src/Models/Common/ShoppingListLineItem.php new file mode 100644 index 00000000000..cb716bdbb87 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShoppingListLineItem.php @@ -0,0 +1,205 @@ +Date and time (UTC) the ShoppingListLineItem was added to the ShoppingList.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ + public function getAddedAt(); + + /** + *

                                                                                                                            Custom Fields of the ShoppingListLineItem.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom(); + + /** + *

                                                                                                                            If the Product or Product Variant is deleted, deactivatedAt is the date and time (UTC) of deletion.

                                                                                                                            + *

                                                                                                                            This data is updated in an eventual consistent manner when the Product Variant cannot be ordered anymore.

                                                                                                                            + * + + * @return null|DateTimeImmutable + */ + public function getDeactivatedAt(); + + /** + *

                                                                                                                            Unique identifier of the ShoppingListLineItem.

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

                                                                                                                            User-defined identifier of the ShoppingListLineItem. It is unique per ShoppingList.

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

                                                                                                                            Name of the Product.

                                                                                                                            + *

                                                                                                                            This data is updated in an eventual consistent manner when the Product's name changes.

                                                                                                                            + * + + * @return null|LocalizedString + */ + public function getName(); + + /** + *

                                                                                                                            Unique identifier of a Product.

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

                                                                                                                            The Product Type defining the Attributes of the Product.

                                                                                                                            + * + + * @return null|ProductTypeReference + */ + public function getProductType(); + + /** + *

                                                                                                                            Whether the related Product is published or not.

                                                                                                                            + *

                                                                                                                            This data is updated in an eventual consistent manner when the Product's published status changes.

                                                                                                                            + * + + * @return null|bool + */ + public function getPublished(); + + /** + *

                                                                                                                            Number of Products in the ShoppingListLineItem.

                                                                                                                            + * + + * @return null|int + */ + public function getQuantity(); + + /** + *

                                                                                                                            id of the ProductVariant the ShoppingListLineItem refers to. If not set, the ShoppingListLineItem refers to the Master Variant.

                                                                                                                            + * + + * @return null|int + */ + public function getVariantId(); + + /** + *

                                                                                                                            Data of the ProductVariant. This data includes all the Product Attributes and Variant Attributes to ensure the full Attribute context of the Product Variant.

                                                                                                                            + *

                                                                                                                            Returned when expanded using expand=lineItems[*].variant. You cannot expand only a single element of the array.

                                                                                                                            + * + + * @return null|ProductVariant + */ + public function getVariant(); + + /** + *

                                                                                                                            Slug of the current ProductData.

                                                                                                                            + *

                                                                                                                            Returned when expanded using expand=lineItems[*].productSlug. You cannot expand only a single element of the array.

                                                                                                                            + * + + * @return null|LocalizedString + */ + public function getProductSlug(); + + /** + * @param ?DateTimeImmutable $addedAt + */ + public function setAddedAt(?DateTimeImmutable $addedAt): void; + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void; + + /** + * @param ?DateTimeImmutable $deactivatedAt + */ + public function setDeactivatedAt(?DateTimeImmutable $deactivatedAt): void; + + /** + * @param ?string $id + */ + public function setId(?string $id): void; + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?LocalizedString $name + */ + public function setName(?LocalizedString $name): void; + + /** + * @param ?string $productId + */ + public function setProductId(?string $productId): void; + + /** + * @param ?ProductTypeReference $productType + */ + public function setProductType(?ProductTypeReference $productType): void; + + /** + * @param ?bool $published + */ + public function setPublished(?bool $published): void; + + /** + * @param ?int $quantity + */ + public function setQuantity(?int $quantity): void; + + /** + * @param ?int $variantId + */ + public function setVariantId(?int $variantId): void; + + /** + * @param ?ProductVariant $variant + */ + public function setVariant(?ProductVariant $variant): void; + + /** + * @param ?LocalizedString $productSlug + */ + public function setProductSlug(?LocalizedString $productSlug): void; +} diff --git a/lib/commercetools-history/src/Models/Common/ShoppingListLineItemBuilder.php b/lib/commercetools-history/src/Models/Common/ShoppingListLineItemBuilder.php new file mode 100644 index 00000000000..775835c06a3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShoppingListLineItemBuilder.php @@ -0,0 +1,471 @@ + + */ +final class ShoppingListLineItemBuilder implements Builder +{ + /** + + * @var ?DateTimeImmutable + */ + private $addedAt; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + + /** + + * @var ?DateTimeImmutable + */ + private $deactivatedAt; + + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $key; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $name; + + /** + + * @var ?string + */ + private $productId; + + /** + + * @var null|ProductTypeReference|ProductTypeReferenceBuilder + */ + private $productType; + + /** + + * @var ?bool + */ + private $published; + + /** + + * @var ?int + */ + private $quantity; + + /** + + * @var ?int + */ + private $variantId; + + /** + + * @var null|ProductVariant|ProductVariantBuilder + */ + private $variant; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $productSlug; + + /** + *

                                                                                                                            Date and time (UTC) the ShoppingListLineItem was added to the ShoppingList.

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

                                                                                                                            Custom Fields of the ShoppingListLineItem.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; + } + + /** + *

                                                                                                                            If the Product or Product Variant is deleted, deactivatedAt is the date and time (UTC) of deletion.

                                                                                                                            + *

                                                                                                                            This data is updated in an eventual consistent manner when the Product Variant cannot be ordered anymore.

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

                                                                                                                            Unique identifier of the ShoppingListLineItem.

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

                                                                                                                            User-defined identifier of the ShoppingListLineItem. It is unique per ShoppingList.

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

                                                                                                                            Name of the Product.

                                                                                                                            + *

                                                                                                                            This data is updated in an eventual consistent manner when the Product's name changes.

                                                                                                                            + * + + * @return null|LocalizedString + */ + public function getName() + { + return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name; + } + + /** + *

                                                                                                                            Unique identifier of a Product.

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

                                                                                                                            The Product Type defining the Attributes of the Product.

                                                                                                                            + * + + * @return null|ProductTypeReference + */ + public function getProductType() + { + return $this->productType instanceof ProductTypeReferenceBuilder ? $this->productType->build() : $this->productType; + } + + /** + *

                                                                                                                            Whether the related Product is published or not.

                                                                                                                            + *

                                                                                                                            This data is updated in an eventual consistent manner when the Product's published status changes.

                                                                                                                            + * + + * @return null|bool + */ + public function getPublished() + { + return $this->published; + } + + /** + *

                                                                                                                            Number of Products in the ShoppingListLineItem.

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

                                                                                                                            id of the ProductVariant the ShoppingListLineItem refers to. If not set, the ShoppingListLineItem refers to the Master Variant.

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

                                                                                                                            Data of the ProductVariant. This data includes all the Product Attributes and Variant Attributes to ensure the full Attribute context of the Product Variant.

                                                                                                                            + *

                                                                                                                            Returned when expanded using expand=lineItems[*].variant. You cannot expand only a single element of the array.

                                                                                                                            + * + + * @return null|ProductVariant + */ + public function getVariant() + { + return $this->variant instanceof ProductVariantBuilder ? $this->variant->build() : $this->variant; + } + + /** + *

                                                                                                                            Slug of the current ProductData.

                                                                                                                            + *

                                                                                                                            Returned when expanded using expand=lineItems[*].productSlug. You cannot expand only a single element of the array.

                                                                                                                            + * + + * @return null|LocalizedString + */ + public function getProductSlug() + { + return $this->productSlug instanceof LocalizedStringBuilder ? $this->productSlug->build() : $this->productSlug; + } + + /** + * @param ?DateTimeImmutable $addedAt + * @return $this + */ + public function withAddedAt(?DateTimeImmutable $addedAt) + { + $this->addedAt = $addedAt; + + return $this; + } + + /** + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @param ?DateTimeImmutable $deactivatedAt + * @return $this + */ + public function withDeactivatedAt(?DateTimeImmutable $deactivatedAt) + { + $this->deactivatedAt = $deactivatedAt; + + return $this; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?LocalizedString $name + * @return $this + */ + public function withName(?LocalizedString $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?string $productId + * @return $this + */ + public function withProductId(?string $productId) + { + $this->productId = $productId; + + return $this; + } + + /** + * @param ?ProductTypeReference $productType + * @return $this + */ + public function withProductType(?ProductTypeReference $productType) + { + $this->productType = $productType; + + return $this; + } + + /** + * @param ?bool $published + * @return $this + */ + public function withPublished(?bool $published) + { + $this->published = $published; + + return $this; + } + + /** + * @param ?int $quantity + * @return $this + */ + public function withQuantity(?int $quantity) + { + $this->quantity = $quantity; + + return $this; + } + + /** + * @param ?int $variantId + * @return $this + */ + public function withVariantId(?int $variantId) + { + $this->variantId = $variantId; + + return $this; + } + + /** + * @param ?ProductVariant $variant + * @return $this + */ + public function withVariant(?ProductVariant $variant) + { + $this->variant = $variant; + + return $this; + } + + /** + * @param ?LocalizedString $productSlug + * @return $this + */ + public function withProductSlug(?LocalizedString $productSlug) + { + $this->productSlug = $productSlug; + + return $this; + } + + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @deprecated use withName() instead + * @return $this + */ + public function withNameBuilder(?LocalizedStringBuilder $name) + { + $this->name = $name; + + return $this; + } + + /** + * @deprecated use withProductType() instead + * @return $this + */ + public function withProductTypeBuilder(?ProductTypeReferenceBuilder $productType) + { + $this->productType = $productType; + + return $this; + } + + /** + * @deprecated use withVariant() instead + * @return $this + */ + public function withVariantBuilder(?ProductVariantBuilder $variant) + { + $this->variant = $variant; + + return $this; + } + + /** + * @deprecated use withProductSlug() instead + * @return $this + */ + public function withProductSlugBuilder(?LocalizedStringBuilder $productSlug) + { + $this->productSlug = $productSlug; + + return $this; + } + + public function build(): ShoppingListLineItem + { + return new ShoppingListLineItemModel( + $this->addedAt, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, + $this->deactivatedAt, + $this->id, + $this->key, + $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name, + $this->productId, + $this->productType instanceof ProductTypeReferenceBuilder ? $this->productType->build() : $this->productType, + $this->published, + $this->quantity, + $this->variantId, + $this->variant instanceof ProductVariantBuilder ? $this->variant->build() : $this->variant, + $this->productSlug instanceof LocalizedStringBuilder ? $this->productSlug->build() : $this->productSlug + ); + } + + public static function of(): ShoppingListLineItemBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShoppingListLineItemCollection.php b/lib/commercetools-history/src/Models/Common/ShoppingListLineItemCollection.php new file mode 100644 index 00000000000..f12ccced7b3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShoppingListLineItemCollection.php @@ -0,0 +1,56 @@ + + * @method ShoppingListLineItem current() + * @method ShoppingListLineItem end() + * @method ShoppingListLineItem at($offset) + */ +class ShoppingListLineItemCollection extends MapperSequence +{ + /** + * @psalm-assert ShoppingListLineItem $value + * @psalm-param ShoppingListLineItem|stdClass $value + * @throws InvalidArgumentException + * + * @return ShoppingListLineItemCollection + */ + public function add($value) + { + if (!$value instanceof ShoppingListLineItem) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ShoppingListLineItem + */ + protected function mapper() + { + return function (?int $index): ?ShoppingListLineItem { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ShoppingListLineItem $data */ + $data = ShoppingListLineItemModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/ShoppingListLineItemModel.php b/lib/commercetools-history/src/Models/Common/ShoppingListLineItemModel.php new file mode 100644 index 00000000000..9836d5b6158 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/ShoppingListLineItemModel.php @@ -0,0 +1,536 @@ +addedAt = $addedAt; + $this->custom = $custom; + $this->deactivatedAt = $deactivatedAt; + $this->id = $id; + $this->key = $key; + $this->name = $name; + $this->productId = $productId; + $this->productType = $productType; + $this->published = $published; + $this->quantity = $quantity; + $this->variantId = $variantId; + $this->variant = $variant; + $this->productSlug = $productSlug; + + } + + /** + *

                                                                                                                            Date and time (UTC) the ShoppingListLineItem was added to the ShoppingList.

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

                                                                                                                            Custom Fields of the ShoppingListLineItem.

                                                                                                                            + * + * + * @return null|CustomFields + */ + public function getCustom() + { + if (is_null($this->custom)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($data)) { + return null; + } + + $this->custom = CustomFieldsModel::of($data); + } + + return $this->custom; + } + + /** + *

                                                                                                                            If the Product or Product Variant is deleted, deactivatedAt is the date and time (UTC) of deletion.

                                                                                                                            + *

                                                                                                                            This data is updated in an eventual consistent manner when the Product Variant cannot be ordered anymore.

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

                                                                                                                            Unique identifier of the ShoppingListLineItem.

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

                                                                                                                            User-defined identifier of the ShoppingListLineItem. It is unique per ShoppingList.

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

                                                                                                                            Name of the Product.

                                                                                                                            + *

                                                                                                                            This data is updated in an eventual consistent manner when the Product's name changes.

                                                                                                                            + * + * + * @return null|LocalizedString + */ + public function getName() + { + if (is_null($this->name)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_NAME); + if (is_null($data)) { + return null; + } + + $this->name = LocalizedStringModel::of($data); + } + + return $this->name; + } + + /** + *

                                                                                                                            Unique identifier of a Product.

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

                                                                                                                            The Product Type defining the Attributes of the Product.

                                                                                                                            + * + * + * @return null|ProductTypeReference + */ + public function getProductType() + { + if (is_null($this->productType)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PRODUCT_TYPE); + if (is_null($data)) { + return null; + } + + $this->productType = ProductTypeReferenceModel::of($data); + } + + return $this->productType; + } + + /** + *

                                                                                                                            Whether the related Product is published or not.

                                                                                                                            + *

                                                                                                                            This data is updated in an eventual consistent manner when the Product's published status changes.

                                                                                                                            + * + * + * @return null|bool + */ + public function getPublished() + { + if (is_null($this->published)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_PUBLISHED); + if (is_null($data)) { + return null; + } + $this->published = (bool) $data; + } + + return $this->published; + } + + /** + *

                                                                                                                            Number of Products in the ShoppingListLineItem.

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

                                                                                                                            id of the ProductVariant the ShoppingListLineItem refers to. If not set, the ShoppingListLineItem refers to the Master Variant.

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

                                                                                                                            Data of the ProductVariant. This data includes all the Product Attributes and Variant Attributes to ensure the full Attribute context of the Product Variant.

                                                                                                                            + *

                                                                                                                            Returned when expanded using expand=lineItems[*].variant. You cannot expand only a single element of the array.

                                                                                                                            + * + * + * @return null|ProductVariant + */ + public function getVariant() + { + if (is_null($this->variant)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_VARIANT); + if (is_null($data)) { + return null; + } + + $this->variant = ProductVariantModel::of($data); + } + + return $this->variant; + } + + /** + *

                                                                                                                            Slug of the current ProductData.

                                                                                                                            + *

                                                                                                                            Returned when expanded using expand=lineItems[*].productSlug. You cannot expand only a single element of the array.

                                                                                                                            + * + * + * @return null|LocalizedString + */ + public function getProductSlug() + { + if (is_null($this->productSlug)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_PRODUCT_SLUG); + if (is_null($data)) { + return null; + } + + $this->productSlug = LocalizedStringModel::of($data); + } + + return $this->productSlug; + } + + + /** + * @param ?DateTimeImmutable $addedAt + */ + public function setAddedAt(?DateTimeImmutable $addedAt): void + { + $this->addedAt = $addedAt; + } + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + + /** + * @param ?DateTimeImmutable $deactivatedAt + */ + public function setDeactivatedAt(?DateTimeImmutable $deactivatedAt): void + { + $this->deactivatedAt = $deactivatedAt; + } + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?LocalizedString $name + */ + public function setName(?LocalizedString $name): void + { + $this->name = $name; + } + + /** + * @param ?string $productId + */ + public function setProductId(?string $productId): void + { + $this->productId = $productId; + } + + /** + * @param ?ProductTypeReference $productType + */ + public function setProductType(?ProductTypeReference $productType): void + { + $this->productType = $productType; + } + + /** + * @param ?bool $published + */ + public function setPublished(?bool $published): void + { + $this->published = $published; + } + + /** + * @param ?int $quantity + */ + public function setQuantity(?int $quantity): void + { + $this->quantity = $quantity; + } + + /** + * @param ?int $variantId + */ + public function setVariantId(?int $variantId): void + { + $this->variantId = $variantId; + } + + /** + * @param ?ProductVariant $variant + */ + public function setVariant(?ProductVariant $variant): void + { + $this->variant = $variant; + } + + /** + * @param ?LocalizedString $productSlug + */ + public function setProductSlug(?LocalizedString $productSlug): void + { + $this->productSlug = $productSlug; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[ShoppingListLineItem::FIELD_ADDED_AT]) && $data[ShoppingListLineItem::FIELD_ADDED_AT] instanceof \DateTimeImmutable) { + $data[ShoppingListLineItem::FIELD_ADDED_AT] = $data[ShoppingListLineItem::FIELD_ADDED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[ShoppingListLineItem::FIELD_DEACTIVATED_AT]) && $data[ShoppingListLineItem::FIELD_DEACTIVATED_AT] instanceof \DateTimeImmutable) { + $data[ShoppingListLineItem::FIELD_DEACTIVATED_AT] = $data[ShoppingListLineItem::FIELD_DEACTIVATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } + +} diff --git a/lib/commercetools-history/src/Models/Common/StateReference.php b/lib/commercetools-history/src/Models/Common/StateReference.php new file mode 100644 index 00000000000..b86b9b90ce3 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/StateReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced State.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/StateReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/StateReferenceBuilder.php new file mode 100644 index 00000000000..0aff2f38e65 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/StateReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class StateReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced State.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): StateReference + { + return new StateReferenceModel( + $this->id + ); + } + + public static function of(): StateReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/StateReferenceCollection.php b/lib/commercetools-history/src/Models/Common/StateReferenceCollection.php new file mode 100644 index 00000000000..51664b37a3d --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/StateReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method StateReference current() + * @method StateReference end() + * @method StateReference at($offset) + */ +class StateReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert StateReference $value + * @psalm-param StateReference|stdClass $value + * @throws InvalidArgumentException + * + * @return StateReferenceCollection + */ + public function add($value) + { + if (!$value instanceof StateReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?StateReference + */ + protected function mapper() + { + return function (?int $index): ?StateReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var StateReference $data */ + $data = StateReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/StateReferenceModel.php b/lib/commercetools-history/src/Models/Common/StateReferenceModel.php new file mode 100644 index 00000000000..7c5cbe56943 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/StateReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced State.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/StoreKeyReference.php b/lib/commercetools-history/src/Models/Common/StoreKeyReference.php new file mode 100644 index 00000000000..d8f48b2e88d --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/StoreKeyReference.php @@ -0,0 +1,30 @@ +Unique and immutable key of the referenced Store.

                                                                                                                            + * + + * @return null|string + */ + public function getKey(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; +} diff --git a/lib/commercetools-history/src/Models/Common/StoreKeyReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/StoreKeyReferenceBuilder.php new file mode 100644 index 00000000000..179a764d75e --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/StoreKeyReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class StoreKeyReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + *

                                                                                                                            Unique and immutable key of the referenced Store.

                                                                                                                            + * + + * @return null|string + */ + public function getKey() + { + return $this->key; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + + public function build(): StoreKeyReference + { + return new StoreKeyReferenceModel( + $this->key + ); + } + + public static function of(): StoreKeyReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/StoreKeyReferenceCollection.php b/lib/commercetools-history/src/Models/Common/StoreKeyReferenceCollection.php new file mode 100644 index 00000000000..a42dc8ac2eb --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/StoreKeyReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method StoreKeyReference current() + * @method StoreKeyReference end() + * @method StoreKeyReference at($offset) + */ +class StoreKeyReferenceCollection extends KeyReferenceCollection +{ + /** + * @psalm-assert StoreKeyReference $value + * @psalm-param StoreKeyReference|stdClass $value + * @throws InvalidArgumentException + * + * @return StoreKeyReferenceCollection + */ + public function add($value) + { + if (!$value instanceof StoreKeyReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?StoreKeyReference + */ + protected function mapper() + { + return function (?int $index): ?StoreKeyReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var StoreKeyReference $data */ + $data = StoreKeyReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/StoreKeyReferenceModel.php b/lib/commercetools-history/src/Models/Common/StoreKeyReferenceModel.php new file mode 100644 index 00000000000..9ee9a2a940e --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/StoreKeyReferenceModel.php @@ -0,0 +1,99 @@ +key = $key; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique and immutable key of the referenced Store.

                                                                                                                            + * + * + * @return null|string + */ + public function getKey() + { + if (is_null($this->key)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_KEY); + if (is_null($data)) { + return null; + } + $this->key = (string) $data; + } + + return $this->key; + } + + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/SubRate.php b/lib/commercetools-history/src/Models/Common/SubRate.php index f03ca2e8f49..c2169fb13f8 100644 --- a/lib/commercetools-history/src/Models/Common/SubRate.php +++ b/lib/commercetools-history/src/Models/Common/SubRate.php @@ -18,6 +18,8 @@ interface SubRate extends JsonObject public const FIELD_AMOUNT = 'amount'; /** + *

                                                                                                                            Name of the SubRate.

                                                                                                                            + * * @return null|string */ @@ -25,7 +27,7 @@ public function getName(); /** - * @return null|int + * @return null|float */ public function getAmount(); @@ -35,7 +37,7 @@ public function getAmount(); public function setName(?string $name): void; /** - * @param ?int $amount + * @param ?float $amount */ - public function setAmount(?int $amount): void; + public function setAmount(?float $amount): void; } diff --git a/lib/commercetools-history/src/Models/Common/SubRateBuilder.php b/lib/commercetools-history/src/Models/Common/SubRateBuilder.php index 6ad1728820e..5695aa8707f 100644 --- a/lib/commercetools-history/src/Models/Common/SubRateBuilder.php +++ b/lib/commercetools-history/src/Models/Common/SubRateBuilder.php @@ -28,11 +28,13 @@ final class SubRateBuilder implements Builder /** - * @var ?int + * @var ?float */ private $amount; /** + *

                                                                                                                            Name of the SubRate.

                                                                                                                            + * * @return null|string */ @@ -43,7 +45,7 @@ public function getName() /** - * @return null|int + * @return null|float */ public function getAmount() { @@ -62,10 +64,10 @@ public function withName(?string $name) } /** - * @param ?int $amount + * @param ?float $amount * @return $this */ - public function withAmount(?int $amount) + public function withAmount(?float $amount) { $this->amount = $amount; diff --git a/lib/commercetools-history/src/Models/Common/SubRateModel.php b/lib/commercetools-history/src/Models/Common/SubRateModel.php index 38a0d1fc440..bbebe57db35 100644 --- a/lib/commercetools-history/src/Models/Common/SubRateModel.php +++ b/lib/commercetools-history/src/Models/Common/SubRateModel.php @@ -29,7 +29,7 @@ final class SubRateModel extends JsonObjectModel implements SubRate /** * - * @var ?int + * @var ?float */ protected $amount; @@ -39,7 +39,7 @@ final class SubRateModel extends JsonObjectModel implements SubRate */ public function __construct( ?string $name = null, - ?int $amount = null + ?float $amount = null ) { $this->name = $name; $this->amount = $amount; @@ -47,6 +47,8 @@ public function __construct( } /** + *

                                                                                                                            Name of the SubRate.

                                                                                                                            + * * * @return null|string */ @@ -66,17 +68,17 @@ public function getName() /** * - * @return null|int + * @return null|float */ public function getAmount() { if (is_null($this->amount)) { - /** @psalm-var ?int $data */ + /** @psalm-var ?float $data */ $data = $this->raw(self::FIELD_AMOUNT); if (is_null($data)) { return null; } - $this->amount = (int) $data; + $this->amount = (float) $data; } return $this->amount; @@ -92,9 +94,9 @@ public function setName(?string $name): void } /** - * @param ?int $amount + * @param ?float $amount */ - public function setAmount(?int $amount): void + public function setAmount(?float $amount): void { $this->amount = $amount; } diff --git a/lib/commercetools-history/src/Models/Common/SyncInfo.php b/lib/commercetools-history/src/Models/Common/SyncInfo.php index bf058688e70..fc26a1c3678 100644 --- a/lib/commercetools-history/src/Models/Common/SyncInfo.php +++ b/lib/commercetools-history/src/Models/Common/SyncInfo.php @@ -10,6 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use DateTimeImmutable; interface SyncInfo extends JsonObject { @@ -19,13 +20,15 @@ interface SyncInfo extends JsonObject public const FIELD_SYNCED_AT = 'syncedAt'; /** + *

                                                                                                                            Connection to a synchronization destination.

                                                                                                                            + * - * @return null|Reference + * @return null|ChannelReference */ public function getChannel(); /** - *

                                                                                                                            Can be used to reference an external order instance, file etc.

                                                                                                                            + *

                                                                                                                            Identifier of an external order instance, file, or other resource.

                                                                                                                            * * @return null|string @@ -33,15 +36,17 @@ public function getChannel(); public function getExternalId(); /** + *

                                                                                                                            Date and time (UTC) the information was synced.

                                                                                                                            + * - * @return null|string + * @return null|DateTimeImmutable */ public function getSyncedAt(); /** - * @param ?Reference $channel + * @param ?ChannelReference $channel */ - public function setChannel(?Reference $channel): void; + public function setChannel(?ChannelReference $channel): void; /** * @param ?string $externalId @@ -49,7 +54,7 @@ public function setChannel(?Reference $channel): void; public function setExternalId(?string $externalId): void; /** - * @param ?string $syncedAt + * @param ?DateTimeImmutable $syncedAt */ - public function setSyncedAt(?string $syncedAt): void; + public function setSyncedAt(?DateTimeImmutable $syncedAt): void; } diff --git a/lib/commercetools-history/src/Models/Common/SyncInfoBuilder.php b/lib/commercetools-history/src/Models/Common/SyncInfoBuilder.php index bdd7b3de0b1..328c05f910b 100644 --- a/lib/commercetools-history/src/Models/Common/SyncInfoBuilder.php +++ b/lib/commercetools-history/src/Models/Common/SyncInfoBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @implements Builder @@ -22,7 +23,7 @@ final class SyncInfoBuilder implements Builder { /** - * @var null|Reference|ReferenceBuilder + * @var null|ChannelReference|ChannelReferenceBuilder */ private $channel; @@ -34,21 +35,23 @@ final class SyncInfoBuilder implements Builder /** - * @var ?string + * @var ?DateTimeImmutable */ private $syncedAt; /** + *

                                                                                                                            Connection to a synchronization destination.

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

                                                                                                                            Can be used to reference an external order instance, file etc.

                                                                                                                            + *

                                                                                                                            Identifier of an external order instance, file, or other resource.

                                                                                                                            * * @return null|string @@ -59,8 +62,10 @@ public function getExternalId() } /** + *

                                                                                                                            Date and time (UTC) the information was synced.

                                                                                                                            + * - * @return null|string + * @return null|DateTimeImmutable */ public function getSyncedAt() { @@ -68,10 +73,10 @@ public function getSyncedAt() } /** - * @param ?Reference $channel + * @param ?ChannelReference $channel * @return $this */ - public function withChannel(?Reference $channel) + public function withChannel(?ChannelReference $channel) { $this->channel = $channel; @@ -90,10 +95,10 @@ public function withExternalId(?string $externalId) } /** - * @param ?string $syncedAt + * @param ?DateTimeImmutable $syncedAt * @return $this */ - public function withSyncedAt(?string $syncedAt) + public function withSyncedAt(?DateTimeImmutable $syncedAt) { $this->syncedAt = $syncedAt; @@ -104,7 +109,7 @@ public function withSyncedAt(?string $syncedAt) * @deprecated use withChannel() instead * @return $this */ - public function withChannelBuilder(?ReferenceBuilder $channel) + public function withChannelBuilder(?ChannelReferenceBuilder $channel) { $this->channel = $channel; @@ -114,7 +119,7 @@ public function withChannelBuilder(?ReferenceBuilder $channel) public function build(): SyncInfo { return new SyncInfoModel( - $this->channel instanceof ReferenceBuilder ? $this->channel->build() : $this->channel, + $this->channel instanceof ChannelReferenceBuilder ? $this->channel->build() : $this->channel, $this->externalId, $this->syncedAt ); diff --git a/lib/commercetools-history/src/Models/Common/SyncInfoModel.php b/lib/commercetools-history/src/Models/Common/SyncInfoModel.php index b46da785d94..450fe76f6b8 100644 --- a/lib/commercetools-history/src/Models/Common/SyncInfoModel.php +++ b/lib/commercetools-history/src/Models/Common/SyncInfoModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @internal @@ -23,7 +24,7 @@ final class SyncInfoModel extends JsonObjectModel implements SyncInfo /** * - * @var ?Reference + * @var ?ChannelReference */ protected $channel; @@ -35,7 +36,7 @@ final class SyncInfoModel extends JsonObjectModel implements SyncInfo /** * - * @var ?string + * @var ?DateTimeImmutable */ protected $syncedAt; @@ -44,9 +45,9 @@ final class SyncInfoModel extends JsonObjectModel implements SyncInfo * @psalm-suppress MissingParamType */ public function __construct( - ?Reference $channel = null, + ?ChannelReference $channel = null, ?string $externalId = null, - ?string $syncedAt = null + ?DateTimeImmutable $syncedAt = null ) { $this->channel = $channel; $this->externalId = $externalId; @@ -55,8 +56,10 @@ public function __construct( } /** + *

                                                                                                                            Connection to a synchronization destination.

                                                                                                                            + * * - * @return null|Reference + * @return null|ChannelReference */ public function getChannel() { @@ -67,14 +70,14 @@ public function getChannel() return null; } - $this->channel = ReferenceModel::of($data); + $this->channel = ChannelReferenceModel::of($data); } return $this->channel; } /** - *

                                                                                                                            Can be used to reference an external order instance, file etc.

                                                                                                                            + *

                                                                                                                            Identifier of an external order instance, file, or other resource.

                                                                                                                            * * * @return null|string @@ -94,8 +97,10 @@ public function getExternalId() } /** + *

                                                                                                                            Date and time (UTC) the information was synced.

                                                                                                                            * - * @return null|string + * + * @return null|DateTimeImmutable */ public function getSyncedAt() { @@ -105,7 +110,11 @@ public function getSyncedAt() if (is_null($data)) { return null; } - $this->syncedAt = (string) $data; + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->syncedAt = $data; } return $this->syncedAt; @@ -113,9 +122,9 @@ public function getSyncedAt() /** - * @param ?Reference $channel + * @param ?ChannelReference $channel */ - public function setChannel(?Reference $channel): void + public function setChannel(?ChannelReference $channel): void { $this->channel = $channel; } @@ -129,13 +138,22 @@ public function setExternalId(?string $externalId): void } /** - * @param ?string $syncedAt + * @param ?DateTimeImmutable $syncedAt */ - public function setSyncedAt(?string $syncedAt): void + public function setSyncedAt(?DateTimeImmutable $syncedAt): void { $this->syncedAt = $syncedAt; } + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[SyncInfo::FIELD_SYNCED_AT]) && $data[SyncInfo::FIELD_SYNCED_AT] instanceof \DateTimeImmutable) { + $data[SyncInfo::FIELD_SYNCED_AT] = $data[SyncInfo::FIELD_SYNCED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } } diff --git a/lib/commercetools-history/src/Models/Common/TaxCategoryReference.php b/lib/commercetools-history/src/Models/Common/TaxCategoryReference.php new file mode 100644 index 00000000000..a5d719a2d2e --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TaxCategoryReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced TaxCategory.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/TaxCategoryReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/TaxCategoryReferenceBuilder.php new file mode 100644 index 00000000000..04fbe48ca80 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TaxCategoryReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class TaxCategoryReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced TaxCategory.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): TaxCategoryReference + { + return new TaxCategoryReferenceModel( + $this->id + ); + } + + public static function of(): TaxCategoryReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/TaxCategoryReferenceCollection.php b/lib/commercetools-history/src/Models/Common/TaxCategoryReferenceCollection.php new file mode 100644 index 00000000000..13a13566f26 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TaxCategoryReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method TaxCategoryReference current() + * @method TaxCategoryReference end() + * @method TaxCategoryReference at($offset) + */ +class TaxCategoryReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert TaxCategoryReference $value + * @psalm-param TaxCategoryReference|stdClass $value + * @throws InvalidArgumentException + * + * @return TaxCategoryReferenceCollection + */ + public function add($value) + { + if (!$value instanceof TaxCategoryReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?TaxCategoryReference + */ + protected function mapper() + { + return function (?int $index): ?TaxCategoryReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var TaxCategoryReference $data */ + $data = TaxCategoryReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/TaxCategoryReferenceModel.php b/lib/commercetools-history/src/Models/Common/TaxCategoryReferenceModel.php new file mode 100644 index 00000000000..e460517ff97 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TaxCategoryReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced TaxCategory.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/TaxPortion.php b/lib/commercetools-history/src/Models/Common/TaxPortion.php new file mode 100644 index 00000000000..310c4fda7d9 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TaxPortion.php @@ -0,0 +1,59 @@ +Name of the tax portion.

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

                                                                                                                            A number in the range 0-1.

                                                                                                                            + * + + * @return null|float + */ + public function getRate(); + + /** + *

                                                                                                                            Money value of the tax portion.

                                                                                                                            + * + + * @return null|CentPrecisionMoney + */ + public function getAmount(); + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param ?float $rate + */ + public function setRate(?float $rate): void; + + /** + * @param ?CentPrecisionMoney $amount + */ + public function setAmount(?CentPrecisionMoney $amount): void; +} diff --git a/lib/commercetools-history/src/Models/Common/TaxPortionBuilder.php b/lib/commercetools-history/src/Models/Common/TaxPortionBuilder.php new file mode 100644 index 00000000000..7e4e080f257 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TaxPortionBuilder.php @@ -0,0 +1,131 @@ + + */ +final class TaxPortionBuilder implements Builder +{ + /** + + * @var ?string + */ + private $name; + + /** + + * @var ?float + */ + private $rate; + + /** + + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder + */ + private $amount; + + /** + *

                                                                                                                            Name of the tax portion.

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

                                                                                                                            A number in the range 0-1.

                                                                                                                            + * + + * @return null|float + */ + public function getRate() + { + return $this->rate; + } + + /** + *

                                                                                                                            Money value of the tax portion.

                                                                                                                            + * + + * @return null|CentPrecisionMoney + */ + public function getAmount() + { + return $this->amount instanceof CentPrecisionMoneyBuilder ? $this->amount->build() : $this->amount; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + /** + * @param ?float $rate + * @return $this + */ + public function withRate(?float $rate) + { + $this->rate = $rate; + + return $this; + } + + /** + * @param ?CentPrecisionMoney $amount + * @return $this + */ + public function withAmount(?CentPrecisionMoney $amount) + { + $this->amount = $amount; + + return $this; + } + + /** + * @deprecated use withAmount() instead + * @return $this + */ + public function withAmountBuilder(?CentPrecisionMoneyBuilder $amount) + { + $this->amount = $amount; + + return $this; + } + + public function build(): TaxPortion + { + return new TaxPortionModel( + $this->name, + $this->rate, + $this->amount instanceof CentPrecisionMoneyBuilder ? $this->amount->build() : $this->amount + ); + } + + public static function of(): TaxPortionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/TaxPortionCollection.php b/lib/commercetools-history/src/Models/Common/TaxPortionCollection.php new file mode 100644 index 00000000000..b42ebfd082a --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TaxPortionCollection.php @@ -0,0 +1,56 @@ + + * @method TaxPortion current() + * @method TaxPortion end() + * @method TaxPortion at($offset) + */ +class TaxPortionCollection extends MapperSequence +{ + /** + * @psalm-assert TaxPortion $value + * @psalm-param TaxPortion|stdClass $value + * @throws InvalidArgumentException + * + * @return TaxPortionCollection + */ + public function add($value) + { + if (!$value instanceof TaxPortion) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?TaxPortion + */ + protected function mapper() + { + return function (?int $index): ?TaxPortion { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var TaxPortion $data */ + $data = TaxPortionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/TaxPortionModel.php b/lib/commercetools-history/src/Models/Common/TaxPortionModel.php new file mode 100644 index 00000000000..aac13a2f899 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TaxPortionModel.php @@ -0,0 +1,145 @@ +name = $name; + $this->rate = $rate; + $this->amount = $amount; + + } + + /** + *

                                                                                                                            Name of the tax portion.

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

                                                                                                                            A number in the range 0-1.

                                                                                                                            + * + * + * @return null|float + */ + public function getRate() + { + if (is_null($this->rate)) { + /** @psalm-var ?float $data */ + $data = $this->raw(self::FIELD_RATE); + if (is_null($data)) { + return null; + } + $this->rate = (float) $data; + } + + return $this->rate; + } + + /** + *

                                                                                                                            Money value of the tax portion.

                                                                                                                            + * + * + * @return null|CentPrecisionMoney + */ + public function getAmount() + { + if (is_null($this->amount)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_AMOUNT); + if (is_null($data)) { + return null; + } + + $this->amount = CentPrecisionMoneyModel::of($data); + } + + return $this->amount; + } + + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param ?float $rate + */ + public function setRate(?float $rate): void + { + $this->rate = $rate; + } + + /** + * @param ?CentPrecisionMoney $amount + */ + public function setAmount(?CentPrecisionMoney $amount): void + { + $this->amount = $amount; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/TaxRate.php b/lib/commercetools-history/src/Models/Common/TaxRate.php index 559e68041f1..38fa457d3bf 100644 --- a/lib/commercetools-history/src/Models/Common/TaxRate.php +++ b/lib/commercetools-history/src/Models/Common/TaxRate.php @@ -15,6 +15,7 @@ interface TaxRate extends JsonObject { public const FIELD_ID = 'id'; + public const FIELD_KEY = 'key'; public const FIELD_NAME = 'name'; public const FIELD_AMOUNT = 'amount'; public const FIELD_INCLUDED_IN_PRICE = 'includedInPrice'; @@ -23,7 +24,8 @@ interface TaxRate extends JsonObject public const FIELD_SUB_RATES = 'subRates'; /** - *

                                                                                                                            The ID is always set if the tax rate is part of a TaxCategory. The external tax rates in a Cart do not contain an id.

                                                                                                                            + *

                                                                                                                            Present if the TaxRate is part of a TaxCategory. + * Absent for external TaxRates in LineItem, CustomLineItem, and ShippingInfo.

                                                                                                                            * * @return null|string @@ -31,27 +33,40 @@ interface TaxRate extends JsonObject public function getId(); /** + *

                                                                                                                            User-defined unique identifier of the TaxRate. + * Present when set using TaxRateDraft. Not available for external TaxRates created using ExternalTaxRateDraft.

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

                                                                                                                            Name of the TaxRate.

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

                                                                                                                            Percentage in the range of [0..1]. The sum of the amounts of all subRates, if there are any.

                                                                                                                            + *

                                                                                                                            Tax rate. If subrates are used, the amount is the sum of all rates in subRates.

                                                                                                                            * - * @return null|int + * @return null|float */ public function getAmount(); /** + *

                                                                                                                            If true, tax is included in Embedded Prices or Standalone Prices, and the taxedPrice is present on LineItems. In this case, the totalNet price on TaxedPrice includes the TaxRate.

                                                                                                                            + * * @return null|bool */ public function getIncludedInPrice(); /** - *

                                                                                                                            Two-digit country code as per ISO 3166-1 alpha-2.

                                                                                                                            + *

                                                                                                                            Country in which the tax rate is applied in ISO 3166-1 alpha-2 format.

                                                                                                                            * * @return null|string @@ -59,7 +74,7 @@ public function getIncludedInPrice(); public function getCountry(); /** - *

                                                                                                                            The state in the country

                                                                                                                            + *

                                                                                                                            State within the country, such as Texas in the United States.

                                                                                                                            * * @return null|string @@ -67,6 +82,9 @@ public function getCountry(); public function getState(); /** + *

                                                                                                                            Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. + * These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

                                                                                                                            + * * @return null|SubRateCollection */ @@ -77,15 +95,20 @@ public function getSubRates(); */ public function setId(?string $id): void; + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + /** * @param ?string $name */ public function setName(?string $name): void; /** - * @param ?int $amount + * @param ?float $amount */ - public function setAmount(?int $amount): void; + public function setAmount(?float $amount): void; /** * @param ?bool $includedInPrice diff --git a/lib/commercetools-history/src/Models/Common/TaxRateBuilder.php b/lib/commercetools-history/src/Models/Common/TaxRateBuilder.php index 78d9d1021c6..8f1f3d68600 100644 --- a/lib/commercetools-history/src/Models/Common/TaxRateBuilder.php +++ b/lib/commercetools-history/src/Models/Common/TaxRateBuilder.php @@ -26,6 +26,12 @@ final class TaxRateBuilder implements Builder */ private $id; + /** + + * @var ?string + */ + private $key; + /** * @var ?string @@ -34,7 +40,7 @@ final class TaxRateBuilder implements Builder /** - * @var ?int + * @var ?float */ private $amount; @@ -63,7 +69,8 @@ final class TaxRateBuilder implements Builder private $subRates; /** - *

                                                                                                                            The ID is always set if the tax rate is part of a TaxCategory. The external tax rates in a Cart do not contain an id.

                                                                                                                            + *

                                                                                                                            Present if the TaxRate is part of a TaxCategory. + * Absent for external TaxRates in LineItem, CustomLineItem, and ShippingInfo.

                                                                                                                            * * @return null|string @@ -74,6 +81,20 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the TaxRate. + * Present when set using TaxRateDraft. Not available for external TaxRates created using ExternalTaxRateDraft.

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

                                                                                                                            Name of the TaxRate.

                                                                                                                            + * * @return null|string */ @@ -83,10 +104,10 @@ public function getName() } /** - *

                                                                                                                            Percentage in the range of [0..1]. The sum of the amounts of all subRates, if there are any.

                                                                                                                            + *

                                                                                                                            Tax rate. If subrates are used, the amount is the sum of all rates in subRates.

                                                                                                                            * - * @return null|int + * @return null|float */ public function getAmount() { @@ -94,6 +115,8 @@ public function getAmount() } /** + *

                                                                                                                            If true, tax is included in Embedded Prices or Standalone Prices, and the taxedPrice is present on LineItems. In this case, the totalNet price on TaxedPrice includes the TaxRate.

                                                                                                                            + * * @return null|bool */ @@ -103,7 +126,7 @@ public function getIncludedInPrice() } /** - *

                                                                                                                            Two-digit country code as per ISO 3166-1 alpha-2.

                                                                                                                            + *

                                                                                                                            Country in which the tax rate is applied in ISO 3166-1 alpha-2 format.

                                                                                                                            * * @return null|string @@ -114,7 +137,7 @@ public function getCountry() } /** - *

                                                                                                                            The state in the country

                                                                                                                            + *

                                                                                                                            State within the country, such as Texas in the United States.

                                                                                                                            * * @return null|string @@ -125,6 +148,9 @@ public function getState() } /** + *

                                                                                                                            Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. + * These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

                                                                                                                            + * * @return null|SubRateCollection */ @@ -144,6 +170,17 @@ public function withId(?string $id) return $this; } + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + /** * @param ?string $name * @return $this @@ -156,10 +193,10 @@ public function withName(?string $name) } /** - * @param ?int $amount + * @param ?float $amount * @return $this */ - public function withAmount(?int $amount) + public function withAmount(?float $amount) { $this->amount = $amount; @@ -215,6 +252,7 @@ public function build(): TaxRate { return new TaxRateModel( $this->id, + $this->key, $this->name, $this->amount, $this->includedInPrice, diff --git a/lib/commercetools-history/src/Models/Common/TaxRateModel.php b/lib/commercetools-history/src/Models/Common/TaxRateModel.php index 63b05ca90f0..0951eb469c7 100644 --- a/lib/commercetools-history/src/Models/Common/TaxRateModel.php +++ b/lib/commercetools-history/src/Models/Common/TaxRateModel.php @@ -27,6 +27,12 @@ final class TaxRateModel extends JsonObjectModel implements TaxRate */ protected $id; + /** + * + * @var ?string + */ + protected $key; + /** * * @var ?string @@ -35,7 +41,7 @@ final class TaxRateModel extends JsonObjectModel implements TaxRate /** * - * @var ?int + * @var ?float */ protected $amount; @@ -69,14 +75,16 @@ final class TaxRateModel extends JsonObjectModel implements TaxRate */ public function __construct( ?string $id = null, + ?string $key = null, ?string $name = null, - ?int $amount = null, + ?float $amount = null, ?bool $includedInPrice = null, ?string $country = null, ?string $state = null, ?SubRateCollection $subRates = null ) { $this->id = $id; + $this->key = $key; $this->name = $name; $this->amount = $amount; $this->includedInPrice = $includedInPrice; @@ -87,7 +95,8 @@ public function __construct( } /** - *

                                                                                                                            The ID is always set if the tax rate is part of a TaxCategory. The external tax rates in a Cart do not contain an id.

                                                                                                                            + *

                                                                                                                            Present if the TaxRate is part of a TaxCategory. + * Absent for external TaxRates in LineItem, CustomLineItem, and ShippingInfo.

                                                                                                                            * * * @return null|string @@ -107,6 +116,29 @@ public function getId() } /** + *

                                                                                                                            User-defined unique identifier of the TaxRate. + * Present when set using TaxRateDraft. Not available for external TaxRates created using ExternalTaxRateDraft.

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

                                                                                                                            Name of the TaxRate.

                                                                                                                            + * * * @return null|string */ @@ -125,26 +157,28 @@ public function getName() } /** - *

                                                                                                                            Percentage in the range of [0..1]. The sum of the amounts of all subRates, if there are any.

                                                                                                                            + *

                                                                                                                            Tax rate. If subrates are used, the amount is the sum of all rates in subRates.

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

                                                                                                                            If true, tax is included in Embedded Prices or Standalone Prices, and the taxedPrice is present on LineItems. In this case, the totalNet price on TaxedPrice includes the TaxRate.

                                                                                                                            + * * * @return null|bool */ @@ -163,7 +197,7 @@ public function getIncludedInPrice() } /** - *

                                                                                                                            Two-digit country code as per ISO 3166-1 alpha-2.

                                                                                                                            + *

                                                                                                                            Country in which the tax rate is applied in ISO 3166-1 alpha-2 format.

                                                                                                                            * * * @return null|string @@ -183,7 +217,7 @@ public function getCountry() } /** - *

                                                                                                                            The state in the country

                                                                                                                            + *

                                                                                                                            State within the country, such as Texas in the United States.

                                                                                                                            * * * @return null|string @@ -203,6 +237,9 @@ public function getState() } /** + *

                                                                                                                            Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. + * These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

                                                                                                                            + * * * @return null|SubRateCollection */ @@ -229,6 +266,14 @@ public function setId(?string $id): void $this->id = $id; } + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + /** * @param ?string $name */ @@ -238,9 +283,9 @@ public function setName(?string $name): void } /** - * @param ?int $amount + * @param ?float $amount */ - public function setAmount(?int $amount): void + public function setAmount(?float $amount): void { $this->amount = $amount; } diff --git a/lib/commercetools-history/src/Models/Common/TaxedItemPrice.php b/lib/commercetools-history/src/Models/Common/TaxedItemPrice.php index 6d871e057ae..081b3e6e0e7 100644 --- a/lib/commercetools-history/src/Models/Common/TaxedItemPrice.php +++ b/lib/commercetools-history/src/Models/Common/TaxedItemPrice.php @@ -16,26 +16,60 @@ interface TaxedItemPrice extends JsonObject public const FIELD_TOTAL_NET = 'totalNet'; public const FIELD_TOTAL_GROSS = 'totalGross'; + public const FIELD_TAX_PORTIONS = 'taxPortions'; + public const FIELD_TOTAL_TAX = 'totalTax'; /** + *

                                                                                                                            Total net amount of the Line Item or Custom Line Item.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalNet(); /** + *

                                                                                                                            Total gross amount of the Line Item or Custom Line Item.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalGross(); /** - * @param ?Money $totalNet + *

                                                                                                                            Taxable portions added to the total net price.

                                                                                                                            + *

                                                                                                                            Calculated from the TaxRates.

                                                                                                                            + * + + * @return null|TaxPortionCollection + */ + public function getTaxPortions(); + + /** + *

                                                                                                                            Total tax applicable for the Line Item or Custom Line Item. + * Automatically calculated as the difference between the totalGross and totalNet values.

                                                                                                                            + * + + * @return null|CentPrecisionMoney + */ + public function getTotalTax(); + + /** + * @param ?CentPrecisionMoney $totalNet + */ + public function setTotalNet(?CentPrecisionMoney $totalNet): void; + + /** + * @param ?CentPrecisionMoney $totalGross + */ + public function setTotalGross(?CentPrecisionMoney $totalGross): void; + + /** + * @param ?TaxPortionCollection $taxPortions */ - public function setTotalNet(?Money $totalNet): void; + public function setTaxPortions(?TaxPortionCollection $taxPortions): void; /** - * @param ?Money $totalGross + * @param ?CentPrecisionMoney $totalTax */ - public function setTotalGross(?Money $totalGross): void; + public function setTotalTax(?CentPrecisionMoney $totalTax): void; } diff --git a/lib/commercetools-history/src/Models/Common/TaxedItemPriceBuilder.php b/lib/commercetools-history/src/Models/Common/TaxedItemPriceBuilder.php index efa37ae519a..e999de4b692 100644 --- a/lib/commercetools-history/src/Models/Common/TaxedItemPriceBuilder.php +++ b/lib/commercetools-history/src/Models/Common/TaxedItemPriceBuilder.php @@ -22,39 +22,79 @@ final class TaxedItemPriceBuilder implements Builder { /** - * @var null|Money|MoneyBuilder + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder */ private $totalNet; /** - * @var null|Money|MoneyBuilder + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder */ private $totalGross; /** - * @return null|Money + * @var ?TaxPortionCollection + */ + private $taxPortions; + + /** + + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder + */ + private $totalTax; + + /** + *

                                                                                                                            Total net amount of the Line Item or Custom Line Item.

                                                                                                                            + * + + * @return null|CentPrecisionMoney */ public function getTotalNet() { - return $this->totalNet instanceof MoneyBuilder ? $this->totalNet->build() : $this->totalNet; + return $this->totalNet instanceof CentPrecisionMoneyBuilder ? $this->totalNet->build() : $this->totalNet; } /** + *

                                                                                                                            Total gross amount of the Line Item or Custom Line Item.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalGross() { - return $this->totalGross instanceof MoneyBuilder ? $this->totalGross->build() : $this->totalGross; + return $this->totalGross instanceof CentPrecisionMoneyBuilder ? $this->totalGross->build() : $this->totalGross; + } + + /** + *

                                                                                                                            Taxable portions added to the total net price.

                                                                                                                            + *

                                                                                                                            Calculated from the TaxRates.

                                                                                                                            + * + + * @return null|TaxPortionCollection + */ + public function getTaxPortions() + { + return $this->taxPortions; } /** - * @param ?Money $totalNet + *

                                                                                                                            Total tax applicable for the Line Item or Custom Line Item. + * Automatically calculated as the difference between the totalGross and totalNet values.

                                                                                                                            + * + + * @return null|CentPrecisionMoney + */ + public function getTotalTax() + { + return $this->totalTax instanceof CentPrecisionMoneyBuilder ? $this->totalTax->build() : $this->totalTax; + } + + /** + * @param ?CentPrecisionMoney $totalNet * @return $this */ - public function withTotalNet(?Money $totalNet) + public function withTotalNet(?CentPrecisionMoney $totalNet) { $this->totalNet = $totalNet; @@ -62,21 +102,43 @@ public function withTotalNet(?Money $totalNet) } /** - * @param ?Money $totalGross + * @param ?CentPrecisionMoney $totalGross * @return $this */ - public function withTotalGross(?Money $totalGross) + public function withTotalGross(?CentPrecisionMoney $totalGross) { $this->totalGross = $totalGross; return $this; } + /** + * @param ?TaxPortionCollection $taxPortions + * @return $this + */ + public function withTaxPortions(?TaxPortionCollection $taxPortions) + { + $this->taxPortions = $taxPortions; + + return $this; + } + + /** + * @param ?CentPrecisionMoney $totalTax + * @return $this + */ + public function withTotalTax(?CentPrecisionMoney $totalTax) + { + $this->totalTax = $totalTax; + + return $this; + } + /** * @deprecated use withTotalNet() instead * @return $this */ - public function withTotalNetBuilder(?MoneyBuilder $totalNet) + public function withTotalNetBuilder(?CentPrecisionMoneyBuilder $totalNet) { $this->totalNet = $totalNet; @@ -87,18 +149,31 @@ public function withTotalNetBuilder(?MoneyBuilder $totalNet) * @deprecated use withTotalGross() instead * @return $this */ - public function withTotalGrossBuilder(?MoneyBuilder $totalGross) + public function withTotalGrossBuilder(?CentPrecisionMoneyBuilder $totalGross) { $this->totalGross = $totalGross; return $this; } + /** + * @deprecated use withTotalTax() instead + * @return $this + */ + public function withTotalTaxBuilder(?CentPrecisionMoneyBuilder $totalTax) + { + $this->totalTax = $totalTax; + + return $this; + } + public function build(): TaxedItemPrice { return new TaxedItemPriceModel( - $this->totalNet instanceof MoneyBuilder ? $this->totalNet->build() : $this->totalNet, - $this->totalGross instanceof MoneyBuilder ? $this->totalGross->build() : $this->totalGross + $this->totalNet instanceof CentPrecisionMoneyBuilder ? $this->totalNet->build() : $this->totalNet, + $this->totalGross instanceof CentPrecisionMoneyBuilder ? $this->totalGross->build() : $this->totalGross, + $this->taxPortions, + $this->totalTax instanceof CentPrecisionMoneyBuilder ? $this->totalTax->build() : $this->totalTax ); } diff --git a/lib/commercetools-history/src/Models/Common/TaxedItemPriceModel.php b/lib/commercetools-history/src/Models/Common/TaxedItemPriceModel.php index 3e22863f6da..c263ef6bf14 100644 --- a/lib/commercetools-history/src/Models/Common/TaxedItemPriceModel.php +++ b/lib/commercetools-history/src/Models/Common/TaxedItemPriceModel.php @@ -23,32 +23,50 @@ final class TaxedItemPriceModel extends JsonObjectModel implements TaxedItemPric /** * - * @var ?Money + * @var ?CentPrecisionMoney */ protected $totalNet; /** * - * @var ?Money + * @var ?CentPrecisionMoney */ protected $totalGross; + /** + * + * @var ?TaxPortionCollection + */ + protected $taxPortions; + + /** + * + * @var ?CentPrecisionMoney + */ + protected $totalTax; + /** * @psalm-suppress MissingParamType */ public function __construct( - ?Money $totalNet = null, - ?Money $totalGross = null + ?CentPrecisionMoney $totalNet = null, + ?CentPrecisionMoney $totalGross = null, + ?TaxPortionCollection $taxPortions = null, + ?CentPrecisionMoney $totalTax = null ) { $this->totalNet = $totalNet; $this->totalGross = $totalGross; + $this->taxPortions = $taxPortions; + $this->totalTax = $totalTax; } /** + *

                                                                                                                            Total net amount of the Line Item or Custom Line Item.

                                                                                                                            + * * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalNet() { @@ -59,15 +77,17 @@ public function getTotalNet() return null; } - $this->totalNet = MoneyModel::of($data); + $this->totalNet = CentPrecisionMoneyModel::of($data); } return $this->totalNet; } /** + *

                                                                                                                            Total gross amount of the Line Item or Custom Line Item.

                                                                                                                            * - * @return null|Money + * + * @return null|CentPrecisionMoney */ public function getTotalGross() { @@ -78,29 +98,88 @@ public function getTotalGross() return null; } - $this->totalGross = MoneyModel::of($data); + $this->totalGross = CentPrecisionMoneyModel::of($data); } return $this->totalGross; } + /** + *

                                                                                                                            Taxable portions added to the total net price.

                                                                                                                            + *

                                                                                                                            Calculated from the TaxRates.

                                                                                                                            + * + * + * @return null|TaxPortionCollection + */ + public function getTaxPortions() + { + if (is_null($this->taxPortions)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_TAX_PORTIONS); + if (is_null($data)) { + return null; + } + $this->taxPortions = TaxPortionCollection::fromArray($data); + } + + return $this->taxPortions; + } + + /** + *

                                                                                                                            Total tax applicable for the Line Item or Custom Line Item. + * Automatically calculated as the difference between the totalGross and totalNet values.

                                                                                                                            + * + * + * @return null|CentPrecisionMoney + */ + public function getTotalTax() + { + if (is_null($this->totalTax)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TOTAL_TAX); + if (is_null($data)) { + return null; + } + + $this->totalTax = CentPrecisionMoneyModel::of($data); + } + + return $this->totalTax; + } + /** - * @param ?Money $totalNet + * @param ?CentPrecisionMoney $totalNet */ - public function setTotalNet(?Money $totalNet): void + public function setTotalNet(?CentPrecisionMoney $totalNet): void { $this->totalNet = $totalNet; } /** - * @param ?Money $totalGross + * @param ?CentPrecisionMoney $totalGross */ - public function setTotalGross(?Money $totalGross): void + public function setTotalGross(?CentPrecisionMoney $totalGross): void { $this->totalGross = $totalGross; } + /** + * @param ?TaxPortionCollection $taxPortions + */ + public function setTaxPortions(?TaxPortionCollection $taxPortions): void + { + $this->taxPortions = $taxPortions; + } + + /** + * @param ?CentPrecisionMoney $totalTax + */ + public function setTotalTax(?CentPrecisionMoney $totalTax): void + { + $this->totalTax = $totalTax; + } + } diff --git a/lib/commercetools-history/src/Models/Common/TaxedPrice.php b/lib/commercetools-history/src/Models/Common/TaxedPrice.php index 8e366898108..a46c9a1948a 100644 --- a/lib/commercetools-history/src/Models/Common/TaxedPrice.php +++ b/lib/commercetools-history/src/Models/Common/TaxedPrice.php @@ -16,30 +16,60 @@ interface TaxedPrice extends JsonObject public const FIELD_TOTAL_NET = 'totalNet'; public const FIELD_TOTAL_GROSS = 'totalGross'; + public const FIELD_TAX_PORTIONS = 'taxPortions'; + public const FIELD_TOTAL_TAX = 'totalTax'; /** - *

                                                                                                                            Total net price of the Order.

                                                                                                                            + *

                                                                                                                            Total net price of the Cart or Order.

                                                                                                                            * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalNet(); /** - *

                                                                                                                            Total gross price of the Order.

                                                                                                                            + *

                                                                                                                            Total gross price of the Cart or Order.

                                                                                                                            * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalGross(); /** - * @param ?Money $totalNet + *

                                                                                                                            Taxable portions added to the total net price.

                                                                                                                            + *

                                                                                                                            Calculated from the TaxRates.

                                                                                                                            + * + + * @return null|TaxPortionCollection + */ + public function getTaxPortions(); + + /** + *

                                                                                                                            Total tax applicable for the Cart or Order.

                                                                                                                            + *

                                                                                                                            Automatically calculated as the difference between the totalGross and totalNet values.

                                                                                                                            + * + + * @return null|CentPrecisionMoney + */ + public function getTotalTax(); + + /** + * @param ?CentPrecisionMoney $totalNet + */ + public function setTotalNet(?CentPrecisionMoney $totalNet): void; + + /** + * @param ?CentPrecisionMoney $totalGross + */ + public function setTotalGross(?CentPrecisionMoney $totalGross): void; + + /** + * @param ?TaxPortionCollection $taxPortions */ - public function setTotalNet(?Money $totalNet): void; + public function setTaxPortions(?TaxPortionCollection $taxPortions): void; /** - * @param ?Money $totalGross + * @param ?CentPrecisionMoney $totalTax */ - public function setTotalGross(?Money $totalGross): void; + public function setTotalTax(?CentPrecisionMoney $totalTax): void; } diff --git a/lib/commercetools-history/src/Models/Common/TaxedPriceBuilder.php b/lib/commercetools-history/src/Models/Common/TaxedPriceBuilder.php index e5a0bdf33a7..162d0215898 100644 --- a/lib/commercetools-history/src/Models/Common/TaxedPriceBuilder.php +++ b/lib/commercetools-history/src/Models/Common/TaxedPriceBuilder.php @@ -22,43 +22,79 @@ final class TaxedPriceBuilder implements Builder { /** - * @var null|Money|MoneyBuilder + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder */ private $totalNet; /** - * @var null|Money|MoneyBuilder + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder */ private $totalGross; /** - *

                                                                                                                            Total net price of the Order.

                                                                                                                            + + * @var ?TaxPortionCollection + */ + private $taxPortions; + + /** + + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder + */ + private $totalTax; + + /** + *

                                                                                                                            Total net price of the Cart or Order.

                                                                                                                            * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalNet() { - return $this->totalNet instanceof MoneyBuilder ? $this->totalNet->build() : $this->totalNet; + return $this->totalNet instanceof CentPrecisionMoneyBuilder ? $this->totalNet->build() : $this->totalNet; } /** - *

                                                                                                                            Total gross price of the Order.

                                                                                                                            + *

                                                                                                                            Total gross price of the Cart or Order.

                                                                                                                            * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalGross() { - return $this->totalGross instanceof MoneyBuilder ? $this->totalGross->build() : $this->totalGross; + return $this->totalGross instanceof CentPrecisionMoneyBuilder ? $this->totalGross->build() : $this->totalGross; } /** - * @param ?Money $totalNet + *

                                                                                                                            Taxable portions added to the total net price.

                                                                                                                            + *

                                                                                                                            Calculated from the TaxRates.

                                                                                                                            + * + + * @return null|TaxPortionCollection + */ + public function getTaxPortions() + { + return $this->taxPortions; + } + + /** + *

                                                                                                                            Total tax applicable for the Cart or Order.

                                                                                                                            + *

                                                                                                                            Automatically calculated as the difference between the totalGross and totalNet values.

                                                                                                                            + * + + * @return null|CentPrecisionMoney + */ + public function getTotalTax() + { + return $this->totalTax instanceof CentPrecisionMoneyBuilder ? $this->totalTax->build() : $this->totalTax; + } + + /** + * @param ?CentPrecisionMoney $totalNet * @return $this */ - public function withTotalNet(?Money $totalNet) + public function withTotalNet(?CentPrecisionMoney $totalNet) { $this->totalNet = $totalNet; @@ -66,21 +102,43 @@ public function withTotalNet(?Money $totalNet) } /** - * @param ?Money $totalGross + * @param ?CentPrecisionMoney $totalGross * @return $this */ - public function withTotalGross(?Money $totalGross) + public function withTotalGross(?CentPrecisionMoney $totalGross) { $this->totalGross = $totalGross; return $this; } + /** + * @param ?TaxPortionCollection $taxPortions + * @return $this + */ + public function withTaxPortions(?TaxPortionCollection $taxPortions) + { + $this->taxPortions = $taxPortions; + + return $this; + } + + /** + * @param ?CentPrecisionMoney $totalTax + * @return $this + */ + public function withTotalTax(?CentPrecisionMoney $totalTax) + { + $this->totalTax = $totalTax; + + return $this; + } + /** * @deprecated use withTotalNet() instead * @return $this */ - public function withTotalNetBuilder(?MoneyBuilder $totalNet) + public function withTotalNetBuilder(?CentPrecisionMoneyBuilder $totalNet) { $this->totalNet = $totalNet; @@ -91,18 +149,31 @@ public function withTotalNetBuilder(?MoneyBuilder $totalNet) * @deprecated use withTotalGross() instead * @return $this */ - public function withTotalGrossBuilder(?MoneyBuilder $totalGross) + public function withTotalGrossBuilder(?CentPrecisionMoneyBuilder $totalGross) { $this->totalGross = $totalGross; return $this; } + /** + * @deprecated use withTotalTax() instead + * @return $this + */ + public function withTotalTaxBuilder(?CentPrecisionMoneyBuilder $totalTax) + { + $this->totalTax = $totalTax; + + return $this; + } + public function build(): TaxedPrice { return new TaxedPriceModel( - $this->totalNet instanceof MoneyBuilder ? $this->totalNet->build() : $this->totalNet, - $this->totalGross instanceof MoneyBuilder ? $this->totalGross->build() : $this->totalGross + $this->totalNet instanceof CentPrecisionMoneyBuilder ? $this->totalNet->build() : $this->totalNet, + $this->totalGross instanceof CentPrecisionMoneyBuilder ? $this->totalGross->build() : $this->totalGross, + $this->taxPortions, + $this->totalTax instanceof CentPrecisionMoneyBuilder ? $this->totalTax->build() : $this->totalTax ); } diff --git a/lib/commercetools-history/src/Models/Common/TaxedPriceModel.php b/lib/commercetools-history/src/Models/Common/TaxedPriceModel.php index dda0db621ac..ddeb91ad42d 100644 --- a/lib/commercetools-history/src/Models/Common/TaxedPriceModel.php +++ b/lib/commercetools-history/src/Models/Common/TaxedPriceModel.php @@ -23,34 +23,50 @@ final class TaxedPriceModel extends JsonObjectModel implements TaxedPrice /** * - * @var ?Money + * @var ?CentPrecisionMoney */ protected $totalNet; /** * - * @var ?Money + * @var ?CentPrecisionMoney */ protected $totalGross; + /** + * + * @var ?TaxPortionCollection + */ + protected $taxPortions; + + /** + * + * @var ?CentPrecisionMoney + */ + protected $totalTax; + /** * @psalm-suppress MissingParamType */ public function __construct( - ?Money $totalNet = null, - ?Money $totalGross = null + ?CentPrecisionMoney $totalNet = null, + ?CentPrecisionMoney $totalGross = null, + ?TaxPortionCollection $taxPortions = null, + ?CentPrecisionMoney $totalTax = null ) { $this->totalNet = $totalNet; $this->totalGross = $totalGross; + $this->taxPortions = $taxPortions; + $this->totalTax = $totalTax; } /** - *

                                                                                                                            Total net price of the Order.

                                                                                                                            + *

                                                                                                                            Total net price of the Cart or Order.

                                                                                                                            * * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalNet() { @@ -61,17 +77,17 @@ public function getTotalNet() return null; } - $this->totalNet = MoneyModel::of($data); + $this->totalNet = CentPrecisionMoneyModel::of($data); } return $this->totalNet; } /** - *

                                                                                                                            Total gross price of the Order.

                                                                                                                            + *

                                                                                                                            Total gross price of the Cart or Order.

                                                                                                                            * * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getTotalGross() { @@ -82,29 +98,88 @@ public function getTotalGross() return null; } - $this->totalGross = MoneyModel::of($data); + $this->totalGross = CentPrecisionMoneyModel::of($data); } return $this->totalGross; } + /** + *

                                                                                                                            Taxable portions added to the total net price.

                                                                                                                            + *

                                                                                                                            Calculated from the TaxRates.

                                                                                                                            + * + * + * @return null|TaxPortionCollection + */ + public function getTaxPortions() + { + if (is_null($this->taxPortions)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_TAX_PORTIONS); + if (is_null($data)) { + return null; + } + $this->taxPortions = TaxPortionCollection::fromArray($data); + } + + return $this->taxPortions; + } + + /** + *

                                                                                                                            Total tax applicable for the Cart or Order.

                                                                                                                            + *

                                                                                                                            Automatically calculated as the difference between the totalGross and totalNet values.

                                                                                                                            + * + * + * @return null|CentPrecisionMoney + */ + public function getTotalTax() + { + if (is_null($this->totalTax)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_TOTAL_TAX); + if (is_null($data)) { + return null; + } + + $this->totalTax = CentPrecisionMoneyModel::of($data); + } + + return $this->totalTax; + } + /** - * @param ?Money $totalNet + * @param ?CentPrecisionMoney $totalNet */ - public function setTotalNet(?Money $totalNet): void + public function setTotalNet(?CentPrecisionMoney $totalNet): void { $this->totalNet = $totalNet; } /** - * @param ?Money $totalGross + * @param ?CentPrecisionMoney $totalGross */ - public function setTotalGross(?Money $totalGross): void + public function setTotalGross(?CentPrecisionMoney $totalGross): void { $this->totalGross = $totalGross; } + /** + * @param ?TaxPortionCollection $taxPortions + */ + public function setTaxPortions(?TaxPortionCollection $taxPortions): void + { + $this->taxPortions = $taxPortions; + } + + /** + * @param ?CentPrecisionMoney $totalTax + */ + public function setTotalTax(?CentPrecisionMoney $totalTax): void + { + $this->totalTax = $totalTax; + } + } diff --git a/lib/commercetools-history/src/Models/Common/TextLineItem.php b/lib/commercetools-history/src/Models/Common/TextLineItem.php index 42ffa4970af..c1cb29f9a82 100644 --- a/lib/commercetools-history/src/Models/Common/TextLineItem.php +++ b/lib/commercetools-history/src/Models/Common/TextLineItem.php @@ -10,6 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use DateTimeImmutable; interface TextLineItem extends JsonObject { @@ -18,49 +19,70 @@ interface TextLineItem extends JsonObject public const FIELD_CUSTOM = 'custom'; public const FIELD_DESCRIPTION = 'description'; public const FIELD_ID = 'id'; + public const FIELD_KEY = 'key'; public const FIELD_NAME = 'name'; public const FIELD_QUANTITY = 'quantity'; /** + *

                                                                                                                            Date and time (UTC) the TextLineItem was added to the ShoppingList.

                                                                                                                            + * - * @return null|string + * @return null|DateTimeImmutable */ public function getAddedAt(); /** + *

                                                                                                                            Custom Fields of the TextLineItem.

                                                                                                                            + * * @return null|CustomFields */ public function getCustom(); /** + *

                                                                                                                            Description of the TextLineItem.

                                                                                                                            + * * @return null|LocalizedString */ public function getDescription(); /** + *

                                                                                                                            Unique identifier of the TextLineItem.

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

                                                                                                                            User-defined identifier of the TextLineItem. It is unique per ShoppingList.

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

                                                                                                                            Name of the TextLineItem.

                                                                                                                            + * * @return null|LocalizedString */ public function getName(); /** + *

                                                                                                                            Number of entries in the TextLineItem.

                                                                                                                            + * * @return null|int */ public function getQuantity(); /** - * @param ?string $addedAt + * @param ?DateTimeImmutable $addedAt */ - public function setAddedAt(?string $addedAt): void; + public function setAddedAt(?DateTimeImmutable $addedAt): void; /** * @param ?CustomFields $custom @@ -77,6 +99,11 @@ public function setDescription(?LocalizedString $description): void; */ public function setId(?string $id): void; + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + /** * @param ?LocalizedString $name */ diff --git a/lib/commercetools-history/src/Models/Common/TextLineItemBuilder.php b/lib/commercetools-history/src/Models/Common/TextLineItemBuilder.php index b779bf6224e..89ca4f0f0d0 100644 --- a/lib/commercetools-history/src/Models/Common/TextLineItemBuilder.php +++ b/lib/commercetools-history/src/Models/Common/TextLineItemBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @implements Builder @@ -22,7 +23,7 @@ final class TextLineItemBuilder implements Builder { /** - * @var ?string + * @var ?DateTimeImmutable */ private $addedAt; @@ -44,6 +45,12 @@ final class TextLineItemBuilder implements Builder */ private $id; + /** + + * @var ?string + */ + private $key; + /** * @var null|LocalizedString|LocalizedStringBuilder @@ -57,8 +64,10 @@ final class TextLineItemBuilder implements Builder private $quantity; /** + *

                                                                                                                            Date and time (UTC) the TextLineItem was added to the ShoppingList.

                                                                                                                            + * - * @return null|string + * @return null|DateTimeImmutable */ public function getAddedAt() { @@ -66,6 +75,8 @@ public function getAddedAt() } /** + *

                                                                                                                            Custom Fields of the TextLineItem.

                                                                                                                            + * * @return null|CustomFields */ @@ -75,6 +86,8 @@ public function getCustom() } /** + *

                                                                                                                            Description of the TextLineItem.

                                                                                                                            + * * @return null|LocalizedString */ @@ -84,6 +97,8 @@ public function getDescription() } /** + *

                                                                                                                            Unique identifier of the TextLineItem.

                                                                                                                            + * * @return null|string */ @@ -93,6 +108,19 @@ public function getId() } /** + *

                                                                                                                            User-defined identifier of the TextLineItem. It is unique per ShoppingList.

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

                                                                                                                            Name of the TextLineItem.

                                                                                                                            + * * @return null|LocalizedString */ @@ -102,6 +130,8 @@ public function getName() } /** + *

                                                                                                                            Number of entries in the TextLineItem.

                                                                                                                            + * * @return null|int */ @@ -111,10 +141,10 @@ public function getQuantity() } /** - * @param ?string $addedAt + * @param ?DateTimeImmutable $addedAt * @return $this */ - public function withAddedAt(?string $addedAt) + public function withAddedAt(?DateTimeImmutable $addedAt) { $this->addedAt = $addedAt; @@ -154,6 +184,17 @@ public function withId(?string $id) return $this; } + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + /** * @param ?LocalizedString $name * @return $this @@ -216,6 +257,7 @@ public function build(): TextLineItem $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description, $this->id, + $this->key, $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name, $this->quantity ); diff --git a/lib/commercetools-history/src/Models/Common/TextLineItemModel.php b/lib/commercetools-history/src/Models/Common/TextLineItemModel.php index da89a4f67f7..039df8d7ad1 100644 --- a/lib/commercetools-history/src/Models/Common/TextLineItemModel.php +++ b/lib/commercetools-history/src/Models/Common/TextLineItemModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @internal @@ -23,7 +24,7 @@ final class TextLineItemModel extends JsonObjectModel implements TextLineItem /** * - * @var ?string + * @var ?DateTimeImmutable */ protected $addedAt; @@ -45,6 +46,12 @@ final class TextLineItemModel extends JsonObjectModel implements TextLineItem */ protected $id; + /** + * + * @var ?string + */ + protected $key; + /** * * @var ?LocalizedString @@ -62,10 +69,11 @@ final class TextLineItemModel extends JsonObjectModel implements TextLineItem * @psalm-suppress MissingParamType */ public function __construct( - ?string $addedAt = null, + ?DateTimeImmutable $addedAt = null, ?CustomFields $custom = null, ?LocalizedString $description = null, ?string $id = null, + ?string $key = null, ?LocalizedString $name = null, ?int $quantity = null ) { @@ -73,14 +81,17 @@ public function __construct( $this->custom = $custom; $this->description = $description; $this->id = $id; + $this->key = $key; $this->name = $name; $this->quantity = $quantity; } /** + *

                                                                                                                            Date and time (UTC) the TextLineItem was added to the ShoppingList.

                                                                                                                            * - * @return null|string + * + * @return null|DateTimeImmutable */ public function getAddedAt() { @@ -90,13 +101,19 @@ public function getAddedAt() if (is_null($data)) { return null; } - $this->addedAt = (string) $data; + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->addedAt = $data; } return $this->addedAt; } /** + *

                                                                                                                            Custom Fields of the TextLineItem.

                                                                                                                            + * * * @return null|CustomFields */ @@ -116,6 +133,8 @@ public function getCustom() } /** + *

                                                                                                                            Description of the TextLineItem.

                                                                                                                            + * * * @return null|LocalizedString */ @@ -135,6 +154,8 @@ public function getDescription() } /** + *

                                                                                                                            Unique identifier of the TextLineItem.

                                                                                                                            + * * * @return null|string */ @@ -153,6 +174,28 @@ public function getId() } /** + *

                                                                                                                            User-defined identifier of the TextLineItem. It is unique per ShoppingList.

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

                                                                                                                            Name of the TextLineItem.

                                                                                                                            + * * * @return null|LocalizedString */ @@ -172,6 +215,8 @@ public function getName() } /** + *

                                                                                                                            Number of entries in the TextLineItem.

                                                                                                                            + * * * @return null|int */ @@ -191,9 +236,9 @@ public function getQuantity() /** - * @param ?string $addedAt + * @param ?DateTimeImmutable $addedAt */ - public function setAddedAt(?string $addedAt): void + public function setAddedAt(?DateTimeImmutable $addedAt): void { $this->addedAt = $addedAt; } @@ -222,6 +267,14 @@ public function setId(?string $id): void $this->id = $id; } + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + /** * @param ?LocalizedString $name */ @@ -239,5 +292,14 @@ public function setQuantity(?int $quantity): void } + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[TextLineItem::FIELD_ADDED_AT]) && $data[TextLineItem::FIELD_ADDED_AT] instanceof \DateTimeImmutable) { + $data[TextLineItem::FIELD_ADDED_AT] = $data[TextLineItem::FIELD_ADDED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } } diff --git a/lib/commercetools-history/src/Models/Common/TrackingData.php b/lib/commercetools-history/src/Models/Common/TrackingData.php index f27a22fa38a..12edf523c35 100644 --- a/lib/commercetools-history/src/Models/Common/TrackingData.php +++ b/lib/commercetools-history/src/Models/Common/TrackingData.php @@ -21,7 +21,7 @@ interface TrackingData extends JsonObject public const FIELD_IS_RETURN = 'isReturn'; /** - *

                                                                                                                            The ID to track one parcel.

                                                                                                                            + *

                                                                                                                            Identifier to track the Parcel.

                                                                                                                            * * @return null|string @@ -29,7 +29,7 @@ interface TrackingData extends JsonObject public function getTrackingId(); /** - *

                                                                                                                            The carrier that delivers the parcel.

                                                                                                                            + *

                                                                                                                            Name of the carrier that delivers the Parcel.

                                                                                                                            * * @return null|string @@ -37,19 +37,26 @@ public function getTrackingId(); public function getCarrier(); /** + *

                                                                                                                            Name of the provider that serves as facade to several carriers.

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

                                                                                                                            Transaction identifier with the provider.

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

                                                                                                                            Flag to distinguish if the parcel is on the way to the customer (false) or on the way back (true).

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • If true, the Parcel is being returned.
                                                                                                                            • + *
                                                                                                                            • If false, the Parcel is being delivered to the customer.
                                                                                                                            • + *
                                                                                                                            * * @return null|bool diff --git a/lib/commercetools-history/src/Models/Common/TrackingDataBuilder.php b/lib/commercetools-history/src/Models/Common/TrackingDataBuilder.php index c9d0adc5806..8d583c75fb2 100644 --- a/lib/commercetools-history/src/Models/Common/TrackingDataBuilder.php +++ b/lib/commercetools-history/src/Models/Common/TrackingDataBuilder.php @@ -51,7 +51,7 @@ final class TrackingDataBuilder implements Builder private $isReturn; /** - *

                                                                                                                            The ID to track one parcel.

                                                                                                                            + *

                                                                                                                            Identifier to track the Parcel.

                                                                                                                            * * @return null|string @@ -62,7 +62,7 @@ public function getTrackingId() } /** - *

                                                                                                                            The carrier that delivers the parcel.

                                                                                                                            + *

                                                                                                                            Name of the carrier that delivers the Parcel.

                                                                                                                            * * @return null|string @@ -73,6 +73,8 @@ public function getCarrier() } /** + *

                                                                                                                            Name of the provider that serves as facade to several carriers.

                                                                                                                            + * * @return null|string */ @@ -82,6 +84,8 @@ public function getProvider() } /** + *

                                                                                                                            Transaction identifier with the provider.

                                                                                                                            + * * @return null|string */ @@ -91,7 +95,10 @@ public function getProviderTransaction() } /** - *

                                                                                                                            Flag to distinguish if the parcel is on the way to the customer (false) or on the way back (true).

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • If true, the Parcel is being returned.
                                                                                                                            • + *
                                                                                                                            • If false, the Parcel is being delivered to the customer.
                                                                                                                            • + *
                                                                                                                            * * @return null|bool diff --git a/lib/commercetools-history/src/Models/Common/TrackingDataModel.php b/lib/commercetools-history/src/Models/Common/TrackingDataModel.php index 3726e7863c9..f3f9bfcfd07 100644 --- a/lib/commercetools-history/src/Models/Common/TrackingDataModel.php +++ b/lib/commercetools-history/src/Models/Common/TrackingDataModel.php @@ -71,7 +71,7 @@ public function __construct( } /** - *

                                                                                                                            The ID to track one parcel.

                                                                                                                            + *

                                                                                                                            Identifier to track the Parcel.

                                                                                                                            * * * @return null|string @@ -91,7 +91,7 @@ public function getTrackingId() } /** - *

                                                                                                                            The carrier that delivers the parcel.

                                                                                                                            + *

                                                                                                                            Name of the carrier that delivers the Parcel.

                                                                                                                            * * * @return null|string @@ -111,6 +111,8 @@ public function getCarrier() } /** + *

                                                                                                                            Name of the provider that serves as facade to several carriers.

                                                                                                                            + * * * @return null|string */ @@ -129,6 +131,8 @@ public function getProvider() } /** + *

                                                                                                                            Transaction identifier with the provider.

                                                                                                                            + * * * @return null|string */ @@ -147,7 +151,10 @@ public function getProviderTransaction() } /** - *

                                                                                                                            Flag to distinguish if the parcel is on the way to the customer (false) or on the way back (true).

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • If true, the Parcel is being returned.
                                                                                                                            • + *
                                                                                                                            • If false, the Parcel is being delivered to the customer.
                                                                                                                            • + *
                                                                                                                            * * * @return null|bool diff --git a/lib/commercetools-history/src/Models/Common/Transaction.php b/lib/commercetools-history/src/Models/Common/Transaction.php index 28bde7ef0be..fe9ea31a92e 100644 --- a/lib/commercetools-history/src/Models/Common/Transaction.php +++ b/lib/commercetools-history/src/Models/Common/Transaction.php @@ -10,6 +10,7 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; +use DateTimeImmutable; interface Transaction extends JsonObject { @@ -20,6 +21,7 @@ interface Transaction extends JsonObject public const FIELD_AMOUNT = 'amount'; public const FIELD_INTERACTION_ID = 'interactionId'; public const FIELD_STATE = 'state'; + public const FIELD_CUSTOM = 'custom'; /** *

                                                                                                                            Unique identifier of the Transaction.

                                                                                                                            @@ -30,27 +32,32 @@ interface Transaction extends JsonObject public function getId(); /** - *

                                                                                                                            Time at which the transaction took place.

                                                                                                                            + *

                                                                                                                            Date and time (UTC) the Transaction took place.

                                                                                                                            * - * @return null|string + * @return null|DateTimeImmutable */ public function getTimestamp(); /** + *

                                                                                                                            Type of the Transaction. For example, Authorization.

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

                                                                                                                            Money value of the Transaction.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getAmount(); /** - *

                                                                                                                            Identifier used by the interface that manages the transaction (usually the PSP). If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction should be findable with this ID.

                                                                                                                            + *

                                                                                                                            Identifier used by the interface that manages the Transaction (usually the PSP). + * If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction can be found with this ID.

                                                                                                                            * * @return null|string @@ -58,20 +65,30 @@ public function getAmount(); public function getInteractionId(); /** + *

                                                                                                                            State of the Transaction.

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

                                                                                                                            Custom Fields defined for the Transaction.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom(); + /** * @param ?string $id */ public function setId(?string $id): void; /** - * @param ?string $timestamp + * @param ?DateTimeImmutable $timestamp */ - public function setTimestamp(?string $timestamp): void; + public function setTimestamp(?DateTimeImmutable $timestamp): void; /** * @param ?string $type @@ -79,9 +96,9 @@ public function setTimestamp(?string $timestamp): void; public function setType(?string $type): void; /** - * @param ?Money $amount + * @param ?CentPrecisionMoney $amount */ - public function setAmount(?Money $amount): void; + public function setAmount(?CentPrecisionMoney $amount): void; /** * @param ?string $interactionId @@ -92,4 +109,9 @@ public function setInteractionId(?string $interactionId): void; * @param ?string $state */ public function setState(?string $state): void; + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void; } diff --git a/lib/commercetools-history/src/Models/Common/TransactionBuilder.php b/lib/commercetools-history/src/Models/Common/TransactionBuilder.php index 56c085ed2dc..46f2be45793 100644 --- a/lib/commercetools-history/src/Models/Common/TransactionBuilder.php +++ b/lib/commercetools-history/src/Models/Common/TransactionBuilder.php @@ -14,6 +14,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @implements Builder @@ -28,7 +29,7 @@ final class TransactionBuilder implements Builder /** - * @var ?string + * @var ?DateTimeImmutable */ private $timestamp; @@ -40,7 +41,7 @@ final class TransactionBuilder implements Builder /** - * @var null|Money|MoneyBuilder + * @var null|CentPrecisionMoney|CentPrecisionMoneyBuilder */ private $amount; @@ -56,6 +57,12 @@ final class TransactionBuilder implements Builder */ private $state; + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + /** *

                                                                                                                            Unique identifier of the Transaction.

                                                                                                                            * @@ -68,10 +75,10 @@ public function getId() } /** - *

                                                                                                                            Time at which the transaction took place.

                                                                                                                            + *

                                                                                                                            Date and time (UTC) the Transaction took place.

                                                                                                                            * - * @return null|string + * @return null|DateTimeImmutable */ public function getTimestamp() { @@ -79,6 +86,8 @@ public function getTimestamp() } /** + *

                                                                                                                            Type of the Transaction. For example, Authorization.

                                                                                                                            + * * @return null|string */ @@ -88,16 +97,19 @@ public function getType() } /** + *

                                                                                                                            Money value of the Transaction.

                                                                                                                            + * - * @return null|Money + * @return null|CentPrecisionMoney */ public function getAmount() { - return $this->amount instanceof MoneyBuilder ? $this->amount->build() : $this->amount; + return $this->amount instanceof CentPrecisionMoneyBuilder ? $this->amount->build() : $this->amount; } /** - *

                                                                                                                            Identifier used by the interface that manages the transaction (usually the PSP). If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction should be findable with this ID.

                                                                                                                            + *

                                                                                                                            Identifier used by the interface that manages the Transaction (usually the PSP). + * If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction can be found with this ID.

                                                                                                                            * * @return null|string @@ -108,6 +120,8 @@ public function getInteractionId() } /** + *

                                                                                                                            State of the Transaction.

                                                                                                                            + * * @return null|string */ @@ -116,6 +130,17 @@ public function getState() return $this->state; } + /** + *

                                                                                                                            Custom Fields defined for the Transaction.

                                                                                                                            + * + + * @return null|CustomFields + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom; + } + /** * @param ?string $id * @return $this @@ -128,10 +153,10 @@ public function withId(?string $id) } /** - * @param ?string $timestamp + * @param ?DateTimeImmutable $timestamp * @return $this */ - public function withTimestamp(?string $timestamp) + public function withTimestamp(?DateTimeImmutable $timestamp) { $this->timestamp = $timestamp; @@ -150,10 +175,10 @@ public function withType(?string $type) } /** - * @param ?Money $amount + * @param ?CentPrecisionMoney $amount * @return $this */ - public function withAmount(?Money $amount) + public function withAmount(?CentPrecisionMoney $amount) { $this->amount = $amount; @@ -182,26 +207,49 @@ public function withState(?string $state) return $this; } + /** + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) + { + $this->custom = $custom; + + return $this; + } + /** * @deprecated use withAmount() instead * @return $this */ - public function withAmountBuilder(?MoneyBuilder $amount) + public function withAmountBuilder(?CentPrecisionMoneyBuilder $amount) { $this->amount = $amount; return $this; } + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + return $this; + } + public function build(): Transaction { return new TransactionModel( $this->id, $this->timestamp, $this->type, - $this->amount instanceof MoneyBuilder ? $this->amount->build() : $this->amount, + $this->amount instanceof CentPrecisionMoneyBuilder ? $this->amount->build() : $this->amount, $this->interactionId, - $this->state + $this->state, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom ); } diff --git a/lib/commercetools-history/src/Models/Common/TransactionModel.php b/lib/commercetools-history/src/Models/Common/TransactionModel.php index 49fc5d858a7..aa26d8a8f3e 100644 --- a/lib/commercetools-history/src/Models/Common/TransactionModel.php +++ b/lib/commercetools-history/src/Models/Common/TransactionModel.php @@ -13,6 +13,7 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; +use DateTimeImmutable; /** * @internal @@ -29,7 +30,7 @@ final class TransactionModel extends JsonObjectModel implements Transaction /** * - * @var ?string + * @var ?DateTimeImmutable */ protected $timestamp; @@ -41,7 +42,7 @@ final class TransactionModel extends JsonObjectModel implements Transaction /** * - * @var ?Money + * @var ?CentPrecisionMoney */ protected $amount; @@ -57,17 +58,24 @@ final class TransactionModel extends JsonObjectModel implements Transaction */ protected $state; + /** + * + * @var ?CustomFields + */ + protected $custom; + /** * @psalm-suppress MissingParamType */ public function __construct( ?string $id = null, - ?string $timestamp = null, + ?DateTimeImmutable $timestamp = null, ?string $type = null, - ?Money $amount = null, + ?CentPrecisionMoney $amount = null, ?string $interactionId = null, - ?string $state = null + ?string $state = null, + ?CustomFields $custom = null ) { $this->id = $id; $this->timestamp = $timestamp; @@ -75,6 +83,7 @@ public function __construct( $this->amount = $amount; $this->interactionId = $interactionId; $this->state = $state; + $this->custom = $custom; } @@ -99,10 +108,10 @@ public function getId() } /** - *

                                                                                                                            Time at which the transaction took place.

                                                                                                                            + *

                                                                                                                            Date and time (UTC) the Transaction took place.

                                                                                                                            * * - * @return null|string + * @return null|DateTimeImmutable */ public function getTimestamp() { @@ -112,13 +121,19 @@ public function getTimestamp() if (is_null($data)) { return null; } - $this->timestamp = (string) $data; + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->timestamp = $data; } return $this->timestamp; } /** + *

                                                                                                                            Type of the Transaction. For example, Authorization.

                                                                                                                            + * * * @return null|string */ @@ -137,8 +152,10 @@ public function getType() } /** + *

                                                                                                                            Money value of the Transaction.

                                                                                                                            * - * @return null|Money + * + * @return null|CentPrecisionMoney */ public function getAmount() { @@ -149,14 +166,15 @@ public function getAmount() return null; } - $this->amount = MoneyModel::of($data); + $this->amount = CentPrecisionMoneyModel::of($data); } return $this->amount; } /** - *

                                                                                                                            Identifier used by the interface that manages the transaction (usually the PSP). If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction should be findable with this ID.

                                                                                                                            + *

                                                                                                                            Identifier used by the interface that manages the Transaction (usually the PSP). + * If a matching interaction was logged in the interfaceInteractions array, the corresponding interaction can be found with this ID.

                                                                                                                            * * * @return null|string @@ -176,6 +194,8 @@ public function getInteractionId() } /** + *

                                                                                                                            State of the Transaction.

                                                                                                                            + * * * @return null|string */ @@ -193,6 +213,27 @@ public function getState() return $this->state; } + /** + *

                                                                                                                            Custom Fields defined for the Transaction.

                                                                                                                            + * + * + * @return null|CustomFields + */ + public function getCustom() + { + if (is_null($this->custom)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_CUSTOM); + if (is_null($data)) { + return null; + } + + $this->custom = CustomFieldsModel::of($data); + } + + return $this->custom; + } + /** * @param ?string $id @@ -203,9 +244,9 @@ public function setId(?string $id): void } /** - * @param ?string $timestamp + * @param ?DateTimeImmutable $timestamp */ - public function setTimestamp(?string $timestamp): void + public function setTimestamp(?DateTimeImmutable $timestamp): void { $this->timestamp = $timestamp; } @@ -219,9 +260,9 @@ public function setType(?string $type): void } /** - * @param ?Money $amount + * @param ?CentPrecisionMoney $amount */ - public function setAmount(?Money $amount): void + public function setAmount(?CentPrecisionMoney $amount): void { $this->amount = $amount; } @@ -242,6 +283,23 @@ public function setState(?string $state): void $this->state = $state; } + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Transaction::FIELD_TIMESTAMP]) && $data[Transaction::FIELD_TIMESTAMP] instanceof \DateTimeImmutable) { + $data[Transaction::FIELD_TIMESTAMP] = $data[Transaction::FIELD_TIMESTAMP]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } + } diff --git a/lib/commercetools-history/src/Models/Common/TypeReference.php b/lib/commercetools-history/src/Models/Common/TypeReference.php new file mode 100644 index 00000000000..1f4cd393ccf --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TypeReference.php @@ -0,0 +1,30 @@ +Unique identifier of the referenced Type.

                                                                                                                            + * + + * @return null|string + */ + public function getId(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-history/src/Models/Common/TypeReferenceBuilder.php b/lib/commercetools-history/src/Models/Common/TypeReferenceBuilder.php new file mode 100644 index 00000000000..83789622ccf --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TypeReferenceBuilder.php @@ -0,0 +1,63 @@ + + */ +final class TypeReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + *

                                                                                                                            Unique identifier of the referenced Type.

                                                                                                                            + * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + + public function build(): TypeReference + { + return new TypeReferenceModel( + $this->id + ); + } + + public static function of(): TypeReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/TypeReferenceCollection.php b/lib/commercetools-history/src/Models/Common/TypeReferenceCollection.php new file mode 100644 index 00000000000..65c71dea66e --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TypeReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method TypeReference current() + * @method TypeReference end() + * @method TypeReference at($offset) + */ +class TypeReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert TypeReference $value + * @psalm-param TypeReference|stdClass $value + * @throws InvalidArgumentException + * + * @return TypeReferenceCollection + */ + public function add($value) + { + if (!$value instanceof TypeReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?TypeReference + */ + protected function mapper() + { + return function (?int $index): ?TypeReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var TypeReference $data */ + $data = TypeReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/TypeReferenceModel.php b/lib/commercetools-history/src/Models/Common/TypeReferenceModel.php new file mode 100644 index 00000000000..0308b24f20d --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TypeReferenceModel.php @@ -0,0 +1,99 @@ +id = $id; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

                                                                                                                            Type of referenced resource.

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

                                                                                                                            Unique identifier of the referenced Type.

                                                                                                                            + * + * + * @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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + + +} diff --git a/lib/commercetools-history/src/Models/Common/TypedMoney.php b/lib/commercetools-history/src/Models/Common/TypedMoney.php new file mode 100644 index 00000000000..2acb6e3ecf0 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TypedMoney.php @@ -0,0 +1,44 @@ +Type of money used.

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

                                                                                                                            Number of digits after the decimal separator.

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • For CentPrecisionMoney, it is equal to the default number of fraction digits for a currency.
                                                                                                                            • + *
                                                                                                                            • For HighPrecisionMoney, it is greater than the default number of fraction digits for a currency.
                                                                                                                            • + *
                                                                                                                            + * + + * @return null|int + */ + public function getFractionDigits(); + + /** + * @param ?int $fractionDigits + */ + public function setFractionDigits(?int $fractionDigits): void; +} diff --git a/lib/commercetools-history/src/Models/Common/TypedMoneyBuilder.php b/lib/commercetools-history/src/Models/Common/TypedMoneyBuilder.php new file mode 100644 index 00000000000..ebd8ee83c39 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TypedMoneyBuilder.php @@ -0,0 +1,129 @@ + + */ +final class TypedMoneyBuilder implements Builder +{ + /** + + * @var ?int + */ + private $centAmount; + + /** + + * @var ?string + */ + private $currencyCode; + + /** + + * @var ?int + */ + private $fractionDigits; + + /** + *

                                                                                                                            Amount in the smallest indivisible unit of a currency, such as:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as 500).
                                                                                                                            • + *
                                                                                                                            • The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as 5).
                                                                                                                            • + *
                                                                                                                            + * + + * @return null|int + */ + public function getCentAmount() + { + return $this->centAmount; + } + + /** + *

                                                                                                                            Currency code compliant to ISO 4217.

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

                                                                                                                            Number of digits after the decimal separator.

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • For CentPrecisionMoney, it is equal to the default number of fraction digits for a currency.
                                                                                                                            • + *
                                                                                                                            • For HighPrecisionMoney, it is greater than the default number of fraction digits for a currency.
                                                                                                                            • + *
                                                                                                                            + * + + * @return null|int + */ + public function getFractionDigits() + { + return $this->fractionDigits; + } + + /** + * @param ?int $centAmount + * @return $this + */ + public function withCentAmount(?int $centAmount) + { + $this->centAmount = $centAmount; + + return $this; + } + + /** + * @param ?string $currencyCode + * @return $this + */ + public function withCurrencyCode(?string $currencyCode) + { + $this->currencyCode = $currencyCode; + + return $this; + } + + /** + * @param ?int $fractionDigits + * @return $this + */ + public function withFractionDigits(?int $fractionDigits) + { + $this->fractionDigits = $fractionDigits; + + return $this; + } + + + public function build(): TypedMoney + { + return new TypedMoneyModel( + $this->centAmount, + $this->currencyCode, + $this->fractionDigits + ); + } + + public static function of(): TypedMoneyBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-history/src/Models/Common/TypedMoneyCollection.php b/lib/commercetools-history/src/Models/Common/TypedMoneyCollection.php new file mode 100644 index 00000000000..bb21c0a3d04 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TypedMoneyCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method TypedMoney current() + * @method TypedMoney end() + * @method TypedMoney at($offset) + */ +class TypedMoneyCollection extends MoneyCollection +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return TypedMoneyCollection + */ + public function add($value) + { + if (!$value instanceof TypedMoney) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?TypedMoney { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = TypedMoneyModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-history/src/Models/Common/TypedMoneyModel.php b/lib/commercetools-history/src/Models/Common/TypedMoneyModel.php new file mode 100644 index 00000000000..5e942a65639 --- /dev/null +++ b/lib/commercetools-history/src/Models/Common/TypedMoneyModel.php @@ -0,0 +1,213 @@ + > + * + */ + private static $discriminatorClasses = [ + 'centPrecision' => CentPrecisionMoneyModel::class, + ]; + + /** + * @psalm-suppress MissingParamType + */ + public function __construct( + ?int $centAmount = null, + ?string $currencyCode = null, + ?int $fractionDigits = null, + ?string $type = null + ) { + $this->centAmount = $centAmount; + $this->currencyCode = $currencyCode; + $this->fractionDigits = $fractionDigits; + $this->type = $type; + + } + + /** + *

                                                                                                                            Amount in the smallest indivisible unit of a currency, such as:

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as 500).
                                                                                                                            • + *
                                                                                                                            • The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as 5).
                                                                                                                            • + *
                                                                                                                            + * + * + * @return null|int + */ + public function getCentAmount() + { + if (is_null($this->centAmount)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_CENT_AMOUNT); + if (is_null($data)) { + return null; + } + $this->centAmount = (int) $data; + } + + return $this->centAmount; + } + + /** + *

                                                                                                                            Currency code compliant to ISO 4217.

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

                                                                                                                            Type of money used.

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

                                                                                                                            Number of digits after the decimal separator.

                                                                                                                            + *
                                                                                                                              + *
                                                                                                                            • For CentPrecisionMoney, it is equal to the default number of fraction digits for a currency.
                                                                                                                            • + *
                                                                                                                            • For HighPrecisionMoney, it is greater than the default number of fraction digits for a currency.
                                                                                                                            • + *
                                                                                                                            + * + * + * @return null|int + */ + public function getFractionDigits() + { + if (is_null($this->fractionDigits)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_FRACTION_DIGITS); + if (is_null($data)) { + return null; + } + $this->fractionDigits = (int) $data; + } + + return $this->fractionDigits; + } + + + /** + * @param ?int $centAmount + */ + public function setCentAmount(?int $centAmount): void + { + $this->centAmount = $centAmount; + } + + /** + * @param ?string $currencyCode + */ + public function setCurrencyCode(?string $currencyCode): void + { + $this->currencyCode = $currencyCode; + } + + /** + * @param ?int $fractionDigits + */ + public function setFractionDigits(?int $fractionDigits): void + { + $this->fractionDigits = $fractionDigits; + } + + + + /** + * @psalm-param stdClass|array $value + * @psalm-return class-string + */ + public static function resolveDiscriminatorClass($value): string + { + $fieldName = TypedMoney::DISCRIMINATOR_FIELD; + if (is_object($value) && isset($value->$fieldName)) { + /** @psalm-var string $discriminatorValue */ + $discriminatorValue = $value->$fieldName; + if (isset(self::$discriminatorClasses[$discriminatorValue])) { + return self::$discriminatorClasses[$discriminatorValue]; + } + } + if (is_array($value) && isset($value[$fieldName])) { + /** @psalm-var string $discriminatorValue */ + $discriminatorValue = $value[$fieldName]; + if (isset(self::$discriminatorClasses[$discriminatorValue])) { + return self::$discriminatorClasses[$discriminatorValue]; + } + } + + /** @psalm-var class-string */ + $type = TypedMoneyModel::class; + return $type; + } +} diff --git a/lib/commercetools-history/src/Models/Label/QuoteLabelModel.php b/lib/commercetools-history/src/Models/Label/QuoteLabelModel.php index 16c45b975ac..0c62568cbc1 100644 --- a/lib/commercetools-history/src/Models/Label/QuoteLabelModel.php +++ b/lib/commercetools-history/src/Models/Label/QuoteLabelModel.php @@ -123,8 +123,8 @@ public function getCustomer() if (is_null($data)) { return null; } - - $this->customer = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->customer = $className::of($data); } return $this->customer; @@ -144,8 +144,8 @@ public function getStagedQuote() if (is_null($data)) { return null; } - - $this->stagedQuote = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->stagedQuote = $className::of($data); } return $this->stagedQuote; @@ -165,8 +165,8 @@ public function getQuoteRequest() if (is_null($data)) { return null; } - - $this->quoteRequest = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->quoteRequest = $className::of($data); } return $this->quoteRequest; diff --git a/lib/commercetools-history/src/Models/Label/QuoteRequestLabelModel.php b/lib/commercetools-history/src/Models/Label/QuoteRequestLabelModel.php index 8d18c5eb76c..7bb153dcf95 100644 --- a/lib/commercetools-history/src/Models/Label/QuoteRequestLabelModel.php +++ b/lib/commercetools-history/src/Models/Label/QuoteRequestLabelModel.php @@ -107,8 +107,8 @@ public function getCustomer() if (is_null($data)) { return null; } - - $this->customer = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->customer = $className::of($data); } return $this->customer; diff --git a/lib/commercetools-history/src/Models/Label/StagedQuoteLabelModel.php b/lib/commercetools-history/src/Models/Label/StagedQuoteLabelModel.php index e116e479c68..81af3b69847 100644 --- a/lib/commercetools-history/src/Models/Label/StagedQuoteLabelModel.php +++ b/lib/commercetools-history/src/Models/Label/StagedQuoteLabelModel.php @@ -115,8 +115,8 @@ public function getCustomer() if (is_null($data)) { return null; } - - $this->customer = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->customer = $className::of($data); } return $this->customer; @@ -136,8 +136,8 @@ public function getQuoteRequest() if (is_null($data)) { return null; } - - $this->quoteRequest = ReferenceModel::of($data); + $className = ReferenceModel::resolveDiscriminatorClass($data); + $this->quoteRequest = $className::of($data); } return $this->quoteRequest; diff --git a/lib/commercetools-import-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php b/lib/commercetools-import-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php index ee38e9ba5b6..7ee3cda6ec6 100644 --- a/lib/commercetools-import-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php +++ b/lib/commercetools-import-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php @@ -89,6 +89,16 @@ function (ImportRequestBuilder $builder): ResourceByProjectKeyImportOperations { ['projectKey' => 'test_projectKey'], '/{projectKey}/import-operations' ], + 'ResourceByProjectKeyBusinessUnits' => [ + function (ImportRequestBuilder $builder): ResourceByProjectKeyBusinessUnits { + return $builder + ->withProjectKeyValue("test_projectKey") + ->businessUnits(); + }, + ResourceByProjectKeyBusinessUnits::class, + ['projectKey' => 'test_projectKey'], + '/{projectKey}/business-units' + ], 'ResourceByProjectKeyCategories' => [ function (ImportRequestBuilder $builder): ResourceByProjectKeyCategories { return $builder @@ -99,6 +109,26 @@ function (ImportRequestBuilder $builder): ResourceByProjectKeyCategories { ['projectKey' => 'test_projectKey'], '/{projectKey}/categories' ], + 'ResourceByProjectKeyCustomers' => [ + function (ImportRequestBuilder $builder): ResourceByProjectKeyCustomers { + return $builder + ->withProjectKeyValue("test_projectKey") + ->customers(); + }, + ResourceByProjectKeyCustomers::class, + ['projectKey' => 'test_projectKey'], + '/{projectKey}/customers' + ], + 'ResourceByProjectKeyDiscountCodes' => [ + function (ImportRequestBuilder $builder): ResourceByProjectKeyDiscountCodes { + return $builder + ->withProjectKeyValue("test_projectKey") + ->discountCodes(); + }, + ResourceByProjectKeyDiscountCodes::class, + ['projectKey' => 'test_projectKey'], + '/{projectKey}/discount-codes' + ], 'ResourceByProjectKeyPrices' => [ function (ImportRequestBuilder $builder): ResourceByProjectKeyPrices { return $builder @@ -109,15 +139,15 @@ function (ImportRequestBuilder $builder): ResourceByProjectKeyPrices { ['projectKey' => 'test_projectKey'], '/{projectKey}/prices' ], - 'ResourceByProjectKeyStandalonePrices' => [ - function (ImportRequestBuilder $builder): ResourceByProjectKeyStandalonePrices { + 'ResourceByProjectKeyInventories' => [ + function (ImportRequestBuilder $builder): ResourceByProjectKeyInventories { return $builder ->withProjectKeyValue("test_projectKey") - ->standalonePrices(); + ->inventories(); }, - ResourceByProjectKeyStandalonePrices::class, + ResourceByProjectKeyInventories::class, ['projectKey' => 'test_projectKey'], - '/{projectKey}/standalone-prices' + '/{projectKey}/inventories' ], 'ResourceByProjectKeyProducts' => [ function (ImportRequestBuilder $builder): ResourceByProjectKeyProducts { @@ -169,6 +199,16 @@ function (ImportRequestBuilder $builder): ResourceByProjectKeyProductVariantPatc ['projectKey' => 'test_projectKey'], '/{projectKey}/product-variant-patches' ], + 'ResourceByProjectKeyProductSelections' => [ + function (ImportRequestBuilder $builder): ResourceByProjectKeyProductSelections { + return $builder + ->withProjectKeyValue("test_projectKey") + ->productSelections(); + }, + ResourceByProjectKeyProductSelections::class, + ['projectKey' => 'test_projectKey'], + '/{projectKey}/product-selections' + ], 'ResourceByProjectKeyOrders' => [ function (ImportRequestBuilder $builder): ResourceByProjectKeyOrders { return $builder @@ -189,25 +229,15 @@ function (ImportRequestBuilder $builder): ResourceByProjectKeyOrderPatches { ['projectKey' => 'test_projectKey'], '/{projectKey}/order-patches' ], - 'ResourceByProjectKeyCustomers' => [ - function (ImportRequestBuilder $builder): ResourceByProjectKeyCustomers { - return $builder - ->withProjectKeyValue("test_projectKey") - ->customers(); - }, - ResourceByProjectKeyCustomers::class, - ['projectKey' => 'test_projectKey'], - '/{projectKey}/customers' - ], - 'ResourceByProjectKeyInventories' => [ - function (ImportRequestBuilder $builder): ResourceByProjectKeyInventories { + 'ResourceByProjectKeyStandalonePrices' => [ + function (ImportRequestBuilder $builder): ResourceByProjectKeyStandalonePrices { return $builder ->withProjectKeyValue("test_projectKey") - ->inventories(); + ->standalonePrices(); }, - ResourceByProjectKeyInventories::class, + ResourceByProjectKeyStandalonePrices::class, ['projectKey' => 'test_projectKey'], - '/{projectKey}/inventories' + '/{projectKey}/standalone-prices' ], 'ResourceByProjectKeyTypes' => [ function (ImportRequestBuilder $builder): ResourceByProjectKeyTypes { @@ -218,36 +248,6 @@ function (ImportRequestBuilder $builder): ResourceByProjectKeyTypes { ResourceByProjectKeyTypes::class, ['projectKey' => 'test_projectKey'], '/{projectKey}/types' - ], - 'ResourceByProjectKeyDiscountCodes' => [ - function (ImportRequestBuilder $builder): ResourceByProjectKeyDiscountCodes { - return $builder - ->withProjectKeyValue("test_projectKey") - ->discountCodes(); - }, - ResourceByProjectKeyDiscountCodes::class, - ['projectKey' => 'test_projectKey'], - '/{projectKey}/discount-codes' - ], - 'ResourceByProjectKeyProductSelections' => [ - function (ImportRequestBuilder $builder): ResourceByProjectKeyProductSelections { - return $builder - ->withProjectKeyValue("test_projectKey") - ->productSelections(); - }, - ResourceByProjectKeyProductSelections::class, - ['projectKey' => 'test_projectKey'], - '/{projectKey}/product-selections' - ], - 'ResourceByProjectKeyBusinessUnits' => [ - function (ImportRequestBuilder $builder): ResourceByProjectKeyBusinessUnits { - return $builder - ->withProjectKeyValue("test_projectKey") - ->businessUnits(); - }, - ResourceByProjectKeyBusinessUnits::class, - ['projectKey' => 'test_projectKey'], - '/{projectKey}/business-units' ] ]; } diff --git a/lib/commercetools-import/docs/RequestBuilder.md b/lib/commercetools-import/docs/RequestBuilder.md index 11b9e6443f1..d73647164a2 100644 --- a/lib/commercetools-import/docs/RequestBuilder.md +++ b/lib/commercetools-import/docs/RequestBuilder.md @@ -251,7 +251,7 @@ $request = $builder ``` ## `withProjectKeyValue("projectKey")->prices()->importContainers()->withImportContainerKeyValue("importContainerKey")->post(null)` -Creates an Import Request for Prices. +Creates an Import Request for Embedded Prices. ### Example ```php diff --git a/lib/commercetools-import/src/Client/Resource/ResourceByProjectKey.php b/lib/commercetools-import/src/Client/Resource/ResourceByProjectKey.php index 281cc6efd7e..bb9a4c605cb 100644 --- a/lib/commercetools-import/src/Client/Resource/ResourceByProjectKey.php +++ b/lib/commercetools-import/src/Client/Resource/ResourceByProjectKey.php @@ -43,130 +43,130 @@ public function importOperations(): ResourceByProjectKeyImportOperations } /** */ - public function categories(): ResourceByProjectKeyCategories + public function businessUnits(): ResourceByProjectKeyBusinessUnits { $args = $this->getArgs(); - return new ResourceByProjectKeyCategories($args, $this->getClient()); + return new ResourceByProjectKeyBusinessUnits($args, $this->getClient()); } /** */ - public function prices(): ResourceByProjectKeyPrices + public function categories(): ResourceByProjectKeyCategories { $args = $this->getArgs(); - return new ResourceByProjectKeyPrices($args, $this->getClient()); + return new ResourceByProjectKeyCategories($args, $this->getClient()); } /** */ - public function standalonePrices(): ResourceByProjectKeyStandalonePrices + public function customers(): ResourceByProjectKeyCustomers { $args = $this->getArgs(); - return new ResourceByProjectKeyStandalonePrices($args, $this->getClient()); + return new ResourceByProjectKeyCustomers($args, $this->getClient()); } /** */ - public function products(): ResourceByProjectKeyProducts + public function discountCodes(): ResourceByProjectKeyDiscountCodes { $args = $this->getArgs(); - return new ResourceByProjectKeyProducts($args, $this->getClient()); + return new ResourceByProjectKeyDiscountCodes($args, $this->getClient()); } /** */ - public function productDrafts(): ResourceByProjectKeyProductDrafts + public function prices(): ResourceByProjectKeyPrices { $args = $this->getArgs(); - return new ResourceByProjectKeyProductDrafts($args, $this->getClient()); + return new ResourceByProjectKeyPrices($args, $this->getClient()); } /** */ - public function productTypes(): ResourceByProjectKeyProductTypes + public function inventories(): ResourceByProjectKeyInventories { $args = $this->getArgs(); - return new ResourceByProjectKeyProductTypes($args, $this->getClient()); + return new ResourceByProjectKeyInventories($args, $this->getClient()); } /** */ - public function productVariants(): ResourceByProjectKeyProductVariants + public function products(): ResourceByProjectKeyProducts { $args = $this->getArgs(); - return new ResourceByProjectKeyProductVariants($args, $this->getClient()); + return new ResourceByProjectKeyProducts($args, $this->getClient()); } /** */ - public function productVariantPatches(): ResourceByProjectKeyProductVariantPatches + public function productDrafts(): ResourceByProjectKeyProductDrafts { $args = $this->getArgs(); - return new ResourceByProjectKeyProductVariantPatches($args, $this->getClient()); + return new ResourceByProjectKeyProductDrafts($args, $this->getClient()); } /** */ - public function orders(): ResourceByProjectKeyOrders + public function productTypes(): ResourceByProjectKeyProductTypes { $args = $this->getArgs(); - return new ResourceByProjectKeyOrders($args, $this->getClient()); + return new ResourceByProjectKeyProductTypes($args, $this->getClient()); } /** */ - public function orderPatches(): ResourceByProjectKeyOrderPatches + public function productVariants(): ResourceByProjectKeyProductVariants { $args = $this->getArgs(); - return new ResourceByProjectKeyOrderPatches($args, $this->getClient()); + return new ResourceByProjectKeyProductVariants($args, $this->getClient()); } /** */ - public function customers(): ResourceByProjectKeyCustomers + public function productVariantPatches(): ResourceByProjectKeyProductVariantPatches { $args = $this->getArgs(); - return new ResourceByProjectKeyCustomers($args, $this->getClient()); + return new ResourceByProjectKeyProductVariantPatches($args, $this->getClient()); } /** */ - public function inventories(): ResourceByProjectKeyInventories + public function productSelections(): ResourceByProjectKeyProductSelections { $args = $this->getArgs(); - return new ResourceByProjectKeyInventories($args, $this->getClient()); + return new ResourceByProjectKeyProductSelections($args, $this->getClient()); } /** */ - public function types(): ResourceByProjectKeyTypes + public function orders(): ResourceByProjectKeyOrders { $args = $this->getArgs(); - return new ResourceByProjectKeyTypes($args, $this->getClient()); + return new ResourceByProjectKeyOrders($args, $this->getClient()); } /** */ - public function discountCodes(): ResourceByProjectKeyDiscountCodes + public function orderPatches(): ResourceByProjectKeyOrderPatches { $args = $this->getArgs(); - return new ResourceByProjectKeyDiscountCodes($args, $this->getClient()); + return new ResourceByProjectKeyOrderPatches($args, $this->getClient()); } /** */ - public function productSelections(): ResourceByProjectKeyProductSelections + public function standalonePrices(): ResourceByProjectKeyStandalonePrices { $args = $this->getArgs(); - return new ResourceByProjectKeyProductSelections($args, $this->getClient()); + return new ResourceByProjectKeyStandalonePrices($args, $this->getClient()); } /** */ - public function businessUnits(): ResourceByProjectKeyBusinessUnits + public function types(): ResourceByProjectKeyTypes { $args = $this->getArgs(); - return new ResourceByProjectKeyBusinessUnits($args, $this->getClient()); + return new ResourceByProjectKeyTypes($args, $this->getClient()); } } diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldBooleanTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldBooleanTypeModel.php index ed059cf3c8e..d06c5713037 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldBooleanTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldBooleanTypeModel.php @@ -37,7 +37,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldDateTimeTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldDateTimeTypeModel.php index 45d69c73ac6..f0b276811f0 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldDateTimeTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldDateTimeTypeModel.php @@ -37,7 +37,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldDateTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldDateTypeModel.php index efa38e6133f..f5e319c7085 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldDateTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldDateTypeModel.php @@ -37,7 +37,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldEnumTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldEnumTypeModel.php index 00dc1de98e3..22358097b31 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldEnumTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldEnumTypeModel.php @@ -45,7 +45,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldLocalizedEnumTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldLocalizedEnumTypeModel.php index 1285275f29b..7e2085a16b9 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldLocalizedEnumTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldLocalizedEnumTypeModel.php @@ -45,7 +45,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldLocalizedStringTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldLocalizedStringTypeModel.php index 1393afc641a..b10b890bfdc 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldLocalizedStringTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldLocalizedStringTypeModel.php @@ -37,7 +37,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldMoneyTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldMoneyTypeModel.php index 34ee892324a..9a7631647f5 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldMoneyTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldMoneyTypeModel.php @@ -37,7 +37,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldNumberTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldNumberTypeModel.php index 89f181d0053..30441d3dff7 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldNumberTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldNumberTypeModel.php @@ -37,7 +37,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldReferenceTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldReferenceTypeModel.php index a8c543052c3..29fde9e85b2 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldReferenceTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldReferenceTypeModel.php @@ -45,7 +45,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldSetTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldSetTypeModel.php index 444588e95f9..5a6b3924994 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldSetTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldSetTypeModel.php @@ -45,7 +45,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldStringTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldStringTypeModel.php index aa3fcae944c..c89246c63c2 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldStringTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldStringTypeModel.php @@ -37,7 +37,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/CustomFieldTimeTypeModel.php b/lib/commercetools-import/src/Models/Types/CustomFieldTimeTypeModel.php index bd480f35e97..3427f9253f7 100644 --- a/lib/commercetools-import/src/Models/Types/CustomFieldTimeTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/CustomFieldTimeTypeModel.php @@ -37,7 +37,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/FieldDefinition.php b/lib/commercetools-import/src/Models/Types/FieldDefinition.php index 03870f74dd4..39a79173829 100644 --- a/lib/commercetools-import/src/Models/Types/FieldDefinition.php +++ b/lib/commercetools-import/src/Models/Types/FieldDefinition.php @@ -29,7 +29,10 @@ interface FieldDefinition extends JsonObject public function getType(); /** - *

                                                                                                                            Name of the Custom Field to define. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Name of the Custom Field that you want to define. + * The name must be unique for a given ResourceTypeId. + * If a FieldDefinition with the same name is defined in another Type for the same ResourceTypeId, then both FieldDefinitions must have the same type. + * This value can't be changed after you import the Type.

                                                                                                                            * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/FieldDefinitionBuilder.php b/lib/commercetools-import/src/Models/Types/FieldDefinitionBuilder.php index c6817fa27b7..3c0f9780728 100644 --- a/lib/commercetools-import/src/Models/Types/FieldDefinitionBuilder.php +++ b/lib/commercetools-import/src/Models/Types/FieldDefinitionBuilder.php @@ -64,7 +64,10 @@ public function getType() } /** - *

                                                                                                                            Name of the Custom Field to define. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Name of the Custom Field that you want to define. + * The name must be unique for a given ResourceTypeId. + * If a FieldDefinition with the same name is defined in another Type for the same ResourceTypeId, then both FieldDefinitions must have the same type. + * This value can't be changed after you import the Type.

                                                                                                                            * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/FieldDefinitionModel.php b/lib/commercetools-import/src/Models/Types/FieldDefinitionModel.php index 8f29b89304e..400f9c04331 100644 --- a/lib/commercetools-import/src/Models/Types/FieldDefinitionModel.php +++ b/lib/commercetools-import/src/Models/Types/FieldDefinitionModel.php @@ -91,7 +91,10 @@ public function getType() } /** - *

                                                                                                                            Name of the Custom Field to define. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Name of the Custom Field that you want to define. + * The name must be unique for a given ResourceTypeId. + * If a FieldDefinition with the same name is defined in another Type for the same ResourceTypeId, then both FieldDefinitions must have the same type. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/FieldType.php b/lib/commercetools-import/src/Models/Types/FieldType.php index 11b6555e00b..5f9c1d1bd7e 100644 --- a/lib/commercetools-import/src/Models/Types/FieldType.php +++ b/lib/commercetools-import/src/Models/Types/FieldType.php @@ -17,7 +17,8 @@ interface FieldType extends JsonObject public const FIELD_NAME = 'name'; /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * @return null|string diff --git a/lib/commercetools-import/src/Models/Types/FieldTypeModel.php b/lib/commercetools-import/src/Models/Types/FieldTypeModel.php index e935592209a..c9a15c606c2 100644 --- a/lib/commercetools-import/src/Models/Types/FieldTypeModel.php +++ b/lib/commercetools-import/src/Models/Types/FieldTypeModel.php @@ -55,7 +55,8 @@ public function __construct( } /** - *

                                                                                                                            Name of the field type. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type. This value cannot be changed after the Type is imported.

                                                                                                                            + *

                                                                                                                            Discriminator that determines the type of the field. + * This value can't be changed after you import the Type.

                                                                                                                            * * * @return null|string diff --git a/references.txt b/references.txt index 1033c4f9c38..fc3330f4f01 100644 --- a/references.txt +++ b/references.txt @@ -520,3 +520,34 @@ e5d97cd9fa03ef3c4fe45f051ad8a4a80e690656 07aa50f3b215723c6a2719cdcf78d70a45c219e2 2b09ff0ae5722d1867af3a5c93f9f4ec7de2b423 85ec5b54fce964cd50dc254ed39d0ab1137076bc +65b14540239650479b1799503b3c9e3180d93186 +2e90c8c066eb618de26c10124e1d007cdfc842a4 +3999f168839d6e67496250d2c2c83edd7f7f5a59 +524cda1d7939151daccfc43d29db2af42b52c592 +a30cdb4639c838f3864da68ab5ca314593dd5c85 +0e0cb6a92a4b302f905cbd657d43b94635e5dfb3 +2d80e476e7b846987e3c2db6fdba76c470f1c173 +2ca7fba4e989ff96a2a3008d3168ea243c9cc3a8 +62910ed7ec4d1110dd8e5c98acc931a7df092a2e +021ca761240e06e31ec45855e8660b712be31817 +8f3d4c3294e504aef6102f2ce130bacf1a477916 +fea3fbfdc8dedcaeb467c0c66bd4968c1d79156c +0eb82a344545c68d83a79ce78e4d353ba3a94a6f +279d1c35e88624bdf58992b694e380fa1e53a85f +18c787052fbe07c50524d8249ada01228db2a8c9 +681c61f208c763fb7e0171b337956ebd3773aba1 +7fe613ca616e3dc91ba35bb3a8109ff1a4ec534a +f3c35b1b92ccc332f0b95003f0f22ea8f0e5f8e0 +bfb534af33764ac81a3784290b35530d926fccf1 +191aae538dbd5834105b736f21d4c04a53c20409 +ccd88b54c3412f4164e4d3dec13e524ffc38059b +37f4edec0935ea3be543d48720fb67438c2ab341 +47d240c55478dd0c0e1aa47288c432f785240168 +68fb22e84fc95421ac888349924233d728ef2838 +78d1ed9c74ad1fd8f47f014bc4fe96ce2720d509 +603e489748f9c32c1891d60d6f767892a8ea5207 +d4e4e8a84aecf33d0482a5829b97a450a6d3234d +59bf0ffb85d4043aaa090400511f3d6c658ca649 +dd952279caa05a020c427ea1899d4bf0897cb802 +985c8f2c9814fe367cb77e11c237968db008a306 +a3e408093873cfed8ced6708aa90deec2e7daa44