diff --git a/changes.md b/changes.md index fe8fca7df90..9cccb8e162d 100644 --- a/changes.md +++ b/changes.md @@ -11,19 +11,33 @@ Added QueryParameter(s) - added query parameter `priceCustomerGroupAssignments` to method `get /{projectKey}/products` +- added query parameter `priceRecurrencePolicy` to method `get /{projectKey}/products` - added query parameter `priceCustomerGroupAssignments` to method `post /{projectKey}/products` +- added query parameter `priceRecurrencePolicy` to method `post /{projectKey}/products` - added query parameter `priceCustomerGroupAssignments` to method `get /{projectKey}/product-projections` +- added query parameter `priceRecurrencePolicy` to method `get /{projectKey}/product-projections` - added query parameter `priceCustomerGroupAssignments` to method `get /{projectKey}/products/key={key}` +- added query parameter `priceRecurrencePolicy` to method `get /{projectKey}/products/key={key}` - added query parameter `priceCustomerGroupAssignments` to method `post /{projectKey}/products/key={key}` +- added query parameter `priceRecurrencePolicy` to method `post /{projectKey}/products/key={key}` - added query parameter `priceCustomerGroupAssignments` to method `delete /{projectKey}/products/key={key}` +- added query parameter `priceRecurrencePolicy` to method `delete /{projectKey}/products/key={key}` - added query parameter `priceCustomerGroupAssignments` to method `get /{projectKey}/products/{ID}` +- added query parameter `priceRecurrencePolicy` to method `get /{projectKey}/products/{ID}` - added query parameter `priceCustomerGroupAssignments` to method `post /{projectKey}/products/{ID}` +- added query parameter `priceRecurrencePolicy` to method `post /{projectKey}/products/{ID}` - added query parameter `priceCustomerGroupAssignments` to method `delete /{projectKey}/products/{ID}` +- added query parameter `priceRecurrencePolicy` to method `delete /{projectKey}/products/{ID}` - added query parameter `priceCustomerGroupAssignments` to method `get /{projectKey}/product-projections/search` +- added query parameter `priceRecurrencePolicy` to method `get /{projectKey}/product-projections/search` - added query parameter `priceCustomerGroupAssignments` to method `get /{projectKey}/product-projections/key={key}` +- added query parameter `priceRecurrencePolicy` to method `get /{projectKey}/product-projections/key={key}` - added query parameter `priceCustomerGroupAssignments` to method `get /{projectKey}/product-projections/{ID}` +- added query parameter `priceRecurrencePolicy` to method `get /{projectKey}/product-projections/{ID}` - added query parameter `priceCustomerGroupAssignments` to method `get /{projectKey}/in-store/key={storeKey}/product-projections/key={key}` +- added query parameter `priceRecurrencePolicy` to method `get /{projectKey}/in-store/key={storeKey}/product-projections/key={key}` - added query parameter `priceCustomerGroupAssignments` to method `get /{projectKey}/in-store/key={storeKey}/product-projections/{ID}` +- added query parameter `priceRecurrencePolicy` to method `get /{projectKey}/in-store/key={storeKey}/product-projections/{ID}` @@ -44,6 +58,8 @@ - added type `DiscountTypeCombination` - added type `Stacking` - added type `CartChangePriceRoundingModeAction` +- added type `CartSetCustomLineItemRecurrenceInfoAction` +- added type `CartSetLineItemRecurrenceInfoAction` - added type `CustomerGroupAssignment` - added type `CustomerGroupAssignmentDraft` - added type `CustomerAddCustomerGroupAssignmentAction` @@ -89,6 +105,8 @@ - added type `ImportUnresolvedEventData` - added type `ImportValidationFailedEventData` - added type `ImportWaitForMasterVariantEventData` +- added type `MyCartSetCustomLineItemRecurrenceInfoAction` +- added type `MyCartSetLineItemRecurrenceInfoAction` - added type `MyPaymentSetMethodInfoCustomFieldAction` - added type `MyPaymentSetMethodInfoCustomTypeAction` - added type `MyPaymentSetMethodInfoInterfaceAccountAction` @@ -103,6 +121,7 @@ - added type `DiscountGroupKeySetMessage` - added type `DiscountGroupSortOrderSetMessage` - added type `OrderBusinessUnitSetMessage` +- added type `OrderCreatedFromRecurringOrderMessage` - added type `PaymentInterfaceIdSetMessage` - added type `PaymentMethodCreatedMessage` - added type `PaymentMethodCustomFieldAddedMessage` @@ -128,6 +147,17 @@ - added type `PaymentMethodNameSetMessage` - added type `PaymentMethodPaymentInterfaceSetMessage` - added type `PaymentMethodPaymentMethodStatusSetMessage` +- added type `RecurringOrderCreatedMessage` +- added type `RecurringOrderCustomFieldAddedMessage` +- added type `RecurringOrderCustomFieldChangedMessage` +- added type `RecurringOrderCustomFieldRemovedMessage` +- added type `RecurringOrderCustomTypeRemovedMessage` +- added type `RecurringOrderCustomTypeSetMessage` +- added type `RecurringOrderKeySetMessage` +- added type `RecurringOrderScheduleSetMessage` +- added type `RecurringOrderStartsAtSetMessage` +- added type `RecurringOrderStateChangedMessage` +- added type `RecurringOrderStateTransitionMessage` - added type `AssociateRoleNameSetMessagePayload` - added type `BusinessUnitTopLevelUnitSetMessagePayload` - added type `BusinessUnitTypeSetMessagePayload` @@ -139,6 +169,7 @@ - added type `DiscountGroupKeySetMessagePayload` - added type `DiscountGroupSortOrderSetMessagePayload` - added type `OrderBusinessUnitSetMessagePayload` +- added type `OrderCreatedFromRecurringOrderMessagePayload` - added type `PaymentInterfaceIdSetMessagePayload` - added type `PaymentMethodCreatedMessagePayload` - added type `PaymentMethodCustomFieldAddedMessagePayload` @@ -164,6 +195,18 @@ - added type `PaymentMethodNameSetMessagePayload` - added type `PaymentMethodPaymentInterfaceSetMessagePayload` - added type `PaymentMethodPaymentMethodStatusSetMessagePayload` +- added type `RecurringOrderCreatedMessagePayload` +- added type `RecurringOrderCustomFieldAddedMessagePayload` +- added type `RecurringOrderCustomFieldChangedMessagePayload` +- added type `RecurringOrderCustomFieldRemovedMessagePayload` +- added type `RecurringOrderCustomTypeRemovedMessagePayload` +- added type `RecurringOrderCustomTypeSetMessagePayload` +- added type `RecurringOrderKeySetMessagePayload` +- added type `RecurringOrderMessagePayload` +- added type `RecurringOrderScheduleSetMessagePayload` +- added type `RecurringOrderStartsAtSetMessagePayload` +- added type `RecurringOrderStateChangedMessagePayload` +- added type `RecurringOrderStateTransitionMessagePayload` - added type `StagedOrderChangePriceRoundingModeAction` - added type `StagedOrderSetBusinessUnitAction` - added type `OrderSetBusinessUnitAction` @@ -195,6 +238,54 @@ - added type `ProductSetProductAttributeAction` - added type `ProjectChangePriceRoundingModeAction` - added type `ProjectChangeTaxRoundingModeAction` +- added type `DayOfMonthSchedule` +- added type `DayOfMonthScheduleDraft` +- added type `IntervalUnit` +- added type `RecurrencePolicy` +- added type `RecurrencePolicyDraft` +- added type `RecurrencePolicyPagedQueryResponse` +- added type `RecurrencePolicyReference` +- added type `RecurrencePolicyResourceIdentifier` +- added type `RecurrencePolicySchedule` +- added type `RecurrencePolicyScheduleDraft` +- added type `RecurrencePolicyUpdate` +- added type `RecurrencePolicyUpdateAction` +- added type `StandardSchedule` +- added type `StandardScheduleDraft` +- added type `RecurrencePolicySetDescriptionAction` +- added type `RecurrencePolicySetKeyAction` +- added type `RecurrencePolicySetNameAction` +- added type `RecurrencePolicySetScheduleAction` +- added type `Counter` +- added type `CounterDraft` +- added type `CustomLineItemRecurrenceInfo` +- added type `CustomLineItemRecurrenceInfoDraft` +- added type `LineItemRecurrenceInfo` +- added type `LineItemRecurrenceInfoDraft` +- added type `PriceSelectionMode` +- added type `RecurringOrder` +- added type `RecurringOrderActive` +- added type `RecurringOrderCanceled` +- added type `RecurringOrderDraft` +- added type `RecurringOrderExpired` +- added type `RecurringOrderPagedQueryResponse` +- added type `RecurringOrderPaused` +- added type `RecurringOrderReference` +- added type `RecurringOrderResourceIdentifier` +- added type `RecurringOrderState` +- added type `RecurringOrderStateDraft` +- added type `RecurringOrderUpdate` +- added type `RecurringOrderUpdateAction` +- added type `SkipConfiguration` +- added type `SkipConfigurationDraft` +- added type `RecurringOrderSetCustomFieldAction` +- added type `RecurringOrderSetCustomTypeAction` +- added type `RecurringOrderSetKeyAction` +- added type `RecurringOrderSetOrderSkipConfigurationAction` +- added type `RecurringOrderSetScheduleAction` +- added type `RecurringOrderSetStartsAtAction` +- added type `RecurringOrderSetStateAction` +- added type `RecurringOrderTransitionStateAction` - added type `ShoppingListSetBusinessUnitAction` - added type `EventDeliveryPayload` - added type `EventSubscription` @@ -225,10 +316,17 @@ - added enum `CreateOthersShoppingLists` to type `Permission` - added enum `DeleteMyShoppingLists` to type `Permission` - added enum `DeleteOthersShoppingLists` to type `Permission` +- added enum `RecurringOrder` to type `CartOrigin` - added enum `ApplicationStoppedByGroupBestDeal` to type `DiscountCodeState` - added enum `discount-group` to type `ReferenceTypeId` - added enum `payment-method` to type `ReferenceTypeId` +- added enum `recurrence-policy` to type `ReferenceTypeId` +- added enum `recurring-order` to type `ReferenceTypeId` - added enum `payment-method` to type `ExtensionResourceTypeId` +- added enum `RecurringOrderState` to type `StateTypeEnum` +- added enum `recurrence-policy` to type `ChangeSubscriptionResourceTypeId` +- added enum `recurring-order` to type `ChangeSubscriptionResourceTypeId` +- added enum `recurring-order` to type `ResourceTypeId` @@ -244,11 +342,21 @@ - added property `priceRoundingMode` to type `Cart` - added property `discountTypeCombination` to type `Cart` - added property `priceRoundingMode` to type `CartDraft` +- added property `recurrenceInfo` to type `CustomLineItem` +- added property `recurrenceInfo` to type `CustomLineItemDraft` +- added property `recurrenceInfo` to type `LineItem` +- added property `recurrenceInfo` to type `LineItemDraft` +- added property `recurrenceInfo` to type `CartAddCustomLineItemAction` +- added property `recurrenceInfo` to type `CartAddLineItemAction` +- added property `recurrencePolicy` to type `Price` +- added property `recurrencePolicy` to type `PriceDraft` - added property `customerGroupAssignments` to type `Customer` - added property `invalidateOlderTokens` to type `CustomerCreateEmailToken` - added property `invalidateOlderTokens` to type `CustomerCreatePasswordResetToken` - added property `customerGroupAssignments` to type `CustomerDraft` - added property `invalidateOlderTokens` to type `CustomerToken` +- added property `recurrenceInfo` to type `MyLineItemDraft` +- added property `recurrenceInfo` to type `MyCartAddLineItemAction` - added property `value` to type `CustomerEmailTokenCreatedMessage` - added property `invalidateOlderTokens` to type `CustomerEmailTokenCreatedMessage` - added property `value` to type `CustomerPasswordTokenCreatedMessage` @@ -260,8 +368,12 @@ - added property `invalidateOlderTokens` to type `CustomerPasswordTokenCreatedMessagePayload` - added property `attributes` to type `ProductTailoringCreatedMessagePayload` - added property `priceRoundingMode` to type `StagedOrder` +- added property `recurringOrder` to type `StagedOrder` - added property `discountTypeCombination` to type `StagedOrder` +- added property `recurrenceInfo` to type `StagedOrderAddCustomLineItemAction` +- added property `recurrenceInfo` to type `StagedOrderAddLineItemAction` - added property `priceRoundingMode` to type `Order` +- added property `recurringOrder` to type `Order` - added property `discountTypeCombination` to type `Order` - added property `priceRoundingMode` to type `OrderImportDraft` - added property `token` to type `PaymentMethodInfo` @@ -277,6 +389,7 @@ - added property `attributes` to type `ProductData` - added property `attributes` to type `ProductDraft` - added property `attributes` to type `ProductProjection` +- added property `recurrencePrices` to type `ProductVariant` - 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 `priceRoundingMode` to type `CartsConfiguration` - added property `taxRoundingMode` to type `CartsConfiguration` @@ -285,6 +398,8 @@ - added property `businessUnit` to type `ShoppingList` - added property `businessUnit` to type `ShoppingListDraft` - added property `published` to type `ShoppingListLineItem` +- added property `recurrencePolicy` to type `StandalonePrice` +- added property `recurrencePolicy` to type `StandalonePriceDraft` - added property `events` to type `Subscription` - added property `events` to type `SubscriptionDraft` @@ -336,6 +451,12 @@ - added method `$apiRoot->withProjectKey()->paymentMethods()->get()` - added method `$apiRoot->withProjectKey()->paymentMethods()->head()` - added method `$apiRoot->withProjectKey()->paymentMethods()->post()` +- added method `$apiRoot->withProjectKey()->recurringOrders()->get()` +- added method `$apiRoot->withProjectKey()->recurringOrders()->head()` +- added method `$apiRoot->withProjectKey()->recurringOrders()->post()` +- added method `$apiRoot->withProjectKey()->recurrencePolicies()->get()` +- added method `$apiRoot->withProjectKey()->recurrencePolicies()->head()` +- added method `$apiRoot->withProjectKey()->recurrencePolicies()->post()` - added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->get()` - added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->head()` - added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->post()` @@ -365,6 +486,18 @@ - added method `$apiRoot->withProjectKey()->paymentMethods()->withId()->head()` - added method `$apiRoot->withProjectKey()->paymentMethods()->withId()->post()` - added method `$apiRoot->withProjectKey()->paymentMethods()->withId()->delete()` +- added method `$apiRoot->withProjectKey()->recurringOrders()->withId()->get()` +- added method `$apiRoot->withProjectKey()->recurringOrders()->withId()->head()` +- added method `$apiRoot->withProjectKey()->recurringOrders()->withId()->post()` +- added method `$apiRoot->withProjectKey()->recurringOrders()->withKey()->get()` +- added method `$apiRoot->withProjectKey()->recurringOrders()->withKey()->head()` +- added method `$apiRoot->withProjectKey()->recurringOrders()->withKey()->post()` +- added method `$apiRoot->withProjectKey()->recurrencePolicies()->withKey()->get()` +- added method `$apiRoot->withProjectKey()->recurrencePolicies()->withKey()->head()` +- added method `$apiRoot->withProjectKey()->recurrencePolicies()->withKey()->post()` +- added method `$apiRoot->withProjectKey()->recurrencePolicies()->withId()->get()` +- added method `$apiRoot->withProjectKey()->recurrencePolicies()->withId()->head()` +- added method `$apiRoot->withProjectKey()->recurrencePolicies()->withId()->post()` - added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->get()` - added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->head()` - added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->post()` @@ -386,6 +519,8 @@ - added resource `/{projectKey}/discount-groups` - added resource `/{projectKey}/payment-methods` +- added resource `/{projectKey}/recurring-orders` +- added resource `/{projectKey}/recurrence-policies` - added resource `/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists` - added resource `/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/key={key}` - added resource `/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}` @@ -395,6 +530,10 @@ - added resource `/{projectKey}/discount-groups/{ID}` - added resource `/{projectKey}/payment-methods/key={key}` - added resource `/{projectKey}/payment-methods/{ID}` +- added resource `/{projectKey}/recurring-orders/{ID}` +- added resource `/{projectKey}/recurring-orders/key={key}` +- added resource `/{projectKey}/recurrence-policies/key={key}` +- added resource `/{projectKey}/recurrence-policies/{ID}` - added resource `/{projectKey}/in-store/key={storeKey}/business-units` - added resource `/{projectKey}/in-store/key={storeKey}/business-units/key={key}` - added resource `/{projectKey}/in-store/key={storeKey}/business-units/{ID}` @@ -482,6 +621,7 @@ - added enum `setAssetKey` to type `UpdateType` - added enum `ApplicationStoppedByGroupBestDeal` to type `DiscountCodeState` - added enum `payment-method` to type `ReferenceTypeId` +- added enum `RecurringOrderState` to type `StateTypeEnum` diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDTest.php index dae83d10ec7..e64ca249000 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDTest.php @@ -169,6 +169,19 @@ function (ApiRequestBuilder $builder): RequestInterface { 'get', 'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceChannel=priceChannel', ], + 'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->productProjections() + ->withId('test_ID') + ->get() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withLocaleProjection' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyTest.php index cfb73fb041f..c3857081472 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyTest.php @@ -169,6 +169,19 @@ function (ApiRequestBuilder $builder): RequestInterface { 'get', 'test_projectKey/in-store/key=test_storeKey/product-projections/key=test_key?priceChannel=priceChannel', ], + 'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyGet_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->productProjections() + ->withKey('test_key') + ->get() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/product-projections/key=test_key?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyGet_withLocaleProjection' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsByIDTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsByIDTest.php index 158f8652ce8..7aa7766e9c1 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsByIDTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsByIDTest.php @@ -163,6 +163,18 @@ function (ApiRequestBuilder $builder): RequestInterface { 'get', 'test_projectKey/product-projections/test_ID?priceChannel=priceChannel', ], + 'ByProjectKeyProductProjectionsByIDGet_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->productProjections() + ->withId('test_ID') + ->get() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'get', + 'test_projectKey/product-projections/test_ID?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductProjectionsByIDGet_withLocaleProjection' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsKeyByKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsKeyByKeyTest.php index 9016cdb0e52..c5f167e7bfd 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsKeyByKeyTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsKeyByKeyTest.php @@ -163,6 +163,18 @@ function (ApiRequestBuilder $builder): RequestInterface { 'get', 'test_projectKey/product-projections/key=test_key?priceChannel=priceChannel', ], + 'ByProjectKeyProductProjectionsKeyByKeyGet_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->productProjections() + ->withKey('test_key') + ->get() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'get', + 'test_projectKey/product-projections/key=test_key?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductProjectionsKeyByKeyGet_withLocaleProjection' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsSearchTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsSearchTest.php index b20d231f58a..7c109237546 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsSearchTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsSearchTest.php @@ -318,6 +318,18 @@ function (ApiRequestBuilder $builder): RequestInterface { 'get', 'test_projectKey/product-projections/search?priceChannel=priceChannel', ], + 'ByProjectKeyProductProjectionsSearchGet_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->productProjections() + ->search() + ->get() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'get', + 'test_projectKey/product-projections/search?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductProjectionsSearchGet_withLocaleProjection' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsTest.php index 41c416d7eac..ed8f269f47b 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductProjectionsTest.php @@ -170,6 +170,17 @@ function (ApiRequestBuilder $builder): RequestInterface { 'get', 'test_projectKey/product-projections?priceChannel=priceChannel', ], + 'ByProjectKeyProductProjectionsGet_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->productProjections() + ->get() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'get', + 'test_projectKey/product-projections?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductProjectionsGet_withLocaleProjection' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsByIDTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsByIDTest.php index 1232a645555..337170a32c0 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsByIDTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsByIDTest.php @@ -164,6 +164,18 @@ function (ApiRequestBuilder $builder): RequestInterface { 'get', 'test_projectKey/products/test_ID?priceChannel=priceChannel', ], + 'ByProjectKeyProductsByIDGet_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->products() + ->withId('test_ID') + ->get() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'get', + 'test_projectKey/products/test_ID?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductsByIDGet_withExpand' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder @@ -258,6 +270,18 @@ function (ApiRequestBuilder $builder): RequestInterface { 'post', 'test_projectKey/products/test_ID?priceChannel=priceChannel', ], + 'ByProjectKeyProductsByIDPost_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->products() + ->withId('test_ID') + ->post(null) + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'post', + 'test_projectKey/products/test_ID?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductsByIDPost_withExpand' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder @@ -341,6 +365,18 @@ function (ApiRequestBuilder $builder): RequestInterface { 'delete', 'test_projectKey/products/test_ID?priceChannel=priceChannel', ], + 'ByProjectKeyProductsByIDDelete_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->products() + ->withId('test_ID') + ->delete() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'delete', + 'test_projectKey/products/test_ID?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductsByIDDelete_withVersion' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsKeyByKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsKeyByKeyTest.php index 0484389b10d..272a4d19265 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsKeyByKeyTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsKeyByKeyTest.php @@ -163,6 +163,18 @@ function (ApiRequestBuilder $builder): RequestInterface { 'get', 'test_projectKey/products/key=test_key?priceChannel=priceChannel', ], + 'ByProjectKeyProductsKeyByKeyGet_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->products() + ->withKey('test_key') + ->get() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'get', + 'test_projectKey/products/key=test_key?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductsKeyByKeyGet_withExpand' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder @@ -257,6 +269,18 @@ function (ApiRequestBuilder $builder): RequestInterface { 'post', 'test_projectKey/products/key=test_key?priceChannel=priceChannel', ], + 'ByProjectKeyProductsKeyByKeyPost_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->products() + ->withKey('test_key') + ->post(null) + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'post', + 'test_projectKey/products/key=test_key?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductsKeyByKeyPost_withExpand' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder @@ -340,6 +364,18 @@ function (ApiRequestBuilder $builder): RequestInterface { 'delete', 'test_projectKey/products/key=test_key?priceChannel=priceChannel', ], + 'ByProjectKeyProductsKeyByKeyDelete_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->products() + ->withKey('test_key') + ->delete() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'delete', + 'test_projectKey/products/key=test_key?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductsKeyByKeyDelete_withVersion' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsTest.php index d2b02b69f23..5b125cb92e1 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyProductsTest.php @@ -170,6 +170,17 @@ function (ApiRequestBuilder $builder): RequestInterface { 'get', 'test_projectKey/products?priceChannel=priceChannel', ], + 'ByProjectKeyProductsGet_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->products() + ->get() + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'get', + 'test_projectKey/products?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductsGet_withExpand' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder @@ -322,6 +333,17 @@ function (ApiRequestBuilder $builder): RequestInterface { 'post', 'test_projectKey/products?priceChannel=priceChannel', ], + 'ByProjectKeyProductsPost_withPriceRecurrencePolicy' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->products() + ->post(null) + ->withPriceRecurrencePolicy('priceRecurrencePolicy'); + }, + 'post', + 'test_projectKey/products?priceRecurrencePolicy=priceRecurrencePolicy', + ], 'ByProjectKeyProductsPost_withExpand' => [ function (ApiRequestBuilder $builder): RequestInterface { return $builder diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurrencePoliciesByIDTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurrencePoliciesByIDTest.php new file mode 100644 index 00000000000..4c13f929283 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurrencePoliciesByIDTest.php @@ -0,0 +1,479 @@ +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 [ + 'ByProjectKeyRecurrencePoliciesByIDGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->withId('test_ID') + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/recurrence-policies/test_ID?expand=expand', + ], + 'ByProjectKeyRecurrencePoliciesByIDGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->withId("test_ID") + ->get(); + }, + 'get', + 'test_projectKey/recurrence-policies/test_ID', + ], + 'ByProjectKeyRecurrencePoliciesByIDHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->withId("test_ID") + ->head(); + }, + 'head', + 'test_projectKey/recurrence-policies/test_ID', + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->withId('test_ID') + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/recurrence-policies/test_ID?expand=expand', + ], + 'ByProjectKeyRecurrencePoliciesByIDPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->withId("test_ID") + ->post(null); + }, + 'post', + 'test_projectKey/recurrence-policies/test_ID', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyRecurrencePoliciesByIDGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + } + ], + 'ByProjectKeyRecurrencePoliciesByIDHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + } + ], + 'ByProjectKeyRecurrencePoliciesByIDPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyRecurrencePoliciesByIDGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + }, + 200 + ], + 'ByProjectKeyRecurrencePoliciesByIDGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + }, + 400 + ], + 'ByProjectKeyRecurrencePoliciesByIDGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + }, + 401 + ], + 'ByProjectKeyRecurrencePoliciesByIDGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + }, + 403 + ], + 'ByProjectKeyRecurrencePoliciesByIDGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + }, + 404 + ], + 'ByProjectKeyRecurrencePoliciesByIDGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + }, + 500 + ], + 'ByProjectKeyRecurrencePoliciesByIDGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + }, + 502 + ], + 'ByProjectKeyRecurrencePoliciesByIDGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + }, + 503 + ], + 'ByProjectKeyRecurrencePoliciesByIDGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); + }, + 599 + ], + 'ByProjectKeyRecurrencePoliciesByIDHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + }, + 200 + ], + 'ByProjectKeyRecurrencePoliciesByIDHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + }, + 404 + ], + 'ByProjectKeyRecurrencePoliciesByIDHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + }, + 400 + ], + 'ByProjectKeyRecurrencePoliciesByIDHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + }, + 401 + ], + 'ByProjectKeyRecurrencePoliciesByIDHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + }, + 403 + ], + 'ByProjectKeyRecurrencePoliciesByIDHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + }, + 500 + ], + 'ByProjectKeyRecurrencePoliciesByIDHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + }, + 502 + ], + 'ByProjectKeyRecurrencePoliciesByIDHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + }, + 503 + ], + 'ByProjectKeyRecurrencePoliciesByIDHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); + }, + 599 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 200 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 409 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 400 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 401 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 403 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 404 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 500 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 502 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 503 + ], + 'ByProjectKeyRecurrencePoliciesByIDPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurrencePoliciesKeyByKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurrencePoliciesKeyByKeyTest.php new file mode 100644 index 00000000000..2cd34cabd2d --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurrencePoliciesKeyByKeyTest.php @@ -0,0 +1,479 @@ +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 [ + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->withKey('test_key') + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/recurrence-policies/key=test_key?expand=expand', + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->withKey("test_key") + ->get(); + }, + 'get', + 'test_projectKey/recurrence-policies/key=test_key', + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->withKey("test_key") + ->head(); + }, + 'head', + 'test_projectKey/recurrence-policies/key=test_key', + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->withKey('test_key') + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/recurrence-policies/key=test_key?expand=expand', + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->withKey("test_key") + ->post(null); + }, + 'post', + 'test_projectKey/recurrence-policies/key=test_key', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + } + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + } + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + }, + 200 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + }, + 400 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + }, + 401 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + }, + 403 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + }, + 404 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + }, + 500 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + }, + 502 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + }, + 503 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); + }, + 599 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + }, + 200 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + }, + 404 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + }, + 400 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + }, + 401 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + }, + 403 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + }, + 500 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + }, + 502 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + }, + 503 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); + }, + 599 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 200 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 409 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 400 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 401 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 403 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 404 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 500 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 502 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 503 + ], + 'ByProjectKeyRecurrencePoliciesKeyByKeyPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurrencePoliciesTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurrencePoliciesTest.php new file mode 100644 index 00000000000..9d13646b017 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurrencePoliciesTest.php @@ -0,0 +1,544 @@ +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 getResources() + */ + public function testResources(callable $builderFunction, string $class, array $expectedArgs) + { + $builder = new ApiRequestBuilder(); + $resource = $builderFunction($builder); + $this->assertInstanceOf($class, $resource); + $this->assertEquals($expectedArgs, $resource->getArgs()); + } + + /** + * @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 [ + 'ByProjectKeyRecurrencePoliciesGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/recurrence-policies?expand=expand', + ], + 'ByProjectKeyRecurrencePoliciesGet_withSort' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->get() + ->withSort('sort'); + }, + 'get', + 'test_projectKey/recurrence-policies?sort=sort', + ], + 'ByProjectKeyRecurrencePoliciesGet_withLimit' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->get() + ->withLimit('limit'); + }, + 'get', + 'test_projectKey/recurrence-policies?limit=limit', + ], + 'ByProjectKeyRecurrencePoliciesGet_withOffset' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->get() + ->withOffset('offset'); + }, + 'get', + 'test_projectKey/recurrence-policies?offset=offset', + ], + 'ByProjectKeyRecurrencePoliciesGet_withWithTotal' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->get() + ->withWithTotal('withTotal'); + }, + 'get', + 'test_projectKey/recurrence-policies?withTotal=withTotal', + ], + 'ByProjectKeyRecurrencePoliciesGet_withWhere' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->get() + ->withWhere('where'); + }, + 'get', + 'test_projectKey/recurrence-policies?where=where', + ], + 'ByProjectKeyRecurrencePoliciesGet_withPredicateVar' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->get() + ->withPredicateVar('varName', 'var.varName'); + }, + 'get', + 'test_projectKey/recurrence-policies?var.varName=var.varName', + ], + 'ByProjectKeyRecurrencePoliciesGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->get(); + }, + 'get', + 'test_projectKey/recurrence-policies', + ], + 'ByProjectKeyRecurrencePoliciesHead_withWhere' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->head() + ->withWhere('where'); + }, + 'head', + 'test_projectKey/recurrence-policies?where=where', + ], + 'ByProjectKeyRecurrencePoliciesHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->head(); + }, + 'head', + 'test_projectKey/recurrence-policies', + ], + 'ByProjectKeyRecurrencePoliciesPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurrencePolicies() + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/recurrence-policies?expand=expand', + ], + 'ByProjectKeyRecurrencePoliciesPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->post(null); + }, + 'post', + 'test_projectKey/recurrence-policies', + ] + ]; + } + + public function getResources() + { + return [ + 'ResourceByProjectKeyRecurrencePoliciesKeyByKey' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyRecurrencePoliciesKeyByKey { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->withKey("test_key"); + }, + ResourceByProjectKeyRecurrencePoliciesKeyByKey::class, + ['projectKey' => 'test_projectKey', 'key' => 'test_key'], + '/{projectKey}/recurrence-policies/key={key}' + ], + 'ResourceByProjectKeyRecurrencePoliciesByID' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyRecurrencePoliciesByID { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies() + ->withId("test_ID"); + }, + ResourceByProjectKeyRecurrencePoliciesByID::class, + ['projectKey' => 'test_projectKey', 'ID' => 'test_ID'], + '/{projectKey}/recurrence-policies/{ID}' + ] + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyRecurrencePoliciesGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + } + ], + 'ByProjectKeyRecurrencePoliciesHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + } + ], + 'ByProjectKeyRecurrencePoliciesPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyRecurrencePoliciesGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + }, + 200 + ], + 'ByProjectKeyRecurrencePoliciesGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + }, + 400 + ], + 'ByProjectKeyRecurrencePoliciesGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + }, + 401 + ], + 'ByProjectKeyRecurrencePoliciesGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + }, + 403 + ], + 'ByProjectKeyRecurrencePoliciesGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + }, + 404 + ], + 'ByProjectKeyRecurrencePoliciesGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + }, + 500 + ], + 'ByProjectKeyRecurrencePoliciesGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + }, + 502 + ], + 'ByProjectKeyRecurrencePoliciesGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + }, + 503 + ], + 'ByProjectKeyRecurrencePoliciesGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); + }, + 599 + ], + 'ByProjectKeyRecurrencePoliciesHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + }, + 200 + ], + 'ByProjectKeyRecurrencePoliciesHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + }, + 404 + ], + 'ByProjectKeyRecurrencePoliciesHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + }, + 400 + ], + 'ByProjectKeyRecurrencePoliciesHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + }, + 401 + ], + 'ByProjectKeyRecurrencePoliciesHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + }, + 403 + ], + 'ByProjectKeyRecurrencePoliciesHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + }, + 500 + ], + 'ByProjectKeyRecurrencePoliciesHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + }, + 502 + ], + 'ByProjectKeyRecurrencePoliciesHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + }, + 503 + ], + 'ByProjectKeyRecurrencePoliciesHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); + }, + 599 + ], + 'ByProjectKeyRecurrencePoliciesPost_201' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + }, + 201 + ], + 'ByProjectKeyRecurrencePoliciesPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + }, + 400 + ], + 'ByProjectKeyRecurrencePoliciesPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + }, + 401 + ], + 'ByProjectKeyRecurrencePoliciesPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + }, + 403 + ], + 'ByProjectKeyRecurrencePoliciesPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + }, + 404 + ], + 'ByProjectKeyRecurrencePoliciesPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + }, + 500 + ], + 'ByProjectKeyRecurrencePoliciesPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + }, + 502 + ], + 'ByProjectKeyRecurrencePoliciesPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + }, + 503 + ], + 'ByProjectKeyRecurrencePoliciesPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurringOrdersByIDTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurringOrdersByIDTest.php new file mode 100644 index 00000000000..feba0183a8f --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurringOrdersByIDTest.php @@ -0,0 +1,479 @@ +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 [ + 'ByProjectKeyRecurringOrdersByIDGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->withId('test_ID') + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/recurring-orders/test_ID?expand=expand', + ], + 'ByProjectKeyRecurringOrdersByIDGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->withId("test_ID") + ->get(); + }, + 'get', + 'test_projectKey/recurring-orders/test_ID', + ], + 'ByProjectKeyRecurringOrdersByIDHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->withId("test_ID") + ->head(); + }, + 'head', + 'test_projectKey/recurring-orders/test_ID', + ], + 'ByProjectKeyRecurringOrdersByIDPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->withId('test_ID') + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/recurring-orders/test_ID?expand=expand', + ], + 'ByProjectKeyRecurringOrdersByIDPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->withId("test_ID") + ->post(null); + }, + 'post', + 'test_projectKey/recurring-orders/test_ID', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyRecurringOrdersByIDGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + } + ], + 'ByProjectKeyRecurringOrdersByIDHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + } + ], + 'ByProjectKeyRecurringOrdersByIDPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyRecurringOrdersByIDGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + }, + 200 + ], + 'ByProjectKeyRecurringOrdersByIDGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + }, + 400 + ], + 'ByProjectKeyRecurringOrdersByIDGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + }, + 401 + ], + 'ByProjectKeyRecurringOrdersByIDGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + }, + 403 + ], + 'ByProjectKeyRecurringOrdersByIDGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + }, + 404 + ], + 'ByProjectKeyRecurringOrdersByIDGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + }, + 500 + ], + 'ByProjectKeyRecurringOrdersByIDGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + }, + 502 + ], + 'ByProjectKeyRecurringOrdersByIDGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + }, + 503 + ], + 'ByProjectKeyRecurringOrdersByIDGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); + }, + 599 + ], + 'ByProjectKeyRecurringOrdersByIDHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + }, + 200 + ], + 'ByProjectKeyRecurringOrdersByIDHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + }, + 404 + ], + 'ByProjectKeyRecurringOrdersByIDHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + }, + 400 + ], + 'ByProjectKeyRecurringOrdersByIDHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + }, + 401 + ], + 'ByProjectKeyRecurringOrdersByIDHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + }, + 403 + ], + 'ByProjectKeyRecurringOrdersByIDHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + }, + 500 + ], + 'ByProjectKeyRecurringOrdersByIDHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + }, + 502 + ], + 'ByProjectKeyRecurringOrdersByIDHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + }, + 503 + ], + 'ByProjectKeyRecurringOrdersByIDHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); + }, + 599 + ], + 'ByProjectKeyRecurringOrdersByIDPost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 200 + ], + 'ByProjectKeyRecurringOrdersByIDPost_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 409 + ], + 'ByProjectKeyRecurringOrdersByIDPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 400 + ], + 'ByProjectKeyRecurringOrdersByIDPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 401 + ], + 'ByProjectKeyRecurringOrdersByIDPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 403 + ], + 'ByProjectKeyRecurringOrdersByIDPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 404 + ], + 'ByProjectKeyRecurringOrdersByIDPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 500 + ], + 'ByProjectKeyRecurringOrdersByIDPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 502 + ], + 'ByProjectKeyRecurringOrdersByIDPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 503 + ], + 'ByProjectKeyRecurringOrdersByIDPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurringOrdersKeyByKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurringOrdersKeyByKeyTest.php new file mode 100644 index 00000000000..488bd9b7bfa --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurringOrdersKeyByKeyTest.php @@ -0,0 +1,479 @@ +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 [ + 'ByProjectKeyRecurringOrdersKeyByKeyGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->withKey('test_key') + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/recurring-orders/key=test_key?expand=expand', + ], + 'ByProjectKeyRecurringOrdersKeyByKeyGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->withKey("test_key") + ->get(); + }, + 'get', + 'test_projectKey/recurring-orders/key=test_key', + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->withKey("test_key") + ->head(); + }, + 'head', + 'test_projectKey/recurring-orders/key=test_key', + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->withKey('test_key') + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/recurring-orders/key=test_key?expand=expand', + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->withKey("test_key") + ->post(null); + }, + 'post', + 'test_projectKey/recurring-orders/key=test_key', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyRecurringOrdersKeyByKeyGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + } + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + } + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyRecurringOrdersKeyByKeyGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + }, + 200 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + }, + 400 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + }, + 401 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + }, + 403 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + }, + 404 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + }, + 500 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + }, + 502 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + }, + 503 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); + }, + 599 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + }, + 200 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + }, + 404 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + }, + 400 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + }, + 401 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + }, + 403 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + }, + 500 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + }, + 502 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + }, + 503 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); + }, + 599 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 200 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 409 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 400 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 401 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 403 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 404 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 500 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 502 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 503 + ], + 'ByProjectKeyRecurringOrdersKeyByKeyPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurringOrdersTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurringOrdersTest.php new file mode 100644 index 00000000000..479ce5bbc12 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyRecurringOrdersTest.php @@ -0,0 +1,553 @@ +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 getResources() + */ + public function testResources(callable $builderFunction, string $class, array $expectedArgs) + { + $builder = new ApiRequestBuilder(); + $resource = $builderFunction($builder); + $this->assertInstanceOf($class, $resource); + $this->assertEquals($expectedArgs, $resource->getArgs()); + } + + /** + * @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 [ + 'ByProjectKeyRecurringOrdersGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/recurring-orders?expand=expand', + ], + 'ByProjectKeyRecurringOrdersGet_withSort' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->get() + ->withSort('sort'); + }, + 'get', + 'test_projectKey/recurring-orders?sort=sort', + ], + 'ByProjectKeyRecurringOrdersGet_withLimit' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->get() + ->withLimit('limit'); + }, + 'get', + 'test_projectKey/recurring-orders?limit=limit', + ], + 'ByProjectKeyRecurringOrdersGet_withOffset' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->get() + ->withOffset('offset'); + }, + 'get', + 'test_projectKey/recurring-orders?offset=offset', + ], + 'ByProjectKeyRecurringOrdersGet_withWithTotal' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->get() + ->withWithTotal('withTotal'); + }, + 'get', + 'test_projectKey/recurring-orders?withTotal=withTotal', + ], + 'ByProjectKeyRecurringOrdersGet_withWhere' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->get() + ->withWhere('where'); + }, + 'get', + 'test_projectKey/recurring-orders?where=where', + ], + 'ByProjectKeyRecurringOrdersGet_withPredicateVar' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->get() + ->withPredicateVar('varName', 'var.varName'); + }, + 'get', + 'test_projectKey/recurring-orders?var.varName=var.varName', + ], + 'ByProjectKeyRecurringOrdersGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->get(); + }, + 'get', + 'test_projectKey/recurring-orders', + ], + 'ByProjectKeyRecurringOrdersHead_withWhere' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->head() + ->withWhere('where'); + }, + 'head', + 'test_projectKey/recurring-orders?where=where', + ], + 'ByProjectKeyRecurringOrdersHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->head(); + }, + 'head', + 'test_projectKey/recurring-orders', + ], + 'ByProjectKeyRecurringOrdersPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->recurringOrders() + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/recurring-orders?expand=expand', + ], + 'ByProjectKeyRecurringOrdersPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->post(null); + }, + 'post', + 'test_projectKey/recurring-orders', + ] + ]; + } + + public function getResources() + { + return [ + 'ResourceByProjectKeyRecurringOrdersByID' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyRecurringOrdersByID { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->withId("test_ID"); + }, + ResourceByProjectKeyRecurringOrdersByID::class, + ['projectKey' => 'test_projectKey', 'ID' => 'test_ID'], + '/{projectKey}/recurring-orders/{ID}' + ], + 'ResourceByProjectKeyRecurringOrdersKeyByKey' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyRecurringOrdersKeyByKey { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders() + ->withKey("test_key"); + }, + ResourceByProjectKeyRecurringOrdersKeyByKey::class, + ['projectKey' => 'test_projectKey', 'key' => 'test_key'], + '/{projectKey}/recurring-orders/key={key}' + ] + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyRecurringOrdersGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + } + ], + 'ByProjectKeyRecurringOrdersHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + } + ], + 'ByProjectKeyRecurringOrdersPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyRecurringOrdersGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + }, + 200 + ], + 'ByProjectKeyRecurringOrdersGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + }, + 400 + ], + 'ByProjectKeyRecurringOrdersGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + }, + 401 + ], + 'ByProjectKeyRecurringOrdersGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + }, + 403 + ], + 'ByProjectKeyRecurringOrdersGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + }, + 404 + ], + 'ByProjectKeyRecurringOrdersGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + }, + 500 + ], + 'ByProjectKeyRecurringOrdersGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + }, + 502 + ], + 'ByProjectKeyRecurringOrdersGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + }, + 503 + ], + 'ByProjectKeyRecurringOrdersGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); + }, + 599 + ], + 'ByProjectKeyRecurringOrdersHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + }, + 200 + ], + 'ByProjectKeyRecurringOrdersHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + }, + 404 + ], + 'ByProjectKeyRecurringOrdersHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + }, + 400 + ], + 'ByProjectKeyRecurringOrdersHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + }, + 401 + ], + 'ByProjectKeyRecurringOrdersHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + }, + 403 + ], + 'ByProjectKeyRecurringOrdersHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + }, + 500 + ], + 'ByProjectKeyRecurringOrdersHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + }, + 502 + ], + 'ByProjectKeyRecurringOrdersHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + }, + 503 + ], + 'ByProjectKeyRecurringOrdersHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); + }, + 599 + ], + 'ByProjectKeyRecurringOrdersPost_201' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 201 + ], + 'ByProjectKeyRecurringOrdersPost_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 409 + ], + 'ByProjectKeyRecurringOrdersPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 400 + ], + 'ByProjectKeyRecurringOrdersPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 401 + ], + 'ByProjectKeyRecurringOrdersPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 403 + ], + 'ByProjectKeyRecurringOrdersPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 404 + ], + 'ByProjectKeyRecurringOrdersPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 500 + ], + 'ByProjectKeyRecurringOrdersPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 502 + ], + 'ByProjectKeyRecurringOrdersPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 503 + ], + 'ByProjectKeyRecurringOrdersPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php index 0f6e86c17cc..ff50e02fb3d 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php @@ -42,6 +42,8 @@ use Commercetools\Api\Client\Resource\ResourceByProjectKeyProductTypes; use Commercetools\Api\Client\Resource\ResourceByProjectKeyQuoteRequests; use Commercetools\Api\Client\Resource\ResourceByProjectKeyQuotes; +use Commercetools\Api\Client\Resource\ResourceByProjectKeyRecurrencePolicies; +use Commercetools\Api\Client\Resource\ResourceByProjectKeyRecurringOrders; use Commercetools\Api\Client\Resource\ResourceByProjectKeyReviews; use Commercetools\Api\Client\Resource\ResourceByProjectKeyShippingMethods; use Commercetools\Api\Client\Resource\ResourceByProjectKeyShoppingLists; @@ -458,6 +460,26 @@ function (ApiRequestBuilder $builder): ResourceByProjectKeyStagedQuotes { ['projectKey' => 'test_projectKey'], '/{projectKey}/staged-quotes' ], + 'ResourceByProjectKeyRecurringOrders' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyRecurringOrders { + return $builder + ->withProjectKey("test_projectKey") + ->recurringOrders(); + }, + ResourceByProjectKeyRecurringOrders::class, + ['projectKey' => 'test_projectKey'], + '/{projectKey}/recurring-orders' + ], + 'ResourceByProjectKeyRecurrencePolicies' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyRecurrencePolicies { + return $builder + ->withProjectKey("test_projectKey") + ->recurrencePolicies(); + }, + ResourceByProjectKeyRecurrencePolicies::class, + ['projectKey' => 'test_projectKey'], + '/{projectKey}/recurrence-policies' + ], 'ResourceByProjectKeyReviews' => [ function (ApiRequestBuilder $builder): ResourceByProjectKeyReviews { return $builder diff --git a/lib/commercetools-api/docs/RequestBuilder.md b/lib/commercetools-api/docs/RequestBuilder.md index 269e59288c4..c13ece965fc 100644 --- a/lib/commercetools-api/docs/RequestBuilder.md +++ b/lib/commercetools-api/docs/RequestBuilder.md @@ -8528,7 +8528,7 @@ The Cart must have a shipping address and an active Shipping Method set. The shipping address is used for tax calculation for a Cart with `Platform` [TaxMode](ctp:api:type:TaxMode). -Creating an Order produces the [OrderCreated](ctp:api:type:OrderCreatedMessage) Message. +Creating an Order produces the [OrderCreated](ctp:api:type:OrderCreatedMessage) Message. If the Order is created from a Recurring Order schedule, the [OrderCreatedFromRecurringOrder](ctp:api:type:OrderCreatedFromRecurringOrderMessage) Message is generated. If a server-side problem occurs, indicated by a 500 Internal Server Error HTTP response, the Order creation may still successfully complete after the error is returned. If you receive this error, you should verify the status of the Order by querying a unique identifier supplied during the creation request, such as the Order number. @@ -10683,6 +10683,294 @@ $request = $builder ->withKey("key") ->delete(); ``` +## `withProjectKey("projectKey")->recurrencePolicies()->get()` + +Retrieves Recurrence Policies in the Project. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->get(); +``` +## `withProjectKey("projectKey")->recurrencePolicies()->head()` + +Checks if one or more Recurrence Policies exist for the provided query predicate. Returns a `200 OK` status if any Recurrence Policies match the query predicate, or a [NotFound](ctp:api:type:ResourceNotFoundError) error otherwise. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->head(); +``` +## `withProjectKey("projectKey")->recurrencePolicies()->post(null)` + +Creates a Recurrence Policy in the Project. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->post(null); +``` +## `withProjectKey("projectKey")->recurrencePolicies()->withId("ID")->get()` + +Retrieves a Recurrence Policy with the provided `id`. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->get(); +``` +## `withProjectKey("projectKey")->recurrencePolicies()->withId("ID")->head()` + +Checks if a Recurrence Policy exists with the provided `id`. Returns a `200 OK` status if the Recurrence Policy exists, or a [NotFound](ctp:api:type:ResourceNotFoundError) error otherwise. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->head(); +``` +## `withProjectKey("projectKey")->recurrencePolicies()->withId("ID")->post(null)` + +Updates a Recurrence Policy using one or more [update actions](/../api/projects/recurrence-policies#update-actions). + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withId("ID") + ->post(null); +``` +## `withProjectKey("projectKey")->recurrencePolicies()->withKey("key")->get()` + +Retrieves a Recurrence Policy with the provided `key`. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->get(); +``` +## `withProjectKey("projectKey")->recurrencePolicies()->withKey("key")->head()` + +Checks if a Recurrence Policy exists with the provided `key`. Returns a `200 OK` status if the Recurrence Policy exists, or a [NotFound](ctp:api:type:ResourceNotFoundError) error otherwise. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->head(); +``` +## `withProjectKey("projectKey")->recurrencePolicies()->withKey("key")->post(null)` + +Updates a Recurrence Policy using one or more [update actions](/../api/projects/recurrence-policies#update-actions). + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurrencePolicies() + ->withKey("key") + ->post(null); +``` +## `withProjectKey("projectKey")->recurringOrders()->get()` + +Retrieves Recurring Orders in the Project. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->get(); +``` +## `withProjectKey("projectKey")->recurringOrders()->head()` + +Checks if one or more Recurring Orders exist for the provided query predicate. Returns a `200 OK` status if any Recurring Orders match the query predicate, or a [NotFound](ctp:api:type:ResourceNotFoundError) error otherwise. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->head(); +``` +## `withProjectKey("projectKey")->recurringOrders()->post(null)` + +Creates a Recurring Order in the Project. +The Cart is validated to ensure that it is convertible to an [Order](ctp:api:type:Order). If validation fails, an error is returned. + +Produces the [RecurringOrderCreated](ctp:api:type:RecurringOrderCreatedMessage) message. + +If a server-side problem occurs, indicated by a 500 Internal Server Error HTTP response, the Recurring Order creation may still successfully complete after the error is returned. +If you receive this error, you should verify the status of the Recurring Order by querying a unique identifier supplied during the creation request, such as the key. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->post(null); +``` +## `withProjectKey("projectKey")->recurringOrders()->withId("ID")->get()` + +Retrieves a Recurring Order with the provided `id`. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->get(); +``` +## `withProjectKey("projectKey")->recurringOrders()->withId("ID")->head()` + +Checks if a Recurring Order exists with the provided `id`. Returns a `200 OK` status if the Recurring Order exists, or a [NotFound](ctp:api:type:ResourceNotFoundError) error otherwise. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->head(); +``` +## `withProjectKey("projectKey")->recurringOrders()->withId("ID")->post(null)` + +Updates a Recurring Order using one or more [update actions](/../api/projects/recurring-orders#update-actions). + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withId("ID") + ->post(null); +``` +## `withProjectKey("projectKey")->recurringOrders()->withKey("key")->get()` + +Retrieves a Recurring Order with the provided `key`. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->get(); +``` +## `withProjectKey("projectKey")->recurringOrders()->withKey("key")->head()` + +Checks if a Recurring Order exists with the provided `key`. Returns a `200 OK` status if the Recurring Order exists, or a [NotFound](ctp:api:type:ResourceNotFoundError) error otherwise. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->head(); +``` +## `withProjectKey("projectKey")->recurringOrders()->withKey("key")->post(null)` + +Updates a Recurring Order using one or more [update actions](/../api/projects/recurring-orders#update-actions). + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->recurringOrders() + ->withKey("key") + ->post(null); +``` ## `withProjectKey("projectKey")->reviews()->get()` null diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet.php index 16b39ec255c..2d7e6a1bbdf 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet.php @@ -201,6 +201,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyInStoreKeyByStoreKe return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $localeProjection diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyGet.php index 33c51a2cc1e..4711a705565 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyGet.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyGet.php @@ -201,6 +201,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyInStoreKeyByStoreKe return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyGet + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $localeProjection diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsByIDGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsByIDGet.php index cfd468ba443..10fa2036498 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsByIDGet.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsByIDGet.php @@ -202,6 +202,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductProjectionsB return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductProjectionsByIDGet + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $localeProjection diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsGet.php index 05baf97b801..c7dab029cdf 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsGet.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsGet.php @@ -205,6 +205,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductProjectionsG return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductProjectionsGet + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $localeProjection diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsKeyByKeyGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsKeyByKeyGet.php index 3ffdff59e02..75800c4b6e8 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsKeyByKeyGet.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsKeyByKeyGet.php @@ -202,6 +202,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductProjectionsK return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductProjectionsKeyByKeyGet + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $localeProjection diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsSearchGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsSearchGet.php index ba76e80f20c..58799049c37 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsSearchGet.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductProjectionsSearchGet.php @@ -309,6 +309,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductProjectionsS return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductProjectionsSearchGet + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $localeProjection diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDDelete.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDDelete.php index e48e443f25c..7cefce9b07f 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDDelete.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDDelete.php @@ -196,6 +196,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductsByIDDelete return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductsByIDDelete + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $version diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDGet.php index e86c5b9f017..4ba6a8b1c5a 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDGet.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDGet.php @@ -190,6 +190,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductsByIDGet return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductsByIDGet + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $expand diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDPost.php index c2aadba3074..455563d74c1 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDPost.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsByIDPost.php @@ -195,6 +195,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductsByIDPost return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductsByIDPost + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $expand diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsGet.php index 9407d50f1fb..8ea91451f47 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsGet.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsGet.php @@ -202,6 +202,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductsGet return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductsGet + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $expand diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyDelete.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyDelete.php index a10bdd5c517..3c5821fd825 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyDelete.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyDelete.php @@ -196,6 +196,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductsKeyByKeyDel return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductsKeyByKeyDelete + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $version diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyGet.php index bccbdbe71c5..c9ff862ed0d 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyGet.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyGet.php @@ -190,6 +190,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductsKeyByKeyGet return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductsKeyByKeyGet + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $expand diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyPost.php index 2d289e19d2f..7fd23b6c039 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyPost.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsKeyByKeyPost.php @@ -195,6 +195,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductsKeyByKeyPos return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductsKeyByKeyPost + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $expand diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsPost.php index 1c07e653e9f..fec75148505 100644 --- a/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsPost.php +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyProductsPost.php @@ -190,6 +190,15 @@ public function withPriceChannel($priceChannel): ByProjectKeyProductsPost return $this->withQueryParam('priceChannel', $priceChannel); } + /** + * + * @psalm-param scalar|scalar[] $priceRecurrencePolicy + */ + public function withPriceRecurrencePolicy($priceRecurrencePolicy): ByProjectKeyProductsPost + { + return $this->withQueryParam('priceRecurrencePolicy', $priceRecurrencePolicy); + } + /** * * @psalm-param scalar|scalar[] $expand diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesByIDGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesByIDGet.php new file mode 100644 index 00000000000..b3cb05603a2 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesByIDGet.php @@ -0,0 +1,155 @@ + + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurrencePoliciesByIDGet extends ApiRequest implements Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{ID}'], [$projectKey, $ID], '{projectKey}/recurrence-policies/{ID}'); + parent::__construct($client, 'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|RecurrencePolicy|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 = RecurrencePolicyModel::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|ErrorResponse|JsonObject|RecurrencePolicy + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurrencePoliciesByIDGet + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesByIDHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesByIDHead.php new file mode 100644 index 00000000000..58caa2a5119 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesByIDHead.php @@ -0,0 +1,139 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurrencePoliciesByIDHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{ID}'], [$projectKey, $ID], '{projectKey}/recurrence-policies/{ID}'); + parent::__construct($client, 'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return 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 '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|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/ByProjectKeyRecurrencePoliciesByIDPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesByIDPost.php new file mode 100644 index 00000000000..fc1ab8602a8 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesByIDPost.php @@ -0,0 +1,160 @@ + + * @template-implements Expandable + * @template-implements Deprecatable200 + * @template-implements Errorable + */ +class ByProjectKeyRecurrencePoliciesByIDPost extends ApiRequest implements Conflicting, Expandable, Deprecatable200, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{ID}'], [$projectKey, $ID], '{projectKey}/recurrence-policies/{ID}'); + 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 ErrorResponse|JsonObject|RecurrencePolicy|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 = RecurrencePolicyModel::class; + + break; + case '409': + $resultType = ErrorResponseModel::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|ErrorResponse|JsonObject|RecurrencePolicy + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurrencePoliciesByIDPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesGet.php new file mode 100644 index 00000000000..d5ce5de30c9 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesGet.php @@ -0,0 +1,212 @@ + + * @template-implements Sortable + * @template-implements Paging + * @template-implements Query + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurrencePoliciesGet extends ApiRequest implements Expandable, Sortable, Paging, Query, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}'], [$projectKey], '{projectKey}/recurrence-policies'); + parent::__construct($client, 'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|RecurrencePolicyPagedQueryResponse|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 = RecurrencePolicyPagedQueryResponseModel::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|ErrorResponse|JsonObject|RecurrencePolicyPagedQueryResponse + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurrencePoliciesGet + { + return $this->withQueryParam('expand', $expand); + } + + /** + * + * @psalm-param scalar|scalar[] $sort + */ + public function withSort($sort): ByProjectKeyRecurrencePoliciesGet + { + return $this->withQueryParam('sort', $sort); + } + + /** + * + * @psalm-param scalar|scalar[] $limit + */ + public function withLimit($limit): ByProjectKeyRecurrencePoliciesGet + { + return $this->withQueryParam('limit', $limit); + } + + /** + * + * @psalm-param scalar|scalar[] $offset + */ + public function withOffset($offset): ByProjectKeyRecurrencePoliciesGet + { + return $this->withQueryParam('offset', $offset); + } + + /** + * + * @psalm-param scalar|scalar[] $withTotal + */ + public function withWithTotal($withTotal): ByProjectKeyRecurrencePoliciesGet + { + return $this->withQueryParam('withTotal', $withTotal); + } + + /** + * + * @psalm-param scalar|scalar[] $where + */ + public function withWhere($where): ByProjectKeyRecurrencePoliciesGet + { + return $this->withQueryParam('where', $where); + } + + /** + * @psalm-param string $varName + * @psalm-param scalar|scalar[] $predicateVar + */ + public function withPredicateVar(string $varName, $predicateVar): ByProjectKeyRecurrencePoliciesGet + { + return $this->withQueryParam(sprintf('var.%s', $varName), $predicateVar); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesHead.php new file mode 100644 index 00000000000..83162ef7203 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesHead.php @@ -0,0 +1,148 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurrencePoliciesHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}'], [$projectKey], '{projectKey}/recurrence-policies'); + parent::__construct($client, 'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return 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 '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|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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $where + */ + public function withWhere($where): ByProjectKeyRecurrencePoliciesHead + { + return $this->withQueryParam('where', $where); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesKeyByKeyGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesKeyByKeyGet.php new file mode 100644 index 00000000000..e55ff3d5142 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesKeyByKeyGet.php @@ -0,0 +1,155 @@ + + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurrencePoliciesKeyByKeyGet extends ApiRequest implements Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{key}'], [$projectKey, $key], '{projectKey}/recurrence-policies/key={key}'); + parent::__construct($client, 'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|RecurrencePolicy|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 = RecurrencePolicyModel::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|ErrorResponse|JsonObject|RecurrencePolicy + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurrencePoliciesKeyByKeyGet + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesKeyByKeyHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesKeyByKeyHead.php new file mode 100644 index 00000000000..e7415b48033 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesKeyByKeyHead.php @@ -0,0 +1,139 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurrencePoliciesKeyByKeyHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{key}'], [$projectKey, $key], '{projectKey}/recurrence-policies/key={key}'); + parent::__construct($client, 'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return 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 '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|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/ByProjectKeyRecurrencePoliciesKeyByKeyPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesKeyByKeyPost.php new file mode 100644 index 00000000000..51844dea827 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesKeyByKeyPost.php @@ -0,0 +1,160 @@ + + * @template-implements Expandable + * @template-implements Deprecatable200 + * @template-implements Errorable + */ +class ByProjectKeyRecurrencePoliciesKeyByKeyPost extends ApiRequest implements Conflicting, Expandable, Deprecatable200, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{key}'], [$projectKey, $key], '{projectKey}/recurrence-policies/key={key}'); + 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 ErrorResponse|JsonObject|RecurrencePolicy|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 = RecurrencePolicyModel::class; + + break; + case '409': + $resultType = ErrorResponseModel::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|ErrorResponse|JsonObject|RecurrencePolicy + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurrencePoliciesKeyByKeyPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesPost.php new file mode 100644 index 00000000000..e9bd6e0dcd8 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurrencePoliciesPost.php @@ -0,0 +1,155 @@ + + * @template-implements Deprecatable201 + * @template-implements Errorable + */ +class ByProjectKeyRecurrencePoliciesPost extends ApiRequest implements Expandable, Deprecatable201, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}'], [$projectKey], '{projectKey}/recurrence-policies'); + 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 ErrorResponse|JsonObject|RecurrencePolicy|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '201': + $resultType = RecurrencePolicyModel::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|ErrorResponse|JsonObject|RecurrencePolicy + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurrencePoliciesPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersByIDGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersByIDGet.php new file mode 100644 index 00000000000..9b5915f83c8 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersByIDGet.php @@ -0,0 +1,155 @@ + + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurringOrdersByIDGet extends ApiRequest implements Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{ID}'], [$projectKey, $ID], '{projectKey}/recurring-orders/{ID}'); + parent::__construct($client, 'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|RecurringOrder|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 = RecurringOrderModel::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|ErrorResponse|JsonObject|RecurringOrder + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurringOrdersByIDGet + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersByIDHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersByIDHead.php new file mode 100644 index 00000000000..7c6ebcc00c0 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersByIDHead.php @@ -0,0 +1,139 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurringOrdersByIDHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{ID}'], [$projectKey, $ID], '{projectKey}/recurring-orders/{ID}'); + parent::__construct($client, 'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return 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 '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|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/ByProjectKeyRecurringOrdersByIDPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersByIDPost.php new file mode 100644 index 00000000000..e94748c5ce0 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersByIDPost.php @@ -0,0 +1,160 @@ + + * @template-implements Expandable + * @template-implements Deprecatable200 + * @template-implements Errorable + */ +class ByProjectKeyRecurringOrdersByIDPost extends ApiRequest implements Conflicting, Expandable, Deprecatable200, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{ID}'], [$projectKey, $ID], '{projectKey}/recurring-orders/{ID}'); + 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 ErrorResponse|JsonObject|RecurringOrder|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 = RecurringOrderModel::class; + + break; + case '409': + $resultType = ErrorResponseModel::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|ErrorResponse|JsonObject|RecurringOrder + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurringOrdersByIDPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersGet.php new file mode 100644 index 00000000000..e9efde7eee9 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersGet.php @@ -0,0 +1,212 @@ + + * @template-implements Sortable + * @template-implements Paging + * @template-implements Query + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurringOrdersGet extends ApiRequest implements Expandable, Sortable, Paging, Query, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}'], [$projectKey], '{projectKey}/recurring-orders'); + parent::__construct($client, 'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|RecurringOrderPagedQueryResponse|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 = RecurringOrderPagedQueryResponseModel::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|ErrorResponse|JsonObject|RecurringOrderPagedQueryResponse + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurringOrdersGet + { + return $this->withQueryParam('expand', $expand); + } + + /** + * + * @psalm-param scalar|scalar[] $sort + */ + public function withSort($sort): ByProjectKeyRecurringOrdersGet + { + return $this->withQueryParam('sort', $sort); + } + + /** + * + * @psalm-param scalar|scalar[] $limit + */ + public function withLimit($limit): ByProjectKeyRecurringOrdersGet + { + return $this->withQueryParam('limit', $limit); + } + + /** + * + * @psalm-param scalar|scalar[] $offset + */ + public function withOffset($offset): ByProjectKeyRecurringOrdersGet + { + return $this->withQueryParam('offset', $offset); + } + + /** + * + * @psalm-param scalar|scalar[] $withTotal + */ + public function withWithTotal($withTotal): ByProjectKeyRecurringOrdersGet + { + return $this->withQueryParam('withTotal', $withTotal); + } + + /** + * + * @psalm-param scalar|scalar[] $where + */ + public function withWhere($where): ByProjectKeyRecurringOrdersGet + { + return $this->withQueryParam('where', $where); + } + + /** + * @psalm-param string $varName + * @psalm-param scalar|scalar[] $predicateVar + */ + public function withPredicateVar(string $varName, $predicateVar): ByProjectKeyRecurringOrdersGet + { + return $this->withQueryParam(sprintf('var.%s', $varName), $predicateVar); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersHead.php new file mode 100644 index 00000000000..f602ed217f1 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersHead.php @@ -0,0 +1,148 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurringOrdersHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}'], [$projectKey], '{projectKey}/recurring-orders'); + parent::__construct($client, 'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return 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 '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|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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $where + */ + public function withWhere($where): ByProjectKeyRecurringOrdersHead + { + return $this->withQueryParam('where', $where); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersKeyByKeyGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersKeyByKeyGet.php new file mode 100644 index 00000000000..893a4ef144d --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersKeyByKeyGet.php @@ -0,0 +1,155 @@ + + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurringOrdersKeyByKeyGet extends ApiRequest implements Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{key}'], [$projectKey, $key], '{projectKey}/recurring-orders/key={key}'); + parent::__construct($client, 'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|RecurringOrder|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 = RecurringOrderModel::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|ErrorResponse|JsonObject|RecurringOrder + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurringOrdersKeyByKeyGet + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersKeyByKeyHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersKeyByKeyHead.php new file mode 100644 index 00000000000..f07dedcf23d --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersKeyByKeyHead.php @@ -0,0 +1,139 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyRecurringOrdersKeyByKeyHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{key}'], [$projectKey, $key], '{projectKey}/recurring-orders/key={key}'); + parent::__construct($client, 'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return 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 '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|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/ByProjectKeyRecurringOrdersKeyByKeyPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersKeyByKeyPost.php new file mode 100644 index 00000000000..080ae947ff5 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersKeyByKeyPost.php @@ -0,0 +1,160 @@ + + * @template-implements Expandable + * @template-implements Deprecatable200 + * @template-implements Errorable + */ +class ByProjectKeyRecurringOrdersKeyByKeyPost extends ApiRequest implements Conflicting, Expandable, Deprecatable200, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{key}'], [$projectKey, $key], '{projectKey}/recurring-orders/key={key}'); + 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 ErrorResponse|JsonObject|RecurringOrder|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 = RecurringOrderModel::class; + + break; + case '409': + $resultType = ErrorResponseModel::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|ErrorResponse|JsonObject|RecurringOrder + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurringOrdersKeyByKeyPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersPost.php new file mode 100644 index 00000000000..0188c4ebd2f --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyRecurringOrdersPost.php @@ -0,0 +1,160 @@ + + * @template-implements Expandable + * @template-implements Deprecatable201 + * @template-implements Errorable + */ +class ByProjectKeyRecurringOrdersPost extends ApiRequest implements Conflicting, Expandable, Deprecatable201, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}'], [$projectKey], '{projectKey}/recurring-orders'); + 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 ErrorResponse|JsonObject|RecurringOrder|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '201': + $resultType = RecurringOrderModel::class; + + break; + case '409': + $resultType = ErrorResponseModel::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|ErrorResponse|JsonObject|RecurringOrder + */ + 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; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyRecurringOrdersPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/PriceSelecting.php b/lib/commercetools-api/src/Client/Resource/PriceSelecting.php index 4172be0e796..4686194296d 100644 --- a/lib/commercetools-api/src/Client/Resource/PriceSelecting.php +++ b/lib/commercetools-api/src/Client/Resource/PriceSelecting.php @@ -45,4 +45,10 @@ public function withPriceCustomerGroupAssignments(string $priceCustomerGroupAssi * @psalm-return T */ public function withPriceChannel(string $priceChannel); + + /** + * @return ApiRequestInterface + * @psalm-return T + */ + public function withPriceRecurrencePolicy(string $priceRecurrencePolicy); } diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKey.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKey.php index 37323c1e335..5db8624925a 100644 --- a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKey.php +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKey.php @@ -250,6 +250,22 @@ public function stagedQuotes(): ResourceByProjectKeyStagedQuotes return new ResourceByProjectKeyStagedQuotes($args, $this->getClient()); } + /** + */ + public function recurringOrders(): ResourceByProjectKeyRecurringOrders + { + $args = $this->getArgs(); + + return new ResourceByProjectKeyRecurringOrders($args, $this->getClient()); + } + /** + */ + public function recurrencePolicies(): ResourceByProjectKeyRecurrencePolicies + { + $args = $this->getArgs(); + + return new ResourceByProjectKeyRecurrencePolicies($args, $this->getClient()); + } /** */ public function reviews(): ResourceByProjectKeyReviews diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurrencePolicies.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurrencePolicies.php new file mode 100644 index 00000000000..7062813ad9c --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurrencePolicies.php @@ -0,0 +1,82 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/recurrence-policies', $args, $client); + } + + /** + */ + public function withKey(?string $key = null): ResourceByProjectKeyRecurrencePoliciesKeyByKey + { + $args = $this->getArgs(); + if (!is_null($key)) { + $args['key'] = $key; + } + + return new ResourceByProjectKeyRecurrencePoliciesKeyByKey($args, $this->getClient()); + } + /** + */ + public function withId(?string $ID = null): ResourceByProjectKeyRecurrencePoliciesByID + { + $args = $this->getArgs(); + if (!is_null($ID)) { + $args['ID'] = $ID; + } + + return new ResourceByProjectKeyRecurrencePoliciesByID($args, $this->getClient()); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyRecurrencePoliciesGet + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurrencePoliciesGet($args['projectKey'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyRecurrencePoliciesHead + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurrencePoliciesHead($args['projectKey'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?RecurrencePolicyDraft $body + * @psalm-param array $headers + */ + public function post(?RecurrencePolicyDraft $body = null, array $headers = []): ByProjectKeyRecurrencePoliciesPost + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurrencePoliciesPost($args['projectKey'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurrencePoliciesByID.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurrencePoliciesByID.php new file mode 100644 index 00000000000..35c2826893b --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurrencePoliciesByID.php @@ -0,0 +1,59 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/recurrence-policies/{ID}', $args, $client); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyRecurrencePoliciesByIDGet + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurrencePoliciesByIDGet($args['projectKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyRecurrencePoliciesByIDHead + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurrencePoliciesByIDHead($args['projectKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?RecurrencePolicyUpdate $body + * @psalm-param array $headers + */ + public function post(?RecurrencePolicyUpdate $body = null, array $headers = []): ByProjectKeyRecurrencePoliciesByIDPost + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurrencePoliciesByIDPost($args['projectKey'], $args['ID'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurrencePoliciesKeyByKey.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurrencePoliciesKeyByKey.php new file mode 100644 index 00000000000..40881faa8d0 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurrencePoliciesKeyByKey.php @@ -0,0 +1,59 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/recurrence-policies/key={key}', $args, $client); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyRecurrencePoliciesKeyByKeyGet + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurrencePoliciesKeyByKeyGet($args['projectKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyRecurrencePoliciesKeyByKeyHead + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurrencePoliciesKeyByKeyHead($args['projectKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?RecurrencePolicyUpdate $body + * @psalm-param array $headers + */ + public function post(?RecurrencePolicyUpdate $body = null, array $headers = []): ByProjectKeyRecurrencePoliciesKeyByKeyPost + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurrencePoliciesKeyByKeyPost($args['projectKey'], $args['key'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurringOrders.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurringOrders.php new file mode 100644 index 00000000000..18d20751b8e --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurringOrders.php @@ -0,0 +1,82 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/recurring-orders', $args, $client); + } + + /** + */ + public function withId(?string $ID = null): ResourceByProjectKeyRecurringOrdersByID + { + $args = $this->getArgs(); + if (!is_null($ID)) { + $args['ID'] = $ID; + } + + return new ResourceByProjectKeyRecurringOrdersByID($args, $this->getClient()); + } + /** + */ + public function withKey(?string $key = null): ResourceByProjectKeyRecurringOrdersKeyByKey + { + $args = $this->getArgs(); + if (!is_null($key)) { + $args['key'] = $key; + } + + return new ResourceByProjectKeyRecurringOrdersKeyByKey($args, $this->getClient()); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyRecurringOrdersGet + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurringOrdersGet($args['projectKey'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyRecurringOrdersHead + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurringOrdersHead($args['projectKey'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?RecurringOrderDraft $body + * @psalm-param array $headers + */ + public function post(?RecurringOrderDraft $body = null, array $headers = []): ByProjectKeyRecurringOrdersPost + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurringOrdersPost($args['projectKey'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurringOrdersByID.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurringOrdersByID.php new file mode 100644 index 00000000000..41def2146a2 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurringOrdersByID.php @@ -0,0 +1,59 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/recurring-orders/{ID}', $args, $client); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyRecurringOrdersByIDGet + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurringOrdersByIDGet($args['projectKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyRecurringOrdersByIDHead + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurringOrdersByIDHead($args['projectKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?RecurringOrderUpdate $body + * @psalm-param array $headers + */ + public function post(?RecurringOrderUpdate $body = null, array $headers = []): ByProjectKeyRecurringOrdersByIDPost + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurringOrdersByIDPost($args['projectKey'], $args['ID'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurringOrdersKeyByKey.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurringOrdersKeyByKey.php new file mode 100644 index 00000000000..3392bdcb40b --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyRecurringOrdersKeyByKey.php @@ -0,0 +1,59 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/recurring-orders/key={key}', $args, $client); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyRecurringOrdersKeyByKeyGet + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurringOrdersKeyByKeyGet($args['projectKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyRecurringOrdersKeyByKeyHead + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurringOrdersKeyByKeyHead($args['projectKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?RecurringOrderUpdate $body + * @psalm-param array $headers + */ + public function post(?RecurringOrderUpdate $body = null, array $headers = []): ByProjectKeyRecurringOrdersKeyByKeyPost + { + $args = $this->getArgs(); + + return new ByProjectKeyRecurringOrdersKeyByKeyPost($args['projectKey'], $args['key'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php index 0610c407fac..3352a34a847 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php @@ -110,8 +110,8 @@ public function getStatus(); /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php index c1d7f7083be..9eb6a39b790 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php @@ -271,8 +271,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraft.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraft.php index b67d7916966..63a23c1edaa 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraft.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraft.php @@ -53,8 +53,8 @@ public function getStatus(); /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftBuilder.php index f4435c8a34c..28b6cd5e9d7 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftBuilder.php @@ -139,8 +139,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftModel.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftModel.php index 1c6f0c23e1b..d068666f798 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftModel.php @@ -211,8 +211,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php index 3cc8a5f51a1..9b823622e27 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php @@ -427,8 +427,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php index db9212c9783..1cad6cb3724 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php @@ -269,8 +269,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftBuilder.php index d89c9c0cf63..b5b0e62aa74 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftBuilder.php @@ -139,8 +139,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftModel.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftModel.php index a9ed29b3795..613fa3de9e5 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftModel.php @@ -203,8 +203,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php index a2eb8f41946..23411839ef9 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php @@ -417,8 +417,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php index 8b16e9e21f3..3dc1f61374c 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php @@ -269,8 +269,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftBuilder.php index a8f852be33b..16d330cb1f1 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftBuilder.php @@ -145,8 +145,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftModel.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftModel.php index 9d13cbbbb52..476b6a044bf 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftModel.php @@ -211,8 +211,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php index 3d5ae6781e1..44849b090dc 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php @@ -417,8 +417,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Recurring Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemAction.php b/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemAction.php index afc6a050bf7..23bb91fca35 100644 --- a/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemAction.php +++ b/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemAction.php @@ -10,6 +10,7 @@ use Commercetools\Api\Models\Common\LocalizedString; use Commercetools\Api\Models\Common\Money; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraft; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifier; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; @@ -27,6 +28,7 @@ interface CartAddCustomLineItemAction extends CartUpdateAction public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; public const FIELD_CUSTOM = 'custom'; public const FIELD_PRICE_MODE = 'priceMode'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; /** *

Money value of the Custom Line Item. @@ -114,6 +116,14 @@ public function getCustom(); */ public function getPriceMode(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + /** * @param ?Money $money */ @@ -163,4 +173,9 @@ public function setCustom(?CustomFieldsDraft $custom): void; * @param ?string $priceMode */ public function setPriceMode(?string $priceMode): void; + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void; } diff --git a/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemActionBuilder.php b/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemActionBuilder.php index 3c3bb1a14ac..84663c91869 100644 --- a/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemActionBuilder.php +++ b/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemActionBuilder.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Common\LocalizedStringBuilder; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Common\MoneyBuilder; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraftBuilder; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifier; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifierBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; @@ -88,6 +90,12 @@ final class CartAddCustomLineItemActionBuilder implements Builder */ private $priceMode; + /** + + * @var null|CustomLineItemRecurrenceInfoDraft|CustomLineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + /** *

Money value of the Custom Line Item. * The value can be negative.

@@ -204,6 +212,17 @@ public function getPriceMode() return $this->priceMode; } + /** + *

Recurring Order and frequency data.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + /** * @param ?Money $money * @return $this @@ -314,6 +333,17 @@ public function withPriceMode(?string $priceMode) return $this; } + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withMoney() instead * @return $this @@ -380,6 +410,17 @@ public function withCustomBuilder(?CustomFieldsDraftBuilder $custom) return $this; } + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?CustomLineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + public function build(): CartAddCustomLineItemAction { return new CartAddCustomLineItemActionModel( @@ -392,7 +433,8 @@ public function build(): CartAddCustomLineItemAction $this->externalTaxRate instanceof ExternalTaxRateDraftBuilder ? $this->externalTaxRate->build() : $this->externalTaxRate, $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails, $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom, - $this->priceMode + $this->priceMode, + $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo ); } diff --git a/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemActionModel.php b/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemActionModel.php index aa544dda91a..a7e7fed4393 100644 --- a/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemActionModel.php +++ b/lib/commercetools-api/src/Models/Cart/CartAddCustomLineItemActionModel.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Common\LocalizedStringModel; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Common\MoneyModel; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraftModel; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifier; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifierModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; @@ -94,6 +96,12 @@ final class CartAddCustomLineItemActionModel extends JsonObjectModel implements */ protected $priceMode; + /** + * + * @var ?CustomLineItemRecurrenceInfoDraft + */ + protected $recurrenceInfo; + /** * @psalm-suppress MissingParamType @@ -109,6 +117,7 @@ public function __construct( ?ItemShippingDetailsDraft $shippingDetails = null, ?CustomFieldsDraft $custom = null, ?string $priceMode = null, + ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo = null, ?string $action = null ) { $this->money = $money; @@ -121,6 +130,7 @@ public function __construct( $this->shippingDetails = $shippingDetails; $this->custom = $custom; $this->priceMode = $priceMode; + $this->recurrenceInfo = $recurrenceInfo; $this->action = $action ?? self::DISCRIMINATOR_VALUE; } @@ -354,6 +364,27 @@ public function getPriceMode() return $this->priceMode; } + /** + *

Recurring Order and frequency data.

+ * + * + * @return null|CustomLineItemRecurrenceInfoDraft + */ + 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 = CustomLineItemRecurrenceInfoDraftModel::of($data); + } + + return $this->recurrenceInfo; + } + /** * @param ?Money $money @@ -434,4 +465,12 @@ public function setPriceMode(?string $priceMode): void { $this->priceMode = $priceMode; } + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } } diff --git a/lib/commercetools-api/src/Models/Cart/CartAddLineItemAction.php b/lib/commercetools-api/src/Models/Cart/CartAddLineItemAction.php index fed5888ac5f..eff9ec85f95 100644 --- a/lib/commercetools-api/src/Models/Cart/CartAddLineItemAction.php +++ b/lib/commercetools-api/src/Models/Cart/CartAddLineItemAction.php @@ -10,6 +10,7 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; use Commercetools\Api\Models\Common\Money; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\Base\JsonObject; @@ -31,6 +32,7 @@ interface CartAddLineItemAction extends CartUpdateAction public const FIELD_PER_METHOD_EXTERNAL_TAX_RATE = 'perMethodExternalTaxRate'; public const FIELD_INVENTORY_MODE = 'inventoryMode'; public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; public const FIELD_CUSTOM = 'custom'; /** @@ -155,6 +157,14 @@ public function getInventoryMode(); */ public function getShippingDetails(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + /** *

Custom Fields for the Line Item.

* @@ -233,6 +243,11 @@ public function setInventoryMode(?string $inventoryMode): void; */ public function setShippingDetails(?ItemShippingDetailsDraft $shippingDetails): void; + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void; + /** * @param ?CustomFieldsDraft $custom */ diff --git a/lib/commercetools-api/src/Models/Cart/CartAddLineItemActionBuilder.php b/lib/commercetools-api/src/Models/Cart/CartAddLineItemActionBuilder.php index f7ccf3bfb69..d3eb32859de 100644 --- a/lib/commercetools-api/src/Models/Cart/CartAddLineItemActionBuilder.php +++ b/lib/commercetools-api/src/Models/Cart/CartAddLineItemActionBuilder.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifierBuilder; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Common\MoneyBuilder; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftBuilder; use Commercetools\Base\Builder; @@ -111,6 +113,12 @@ final class CartAddLineItemActionBuilder implements Builder */ private $shippingDetails; + /** + + * @var null|LineItemRecurrenceInfoDraft|LineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + /** * @var null|CustomFieldsDraft|CustomFieldsDraftBuilder @@ -281,6 +289,17 @@ public function getShippingDetails() return $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails; } + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + /** *

Custom Fields for the Line Item.

* @@ -446,6 +465,17 @@ public function withShippingDetails(?ItemShippingDetailsDraft $shippingDetails) return $this; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @param ?CustomFieldsDraft $custom * @return $this @@ -523,6 +553,17 @@ public function withShippingDetailsBuilder(?ItemShippingDetailsDraftBuilder $shi return $this; } + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?LineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withCustom() instead * @return $this @@ -551,6 +592,7 @@ public function build(): CartAddLineItemAction $this->perMethodExternalTaxRate, $this->inventoryMode, $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails, + $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo, $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom ); } diff --git a/lib/commercetools-api/src/Models/Cart/CartAddLineItemActionModel.php b/lib/commercetools-api/src/Models/Cart/CartAddLineItemActionModel.php index 74344192e67..32b306c3358 100644 --- a/lib/commercetools-api/src/Models/Cart/CartAddLineItemActionModel.php +++ b/lib/commercetools-api/src/Models/Cart/CartAddLineItemActionModel.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifierModel; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Common\MoneyModel; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftModel; use Commercetools\Base\DateTimeImmutableCollection; @@ -117,6 +119,12 @@ final class CartAddLineItemActionModel extends JsonObjectModel implements CartAd */ protected $shippingDetails; + /** + * + * @var ?LineItemRecurrenceInfoDraft + */ + protected $recurrenceInfo; + /** * * @var ?CustomFieldsDraft @@ -142,6 +150,7 @@ public function __construct( ?MethodExternalTaxRateDraftCollection $perMethodExternalTaxRate = null, ?string $inventoryMode = null, ?ItemShippingDetailsDraft $shippingDetails = null, + ?LineItemRecurrenceInfoDraft $recurrenceInfo = null, ?CustomFieldsDraft $custom = null, ?string $action = null ) { @@ -159,6 +168,7 @@ public function __construct( $this->perMethodExternalTaxRate = $perMethodExternalTaxRate; $this->inventoryMode = $inventoryMode; $this->shippingDetails = $shippingDetails; + $this->recurrenceInfo = $recurrenceInfo; $this->custom = $custom; $this->action = $action ?? self::DISCRIMINATOR_VALUE; } @@ -481,6 +491,27 @@ public function getShippingDetails() return $this->shippingDetails; } + /** + *

Recurring Order and frequency data.

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

Custom Fields for the Line Item.

* @@ -615,6 +646,14 @@ public function setShippingDetails(?ItemShippingDetailsDraft $shippingDetails): $this->shippingDetails = $shippingDetails; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } + /** * @param ?CustomFieldsDraft $custom */ diff --git a/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoAction.php b/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoAction.php new file mode 100644 index 00000000000..b7246f8ba79 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoAction.php @@ -0,0 +1,60 @@ +id of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

key of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void; + + /** + * @param ?string $customLineItemKey + */ + public function setCustomLineItemKey(?string $customLineItemKey): void; + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void; +} diff --git a/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoActionBuilder.php b/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoActionBuilder.php new file mode 100644 index 00000000000..c05b731aa58 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoActionBuilder.php @@ -0,0 +1,134 @@ + + */ +final class CartSetCustomLineItemRecurrenceInfoActionBuilder implements Builder +{ + /** + + * @var ?string + */ + private $customLineItemId; + + /** + + * @var ?string + */ + private $customLineItemKey; + + /** + + * @var null|CustomLineItemRecurrenceInfoDraft|CustomLineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + + /** + *

id of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

key of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + + /** + * @param ?string $customLineItemId + * @return $this + */ + public function withCustomLineItemId(?string $customLineItemId) + { + $this->customLineItemId = $customLineItemId; + + return $this; + } + + /** + * @param ?string $customLineItemKey + * @return $this + */ + public function withCustomLineItemKey(?string $customLineItemKey) + { + $this->customLineItemKey = $customLineItemKey; + + return $this; + } + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?CustomLineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + + public function build(): CartSetCustomLineItemRecurrenceInfoAction + { + return new CartSetCustomLineItemRecurrenceInfoActionModel( + $this->customLineItemId, + $this->customLineItemKey, + $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo + ); + } + + public static function of(): CartSetCustomLineItemRecurrenceInfoActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoActionCollection.php b/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoActionCollection.php new file mode 100644 index 00000000000..a6d86b00a46 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoActionCollection.php @@ -0,0 +1,56 @@ + + * @method CartSetCustomLineItemRecurrenceInfoAction current() + * @method CartSetCustomLineItemRecurrenceInfoAction end() + * @method CartSetCustomLineItemRecurrenceInfoAction at($offset) + */ +class CartSetCustomLineItemRecurrenceInfoActionCollection extends CartUpdateActionCollection +{ + /** + * @psalm-assert CartSetCustomLineItemRecurrenceInfoAction $value + * @psalm-param CartSetCustomLineItemRecurrenceInfoAction|stdClass $value + * @throws InvalidArgumentException + * + * @return CartSetCustomLineItemRecurrenceInfoActionCollection + */ + public function add($value) + { + if (!$value instanceof CartSetCustomLineItemRecurrenceInfoAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CartSetCustomLineItemRecurrenceInfoAction + */ + protected function mapper() + { + return function (?int $index): ?CartSetCustomLineItemRecurrenceInfoAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CartSetCustomLineItemRecurrenceInfoAction $data */ + $data = CartSetCustomLineItemRecurrenceInfoActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoActionModel.php b/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoActionModel.php new file mode 100644 index 00000000000..a61946ae5f9 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/CartSetCustomLineItemRecurrenceInfoActionModel.php @@ -0,0 +1,169 @@ +customLineItemId = $customLineItemId; + $this->customLineItemKey = $customLineItemKey; + $this->recurrenceInfo = $recurrenceInfo; + $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; + } + + /** + *

id of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

key of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + * + * @return null|CustomLineItemRecurrenceInfoDraft + */ + 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 = CustomLineItemRecurrenceInfoDraftModel::of($data); + } + + return $this->recurrenceInfo; + } + + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void + { + $this->customLineItemId = $customLineItemId; + } + + /** + * @param ?string $customLineItemKey + */ + public function setCustomLineItemKey(?string $customLineItemKey): void + { + $this->customLineItemKey = $customLineItemKey; + } + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } +} diff --git a/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoAction.php b/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoAction.php new file mode 100644 index 00000000000..df103213a29 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoAction.php @@ -0,0 +1,60 @@ +id of the LineItem to update. Either lineItemId or lineItemKey is required.

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

key of the LineItem to update. Either lineItemId or lineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; + + /** + * @param ?string $lineItemKey + */ + public function setLineItemKey(?string $lineItemKey): void; + + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void; +} diff --git a/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoActionBuilder.php b/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoActionBuilder.php new file mode 100644 index 00000000000..46bbe4924dc --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoActionBuilder.php @@ -0,0 +1,134 @@ + + */ +final class CartSetLineItemRecurrenceInfoActionBuilder implements Builder +{ + /** + + * @var ?string + */ + private $lineItemId; + + /** + + * @var ?string + */ + private $lineItemKey; + + /** + + * @var null|LineItemRecurrenceInfoDraft|LineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + + /** + *

id of the LineItem to update. Either lineItemId or lineItemKey is required.

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

key of the LineItem to update. Either lineItemId or lineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + + /** + * @param ?string $lineItemKey + * @return $this + */ + public function withLineItemKey(?string $lineItemKey) + { + $this->lineItemKey = $lineItemKey; + + return $this; + } + + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?LineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + + public function build(): CartSetLineItemRecurrenceInfoAction + { + return new CartSetLineItemRecurrenceInfoActionModel( + $this->lineItemId, + $this->lineItemKey, + $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo + ); + } + + public static function of(): CartSetLineItemRecurrenceInfoActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoActionCollection.php b/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoActionCollection.php new file mode 100644 index 00000000000..1b33c9b5b91 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoActionCollection.php @@ -0,0 +1,56 @@ + + * @method CartSetLineItemRecurrenceInfoAction current() + * @method CartSetLineItemRecurrenceInfoAction end() + * @method CartSetLineItemRecurrenceInfoAction at($offset) + */ +class CartSetLineItemRecurrenceInfoActionCollection extends CartUpdateActionCollection +{ + /** + * @psalm-assert CartSetLineItemRecurrenceInfoAction $value + * @psalm-param CartSetLineItemRecurrenceInfoAction|stdClass $value + * @throws InvalidArgumentException + * + * @return CartSetLineItemRecurrenceInfoActionCollection + */ + public function add($value) + { + if (!$value instanceof CartSetLineItemRecurrenceInfoAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CartSetLineItemRecurrenceInfoAction + */ + protected function mapper() + { + return function (?int $index): ?CartSetLineItemRecurrenceInfoAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CartSetLineItemRecurrenceInfoAction $data */ + $data = CartSetLineItemRecurrenceInfoActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoActionModel.php b/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoActionModel.php new file mode 100644 index 00000000000..9f1635ead52 --- /dev/null +++ b/lib/commercetools-api/src/Models/Cart/CartSetLineItemRecurrenceInfoActionModel.php @@ -0,0 +1,169 @@ +lineItemId = $lineItemId; + $this->lineItemKey = $lineItemKey; + $this->recurrenceInfo = $recurrenceInfo; + $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; + } + + /** + *

id of the LineItem to update. Either lineItemId or lineItemKey is required.

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

key of the LineItem to update. Either lineItemId or lineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + * + * @return null|LineItemRecurrenceInfoDraft + */ + 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 = LineItemRecurrenceInfoDraftModel::of($data); + } + + return $this->recurrenceInfo; + } + + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + + /** + * @param ?string $lineItemKey + */ + public function setLineItemKey(?string $lineItemKey): void + { + $this->lineItemKey = $lineItemKey; + } + + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } +} diff --git a/lib/commercetools-api/src/Models/Cart/CartUpdateActionModel.php b/lib/commercetools-api/src/Models/Cart/CartUpdateActionModel.php index 534ca1ef4b1..383d3e7b15f 100644 --- a/lib/commercetools-api/src/Models/Cart/CartUpdateActionModel.php +++ b/lib/commercetools-api/src/Models/Cart/CartUpdateActionModel.php @@ -68,6 +68,7 @@ final class CartUpdateActionModel extends JsonObjectModel implements CartUpdateA 'setCustomField' => CartSetCustomFieldActionModel::class, 'setCustomLineItemCustomField' => CartSetCustomLineItemCustomFieldActionModel::class, 'setCustomLineItemCustomType' => CartSetCustomLineItemCustomTypeActionModel::class, + 'setCustomLineItemRecurrenceInfo' => CartSetCustomLineItemRecurrenceInfoActionModel::class, 'setCustomLineItemShippingDetails' => CartSetCustomLineItemShippingDetailsActionModel::class, 'setCustomLineItemTaxAmount' => CartSetCustomLineItemTaxAmountActionModel::class, 'setCustomLineItemTaxRate' => CartSetCustomLineItemTaxRateActionModel::class, @@ -86,6 +87,7 @@ final class CartUpdateActionModel extends JsonObjectModel implements CartUpdateA 'setLineItemDistributionChannel' => CartSetLineItemDistributionChannelActionModel::class, 'setLineItemInventoryMode' => CartSetLineItemInventoryModeActionModel::class, 'setLineItemPrice' => CartSetLineItemPriceActionModel::class, + 'setLineItemRecurrenceInfo' => CartSetLineItemRecurrenceInfoActionModel::class, 'setLineItemShippingDetails' => CartSetLineItemShippingDetailsActionModel::class, 'setLineItemSupplyChannel' => CartSetLineItemSupplyChannelActionModel::class, 'setLineItemTaxAmount' => CartSetLineItemTaxAmountActionModel::class, diff --git a/lib/commercetools-api/src/Models/Cart/CustomLineItem.php b/lib/commercetools-api/src/Models/Cart/CustomLineItem.php index d2fe8da900e..2c1b916c04c 100644 --- a/lib/commercetools-api/src/Models/Cart/CustomLineItem.php +++ b/lib/commercetools-api/src/Models/Cart/CustomLineItem.php @@ -12,6 +12,7 @@ use Commercetools\Api\Models\Common\LocalizedString; use Commercetools\Api\Models\Common\TypedMoney; use Commercetools\Api\Models\Order\ItemStateCollection; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfo; use Commercetools\Api\Models\TaxCategory\TaxCategoryReference; use Commercetools\Api\Models\TaxCategory\TaxRate; use Commercetools\Api\Models\Type\CustomFields; @@ -37,6 +38,7 @@ interface CustomLineItem extends JsonObject public const FIELD_CUSTOM = 'custom'; public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; public const FIELD_PRICE_MODE = 'priceMode'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; /** *

Unique identifier of the Custom Line Item.

@@ -182,6 +184,14 @@ public function getShippingDetails(); */ public function getPriceMode(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|CustomLineItemRecurrenceInfo + */ + public function getRecurrenceInfo(); + /** * @param ?string $id */ @@ -266,4 +276,9 @@ 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-api/src/Models/Cart/CustomLineItemBuilder.php b/lib/commercetools-api/src/Models/Cart/CustomLineItemBuilder.php index 21fa8c89cde..b404c9774ae 100644 --- a/lib/commercetools-api/src/Models/Cart/CustomLineItemBuilder.php +++ b/lib/commercetools-api/src/Models/Cart/CustomLineItemBuilder.php @@ -15,6 +15,8 @@ use Commercetools\Api\Models\Common\TypedMoney; use Commercetools\Api\Models\Common\TypedMoneyBuilder; use Commercetools\Api\Models\Order\ItemStateCollection; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfo; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoBuilder; use Commercetools\Api\Models\TaxCategory\TaxCategoryReference; use Commercetools\Api\Models\TaxCategory\TaxCategoryReferenceBuilder; use Commercetools\Api\Models\TaxCategory\TaxRate; @@ -135,6 +137,12 @@ final class CustomLineItemBuilder implements Builder */ private $priceMode; + /** + + * @var null|CustomLineItemRecurrenceInfo|CustomLineItemRecurrenceInfoBuilder + */ + private $recurrenceInfo; + /** *

Unique identifier of the Custom Line Item.

* @@ -330,6 +338,17 @@ 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 @@ -517,6 +536,17 @@ public function withPriceMode(?string $priceMode) return $this; } + /** + * @param ?CustomLineItemRecurrenceInfo $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?CustomLineItemRecurrenceInfo $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withName() instead * @return $this @@ -605,6 +635,17 @@ public function withShippingDetailsBuilder(?ItemShippingDetailsBuilder $shipping 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( @@ -624,7 +665,8 @@ public function build(): CustomLineItem $this->discountedPricePerQuantity, $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, $this->shippingDetails instanceof ItemShippingDetailsBuilder ? $this->shippingDetails->build() : $this->shippingDetails, - $this->priceMode + $this->priceMode, + $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo ); } diff --git a/lib/commercetools-api/src/Models/Cart/CustomLineItemDraft.php b/lib/commercetools-api/src/Models/Cart/CustomLineItemDraft.php index 741bf81dc59..73e5a535f67 100644 --- a/lib/commercetools-api/src/Models/Cart/CustomLineItemDraft.php +++ b/lib/commercetools-api/src/Models/Cart/CustomLineItemDraft.php @@ -10,6 +10,7 @@ use Commercetools\Api\Models\Common\LocalizedString; use Commercetools\Api\Models\Common\Money; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraft; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifier; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; @@ -27,6 +28,7 @@ interface CustomLineItemDraft extends JsonObject public const FIELD_CUSTOM = 'custom'; public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; public const FIELD_PRICE_MODE = 'priceMode'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; /** *

Name of the Custom Line Item.

@@ -114,6 +116,14 @@ public function getShippingDetails(); */ public function getPriceMode(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + /** * @param ?LocalizedString $name */ @@ -163,4 +173,9 @@ public function setShippingDetails(?ItemShippingDetailsDraft $shippingDetails): * @param ?string $priceMode */ public function setPriceMode(?string $priceMode): void; + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void; } diff --git a/lib/commercetools-api/src/Models/Cart/CustomLineItemDraftBuilder.php b/lib/commercetools-api/src/Models/Cart/CustomLineItemDraftBuilder.php index 06c71925b52..71310037571 100644 --- a/lib/commercetools-api/src/Models/Cart/CustomLineItemDraftBuilder.php +++ b/lib/commercetools-api/src/Models/Cart/CustomLineItemDraftBuilder.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Common\LocalizedStringBuilder; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Common\MoneyBuilder; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraftBuilder; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifier; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifierBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; @@ -88,6 +90,12 @@ final class CustomLineItemDraftBuilder implements Builder */ private $priceMode; + /** + + * @var null|CustomLineItemRecurrenceInfoDraft|CustomLineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + /** *

Name of the Custom Line Item.

* @@ -204,6 +212,17 @@ public function getPriceMode() return $this->priceMode; } + /** + *

Recurring Order and frequency data.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + /** * @param ?LocalizedString $name * @return $this @@ -314,6 +333,17 @@ public function withPriceMode(?string $priceMode) return $this; } + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withName() instead * @return $this @@ -380,6 +410,17 @@ public function withShippingDetailsBuilder(?ItemShippingDetailsDraftBuilder $shi return $this; } + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?CustomLineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + public function build(): CustomLineItemDraft { return new CustomLineItemDraftModel( @@ -392,7 +433,8 @@ public function build(): CustomLineItemDraft $this->externalTaxRate instanceof ExternalTaxRateDraftBuilder ? $this->externalTaxRate->build() : $this->externalTaxRate, $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom, $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails, - $this->priceMode + $this->priceMode, + $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo ); } diff --git a/lib/commercetools-api/src/Models/Cart/CustomLineItemDraftModel.php b/lib/commercetools-api/src/Models/Cart/CustomLineItemDraftModel.php index 83c0e98de93..5c022a6dc5e 100644 --- a/lib/commercetools-api/src/Models/Cart/CustomLineItemDraftModel.php +++ b/lib/commercetools-api/src/Models/Cart/CustomLineItemDraftModel.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Common\LocalizedStringModel; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Common\MoneyModel; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraftModel; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifier; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifierModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; @@ -87,6 +89,12 @@ final class CustomLineItemDraftModel extends JsonObjectModel implements CustomLi */ protected $priceMode; + /** + * + * @var ?CustomLineItemRecurrenceInfoDraft + */ + protected $recurrenceInfo; + /** * @psalm-suppress MissingParamType @@ -101,7 +109,8 @@ public function __construct( ?ExternalTaxRateDraft $externalTaxRate = null, ?CustomFieldsDraft $custom = null, ?ItemShippingDetailsDraft $shippingDetails = null, - ?string $priceMode = null + ?string $priceMode = null, + ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo = null ) { $this->name = $name; $this->key = $key; @@ -113,6 +122,7 @@ public function __construct( $this->custom = $custom; $this->shippingDetails = $shippingDetails; $this->priceMode = $priceMode; + $this->recurrenceInfo = $recurrenceInfo; } /** @@ -327,6 +337,27 @@ public function getPriceMode() return $this->priceMode; } + /** + *

Recurring Order and frequency data.

+ * + * + * @return null|CustomLineItemRecurrenceInfoDraft + */ + 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 = CustomLineItemRecurrenceInfoDraftModel::of($data); + } + + return $this->recurrenceInfo; + } + /** * @param ?LocalizedString $name @@ -407,4 +438,12 @@ public function setPriceMode(?string $priceMode): void { $this->priceMode = $priceMode; } + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } } diff --git a/lib/commercetools-api/src/Models/Cart/CustomLineItemModel.php b/lib/commercetools-api/src/Models/Cart/CustomLineItemModel.php index 3838f1bd8d8..508aeaacccb 100644 --- a/lib/commercetools-api/src/Models/Cart/CustomLineItemModel.php +++ b/lib/commercetools-api/src/Models/Cart/CustomLineItemModel.php @@ -15,6 +15,8 @@ use Commercetools\Api\Models\Common\TypedMoney; use Commercetools\Api\Models\Common\TypedMoneyModel; use Commercetools\Api\Models\Order\ItemStateCollection; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfo; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoModel; use Commercetools\Api\Models\TaxCategory\TaxCategoryReference; use Commercetools\Api\Models\TaxCategory\TaxCategoryReferenceModel; use Commercetools\Api\Models\TaxCategory\TaxRate; @@ -134,6 +136,12 @@ final class CustomLineItemModel extends JsonObjectModel implements CustomLineIte */ protected $priceMode; + /** + * + * @var ?CustomLineItemRecurrenceInfo + */ + protected $recurrenceInfo; + /** * @psalm-suppress MissingParamType @@ -155,7 +163,8 @@ public function __construct( ?DiscountedLineItemPriceForQuantityCollection $discountedPricePerQuantity = null, ?CustomFields $custom = null, ?ItemShippingDetails $shippingDetails = null, - ?string $priceMode = null + ?string $priceMode = null, + ?CustomLineItemRecurrenceInfo $recurrenceInfo = null ) { $this->id = $id; $this->key = $key; @@ -174,6 +183,7 @@ public function __construct( $this->custom = $custom; $this->shippingDetails = $shippingDetails; $this->priceMode = $priceMode; + $this->recurrenceInfo = $recurrenceInfo; } /** @@ -532,6 +542,27 @@ public function getPriceMode() 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 @@ -668,4 +699,12 @@ 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-api/src/Models/Cart/LineItem.php b/lib/commercetools-api/src/Models/Cart/LineItem.php index 6c2f606bfc5..5f03ebc61c6 100644 --- a/lib/commercetools-api/src/Models/Cart/LineItem.php +++ b/lib/commercetools-api/src/Models/Cart/LineItem.php @@ -15,6 +15,7 @@ use Commercetools\Api\Models\Order\ItemStateCollection; use Commercetools\Api\Models\Product\ProductVariant; use Commercetools\Api\Models\ProductType\ProductTypeReference; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfo; use Commercetools\Api\Models\TaxCategory\TaxRate; use Commercetools\Api\Models\Type\CustomFields; use Commercetools\Base\DateTimeImmutableCollection; @@ -49,6 +50,7 @@ interface LineItem extends JsonObject 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.

@@ -275,6 +277,14 @@ public function getAddedAt(); */ public function getLastModifiedAt(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfo + */ + public function getRecurrenceInfo(); + /** * @param ?string $id */ @@ -404,4 +414,9 @@ public function setAddedAt(?DateTimeImmutable $addedAt): void; * @param ?DateTimeImmutable $lastModifiedAt */ public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void; + + /** + * @param ?LineItemRecurrenceInfo $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfo $recurrenceInfo): void; } diff --git a/lib/commercetools-api/src/Models/Cart/LineItemBuilder.php b/lib/commercetools-api/src/Models/Cart/LineItemBuilder.php index 931d642d03e..f1e658ab178 100644 --- a/lib/commercetools-api/src/Models/Cart/LineItemBuilder.php +++ b/lib/commercetools-api/src/Models/Cart/LineItemBuilder.php @@ -21,6 +21,8 @@ use Commercetools\Api\Models\Product\ProductVariantBuilder; use Commercetools\Api\Models\ProductType\ProductTypeReference; use Commercetools\Api\Models\ProductType\ProductTypeReferenceBuilder; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfo; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoBuilder; use Commercetools\Api\Models\TaxCategory\TaxRate; use Commercetools\Api\Models\TaxCategory\TaxRateBuilder; use Commercetools\Api\Models\Type\CustomFields; @@ -194,6 +196,12 @@ final class LineItemBuilder implements Builder */ private $lastModifiedAt; + /** + + * @var null|LineItemRecurrenceInfo|LineItemRecurrenceInfoBuilder + */ + private $recurrenceInfo; + /** *

Unique identifier of the LineItem.

* @@ -497,6 +505,17 @@ 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; + } + /** * @param ?string $id * @return $this @@ -783,6 +802,17 @@ public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt) return $this; } + /** + * @param ?LineItemRecurrenceInfo $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?LineItemRecurrenceInfo $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withName() instead * @return $this @@ -915,6 +945,17 @@ public function withCustomBuilder(?CustomFieldsBuilder $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( @@ -943,7 +984,8 @@ public function build(): LineItem $this->shippingDetails instanceof ItemShippingDetailsBuilder ? $this->shippingDetails->build() : $this->shippingDetails, $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, $this->addedAt, - $this->lastModifiedAt + $this->lastModifiedAt, + $this->recurrenceInfo instanceof LineItemRecurrenceInfoBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo ); } diff --git a/lib/commercetools-api/src/Models/Cart/LineItemDraft.php b/lib/commercetools-api/src/Models/Cart/LineItemDraft.php index 7ea59dd7b40..fa9de381c42 100644 --- a/lib/commercetools-api/src/Models/Cart/LineItemDraft.php +++ b/lib/commercetools-api/src/Models/Cart/LineItemDraft.php @@ -10,6 +10,7 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; use Commercetools\Api\Models\Common\Money; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\Base\JsonObject; @@ -32,6 +33,7 @@ interface LineItemDraft extends JsonObject public const FIELD_INVENTORY_MODE = 'inventoryMode'; public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; public const FIELD_CUSTOM = 'custom'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; /** *

User-defined unique identifier of the LineItem.

@@ -161,6 +163,14 @@ public function getShippingDetails(); */ public function getCustom(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + /** * @param ?string $key */ @@ -235,4 +245,9 @@ public function setShippingDetails(?ItemShippingDetailsDraft $shippingDetails): * @param ?CustomFieldsDraft $custom */ public function setCustom(?CustomFieldsDraft $custom): void; + + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void; } diff --git a/lib/commercetools-api/src/Models/Cart/LineItemDraftBuilder.php b/lib/commercetools-api/src/Models/Cart/LineItemDraftBuilder.php index 85394a5a3ae..72cf39a8392 100644 --- a/lib/commercetools-api/src/Models/Cart/LineItemDraftBuilder.php +++ b/lib/commercetools-api/src/Models/Cart/LineItemDraftBuilder.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifierBuilder; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Common\MoneyBuilder; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftBuilder; use Commercetools\Base\Builder; @@ -117,6 +119,12 @@ final class LineItemDraftBuilder implements Builder */ private $custom; + /** + + * @var null|LineItemRecurrenceInfoDraft|LineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + /** *

User-defined unique identifier of the LineItem.

* @@ -290,6 +298,17 @@ public function getCustom() return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom; } + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + /** * @param ?string $key * @return $this @@ -455,6 +474,17 @@ public function withCustom(?CustomFieldsDraft $custom) return $this; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withDistributionChannel() instead * @return $this @@ -532,6 +562,17 @@ public function withCustomBuilder(?CustomFieldsDraftBuilder $custom) return $this; } + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?LineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + public function build(): LineItemDraft { return new LineItemDraftModel( @@ -549,7 +590,8 @@ public function build(): LineItemDraft $this->perMethodExternalTaxRate, $this->inventoryMode, $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails, - $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom + $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom, + $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo ); } diff --git a/lib/commercetools-api/src/Models/Cart/LineItemDraftModel.php b/lib/commercetools-api/src/Models/Cart/LineItemDraftModel.php index 861efc64ab4..0db88323428 100644 --- a/lib/commercetools-api/src/Models/Cart/LineItemDraftModel.php +++ b/lib/commercetools-api/src/Models/Cart/LineItemDraftModel.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifierModel; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Common\MoneyModel; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftModel; use Commercetools\Base\DateTimeImmutableCollection; @@ -116,6 +118,12 @@ final class LineItemDraftModel extends JsonObjectModel implements LineItemDraft */ protected $custom; + /** + * + * @var ?LineItemRecurrenceInfoDraft + */ + protected $recurrenceInfo; + /** * @psalm-suppress MissingParamType @@ -135,7 +143,8 @@ public function __construct( ?MethodExternalTaxRateDraftCollection $perMethodExternalTaxRate = null, ?string $inventoryMode = null, ?ItemShippingDetailsDraft $shippingDetails = null, - ?CustomFieldsDraft $custom = null + ?CustomFieldsDraft $custom = null, + ?LineItemRecurrenceInfoDraft $recurrenceInfo = null ) { $this->key = $key; $this->productId = $productId; @@ -152,6 +161,7 @@ public function __construct( $this->inventoryMode = $inventoryMode; $this->shippingDetails = $shippingDetails; $this->custom = $custom; + $this->recurrenceInfo = $recurrenceInfo; } /** @@ -473,6 +483,27 @@ public function getCustom() return $this->custom; } + /** + *

Recurring Order and frequency data.

+ * + * + * @return null|LineItemRecurrenceInfoDraft + */ + 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 = LineItemRecurrenceInfoDraftModel::of($data); + } + + return $this->recurrenceInfo; + } + /** * @param ?string $key @@ -594,6 +625,14 @@ public function setCustom(?CustomFieldsDraft $custom): void $this->custom = $custom; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } + #[\ReturnTypeWillChange] public function jsonSerialize() diff --git a/lib/commercetools-api/src/Models/Cart/LineItemModel.php b/lib/commercetools-api/src/Models/Cart/LineItemModel.php index cfbb63d4dc8..1b13c3a6847 100644 --- a/lib/commercetools-api/src/Models/Cart/LineItemModel.php +++ b/lib/commercetools-api/src/Models/Cart/LineItemModel.php @@ -21,6 +21,8 @@ use Commercetools\Api\Models\Product\ProductVariantModel; use Commercetools\Api\Models\ProductType\ProductTypeReference; use Commercetools\Api\Models\ProductType\ProductTypeReferenceModel; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfo; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoModel; use Commercetools\Api\Models\TaxCategory\TaxRate; use Commercetools\Api\Models\TaxCategory\TaxRateModel; use Commercetools\Api\Models\Type\CustomFields; @@ -193,6 +195,12 @@ final class LineItemModel extends JsonObjectModel implements LineItem */ protected $lastModifiedAt; + /** + * + * @var ?LineItemRecurrenceInfo + */ + protected $recurrenceInfo; + /** * @psalm-suppress MissingParamType @@ -223,7 +231,8 @@ public function __construct( ?ItemShippingDetails $shippingDetails = null, ?CustomFields $custom = null, ?DateTimeImmutable $addedAt = null, - ?DateTimeImmutable $lastModifiedAt = null + ?DateTimeImmutable $lastModifiedAt = null, + ?LineItemRecurrenceInfo $recurrenceInfo = null ) { $this->id = $id; $this->key = $key; @@ -251,6 +260,7 @@ public function __construct( $this->custom = $custom; $this->addedAt = $addedAt; $this->lastModifiedAt = $lastModifiedAt; + $this->recurrenceInfo = $recurrenceInfo; } /** @@ -810,6 +820,27 @@ public function getLastModifiedAt() 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 @@ -1019,6 +1050,14 @@ 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() diff --git a/lib/commercetools-api/src/Models/Common/BaseResource.php b/lib/commercetools-api/src/Models/Common/BaseResource.php index 4e415f608ad..45306cb49aa 100644 --- a/lib/commercetools-api/src/Models/Common/BaseResource.php +++ b/lib/commercetools-api/src/Models/Common/BaseResource.php @@ -221,6 +221,17 @@ use Commercetools\Api\Models\Message\QuoteRequestStateTransitionMessage; use Commercetools\Api\Models\Message\QuoteStateChangedMessage; use Commercetools\Api\Models\Message\QuoteStateTransitionMessage; +use Commercetools\Api\Models\Message\RecurringOrderCreatedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldAddedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldChangedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldRemovedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeRemovedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderKeySetMessage; +use Commercetools\Api\Models\Message\RecurringOrderScheduleSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderStartsAtSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderStateChangedMessage; +use Commercetools\Api\Models\Message\RecurringOrderStateTransitionMessage; use Commercetools\Api\Models\Message\ReviewCreatedMessage; use Commercetools\Api\Models\Message\ReviewRatingSetMessage; use Commercetools\Api\Models\Message\ReviewStateTransitionMessage; @@ -267,6 +278,8 @@ use Commercetools\Api\Models\ProductType\ProductType; use Commercetools\Api\Models\Quote\Quote; use Commercetools\Api\Models\QuoteRequest\QuoteRequest; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicy; +use Commercetools\Api\Models\RecurringOrder\RecurringOrder; use Commercetools\Api\Models\Review\Review; use Commercetools\Api\Models\ShippingMethod\ShippingMethod; use Commercetools\Api\Models\ShoppingList\ShoppingList; diff --git a/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php b/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php index a7f7a1c84a5..5d4cdff55ef 100644 --- a/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php +++ b/lib/commercetools-api/src/Models/Common/BaseResourceBuilder.php @@ -434,6 +434,28 @@ use Commercetools\Api\Models\Message\QuoteStateChangedMessageBuilder; use Commercetools\Api\Models\Message\QuoteStateTransitionMessage; use Commercetools\Api\Models\Message\QuoteStateTransitionMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderCreatedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCreatedMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldAddedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldAddedMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldChangedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldChangedMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldRemovedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldRemovedMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeRemovedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeRemovedMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeSetMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderKeySetMessage; +use Commercetools\Api\Models\Message\RecurringOrderKeySetMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderScheduleSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderScheduleSetMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderStartsAtSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderStartsAtSetMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderStateChangedMessage; +use Commercetools\Api\Models\Message\RecurringOrderStateChangedMessageBuilder; +use Commercetools\Api\Models\Message\RecurringOrderStateTransitionMessage; +use Commercetools\Api\Models\Message\RecurringOrderStateTransitionMessageBuilder; use Commercetools\Api\Models\Message\ReviewCreatedMessage; use Commercetools\Api\Models\Message\ReviewCreatedMessageBuilder; use Commercetools\Api\Models\Message\ReviewRatingSetMessage; @@ -526,6 +548,10 @@ use Commercetools\Api\Models\Quote\QuoteBuilder; use Commercetools\Api\Models\QuoteRequest\QuoteRequest; use Commercetools\Api\Models\QuoteRequest\QuoteRequestBuilder; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicy; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyBuilder; +use Commercetools\Api\Models\RecurringOrder\RecurringOrder; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderBuilder; use Commercetools\Api\Models\Review\Review; use Commercetools\Api\Models\Review\ReviewBuilder; use Commercetools\Api\Models\ShippingMethod\ShippingMethod; diff --git a/lib/commercetools-api/src/Models/Common/BaseResourceModel.php b/lib/commercetools-api/src/Models/Common/BaseResourceModel.php index 66a6430295f..dbc99f263b8 100644 --- a/lib/commercetools-api/src/Models/Common/BaseResourceModel.php +++ b/lib/commercetools-api/src/Models/Common/BaseResourceModel.php @@ -434,6 +434,28 @@ use Commercetools\Api\Models\Message\QuoteStateChangedMessageModel; use Commercetools\Api\Models\Message\QuoteStateTransitionMessage; use Commercetools\Api\Models\Message\QuoteStateTransitionMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderCreatedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCreatedMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldAddedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldAddedMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldChangedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldChangedMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldRemovedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomFieldRemovedMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeRemovedMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeRemovedMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderCustomTypeSetMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderKeySetMessage; +use Commercetools\Api\Models\Message\RecurringOrderKeySetMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderScheduleSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderScheduleSetMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderStartsAtSetMessage; +use Commercetools\Api\Models\Message\RecurringOrderStartsAtSetMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderStateChangedMessage; +use Commercetools\Api\Models\Message\RecurringOrderStateChangedMessageModel; +use Commercetools\Api\Models\Message\RecurringOrderStateTransitionMessage; +use Commercetools\Api\Models\Message\RecurringOrderStateTransitionMessageModel; use Commercetools\Api\Models\Message\ReviewCreatedMessage; use Commercetools\Api\Models\Message\ReviewCreatedMessageModel; use Commercetools\Api\Models\Message\ReviewRatingSetMessage; @@ -526,6 +548,10 @@ use Commercetools\Api\Models\Quote\QuoteModel; use Commercetools\Api\Models\QuoteRequest\QuoteRequest; use Commercetools\Api\Models\QuoteRequest\QuoteRequestModel; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicy; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyModel; +use Commercetools\Api\Models\RecurringOrder\RecurringOrder; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderModel; use Commercetools\Api\Models\Review\Review; use Commercetools\Api\Models\Review\ReviewModel; use Commercetools\Api\Models\ShippingMethod\ShippingMethod; diff --git a/lib/commercetools-api/src/Models/Common/Price.php b/lib/commercetools-api/src/Models/Common/Price.php index d7802da1020..c3f4fd78af1 100644 --- a/lib/commercetools-api/src/Models/Common/Price.php +++ b/lib/commercetools-api/src/Models/Common/Price.php @@ -10,6 +10,7 @@ use Commercetools\Api\Models\Channel\ChannelReference; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReference; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReference; use Commercetools\Api\Models\Type\CustomFields; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\Base\JsonObject; @@ -28,6 +29,7 @@ interface Price extends JsonObject 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.

@@ -120,6 +122,14 @@ public function getTiers(); */ public function getCustom(); + /** + *

Recurrence Policy for which this Price is valid.

+ * + + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy(); + /** * @param ?string $id */ @@ -174,4 +184,9 @@ public function setTiers(?PriceTierCollection $tiers): void; * @param ?CustomFields $custom */ public function setCustom(?CustomFields $custom): void; + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy): void; } diff --git a/lib/commercetools-api/src/Models/Common/PriceBuilder.php b/lib/commercetools-api/src/Models/Common/PriceBuilder.php index adb568c44f8..ee70fa17fb2 100644 --- a/lib/commercetools-api/src/Models/Common/PriceBuilder.php +++ b/lib/commercetools-api/src/Models/Common/PriceBuilder.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Channel\ChannelReferenceBuilder; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReference; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReferenceBuilder; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReference; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReferenceBuilder; use Commercetools\Api\Models\Type\CustomFields; use Commercetools\Api\Models\Type\CustomFieldsBuilder; use Commercetools\Base\Builder; @@ -93,6 +95,12 @@ final class PriceBuilder implements Builder */ private $custom; + /** + + * @var null|RecurrencePolicyReference|RecurrencePolicyReferenceBuilder + */ + private $recurrencePolicy; + /** *

Unique identifier of this Price.

* @@ -217,6 +225,17 @@ 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; + } + /** * @param ?string $id * @return $this @@ -338,6 +357,17 @@ public function withCustom(?CustomFields $custom) return $this; } + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + /** * @deprecated use withValue() instead * @return $this @@ -393,6 +423,17 @@ public function withCustomBuilder(?CustomFieldsBuilder $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( @@ -406,7 +447,8 @@ public function build(): Price $this->validUntil, $this->discounted instanceof DiscountedPriceBuilder ? $this->discounted->build() : $this->discounted, $this->tiers, - $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, + $this->recurrencePolicy instanceof RecurrencePolicyReferenceBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy ); } diff --git a/lib/commercetools-api/src/Models/Common/PriceDraft.php b/lib/commercetools-api/src/Models/Common/PriceDraft.php index a2d63560cc3..9354cf0efe1 100644 --- a/lib/commercetools-api/src/Models/Common/PriceDraft.php +++ b/lib/commercetools-api/src/Models/Common/PriceDraft.php @@ -10,6 +10,7 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifier; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifier; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\Base\JsonObject; @@ -27,6 +28,7 @@ interface PriceDraft extends JsonObject public const FIELD_DISCOUNTED = 'discounted'; public const FIELD_TIERS = 'tiers'; public const FIELD_CUSTOM = 'custom'; + public const FIELD_RECURRENCE_POLICY = 'recurrencePolicy'; /** *

User-defined identifier for the Price. It must be unique per ProductVariant.

@@ -117,6 +119,14 @@ public function getTiers(); */ public function getCustom(); + /** + *

RecurrencePolicy for which this Price is valid.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy(); + /** * @param ?string $key */ @@ -166,4 +176,9 @@ public function setTiers(?PriceTierDraftCollection $tiers): void; * @param ?CustomFieldsDraft $custom */ public function setCustom(?CustomFieldsDraft $custom): void; + + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void; } diff --git a/lib/commercetools-api/src/Models/Common/PriceDraftBuilder.php b/lib/commercetools-api/src/Models/Common/PriceDraftBuilder.php index 7caab423f75..ec1fb16d441 100644 --- a/lib/commercetools-api/src/Models/Common/PriceDraftBuilder.php +++ b/lib/commercetools-api/src/Models/Common/PriceDraftBuilder.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifierBuilder; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifier; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifierBuilder; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifier; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifierBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftBuilder; use Commercetools\Base\Builder; @@ -87,6 +89,12 @@ final class PriceDraftBuilder implements Builder */ private $custom; + /** + + * @var null|RecurrencePolicyResourceIdentifier|RecurrencePolicyResourceIdentifierBuilder + */ + private $recurrencePolicy; + /** *

User-defined identifier for the Price. It must be unique per ProductVariant.

* @@ -206,6 +214,17 @@ public function getCustom() return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom; } + /** + *

RecurrencePolicy for which this Price is valid.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy() + { + return $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy; + } + /** * @param ?string $key * @return $this @@ -316,6 +335,17 @@ public function withCustom(?CustomFieldsDraft $custom) return $this; } + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + /** * @deprecated use withValue() instead * @return $this @@ -371,6 +401,17 @@ public function withCustomBuilder(?CustomFieldsDraftBuilder $custom) return $this; } + /** + * @deprecated use withRecurrencePolicy() instead + * @return $this + */ + public function withRecurrencePolicyBuilder(?RecurrencePolicyResourceIdentifierBuilder $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + public function build(): PriceDraft { return new PriceDraftModel( @@ -383,7 +424,8 @@ public function build(): PriceDraft $this->validUntil, $this->discounted instanceof DiscountedPriceDraftBuilder ? $this->discounted->build() : $this->discounted, $this->tiers, - $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom + $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom, + $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy ); } diff --git a/lib/commercetools-api/src/Models/Common/PriceDraftModel.php b/lib/commercetools-api/src/Models/Common/PriceDraftModel.php index c7be25630a1..f3c65d1b125 100644 --- a/lib/commercetools-api/src/Models/Common/PriceDraftModel.php +++ b/lib/commercetools-api/src/Models/Common/PriceDraftModel.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifierModel; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifier; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifierModel; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifier; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifierModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftModel; use Commercetools\Base\DateTimeImmutableCollection; @@ -86,6 +88,12 @@ final class PriceDraftModel extends JsonObjectModel implements PriceDraft */ protected $custom; + /** + * + * @var ?RecurrencePolicyResourceIdentifier + */ + protected $recurrencePolicy; + /** * @psalm-suppress MissingParamType @@ -100,7 +108,8 @@ public function __construct( ?DateTimeImmutable $validUntil = null, ?DiscountedPriceDraft $discounted = null, ?PriceTierDraftCollection $tiers = null, - ?CustomFieldsDraft $custom = null + ?CustomFieldsDraft $custom = null, + ?RecurrencePolicyResourceIdentifier $recurrencePolicy = null ) { $this->key = $key; $this->value = $value; @@ -112,6 +121,7 @@ public function __construct( $this->discounted = $discounted; $this->tiers = $tiers; $this->custom = $custom; + $this->recurrencePolicy = $recurrencePolicy; } /** @@ -336,6 +346,27 @@ public function getCustom() return $this->custom; } + /** + *

RecurrencePolicy for which this Price is valid.

+ * + * + * @return null|RecurrencePolicyResourceIdentifier + */ + 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 = RecurrencePolicyResourceIdentifierModel::of($data); + } + + return $this->recurrencePolicy; + } + /** * @param ?string $key @@ -417,6 +448,14 @@ public function setCustom(?CustomFieldsDraft $custom): void $this->custom = $custom; } + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void + { + $this->recurrencePolicy = $recurrencePolicy; + } + #[\ReturnTypeWillChange] public function jsonSerialize() diff --git a/lib/commercetools-api/src/Models/Common/PriceModel.php b/lib/commercetools-api/src/Models/Common/PriceModel.php index a9db5398142..2746cb5925f 100644 --- a/lib/commercetools-api/src/Models/Common/PriceModel.php +++ b/lib/commercetools-api/src/Models/Common/PriceModel.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Channel\ChannelReferenceModel; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReference; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReferenceModel; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReference; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReferenceModel; use Commercetools\Api\Models\Type\CustomFields; use Commercetools\Api\Models\Type\CustomFieldsModel; use Commercetools\Base\DateTimeImmutableCollection; @@ -92,6 +94,12 @@ final class PriceModel extends JsonObjectModel implements Price */ protected $custom; + /** + * + * @var ?RecurrencePolicyReference + */ + protected $recurrencePolicy; + /** * @psalm-suppress MissingParamType @@ -107,7 +115,8 @@ public function __construct( ?DateTimeImmutable $validUntil = null, ?DiscountedPrice $discounted = null, ?PriceTierCollection $tiers = null, - ?CustomFields $custom = null + ?CustomFields $custom = null, + ?RecurrencePolicyReference $recurrencePolicy = null ) { $this->id = $id; $this->key = $key; @@ -120,6 +129,7 @@ public function __construct( $this->discounted = $discounted; $this->tiers = $tiers; $this->custom = $custom; + $this->recurrencePolicy = $recurrencePolicy; } /** @@ -358,6 +368,27 @@ public function getCustom() 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 @@ -447,6 +478,14 @@ 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() diff --git a/lib/commercetools-api/src/Models/Common/Reference.php b/lib/commercetools-api/src/Models/Common/Reference.php index b5ff3d34263..626d5455eb6 100644 --- a/lib/commercetools-api/src/Models/Common/Reference.php +++ b/lib/commercetools-api/src/Models/Common/Reference.php @@ -35,6 +35,8 @@ use Commercetools\Api\Models\ProductType\ProductTypeReference; use Commercetools\Api\Models\Quote\QuoteReference; use Commercetools\Api\Models\QuoteRequest\QuoteRequestReference; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReference; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReference; use Commercetools\Api\Models\Review\ReviewReference; use Commercetools\Api\Models\ShippingMethod\ShippingMethodReference; use Commercetools\Api\Models\ShoppingList\ShoppingListReference; diff --git a/lib/commercetools-api/src/Models/Common/ReferenceBuilder.php b/lib/commercetools-api/src/Models/Common/ReferenceBuilder.php index 07db57a8744..3ea35053ed9 100644 --- a/lib/commercetools-api/src/Models/Common/ReferenceBuilder.php +++ b/lib/commercetools-api/src/Models/Common/ReferenceBuilder.php @@ -62,6 +62,10 @@ use Commercetools\Api\Models\Quote\QuoteReferenceBuilder; use Commercetools\Api\Models\QuoteRequest\QuoteRequestReference; use Commercetools\Api\Models\QuoteRequest\QuoteRequestReferenceBuilder; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReference; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReferenceBuilder; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReference; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReferenceBuilder; use Commercetools\Api\Models\Review\ReviewReference; use Commercetools\Api\Models\Review\ReviewReferenceBuilder; use Commercetools\Api\Models\ShippingMethod\ShippingMethodReference; diff --git a/lib/commercetools-api/src/Models/Common/ReferenceModel.php b/lib/commercetools-api/src/Models/Common/ReferenceModel.php index c8871089dfa..f85e22d85cc 100644 --- a/lib/commercetools-api/src/Models/Common/ReferenceModel.php +++ b/lib/commercetools-api/src/Models/Common/ReferenceModel.php @@ -62,6 +62,10 @@ use Commercetools\Api\Models\Quote\QuoteReferenceModel; use Commercetools\Api\Models\QuoteRequest\QuoteRequestReference; use Commercetools\Api\Models\QuoteRequest\QuoteRequestReferenceModel; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReference; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReferenceModel; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReference; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReferenceModel; use Commercetools\Api\Models\Review\ReviewReference; use Commercetools\Api\Models\Review\ReviewReferenceModel; use Commercetools\Api\Models\ShippingMethod\ShippingMethodReference; @@ -138,6 +142,8 @@ final class ReferenceModel extends JsonObjectModel implements Reference 'product-type' => ProductTypeReferenceModel::class, 'quote' => QuoteReferenceModel::class, 'quote-request' => QuoteRequestReferenceModel::class, + 'recurrence-policy' => RecurrencePolicyReferenceModel::class, + 'recurring-order' => RecurringOrderReferenceModel::class, 'review' => ReviewReferenceModel::class, 'shipping-method' => ShippingMethodReferenceModel::class, 'shopping-list' => ShoppingListReferenceModel::class, diff --git a/lib/commercetools-api/src/Models/Common/ResourceIdentifier.php b/lib/commercetools-api/src/Models/Common/ResourceIdentifier.php index f8e0e342f3b..a038d2a7041 100644 --- a/lib/commercetools-api/src/Models/Common/ResourceIdentifier.php +++ b/lib/commercetools-api/src/Models/Common/ResourceIdentifier.php @@ -29,6 +29,8 @@ use Commercetools\Api\Models\ProductType\ProductTypeResourceIdentifier; use Commercetools\Api\Models\Quote\QuoteResourceIdentifier; use Commercetools\Api\Models\QuoteRequest\QuoteRequestResourceIdentifier; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifier; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderResourceIdentifier; use Commercetools\Api\Models\Review\ReviewResourceIdentifier; use Commercetools\Api\Models\ShippingMethod\ShippingMethodResourceIdentifier; use Commercetools\Api\Models\ShoppingList\ShoppingListResourceIdentifier; diff --git a/lib/commercetools-api/src/Models/Common/ResourceIdentifierBuilder.php b/lib/commercetools-api/src/Models/Common/ResourceIdentifierBuilder.php index 34be0beaaa4..bda9cef9adc 100644 --- a/lib/commercetools-api/src/Models/Common/ResourceIdentifierBuilder.php +++ b/lib/commercetools-api/src/Models/Common/ResourceIdentifierBuilder.php @@ -50,6 +50,10 @@ use Commercetools\Api\Models\Quote\QuoteResourceIdentifierBuilder; use Commercetools\Api\Models\QuoteRequest\QuoteRequestResourceIdentifier; use Commercetools\Api\Models\QuoteRequest\QuoteRequestResourceIdentifierBuilder; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifier; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifierBuilder; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderResourceIdentifier; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderResourceIdentifierBuilder; use Commercetools\Api\Models\Review\ReviewResourceIdentifier; use Commercetools\Api\Models\Review\ReviewResourceIdentifierBuilder; use Commercetools\Api\Models\ShippingMethod\ShippingMethodResourceIdentifier; diff --git a/lib/commercetools-api/src/Models/Common/ResourceIdentifierModel.php b/lib/commercetools-api/src/Models/Common/ResourceIdentifierModel.php index 0271f1ab164..fb0db3db21d 100644 --- a/lib/commercetools-api/src/Models/Common/ResourceIdentifierModel.php +++ b/lib/commercetools-api/src/Models/Common/ResourceIdentifierModel.php @@ -50,6 +50,10 @@ use Commercetools\Api\Models\Quote\QuoteResourceIdentifierModel; use Commercetools\Api\Models\QuoteRequest\QuoteRequestResourceIdentifier; use Commercetools\Api\Models\QuoteRequest\QuoteRequestResourceIdentifierModel; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifier; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifierModel; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderResourceIdentifier; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderResourceIdentifierModel; use Commercetools\Api\Models\Review\ReviewResourceIdentifier; use Commercetools\Api\Models\Review\ReviewResourceIdentifierModel; use Commercetools\Api\Models\ShippingMethod\ShippingMethodResourceIdentifier; @@ -126,6 +130,8 @@ final class ResourceIdentifierModel extends JsonObjectModel implements ResourceI 'product-type' => ProductTypeResourceIdentifierModel::class, 'quote' => QuoteResourceIdentifierModel::class, 'quote-request' => QuoteRequestResourceIdentifierModel::class, + 'recurrence-policy' => RecurrencePolicyResourceIdentifierModel::class, + 'recurring-order' => RecurringOrderResourceIdentifierModel::class, 'review' => ReviewResourceIdentifierModel::class, 'shipping-method' => ShippingMethodResourceIdentifierModel::class, 'shopping-list' => ShoppingListResourceIdentifierModel::class, diff --git a/lib/commercetools-api/src/Models/Me/MyCartAddLineItemAction.php b/lib/commercetools-api/src/Models/Me/MyCartAddLineItemAction.php index e2e3e79ef4f..d38e47b85b7 100644 --- a/lib/commercetools-api/src/Models/Me/MyCartAddLineItemAction.php +++ b/lib/commercetools-api/src/Models/Me/MyCartAddLineItemAction.php @@ -10,6 +10,7 @@ use Commercetools\Api\Models\Cart\ItemShippingDetailsDraft; use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\Base\JsonObject; @@ -26,6 +27,7 @@ interface MyCartAddLineItemAction extends MyCartUpdateAction public const FIELD_DISTRIBUTION_CHANNEL = 'distributionChannel'; public const FIELD_SUPPLY_CHANNEL = 'supplyChannel'; public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; public const FIELD_CUSTOM = 'custom'; /** @@ -109,6 +111,14 @@ public function getSupplyChannel(); */ public function getShippingDetails(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + /** *

Custom Fields for the Line Item.

* @@ -162,6 +172,11 @@ public function setSupplyChannel(?ChannelResourceIdentifier $supplyChannel): voi */ public function setShippingDetails(?ItemShippingDetailsDraft $shippingDetails): void; + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void; + /** * @param ?CustomFieldsDraft $custom */ diff --git a/lib/commercetools-api/src/Models/Me/MyCartAddLineItemActionBuilder.php b/lib/commercetools-api/src/Models/Me/MyCartAddLineItemActionBuilder.php index aa149e21a84..ea81c7f78ed 100644 --- a/lib/commercetools-api/src/Models/Me/MyCartAddLineItemActionBuilder.php +++ b/lib/commercetools-api/src/Models/Me/MyCartAddLineItemActionBuilder.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Cart\ItemShippingDetailsDraftBuilder; use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; use Commercetools\Api\Models\Channel\ChannelResourceIdentifierBuilder; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftBuilder; use Commercetools\Base\Builder; @@ -81,6 +83,12 @@ final class MyCartAddLineItemActionBuilder implements Builder */ private $shippingDetails; + /** + + * @var null|LineItemRecurrenceInfoDraft|LineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + /** * @var null|CustomFieldsDraft|CustomFieldsDraftBuilder @@ -195,6 +203,17 @@ public function getShippingDetails() return $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails; } + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + /** *

Custom Fields for the Line Item.

* @@ -305,6 +324,17 @@ public function withShippingDetails(?ItemShippingDetailsDraft $shippingDetails) return $this; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @param ?CustomFieldsDraft $custom * @return $this @@ -349,6 +379,17 @@ public function withShippingDetailsBuilder(?ItemShippingDetailsDraftBuilder $shi return $this; } + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?LineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withCustom() instead * @return $this @@ -372,6 +413,7 @@ public function build(): MyCartAddLineItemAction $this->distributionChannel instanceof ChannelResourceIdentifierBuilder ? $this->distributionChannel->build() : $this->distributionChannel, $this->supplyChannel instanceof ChannelResourceIdentifierBuilder ? $this->supplyChannel->build() : $this->supplyChannel, $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails, + $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo, $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom ); } diff --git a/lib/commercetools-api/src/Models/Me/MyCartAddLineItemActionModel.php b/lib/commercetools-api/src/Models/Me/MyCartAddLineItemActionModel.php index 50a4e398ddd..edb75d94df8 100644 --- a/lib/commercetools-api/src/Models/Me/MyCartAddLineItemActionModel.php +++ b/lib/commercetools-api/src/Models/Me/MyCartAddLineItemActionModel.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Cart\ItemShippingDetailsDraftModel; use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; use Commercetools\Api\Models\Channel\ChannelResourceIdentifierModel; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftModel; use Commercetools\Base\DateTimeImmutableCollection; @@ -87,6 +89,12 @@ final class MyCartAddLineItemActionModel extends JsonObjectModel implements MyCa */ protected $shippingDetails; + /** + * + * @var ?LineItemRecurrenceInfoDraft + */ + protected $recurrenceInfo; + /** * * @var ?CustomFieldsDraft @@ -107,6 +115,7 @@ public function __construct( ?ChannelResourceIdentifier $distributionChannel = null, ?ChannelResourceIdentifier $supplyChannel = null, ?ItemShippingDetailsDraft $shippingDetails = null, + ?LineItemRecurrenceInfoDraft $recurrenceInfo = null, ?CustomFieldsDraft $custom = null, ?string $action = null ) { @@ -119,6 +128,7 @@ public function __construct( $this->distributionChannel = $distributionChannel; $this->supplyChannel = $supplyChannel; $this->shippingDetails = $shippingDetails; + $this->recurrenceInfo = $recurrenceInfo; $this->custom = $custom; $this->action = $action ?? self::DISCRIMINATOR_VALUE; } @@ -337,6 +347,27 @@ public function getShippingDetails() return $this->shippingDetails; } + /** + *

Recurring Order and frequency data.

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

Custom Fields for the Line Item.

* @@ -431,6 +462,14 @@ public function setShippingDetails(?ItemShippingDetailsDraft $shippingDetails): $this->shippingDetails = $shippingDetails; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } + /** * @param ?CustomFieldsDraft $custom */ diff --git a/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoAction.php b/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoAction.php new file mode 100644 index 00000000000..eeeefac2359 --- /dev/null +++ b/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoAction.php @@ -0,0 +1,60 @@ +id of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

key of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void; + + /** + * @param ?string $customLineItemKey + */ + public function setCustomLineItemKey(?string $customLineItemKey): void; + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void; +} diff --git a/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoActionBuilder.php b/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoActionBuilder.php new file mode 100644 index 00000000000..640a9502aff --- /dev/null +++ b/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoActionBuilder.php @@ -0,0 +1,134 @@ + + */ +final class MyCartSetCustomLineItemRecurrenceInfoActionBuilder implements Builder +{ + /** + + * @var ?string + */ + private $customLineItemId; + + /** + + * @var ?string + */ + private $customLineItemKey; + + /** + + * @var null|CustomLineItemRecurrenceInfoDraft|CustomLineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + + /** + *

id of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

key of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + + /** + * @param ?string $customLineItemId + * @return $this + */ + public function withCustomLineItemId(?string $customLineItemId) + { + $this->customLineItemId = $customLineItemId; + + return $this; + } + + /** + * @param ?string $customLineItemKey + * @return $this + */ + public function withCustomLineItemKey(?string $customLineItemKey) + { + $this->customLineItemKey = $customLineItemKey; + + return $this; + } + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?CustomLineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + + public function build(): MyCartSetCustomLineItemRecurrenceInfoAction + { + return new MyCartSetCustomLineItemRecurrenceInfoActionModel( + $this->customLineItemId, + $this->customLineItemKey, + $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo + ); + } + + public static function of(): MyCartSetCustomLineItemRecurrenceInfoActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoActionCollection.php b/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoActionCollection.php new file mode 100644 index 00000000000..f1747b474cd --- /dev/null +++ b/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoActionCollection.php @@ -0,0 +1,56 @@ + + * @method MyCartSetCustomLineItemRecurrenceInfoAction current() + * @method MyCartSetCustomLineItemRecurrenceInfoAction end() + * @method MyCartSetCustomLineItemRecurrenceInfoAction at($offset) + */ +class MyCartSetCustomLineItemRecurrenceInfoActionCollection extends MyCartUpdateActionCollection +{ + /** + * @psalm-assert MyCartSetCustomLineItemRecurrenceInfoAction $value + * @psalm-param MyCartSetCustomLineItemRecurrenceInfoAction|stdClass $value + * @throws InvalidArgumentException + * + * @return MyCartSetCustomLineItemRecurrenceInfoActionCollection + */ + public function add($value) + { + if (!$value instanceof MyCartSetCustomLineItemRecurrenceInfoAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?MyCartSetCustomLineItemRecurrenceInfoAction + */ + protected function mapper() + { + return function (?int $index): ?MyCartSetCustomLineItemRecurrenceInfoAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var MyCartSetCustomLineItemRecurrenceInfoAction $data */ + $data = MyCartSetCustomLineItemRecurrenceInfoActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoActionModel.php b/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoActionModel.php new file mode 100644 index 00000000000..735077b4ae6 --- /dev/null +++ b/lib/commercetools-api/src/Models/Me/MyCartSetCustomLineItemRecurrenceInfoActionModel.php @@ -0,0 +1,169 @@ +customLineItemId = $customLineItemId; + $this->customLineItemKey = $customLineItemKey; + $this->recurrenceInfo = $recurrenceInfo; + $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; + } + + /** + *

id of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

key of the CustomLineItem to update. Either customLineItemId or customLineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + * + * @return null|CustomLineItemRecurrenceInfoDraft + */ + 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 = CustomLineItemRecurrenceInfoDraftModel::of($data); + } + + return $this->recurrenceInfo; + } + + + /** + * @param ?string $customLineItemId + */ + public function setCustomLineItemId(?string $customLineItemId): void + { + $this->customLineItemId = $customLineItemId; + } + + /** + * @param ?string $customLineItemKey + */ + public function setCustomLineItemKey(?string $customLineItemKey): void + { + $this->customLineItemKey = $customLineItemKey; + } + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } +} diff --git a/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoAction.php b/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoAction.php new file mode 100644 index 00000000000..8941333256a --- /dev/null +++ b/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoAction.php @@ -0,0 +1,60 @@ +id of the LineItem to update. Either lineItemId or lineItemKey is required.

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

key of the LineItem to update. Either lineItemId or lineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void; + + /** + * @param ?string $lineItemKey + */ + public function setLineItemKey(?string $lineItemKey): void; + + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void; +} diff --git a/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoActionBuilder.php b/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoActionBuilder.php new file mode 100644 index 00000000000..f30874674b7 --- /dev/null +++ b/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoActionBuilder.php @@ -0,0 +1,134 @@ + + */ +final class MyCartSetLineItemRecurrenceInfoActionBuilder implements Builder +{ + /** + + * @var ?string + */ + private $lineItemId; + + /** + + * @var ?string + */ + private $lineItemKey; + + /** + + * @var null|LineItemRecurrenceInfoDraft|LineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + + /** + *

id of the LineItem to update. Either lineItemId or lineItemKey is required.

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

key of the LineItem to update. Either lineItemId or lineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + + /** + * @param ?string $lineItemId + * @return $this + */ + public function withLineItemId(?string $lineItemId) + { + $this->lineItemId = $lineItemId; + + return $this; + } + + /** + * @param ?string $lineItemKey + * @return $this + */ + public function withLineItemKey(?string $lineItemKey) + { + $this->lineItemKey = $lineItemKey; + + return $this; + } + + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?LineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + + public function build(): MyCartSetLineItemRecurrenceInfoAction + { + return new MyCartSetLineItemRecurrenceInfoActionModel( + $this->lineItemId, + $this->lineItemKey, + $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo + ); + } + + public static function of(): MyCartSetLineItemRecurrenceInfoActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoActionCollection.php b/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoActionCollection.php new file mode 100644 index 00000000000..41a5178fb6f --- /dev/null +++ b/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoActionCollection.php @@ -0,0 +1,56 @@ + + * @method MyCartSetLineItemRecurrenceInfoAction current() + * @method MyCartSetLineItemRecurrenceInfoAction end() + * @method MyCartSetLineItemRecurrenceInfoAction at($offset) + */ +class MyCartSetLineItemRecurrenceInfoActionCollection extends MyCartUpdateActionCollection +{ + /** + * @psalm-assert MyCartSetLineItemRecurrenceInfoAction $value + * @psalm-param MyCartSetLineItemRecurrenceInfoAction|stdClass $value + * @throws InvalidArgumentException + * + * @return MyCartSetLineItemRecurrenceInfoActionCollection + */ + public function add($value) + { + if (!$value instanceof MyCartSetLineItemRecurrenceInfoAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?MyCartSetLineItemRecurrenceInfoAction + */ + protected function mapper() + { + return function (?int $index): ?MyCartSetLineItemRecurrenceInfoAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var MyCartSetLineItemRecurrenceInfoAction $data */ + $data = MyCartSetLineItemRecurrenceInfoActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoActionModel.php b/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoActionModel.php new file mode 100644 index 00000000000..df7c9a93cee --- /dev/null +++ b/lib/commercetools-api/src/Models/Me/MyCartSetLineItemRecurrenceInfoActionModel.php @@ -0,0 +1,169 @@ +lineItemId = $lineItemId; + $this->lineItemKey = $lineItemKey; + $this->recurrenceInfo = $recurrenceInfo; + $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; + } + + /** + *

id of the LineItem to update. Either lineItemId or lineItemKey is required.

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

key of the LineItem to update. Either lineItemId or lineItemKey is required.

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

Value to set. + * If empty, any existing value will be removed.

+ * + * + * @return null|LineItemRecurrenceInfoDraft + */ + 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 = LineItemRecurrenceInfoDraftModel::of($data); + } + + return $this->recurrenceInfo; + } + + + /** + * @param ?string $lineItemId + */ + public function setLineItemId(?string $lineItemId): void + { + $this->lineItemId = $lineItemId; + } + + /** + * @param ?string $lineItemKey + */ + public function setLineItemKey(?string $lineItemKey): void + { + $this->lineItemKey = $lineItemKey; + } + + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } +} diff --git a/lib/commercetools-api/src/Models/Me/MyCartUpdateActionModel.php b/lib/commercetools-api/src/Models/Me/MyCartUpdateActionModel.php index b2ee853469a..135fc7c2dd1 100644 --- a/lib/commercetools-api/src/Models/Me/MyCartUpdateActionModel.php +++ b/lib/commercetools-api/src/Models/Me/MyCartUpdateActionModel.php @@ -48,12 +48,14 @@ final class MyCartUpdateActionModel extends JsonObjectModel implements MyCartUpd 'setBusinessUnit' => MyCartSetBusinessUnitActionModel::class, 'setCountry' => MyCartSetCountryActionModel::class, 'setCustomField' => MyCartSetCustomFieldActionModel::class, + 'setCustomLineItemRecurrenceInfo' => MyCartSetCustomLineItemRecurrenceInfoActionModel::class, 'setCustomType' => MyCartSetCustomTypeActionModel::class, 'setCustomerEmail' => MyCartSetCustomerEmailActionModel::class, 'setDeleteDaysAfterLastModification' => MyCartSetDeleteDaysAfterLastModificationActionModel::class, 'setLineItemCustomField' => MyCartSetLineItemCustomFieldActionModel::class, 'setLineItemCustomType' => MyCartSetLineItemCustomTypeActionModel::class, 'setLineItemDistributionChannel' => MyCartSetLineItemDistributionChannelActionModel::class, + 'setLineItemRecurrenceInfo' => MyCartSetLineItemRecurrenceInfoActionModel::class, 'setLineItemShippingDetails' => MyCartSetLineItemShippingDetailsActionModel::class, 'setLineItemSupplyChannel' => MyCartSetLineItemSupplyChannelActionModel::class, 'setLocale' => MyCartSetLocaleActionModel::class, diff --git a/lib/commercetools-api/src/Models/Me/MyLineItemDraft.php b/lib/commercetools-api/src/Models/Me/MyLineItemDraft.php index 77be1900ac5..a72ec478387 100644 --- a/lib/commercetools-api/src/Models/Me/MyLineItemDraft.php +++ b/lib/commercetools-api/src/Models/Me/MyLineItemDraft.php @@ -10,6 +10,7 @@ use Commercetools\Api\Models\Cart\ItemShippingDetailsDraft; use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\Base\JsonObject; @@ -26,6 +27,7 @@ interface MyLineItemDraft extends JsonObject public const FIELD_SUPPLY_CHANNEL = 'supplyChannel'; public const FIELD_DISTRIBUTION_CHANNEL = 'distributionChannel'; public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; public const FIELD_CUSTOM = 'custom'; /** @@ -107,6 +109,14 @@ public function getDistributionChannel(); */ public function getShippingDetails(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + /** *

Custom Fields for the Cart.

* @@ -160,6 +170,11 @@ public function setDistributionChannel(?ChannelResourceIdentifier $distributionC */ public function setShippingDetails(?ItemShippingDetailsDraft $shippingDetails): void; + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void; + /** * @param ?CustomFieldsDraft $custom */ diff --git a/lib/commercetools-api/src/Models/Me/MyLineItemDraftBuilder.php b/lib/commercetools-api/src/Models/Me/MyLineItemDraftBuilder.php index f99a45e16a6..ed37e584768 100644 --- a/lib/commercetools-api/src/Models/Me/MyLineItemDraftBuilder.php +++ b/lib/commercetools-api/src/Models/Me/MyLineItemDraftBuilder.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Cart\ItemShippingDetailsDraftBuilder; use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; use Commercetools\Api\Models\Channel\ChannelResourceIdentifierBuilder; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftBuilder; use Commercetools\Base\Builder; @@ -81,6 +83,12 @@ final class MyLineItemDraftBuilder implements Builder */ private $shippingDetails; + /** + + * @var null|LineItemRecurrenceInfoDraft|LineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + /** * @var null|CustomFieldsDraft|CustomFieldsDraftBuilder @@ -193,6 +201,17 @@ public function getShippingDetails() return $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails; } + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + /** *

Custom Fields for the Cart.

* @@ -303,6 +322,17 @@ public function withShippingDetails(?ItemShippingDetailsDraft $shippingDetails) return $this; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @param ?CustomFieldsDraft $custom * @return $this @@ -347,6 +377,17 @@ public function withShippingDetailsBuilder(?ItemShippingDetailsDraftBuilder $shi return $this; } + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?LineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withCustom() instead * @return $this @@ -370,6 +411,7 @@ public function build(): MyLineItemDraft $this->supplyChannel instanceof ChannelResourceIdentifierBuilder ? $this->supplyChannel->build() : $this->supplyChannel, $this->distributionChannel instanceof ChannelResourceIdentifierBuilder ? $this->distributionChannel->build() : $this->distributionChannel, $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails, + $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo, $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom ); } diff --git a/lib/commercetools-api/src/Models/Me/MyLineItemDraftModel.php b/lib/commercetools-api/src/Models/Me/MyLineItemDraftModel.php index 6d772f6fc07..0f44f31a752 100644 --- a/lib/commercetools-api/src/Models/Me/MyLineItemDraftModel.php +++ b/lib/commercetools-api/src/Models/Me/MyLineItemDraftModel.php @@ -12,6 +12,8 @@ use Commercetools\Api\Models\Cart\ItemShippingDetailsDraftModel; use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; use Commercetools\Api\Models\Channel\ChannelResourceIdentifierModel; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftModel; use Commercetools\Base\DateTimeImmutableCollection; @@ -80,6 +82,12 @@ final class MyLineItemDraftModel extends JsonObjectModel implements MyLineItemDr */ protected $shippingDetails; + /** + * + * @var ?LineItemRecurrenceInfoDraft + */ + protected $recurrenceInfo; + /** * * @var ?CustomFieldsDraft @@ -100,6 +108,7 @@ public function __construct( ?ChannelResourceIdentifier $supplyChannel = null, ?ChannelResourceIdentifier $distributionChannel = null, ?ItemShippingDetailsDraft $shippingDetails = null, + ?LineItemRecurrenceInfoDraft $recurrenceInfo = null, ?CustomFieldsDraft $custom = null ) { $this->key = $key; @@ -111,6 +120,7 @@ public function __construct( $this->supplyChannel = $supplyChannel; $this->distributionChannel = $distributionChannel; $this->shippingDetails = $shippingDetails; + $this->recurrenceInfo = $recurrenceInfo; $this->custom = $custom; } @@ -308,6 +318,27 @@ public function getShippingDetails() return $this->shippingDetails; } + /** + *

Recurring Order and frequency data.

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

Custom Fields for the Cart.

* @@ -402,6 +433,14 @@ public function setShippingDetails(?ItemShippingDetailsDraft $shippingDetails): $this->shippingDetails = $shippingDetails; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } + /** * @param ?CustomFieldsDraft $custom */ diff --git a/lib/commercetools-api/src/Models/Message/MessageModel.php b/lib/commercetools-api/src/Models/Message/MessageModel.php index 06fc1db029d..b06f1639050 100644 --- a/lib/commercetools-api/src/Models/Message/MessageModel.php +++ b/lib/commercetools-api/src/Models/Message/MessageModel.php @@ -221,6 +221,7 @@ final class MessageModel extends JsonObjectModel implements Message 'OrderBillingAddressSet' => OrderBillingAddressSetMessageModel::class, 'OrderBusinessUnitSet' => OrderBusinessUnitSetMessageModel::class, 'OrderCreated' => OrderCreatedMessageModel::class, + 'OrderCreatedFromRecurringOrder' => OrderCreatedFromRecurringOrderMessageModel::class, 'OrderCustomFieldAdded' => OrderCustomFieldAddedMessageModel::class, 'OrderCustomFieldChanged' => OrderCustomFieldChangedMessageModel::class, 'OrderCustomFieldRemoved' => OrderCustomFieldRemovedMessageModel::class, @@ -344,6 +345,17 @@ final class MessageModel extends JsonObjectModel implements Message 'QuoteRequestStateTransition' => QuoteRequestStateTransitionMessageModel::class, 'QuoteStateChanged' => QuoteStateChangedMessageModel::class, 'QuoteStateTransition' => QuoteStateTransitionMessageModel::class, + 'RecurringOrderCreated' => RecurringOrderCreatedMessageModel::class, + 'RecurringOrderCustomFieldAdded' => RecurringOrderCustomFieldAddedMessageModel::class, + 'RecurringOrderCustomFieldChanged' => RecurringOrderCustomFieldChangedMessageModel::class, + 'RecurringOrderCustomFieldRemoved' => RecurringOrderCustomFieldRemovedMessageModel::class, + 'RecurringOrderCustomTypeRemoved' => RecurringOrderCustomTypeRemovedMessageModel::class, + 'RecurringOrderCustomTypeSet' => RecurringOrderCustomTypeSetMessageModel::class, + 'RecurringOrderKeySet' => RecurringOrderKeySetMessageModel::class, + 'RecurringOrderScheduleSet' => RecurringOrderScheduleSetMessageModel::class, + 'RecurringOrderStartsAtSet' => RecurringOrderStartsAtSetMessageModel::class, + 'RecurringOrderStateChanged' => RecurringOrderStateChangedMessageModel::class, + 'RecurringOrderStateTransition' => RecurringOrderStateTransitionMessageModel::class, 'ReturnInfoAdded' => ReturnInfoAddedMessageModel::class, 'ReturnInfoSet' => ReturnInfoSetMessageModel::class, 'ReviewCreated' => ReviewCreatedMessageModel::class, diff --git a/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php index 8efd215f8d4..28b6412cc8b 100644 --- a/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php +++ b/lib/commercetools-api/src/Models/Message/MessagePayloadModel.php @@ -152,6 +152,7 @@ final class MessagePayloadModel extends JsonObjectModel implements MessagePayloa 'OrderBillingAddressSet' => OrderBillingAddressSetMessagePayloadModel::class, 'OrderBusinessUnitSet' => OrderBusinessUnitSetMessagePayloadModel::class, 'OrderCreated' => OrderCreatedMessagePayloadModel::class, + 'OrderCreatedFromRecurringOrder' => OrderCreatedFromRecurringOrderMessagePayloadModel::class, 'OrderCustomFieldAdded' => OrderCustomFieldAddedMessagePayloadModel::class, 'OrderCustomFieldChanged' => OrderCustomFieldChangedMessagePayloadModel::class, 'OrderCustomFieldRemoved' => OrderCustomFieldRemovedMessagePayloadModel::class, @@ -275,6 +276,17 @@ final class MessagePayloadModel extends JsonObjectModel implements MessagePayloa 'QuoteRequestStateTransition' => QuoteRequestStateTransitionMessagePayloadModel::class, 'QuoteStateChanged' => QuoteStateChangedMessagePayloadModel::class, 'QuoteStateTransition' => QuoteStateTransitionMessagePayloadModel::class, + 'RecurringOrderCreated' => RecurringOrderCreatedMessagePayloadModel::class, + 'RecurringOrderCustomFieldAdded' => RecurringOrderCustomFieldAddedMessagePayloadModel::class, + 'RecurringOrderCustomFieldChanged' => RecurringOrderCustomFieldChangedMessagePayloadModel::class, + 'RecurringOrderCustomFieldRemoved' => RecurringOrderCustomFieldRemovedMessagePayloadModel::class, + 'RecurringOrderCustomTypeRemoved' => RecurringOrderCustomTypeRemovedMessagePayloadModel::class, + 'RecurringOrderCustomTypeSet' => RecurringOrderCustomTypeSetMessagePayloadModel::class, + 'RecurringOrderKeySet' => RecurringOrderKeySetMessagePayloadModel::class, + 'RecurringOrderScheduleSet' => RecurringOrderScheduleSetMessagePayloadModel::class, + 'RecurringOrderStartsAtSet' => RecurringOrderStartsAtSetMessagePayloadModel::class, + 'RecurringOrderStateChanged' => RecurringOrderStateChangedMessagePayloadModel::class, + 'RecurringOrderStateTransition' => RecurringOrderStateTransitionMessagePayloadModel::class, 'ReturnInfoAdded' => ReturnInfoAddedMessagePayloadModel::class, 'ReturnInfoSet' => ReturnInfoSetMessagePayloadModel::class, 'ReviewCreated' => ReviewCreatedMessagePayloadModel::class, diff --git a/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessage.php b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessage.php new file mode 100644 index 00000000000..ed6292ec1b1 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessage.php @@ -0,0 +1,46 @@ +Order that was created.

+ * + + * @return null|Order + */ + public function getOrder(); + + /** + *

Reference to the origin Recurring Order.

+ * + + * @return null|RecurringOrderReference + */ + public function getRecurringOrderRef(); + + /** + * @param ?Order $order + */ + public function setOrder(?Order $order): void; + + /** + * @param ?RecurringOrderReference $recurringOrderRef + */ + public function setRecurringOrderRef(?RecurringOrderReference $recurringOrderRef): void; +} diff --git a/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessageBuilder.php b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessageBuilder.php new file mode 100644 index 00000000000..8dba01097d2 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessageBuilder.php @@ -0,0 +1,459 @@ + + */ +final class OrderCreatedFromRecurringOrderMessageBuilder 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|Order|OrderBuilder + */ + private $order; + + /** + + * @var null|RecurringOrderReference|RecurringOrderReferenceBuilder + */ + private $recurringOrderRef; + + /** + *

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

Order that was created.

+ * + + * @return null|Order + */ + public function getOrder() + { + return $this->order instanceof OrderBuilder ? $this->order->build() : $this->order; + } + + /** + *

Reference to the origin Recurring Order.

+ * + + * @return null|RecurringOrderReference + */ + public function getRecurringOrderRef() + { + return $this->recurringOrderRef instanceof RecurringOrderReferenceBuilder ? $this->recurringOrderRef->build() : $this->recurringOrderRef; + } + + /** + * @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 ?Order $order + * @return $this + */ + public function withOrder(?Order $order) + { + $this->order = $order; + + return $this; + } + + /** + * @param ?RecurringOrderReference $recurringOrderRef + * @return $this + */ + public function withRecurringOrderRef(?RecurringOrderReference $recurringOrderRef) + { + $this->recurringOrderRef = $recurringOrderRef; + + 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 withOrder() instead + * @return $this + */ + public function withOrderBuilder(?OrderBuilder $order) + { + $this->order = $order; + + return $this; + } + + /** + * @deprecated use withRecurringOrderRef() instead + * @return $this + */ + public function withRecurringOrderRefBuilder(?RecurringOrderReferenceBuilder $recurringOrderRef) + { + $this->recurringOrderRef = $recurringOrderRef; + + return $this; + } + + public function build(): OrderCreatedFromRecurringOrderMessage + { + return new OrderCreatedFromRecurringOrderMessageModel( + $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->order instanceof OrderBuilder ? $this->order->build() : $this->order, + $this->recurringOrderRef instanceof RecurringOrderReferenceBuilder ? $this->recurringOrderRef->build() : $this->recurringOrderRef + ); + } + + public static function of(): OrderCreatedFromRecurringOrderMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessageCollection.php b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessageCollection.php new file mode 100644 index 00000000000..118c9eecf2e --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessageCollection.php @@ -0,0 +1,56 @@ + + * @method OrderCreatedFromRecurringOrderMessage current() + * @method OrderCreatedFromRecurringOrderMessage end() + * @method OrderCreatedFromRecurringOrderMessage at($offset) + */ +class OrderCreatedFromRecurringOrderMessageCollection extends OrderMessageCollection +{ + /** + * @psalm-assert OrderCreatedFromRecurringOrderMessage $value + * @psalm-param OrderCreatedFromRecurringOrderMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return OrderCreatedFromRecurringOrderMessageCollection + */ + public function add($value) + { + if (!$value instanceof OrderCreatedFromRecurringOrderMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?OrderCreatedFromRecurringOrderMessage + */ + protected function mapper() + { + return function (?int $index): ?OrderCreatedFromRecurringOrderMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var OrderCreatedFromRecurringOrderMessage $data */ + $data = OrderCreatedFromRecurringOrderMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessageModel.php b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessageModel.php new file mode 100644 index 00000000000..6ed6418ccaa --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessageModel.php @@ -0,0 +1,532 @@ +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->order = $order; + $this->recurringOrderRef = $recurringOrderRef; + $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; + } + + /** + *

Order that was created.

+ * + * + * @return null|Order + */ + public function getOrder() + { + if (is_null($this->order)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_ORDER); + if (is_null($data)) { + return null; + } + + $this->order = OrderModel::of($data); + } + + return $this->order; + } + + /** + *

Reference to the origin Recurring Order.

+ * + * + * @return null|RecurringOrderReference + */ + public function getRecurringOrderRef() + { + if (is_null($this->recurringOrderRef)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRING_ORDER_REF); + if (is_null($data)) { + return null; + } + + $this->recurringOrderRef = RecurringOrderReferenceModel::of($data); + } + + return $this->recurringOrderRef; + } + + + /** + * @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 ?Order $order + */ + public function setOrder(?Order $order): void + { + $this->order = $order; + } + + /** + * @param ?RecurringOrderReference $recurringOrderRef + */ + public function setRecurringOrderRef(?RecurringOrderReference $recurringOrderRef): void + { + $this->recurringOrderRef = $recurringOrderRef; + } + + + #[\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/OrderCreatedFromRecurringOrderMessagePayload.php b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayload.php new file mode 100644 index 00000000000..f900e74feb9 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayload.php @@ -0,0 +1,46 @@ +Order that was created.

+ * + + * @return null|Order + */ + public function getOrder(); + + /** + *

Reference to the origin Recurring Order.

+ * + + * @return null|RecurringOrderReference + */ + public function getRecurringOrderRef(); + + /** + * @param ?Order $order + */ + public function setOrder(?Order $order): void; + + /** + * @param ?RecurringOrderReference $recurringOrderRef + */ + public function setRecurringOrderRef(?RecurringOrderReference $recurringOrderRef): void; +} diff --git a/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayloadBuilder.php new file mode 100644 index 00000000000..bc248c7a9d3 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayloadBuilder.php @@ -0,0 +1,117 @@ + + */ +final class OrderCreatedFromRecurringOrderMessagePayloadBuilder implements Builder +{ + /** + + * @var null|Order|OrderBuilder + */ + private $order; + + /** + + * @var null|RecurringOrderReference|RecurringOrderReferenceBuilder + */ + private $recurringOrderRef; + + /** + *

Order that was created.

+ * + + * @return null|Order + */ + public function getOrder() + { + return $this->order instanceof OrderBuilder ? $this->order->build() : $this->order; + } + + /** + *

Reference to the origin Recurring Order.

+ * + + * @return null|RecurringOrderReference + */ + public function getRecurringOrderRef() + { + return $this->recurringOrderRef instanceof RecurringOrderReferenceBuilder ? $this->recurringOrderRef->build() : $this->recurringOrderRef; + } + + /** + * @param ?Order $order + * @return $this + */ + public function withOrder(?Order $order) + { + $this->order = $order; + + return $this; + } + + /** + * @param ?RecurringOrderReference $recurringOrderRef + * @return $this + */ + public function withRecurringOrderRef(?RecurringOrderReference $recurringOrderRef) + { + $this->recurringOrderRef = $recurringOrderRef; + + return $this; + } + + /** + * @deprecated use withOrder() instead + * @return $this + */ + public function withOrderBuilder(?OrderBuilder $order) + { + $this->order = $order; + + return $this; + } + + /** + * @deprecated use withRecurringOrderRef() instead + * @return $this + */ + public function withRecurringOrderRefBuilder(?RecurringOrderReferenceBuilder $recurringOrderRef) + { + $this->recurringOrderRef = $recurringOrderRef; + + return $this; + } + + public function build(): OrderCreatedFromRecurringOrderMessagePayload + { + return new OrderCreatedFromRecurringOrderMessagePayloadModel( + $this->order instanceof OrderBuilder ? $this->order->build() : $this->order, + $this->recurringOrderRef instanceof RecurringOrderReferenceBuilder ? $this->recurringOrderRef->build() : $this->recurringOrderRef + ); + } + + public static function of(): OrderCreatedFromRecurringOrderMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayloadCollection.php new file mode 100644 index 00000000000..124983d022d --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method OrderCreatedFromRecurringOrderMessagePayload current() + * @method OrderCreatedFromRecurringOrderMessagePayload end() + * @method OrderCreatedFromRecurringOrderMessagePayload at($offset) + */ +class OrderCreatedFromRecurringOrderMessagePayloadCollection extends OrderMessagePayloadCollection +{ + /** + * @psalm-assert OrderCreatedFromRecurringOrderMessagePayload $value + * @psalm-param OrderCreatedFromRecurringOrderMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return OrderCreatedFromRecurringOrderMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof OrderCreatedFromRecurringOrderMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?OrderCreatedFromRecurringOrderMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?OrderCreatedFromRecurringOrderMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var OrderCreatedFromRecurringOrderMessagePayload $data */ + $data = OrderCreatedFromRecurringOrderMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayloadModel.php new file mode 100644 index 00000000000..7c432c3c737 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/OrderCreatedFromRecurringOrderMessagePayloadModel.php @@ -0,0 +1,135 @@ +order = $order; + $this->recurringOrderRef = $recurringOrderRef; + $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; + } + + /** + *

Order that was created.

+ * + * + * @return null|Order + */ + public function getOrder() + { + if (is_null($this->order)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_ORDER); + if (is_null($data)) { + return null; + } + + $this->order = OrderModel::of($data); + } + + return $this->order; + } + + /** + *

Reference to the origin Recurring Order.

+ * + * + * @return null|RecurringOrderReference + */ + public function getRecurringOrderRef() + { + if (is_null($this->recurringOrderRef)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRING_ORDER_REF); + if (is_null($data)) { + return null; + } + + $this->recurringOrderRef = RecurringOrderReferenceModel::of($data); + } + + return $this->recurringOrderRef; + } + + + /** + * @param ?Order $order + */ + public function setOrder(?Order $order): void + { + $this->order = $order; + } + + /** + * @param ?RecurringOrderReference $recurringOrderRef + */ + public function setRecurringOrderRef(?RecurringOrderReference $recurringOrderRef): void + { + $this->recurringOrderRef = $recurringOrderRef; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessage.php new file mode 100644 index 00000000000..405b2e52858 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessage.php @@ -0,0 +1,31 @@ +RecurringOrder that was created.

+ * + + * @return null|RecurringOrder + */ + public function getOrder(); + + /** + * @param ?RecurringOrder $order + */ + public function setOrder(?RecurringOrder $order): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessageBuilder.php new file mode 100644 index 00000000000..b8e273f5c25 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessageBuilder.php @@ -0,0 +1,417 @@ + + */ +final class RecurringOrderCreatedMessageBuilder 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|RecurringOrder|RecurringOrderBuilder + */ + private $order; + + /** + *

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

RecurringOrder that was created.

+ * + + * @return null|RecurringOrder + */ + public function getOrder() + { + return $this->order instanceof RecurringOrderBuilder ? $this->order->build() : $this->order; + } + + /** + * @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 ?RecurringOrder $order + * @return $this + */ + public function withOrder(?RecurringOrder $order) + { + $this->order = $order; + + 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 withOrder() instead + * @return $this + */ + public function withOrderBuilder(?RecurringOrderBuilder $order) + { + $this->order = $order; + + return $this; + } + + public function build(): RecurringOrderCreatedMessage + { + return new RecurringOrderCreatedMessageModel( + $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->order instanceof RecurringOrderBuilder ? $this->order->build() : $this->order + ); + } + + public static function of(): RecurringOrderCreatedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessageCollection.php new file mode 100644 index 00000000000..afd19f8d5e9 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCreatedMessage current() + * @method RecurringOrderCreatedMessage end() + * @method RecurringOrderCreatedMessage at($offset) + */ +class RecurringOrderCreatedMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderCreatedMessage $value + * @psalm-param RecurringOrderCreatedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCreatedMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCreatedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCreatedMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCreatedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCreatedMessage $data */ + $data = RecurringOrderCreatedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessageModel.php new file mode 100644 index 00000000000..e70bb14c442 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessageModel.php @@ -0,0 +1,493 @@ +id = $id; + $this->version = $version; + $this->createdAt = $createdAt; + $this->lastModifiedAt = $lastModifiedAt; + $this->lastModifiedBy = $lastModifiedBy; + $this->createdBy = $createdBy; + $this->sequenceNumber = $sequenceNumber; + $this->resource = $resource; + $this->resourceVersion = $resourceVersion; + $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers; + $this->order = $order; + $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; + } + + /** + *

RecurringOrder that was created.

+ * + * + * @return null|RecurringOrder + */ + public function getOrder() + { + if (is_null($this->order)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_ORDER); + if (is_null($data)) { + return null; + } + + $this->order = RecurringOrderModel::of($data); + } + + return $this->order; + } + + + /** + * @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 ?RecurringOrder $order + */ + public function setOrder(?RecurringOrder $order): void + { + $this->order = $order; + } + + + #[\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/RecurringOrderCreatedMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayload.php new file mode 100644 index 00000000000..1e0604cea82 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayload.php @@ -0,0 +1,31 @@ +RecurringOrder that was created.

+ * + + * @return null|RecurringOrder + */ + public function getOrder(); + + /** + * @param ?RecurringOrder $order + */ + public function setOrder(?RecurringOrder $order): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayloadBuilder.php new file mode 100644 index 00000000000..96ed08f269f --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayloadBuilder.php @@ -0,0 +1,75 @@ + + */ +final class RecurringOrderCreatedMessagePayloadBuilder implements Builder +{ + /** + + * @var null|RecurringOrder|RecurringOrderBuilder + */ + private $order; + + /** + *

RecurringOrder that was created.

+ * + + * @return null|RecurringOrder + */ + public function getOrder() + { + return $this->order instanceof RecurringOrderBuilder ? $this->order->build() : $this->order; + } + + /** + * @param ?RecurringOrder $order + * @return $this + */ + public function withOrder(?RecurringOrder $order) + { + $this->order = $order; + + return $this; + } + + /** + * @deprecated use withOrder() instead + * @return $this + */ + public function withOrderBuilder(?RecurringOrderBuilder $order) + { + $this->order = $order; + + return $this; + } + + public function build(): RecurringOrderCreatedMessagePayload + { + return new RecurringOrderCreatedMessagePayloadModel( + $this->order instanceof RecurringOrderBuilder ? $this->order->build() : $this->order + ); + } + + public static function of(): RecurringOrderCreatedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayloadCollection.php new file mode 100644 index 00000000000..4004f58c5b8 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCreatedMessagePayload current() + * @method RecurringOrderCreatedMessagePayload end() + * @method RecurringOrderCreatedMessagePayload at($offset) + */ +class RecurringOrderCreatedMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderCreatedMessagePayload $value + * @psalm-param RecurringOrderCreatedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCreatedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCreatedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCreatedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCreatedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCreatedMessagePayload $data */ + $data = RecurringOrderCreatedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayloadModel.php new file mode 100644 index 00000000000..e4e757b78d4 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCreatedMessagePayloadModel.php @@ -0,0 +1,96 @@ +order = $order; + $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; + } + + /** + *

RecurringOrder that was created.

+ * + * + * @return null|RecurringOrder + */ + public function getOrder() + { + if (is_null($this->order)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_ORDER); + if (is_null($data)) { + return null; + } + + $this->order = RecurringOrderModel::of($data); + } + + return $this->order; + } + + + /** + * @param ?RecurringOrder $order + */ + public function setOrder(?RecurringOrder $order): void + { + $this->order = $order; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessage.php new file mode 100644 index 00000000000..87076f75d9e --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessage.php @@ -0,0 +1,44 @@ +Name of the Custom Field that was added.

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

The added CustomFieldValue based on the FieldType.

+ * + + * @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-api/src/Models/Message/RecurringOrderCustomFieldAddedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessageBuilder.php new file mode 100644 index 00000000000..c63a2189744 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessageBuilder.php @@ -0,0 +1,433 @@ + + */ +final class RecurringOrderCustomFieldAddedMessageBuilder 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 $name; + + /** + + * @var null|mixed|mixed + */ + private $value; + + /** + *

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

Name of the Custom Field that was added.

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

The added CustomFieldValue based on the FieldType.

+ * + + * @return null|mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @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 $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; + } + + /** + * @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(): RecurringOrderCustomFieldAddedMessage + { + return new RecurringOrderCustomFieldAddedMessageModel( + $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->name, + $this->value + ); + } + + public static function of(): RecurringOrderCustomFieldAddedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessageCollection.php new file mode 100644 index 00000000000..6fbdec11ae2 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomFieldAddedMessage current() + * @method RecurringOrderCustomFieldAddedMessage end() + * @method RecurringOrderCustomFieldAddedMessage at($offset) + */ +class RecurringOrderCustomFieldAddedMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderCustomFieldAddedMessage $value + * @psalm-param RecurringOrderCustomFieldAddedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomFieldAddedMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomFieldAddedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomFieldAddedMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomFieldAddedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomFieldAddedMessage $data */ + $data = RecurringOrderCustomFieldAddedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessageModel.php new file mode 100644 index 00000000000..970aea38843 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessageModel.php @@ -0,0 +1,526 @@ +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->name = $name; + $this->value = $value; + $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; + } + + /** + *

Name of the Custom Field that was added.

+ * + * + * @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 added CustomFieldValue based on the FieldType.

+ * + * + * @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 $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 $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param mixed $value + */ + public function setValue($value): void + { + $this->value = $value; + } + + + #[\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/RecurringOrderCustomFieldAddedMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayload.php new file mode 100644 index 00000000000..6121d2a7413 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayload.php @@ -0,0 +1,44 @@ +Name of the Custom Field that was added.

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

The added CustomFieldValue based on the FieldType.

+ * + + * @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-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayloadBuilder.php new file mode 100644 index 00000000000..920bd044e6f --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayloadBuilder.php @@ -0,0 +1,92 @@ + + */ +final class RecurringOrderCustomFieldAddedMessagePayloadBuilder implements Builder +{ + /** + + * @var ?string + */ + private $name; + + /** + + * @var null|mixed|mixed + */ + private $value; + + /** + *

Name of the Custom Field that was added.

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

The added CustomFieldValue based on the FieldType.

+ * + + * @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(): RecurringOrderCustomFieldAddedMessagePayload + { + return new RecurringOrderCustomFieldAddedMessagePayloadModel( + $this->name, + $this->value + ); + } + + public static function of(): RecurringOrderCustomFieldAddedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayloadCollection.php new file mode 100644 index 00000000000..ec8a851dbf5 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomFieldAddedMessagePayload current() + * @method RecurringOrderCustomFieldAddedMessagePayload end() + * @method RecurringOrderCustomFieldAddedMessagePayload at($offset) + */ +class RecurringOrderCustomFieldAddedMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderCustomFieldAddedMessagePayload $value + * @psalm-param RecurringOrderCustomFieldAddedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomFieldAddedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomFieldAddedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomFieldAddedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomFieldAddedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomFieldAddedMessagePayload $data */ + $data = RecurringOrderCustomFieldAddedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayloadModel.php new file mode 100644 index 00000000000..5591ec138f0 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldAddedMessagePayloadModel.php @@ -0,0 +1,129 @@ +name = $name; + $this->value = $value; + $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; + } + + /** + *

Name of the Custom Field that was added.

+ * + * + * @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 added CustomFieldValue based on the FieldType.

+ * + * + * @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-api/src/Models/Message/RecurringOrderCustomFieldChangedMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessage.php new file mode 100644 index 00000000000..0dac78c323d --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessage.php @@ -0,0 +1,59 @@ +Name of the Custom Field that changed.

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

CustomFieldValue based on the FieldType after the Set CustomField update action.

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

CustomFieldValue based on the FieldType before the Set CustomField update action. + * When there has not been a Custom Field with the name on the Order before, an Order Custom Field Added Message is generated instead.

+ * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param mixed $value + */ + public function setValue($value): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue($previousValue): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessageBuilder.php new file mode 100644 index 00000000000..8345041188d --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessageBuilder.php @@ -0,0 +1,463 @@ + + */ +final class RecurringOrderCustomFieldChangedMessageBuilder 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 $name; + + /** + + * @var null|mixed|mixed + */ + private $value; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + *

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

Name of the Custom Field that changed.

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

CustomFieldValue based on the FieldType after the Set CustomField update action.

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

CustomFieldValue based on the FieldType before the Set CustomField update action. + * When there has not been a Custom Field with the name on the Order before, an Order Custom Field Added Message is generated instead.

+ * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + * @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 $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; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue($previousValue) + { + $this->previousValue = $previousValue; + + 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(): RecurringOrderCustomFieldChangedMessage + { + return new RecurringOrderCustomFieldChangedMessageModel( + $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->name, + $this->value, + $this->previousValue + ); + } + + public static function of(): RecurringOrderCustomFieldChangedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessageCollection.php new file mode 100644 index 00000000000..123a9e9f72a --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomFieldChangedMessage current() + * @method RecurringOrderCustomFieldChangedMessage end() + * @method RecurringOrderCustomFieldChangedMessage at($offset) + */ +class RecurringOrderCustomFieldChangedMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderCustomFieldChangedMessage $value + * @psalm-param RecurringOrderCustomFieldChangedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomFieldChangedMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomFieldChangedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomFieldChangedMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomFieldChangedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomFieldChangedMessage $data */ + $data = RecurringOrderCustomFieldChangedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessageModel.php new file mode 100644 index 00000000000..622ec31f722 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessageModel.php @@ -0,0 +1,563 @@ +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->name = $name; + $this->value = $value; + $this->previousValue = $previousValue; + $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; + } + + /** + *

Name of the Custom Field that changed.

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

CustomFieldValue based on the FieldType after the Set CustomField update action.

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

CustomFieldValue based on the FieldType before the Set CustomField update action. + * When there has not been a Custom Field with the name on the Order before, an Order Custom Field Added Message is generated instead.

+ * + * + * @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; + } + + + /** + * @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 $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param mixed $value + */ + public function setValue($value): void + { + $this->value = $value; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue($previousValue): void + { + $this->previousValue = $previousValue; + } + + + #[\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/RecurringOrderCustomFieldChangedMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayload.php new file mode 100644 index 00000000000..f15e5151b79 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayload.php @@ -0,0 +1,59 @@ +Name of the Custom Field that changed.

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

CustomFieldValue based on the FieldType after the Set CustomField update action.

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

CustomFieldValue based on the FieldType before the Set CustomField update action. + * When there has not been a Custom Field with the name on the Order before, an Order Custom Field Added Message is generated instead.

+ * + + * @return null|mixed + */ + public function getPreviousValue(); + + /** + * @param ?string $name + */ + public function setName(?string $name): void; + + /** + * @param mixed $value + */ + public function setValue($value): void; + + /** + * @param mixed $previousValue + */ + public function setPreviousValue($previousValue): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayloadBuilder.php new file mode 100644 index 00000000000..9e9b0702d8e --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayloadBuilder.php @@ -0,0 +1,122 @@ + + */ +final class RecurringOrderCustomFieldChangedMessagePayloadBuilder implements Builder +{ + /** + + * @var ?string + */ + private $name; + + /** + + * @var null|mixed|mixed + */ + private $value; + + /** + + * @var null|mixed|mixed + */ + private $previousValue; + + /** + *

Name of the Custom Field that changed.

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

CustomFieldValue based on the FieldType after the Set CustomField update action.

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

CustomFieldValue based on the FieldType before the Set CustomField update action. + * When there has not been a Custom Field with the name on the Order before, an Order Custom Field Added Message is generated instead.

+ * + + * @return null|mixed + */ + public function getPreviousValue() + { + return $this->previousValue; + } + + /** + * @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; + } + + /** + * @param mixed $previousValue + * @return $this + */ + public function withPreviousValue($previousValue) + { + $this->previousValue = $previousValue; + + return $this; + } + + + public function build(): RecurringOrderCustomFieldChangedMessagePayload + { + return new RecurringOrderCustomFieldChangedMessagePayloadModel( + $this->name, + $this->value, + $this->previousValue + ); + } + + public static function of(): RecurringOrderCustomFieldChangedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayloadCollection.php new file mode 100644 index 00000000000..fa4c4bbae57 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomFieldChangedMessagePayload current() + * @method RecurringOrderCustomFieldChangedMessagePayload end() + * @method RecurringOrderCustomFieldChangedMessagePayload at($offset) + */ +class RecurringOrderCustomFieldChangedMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderCustomFieldChangedMessagePayload $value + * @psalm-param RecurringOrderCustomFieldChangedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomFieldChangedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomFieldChangedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomFieldChangedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomFieldChangedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomFieldChangedMessagePayload $data */ + $data = RecurringOrderCustomFieldChangedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayloadModel.php new file mode 100644 index 00000000000..ebf06c34421 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldChangedMessagePayloadModel.php @@ -0,0 +1,166 @@ +name = $name; + $this->value = $value; + $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; + } + + /** + *

Name of the Custom Field that changed.

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

CustomFieldValue based on the FieldType after the Set CustomField update action.

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

CustomFieldValue based on the FieldType before the Set CustomField update action. + * When there has not been a Custom Field with the name on the Order before, an Order Custom Field Added Message is generated instead.

+ * + * + * @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; + } + + + /** + * @param ?string $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + /** + * @param mixed $value + */ + public function setValue($value): void + { + $this->value = $value; + } + + /** + * @param mixed $previousValue + */ + public function setPreviousValue($previousValue): void + { + $this->previousValue = $previousValue; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessage.php new file mode 100644 index 00000000000..d991231cbcb --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessage.php @@ -0,0 +1,30 @@ +Name of the Custom Field that was removed.

+ * + + * @return null|string + */ + public function getName(); + + /** + * @param ?string $name + */ + public function setName(?string $name): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessageBuilder.php new file mode 100644 index 00000000000..a4f5cf504da --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessageBuilder.php @@ -0,0 +1,404 @@ + + */ +final class RecurringOrderCustomFieldRemovedMessageBuilder 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 $name; + + /** + *

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

Name of the Custom Field that was removed.

+ * + + * @return null|string + */ + public function getName() + { + return $this->name; + } + + /** + * @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 $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + 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(): RecurringOrderCustomFieldRemovedMessage + { + return new RecurringOrderCustomFieldRemovedMessageModel( + $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->name + ); + } + + public static function of(): RecurringOrderCustomFieldRemovedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessageCollection.php new file mode 100644 index 00000000000..1ca4d4ad2e0 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomFieldRemovedMessage current() + * @method RecurringOrderCustomFieldRemovedMessage end() + * @method RecurringOrderCustomFieldRemovedMessage at($offset) + */ +class RecurringOrderCustomFieldRemovedMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderCustomFieldRemovedMessage $value + * @psalm-param RecurringOrderCustomFieldRemovedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomFieldRemovedMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomFieldRemovedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomFieldRemovedMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomFieldRemovedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomFieldRemovedMessage $data */ + $data = RecurringOrderCustomFieldRemovedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessageModel.php new file mode 100644 index 00000000000..6c82521acc7 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessageModel.php @@ -0,0 +1,490 @@ +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->name = $name; + $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; + } + + /** + *

Name of the Custom Field that was removed.

+ * + * + * @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 $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 $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } + + + #[\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/RecurringOrderCustomFieldRemovedMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayload.php new file mode 100644 index 00000000000..d65c9880423 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayload.php @@ -0,0 +1,30 @@ +Name of the Custom Field that was removed.

+ * + + * @return null|string + */ + public function getName(); + + /** + * @param ?string $name + */ + public function setName(?string $name): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayloadBuilder.php new file mode 100644 index 00000000000..b010a042e6a --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayloadBuilder.php @@ -0,0 +1,63 @@ + + */ +final class RecurringOrderCustomFieldRemovedMessagePayloadBuilder implements Builder +{ + /** + + * @var ?string + */ + private $name; + + /** + *

Name of the Custom Field that was removed.

+ * + + * @return null|string + */ + public function getName() + { + return $this->name; + } + + /** + * @param ?string $name + * @return $this + */ + public function withName(?string $name) + { + $this->name = $name; + + return $this; + } + + + public function build(): RecurringOrderCustomFieldRemovedMessagePayload + { + return new RecurringOrderCustomFieldRemovedMessagePayloadModel( + $this->name + ); + } + + public static function of(): RecurringOrderCustomFieldRemovedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayloadCollection.php new file mode 100644 index 00000000000..80a24bd1dcd --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomFieldRemovedMessagePayload current() + * @method RecurringOrderCustomFieldRemovedMessagePayload end() + * @method RecurringOrderCustomFieldRemovedMessagePayload at($offset) + */ +class RecurringOrderCustomFieldRemovedMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderCustomFieldRemovedMessagePayload $value + * @psalm-param RecurringOrderCustomFieldRemovedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomFieldRemovedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomFieldRemovedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomFieldRemovedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomFieldRemovedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomFieldRemovedMessagePayload $data */ + $data = RecurringOrderCustomFieldRemovedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayloadModel.php new file mode 100644 index 00000000000..1c17a0455a9 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomFieldRemovedMessagePayloadModel.php @@ -0,0 +1,93 @@ +name = $name; + $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; + } + + /** + *

Name of the Custom Field that was removed.

+ * + * + * @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 $name + */ + public function setName(?string $name): void + { + $this->name = $name; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessage.php new file mode 100644 index 00000000000..dc01f61a9ef --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessage.php @@ -0,0 +1,30 @@ +id of the Custom Type that was removed. Absent if there was no previous Custom Type present.

+ * + + * @return null|string + */ + public function getPreviousTypeId(); + + /** + * @param ?string $previousTypeId + */ + public function setPreviousTypeId(?string $previousTypeId): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessageBuilder.php new file mode 100644 index 00000000000..0227a2d1185 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessageBuilder.php @@ -0,0 +1,404 @@ + + */ +final class RecurringOrderCustomTypeRemovedMessageBuilder 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 $previousTypeId; + + /** + *

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 Custom Type that was removed. Absent if there was no previous Custom Type present.

+ * + + * @return null|string + */ + public function getPreviousTypeId() + { + return $this->previousTypeId; + } + + /** + * @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 $previousTypeId + * @return $this + */ + public function withPreviousTypeId(?string $previousTypeId) + { + $this->previousTypeId = $previousTypeId; + + 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(): RecurringOrderCustomTypeRemovedMessage + { + return new RecurringOrderCustomTypeRemovedMessageModel( + $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->previousTypeId + ); + } + + public static function of(): RecurringOrderCustomTypeRemovedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessageCollection.php new file mode 100644 index 00000000000..fec5b379e01 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomTypeRemovedMessage current() + * @method RecurringOrderCustomTypeRemovedMessage end() + * @method RecurringOrderCustomTypeRemovedMessage at($offset) + */ +class RecurringOrderCustomTypeRemovedMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderCustomTypeRemovedMessage $value + * @psalm-param RecurringOrderCustomTypeRemovedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomTypeRemovedMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomTypeRemovedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomTypeRemovedMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomTypeRemovedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomTypeRemovedMessage $data */ + $data = RecurringOrderCustomTypeRemovedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessageModel.php new file mode 100644 index 00000000000..a06aa177b52 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessageModel.php @@ -0,0 +1,490 @@ +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->previousTypeId = $previousTypeId; + $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 Custom Type that was removed. Absent if there was no previous Custom Type present.

+ * + * + * @return null|string + */ + public function getPreviousTypeId() + { + if (is_null($this->previousTypeId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_PREVIOUS_TYPE_ID); + if (is_null($data)) { + return null; + } + $this->previousTypeId = (string) $data; + } + + return $this->previousTypeId; + } + + + /** + * @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 $previousTypeId + */ + public function setPreviousTypeId(?string $previousTypeId): void + { + $this->previousTypeId = $previousTypeId; + } + + + #[\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/RecurringOrderCustomTypeRemovedMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayload.php new file mode 100644 index 00000000000..a3081fbed2a --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayload.php @@ -0,0 +1,30 @@ +id of the Custom Type that was removed. Absent if there was no previous Custom Type present.

+ * + + * @return null|string + */ + public function getPreviousTypeId(); + + /** + * @param ?string $previousTypeId + */ + public function setPreviousTypeId(?string $previousTypeId): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayloadBuilder.php new file mode 100644 index 00000000000..35d5f5bc210 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayloadBuilder.php @@ -0,0 +1,63 @@ + + */ +final class RecurringOrderCustomTypeRemovedMessagePayloadBuilder implements Builder +{ + /** + + * @var ?string + */ + private $previousTypeId; + + /** + *

id of the Custom Type that was removed. Absent if there was no previous Custom Type present.

+ * + + * @return null|string + */ + public function getPreviousTypeId() + { + return $this->previousTypeId; + } + + /** + * @param ?string $previousTypeId + * @return $this + */ + public function withPreviousTypeId(?string $previousTypeId) + { + $this->previousTypeId = $previousTypeId; + + return $this; + } + + + public function build(): RecurringOrderCustomTypeRemovedMessagePayload + { + return new RecurringOrderCustomTypeRemovedMessagePayloadModel( + $this->previousTypeId + ); + } + + public static function of(): RecurringOrderCustomTypeRemovedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayloadCollection.php new file mode 100644 index 00000000000..f16f24fd973 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomTypeRemovedMessagePayload current() + * @method RecurringOrderCustomTypeRemovedMessagePayload end() + * @method RecurringOrderCustomTypeRemovedMessagePayload at($offset) + */ +class RecurringOrderCustomTypeRemovedMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderCustomTypeRemovedMessagePayload $value + * @psalm-param RecurringOrderCustomTypeRemovedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomTypeRemovedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomTypeRemovedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomTypeRemovedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomTypeRemovedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomTypeRemovedMessagePayload $data */ + $data = RecurringOrderCustomTypeRemovedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayloadModel.php new file mode 100644 index 00000000000..4a684d44c7d --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeRemovedMessagePayloadModel.php @@ -0,0 +1,93 @@ +previousTypeId = $previousTypeId; + $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 Custom Type that was removed. Absent if there was no previous Custom Type present.

+ * + * + * @return null|string + */ + public function getPreviousTypeId() + { + if (is_null($this->previousTypeId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_PREVIOUS_TYPE_ID); + if (is_null($data)) { + return null; + } + $this->previousTypeId = (string) $data; + } + + return $this->previousTypeId; + } + + + /** + * @param ?string $previousTypeId + */ + public function setPreviousTypeId(?string $previousTypeId): void + { + $this->previousTypeId = $previousTypeId; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessage.php new file mode 100644 index 00000000000..24958103bb8 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessage.php @@ -0,0 +1,45 @@ +The Custom Fields that have been set.

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

id of the previous Custom Type. Absent if there was no previous Custom Type present.

+ * + + * @return null|string + */ + public function getPreviousTypeId(); + + /** + * @param ?CustomFields $customFields + */ + public function setCustomFields(?CustomFields $customFields): void; + + /** + * @param ?string $previousTypeId + */ + public function setPreviousTypeId(?string $previousTypeId): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessageBuilder.php new file mode 100644 index 00000000000..e8d91cd37f4 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessageBuilder.php @@ -0,0 +1,446 @@ + + */ +final class RecurringOrderCustomTypeSetMessageBuilder 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|CustomFields|CustomFieldsBuilder + */ + private $customFields; + + /** + + * @var ?string + */ + private $previousTypeId; + + /** + *

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

The Custom Fields that have been set.

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

id of the previous Custom Type. Absent if there was no previous Custom Type present.

+ * + + * @return null|string + */ + public function getPreviousTypeId() + { + return $this->previousTypeId; + } + + /** + * @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 ?CustomFields $customFields + * @return $this + */ + public function withCustomFields(?CustomFields $customFields) + { + $this->customFields = $customFields; + + return $this; + } + + /** + * @param ?string $previousTypeId + * @return $this + */ + public function withPreviousTypeId(?string $previousTypeId) + { + $this->previousTypeId = $previousTypeId; + + 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 withCustomFields() instead + * @return $this + */ + public function withCustomFieldsBuilder(?CustomFieldsBuilder $customFields) + { + $this->customFields = $customFields; + + return $this; + } + + public function build(): RecurringOrderCustomTypeSetMessage + { + return new RecurringOrderCustomTypeSetMessageModel( + $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->customFields instanceof CustomFieldsBuilder ? $this->customFields->build() : $this->customFields, + $this->previousTypeId + ); + } + + public static function of(): RecurringOrderCustomTypeSetMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessageCollection.php new file mode 100644 index 00000000000..54bd3165ee8 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomTypeSetMessage current() + * @method RecurringOrderCustomTypeSetMessage end() + * @method RecurringOrderCustomTypeSetMessage at($offset) + */ +class RecurringOrderCustomTypeSetMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderCustomTypeSetMessage $value + * @psalm-param RecurringOrderCustomTypeSetMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomTypeSetMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomTypeSetMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomTypeSetMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomTypeSetMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomTypeSetMessage $data */ + $data = RecurringOrderCustomTypeSetMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessageModel.php new file mode 100644 index 00000000000..58cce1ea31c --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessageModel.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->customFields = $customFields; + $this->previousTypeId = $previousTypeId; + $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; + } + + /** + *

The Custom Fields that have been set.

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

id of the previous Custom Type. Absent if there was no previous Custom Type present.

+ * + * + * @return null|string + */ + public function getPreviousTypeId() + { + if (is_null($this->previousTypeId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_PREVIOUS_TYPE_ID); + if (is_null($data)) { + return null; + } + $this->previousTypeId = (string) $data; + } + + return $this->previousTypeId; + } + + + /** + * @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 ?CustomFields $customFields + */ + public function setCustomFields(?CustomFields $customFields): void + { + $this->customFields = $customFields; + } + + /** + * @param ?string $previousTypeId + */ + public function setPreviousTypeId(?string $previousTypeId): void + { + $this->previousTypeId = $previousTypeId; + } + + + #[\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/RecurringOrderCustomTypeSetMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayload.php new file mode 100644 index 00000000000..0d624a0878a --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayload.php @@ -0,0 +1,45 @@ +The Custom Fields that have been set.

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

id of the previous Custom Type. Absent if there was no previous Custom Type present.

+ * + + * @return null|string + */ + public function getPreviousTypeId(); + + /** + * @param ?CustomFields $customFields + */ + public function setCustomFields(?CustomFields $customFields): void; + + /** + * @param ?string $previousTypeId + */ + public function setPreviousTypeId(?string $previousTypeId): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayloadBuilder.php new file mode 100644 index 00000000000..b54f2efb2f5 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayloadBuilder.php @@ -0,0 +1,104 @@ + + */ +final class RecurringOrderCustomTypeSetMessagePayloadBuilder implements Builder +{ + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $customFields; + + /** + + * @var ?string + */ + private $previousTypeId; + + /** + *

The Custom Fields that have been set.

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

id of the previous Custom Type. Absent if there was no previous Custom Type present.

+ * + + * @return null|string + */ + public function getPreviousTypeId() + { + return $this->previousTypeId; + } + + /** + * @param ?CustomFields $customFields + * @return $this + */ + public function withCustomFields(?CustomFields $customFields) + { + $this->customFields = $customFields; + + return $this; + } + + /** + * @param ?string $previousTypeId + * @return $this + */ + public function withPreviousTypeId(?string $previousTypeId) + { + $this->previousTypeId = $previousTypeId; + + return $this; + } + + /** + * @deprecated use withCustomFields() instead + * @return $this + */ + public function withCustomFieldsBuilder(?CustomFieldsBuilder $customFields) + { + $this->customFields = $customFields; + + return $this; + } + + public function build(): RecurringOrderCustomTypeSetMessagePayload + { + return new RecurringOrderCustomTypeSetMessagePayloadModel( + $this->customFields instanceof CustomFieldsBuilder ? $this->customFields->build() : $this->customFields, + $this->previousTypeId + ); + } + + public static function of(): RecurringOrderCustomTypeSetMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayloadCollection.php new file mode 100644 index 00000000000..f9fcd46c51c --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCustomTypeSetMessagePayload current() + * @method RecurringOrderCustomTypeSetMessagePayload end() + * @method RecurringOrderCustomTypeSetMessagePayload at($offset) + */ +class RecurringOrderCustomTypeSetMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderCustomTypeSetMessagePayload $value + * @psalm-param RecurringOrderCustomTypeSetMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCustomTypeSetMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCustomTypeSetMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCustomTypeSetMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCustomTypeSetMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCustomTypeSetMessagePayload $data */ + $data = RecurringOrderCustomTypeSetMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayloadModel.php new file mode 100644 index 00000000000..bbaef8532dd --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderCustomTypeSetMessagePayloadModel.php @@ -0,0 +1,132 @@ +customFields = $customFields; + $this->previousTypeId = $previousTypeId; + $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; + } + + /** + *

The Custom Fields that have been set.

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

id of the previous Custom Type. Absent if there was no previous Custom Type present.

+ * + * + * @return null|string + */ + public function getPreviousTypeId() + { + if (is_null($this->previousTypeId)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_PREVIOUS_TYPE_ID); + if (is_null($data)) { + return null; + } + $this->previousTypeId = (string) $data; + } + + return $this->previousTypeId; + } + + + /** + * @param ?CustomFields $customFields + */ + public function setCustomFields(?CustomFields $customFields): void + { + $this->customFields = $customFields; + } + + /** + * @param ?string $previousTypeId + */ + public function setPreviousTypeId(?string $previousTypeId): void + { + $this->previousTypeId = $previousTypeId; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessage.php new file mode 100644 index 00000000000..cbe9552e8a3 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessage.php @@ -0,0 +1,44 @@ +key value of the RecurringOrder after the Set Key update action.

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

key value of the RecurringOrder before the Set Key update action.

+ * + + * @return null|string + */ + public function getOldKey(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?string $oldKey + */ + public function setOldKey(?string $oldKey): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessageBuilder.php new file mode 100644 index 00000000000..d6247fb8901 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessageBuilder.php @@ -0,0 +1,433 @@ + + */ +final class RecurringOrderKeySetMessageBuilder 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 $key; + + /** + + * @var ?string + */ + private $oldKey; + + /** + *

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

key value of the RecurringOrder after the Set Key update action.

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

key value of the RecurringOrder before the Set Key update action.

+ * + + * @return null|string + */ + public function getOldKey() + { + return $this->oldKey; + } + + /** + * @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 $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?string $oldKey + * @return $this + */ + public function withOldKey(?string $oldKey) + { + $this->oldKey = $oldKey; + + 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(): RecurringOrderKeySetMessage + { + return new RecurringOrderKeySetMessageModel( + $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->key, + $this->oldKey + ); + } + + public static function of(): RecurringOrderKeySetMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessageCollection.php new file mode 100644 index 00000000000..f9268d3ddb1 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderKeySetMessage current() + * @method RecurringOrderKeySetMessage end() + * @method RecurringOrderKeySetMessage at($offset) + */ +class RecurringOrderKeySetMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderKeySetMessage $value + * @psalm-param RecurringOrderKeySetMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderKeySetMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderKeySetMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderKeySetMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderKeySetMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderKeySetMessage $data */ + $data = RecurringOrderKeySetMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessageModel.php new file mode 100644 index 00000000000..92c2dca3b05 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessageModel.php @@ -0,0 +1,526 @@ +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->key = $key; + $this->oldKey = $oldKey; + $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; + } + + /** + *

key value of the RecurringOrder after the Set Key update action.

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

key value of the RecurringOrder before the Set Key update action.

+ * + * + * @return null|string + */ + public function getOldKey() + { + if (is_null($this->oldKey)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_OLD_KEY); + if (is_null($data)) { + return null; + } + $this->oldKey = (string) $data; + } + + return $this->oldKey; + } + + + /** + * @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 $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?string $oldKey + */ + public function setOldKey(?string $oldKey): void + { + $this->oldKey = $oldKey; + } + + + #[\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/RecurringOrderKeySetMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayload.php new file mode 100644 index 00000000000..d176464f2e4 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayload.php @@ -0,0 +1,44 @@ +key value of the RecurringOrder after the Set Key update action.

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

key value of the RecurringOrder before the Set Key update action.

+ * + + * @return null|string + */ + public function getOldKey(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?string $oldKey + */ + public function setOldKey(?string $oldKey): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayloadBuilder.php new file mode 100644 index 00000000000..58408319711 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayloadBuilder.php @@ -0,0 +1,92 @@ + + */ +final class RecurringOrderKeySetMessagePayloadBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + + * @var ?string + */ + private $oldKey; + + /** + *

key value of the RecurringOrder after the Set Key update action.

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

key value of the RecurringOrder before the Set Key update action.

+ * + + * @return null|string + */ + public function getOldKey() + { + return $this->oldKey; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?string $oldKey + * @return $this + */ + public function withOldKey(?string $oldKey) + { + $this->oldKey = $oldKey; + + return $this; + } + + + public function build(): RecurringOrderKeySetMessagePayload + { + return new RecurringOrderKeySetMessagePayloadModel( + $this->key, + $this->oldKey + ); + } + + public static function of(): RecurringOrderKeySetMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayloadCollection.php new file mode 100644 index 00000000000..f72b0c0429b --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderKeySetMessagePayload current() + * @method RecurringOrderKeySetMessagePayload end() + * @method RecurringOrderKeySetMessagePayload at($offset) + */ +class RecurringOrderKeySetMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderKeySetMessagePayload $value + * @psalm-param RecurringOrderKeySetMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderKeySetMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderKeySetMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderKeySetMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderKeySetMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderKeySetMessagePayload $data */ + $data = RecurringOrderKeySetMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayloadModel.php new file mode 100644 index 00000000000..9fb95cec6d6 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderKeySetMessagePayloadModel.php @@ -0,0 +1,129 @@ +key = $key; + $this->oldKey = $oldKey; + $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; + } + + /** + *

key value of the RecurringOrder after the Set Key update action.

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

key value of the RecurringOrder before the Set Key update action.

+ * + * + * @return null|string + */ + public function getOldKey() + { + if (is_null($this->oldKey)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_OLD_KEY); + if (is_null($data)) { + return null; + } + $this->oldKey = (string) $data; + } + + return $this->oldKey; + } + + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?string $oldKey + */ + public function setOldKey(?string $oldKey): void + { + $this->oldKey = $oldKey; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderMessagePayload.php new file mode 100644 index 00000000000..ca50fc135ee --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderMessagePayload.php @@ -0,0 +1,16 @@ + + */ +final class RecurringOrderMessagePayloadBuilder implements Builder +{ + public function build(): RecurringOrderMessagePayload + { + return new RecurringOrderMessagePayloadModel( + ); + } + + public static function of(): RecurringOrderMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderMessagePayloadCollection.php new file mode 100644 index 00000000000..cb6f4182382 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderMessagePayload current() + * @method RecurringOrderMessagePayload end() + * @method RecurringOrderMessagePayload at($offset) + */ +class RecurringOrderMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderMessagePayload $value + * @psalm-param RecurringOrderMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderMessagePayload $data */ + $data = RecurringOrderMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderMessagePayloadModel.php new file mode 100644 index 00000000000..87dfd549f36 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderMessagePayloadModel.php @@ -0,0 +1,55 @@ +type = $type; + } + + /** + * + * @return null|string + */ + public function getType() + { + if (is_null($this->type)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_TYPE); + if (is_null($data)) { + return null; + } + $this->type = (string) $data; + } + + return $this->type; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessage.php new file mode 100644 index 00000000000..01120ef95aa --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessage.php @@ -0,0 +1,45 @@ +Schedule of the Recurring Order after the Set Schedule update action.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getRecurrencePolicySchedule(); + + /** + *

Schedule of the Recurring Order before the Set Schedule update action.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getOldRecurrencePolicySchedule(); + + /** + * @param ?RecurrencePolicySchedule $recurrencePolicySchedule + */ + public function setRecurrencePolicySchedule(?RecurrencePolicySchedule $recurrencePolicySchedule): void; + + /** + * @param ?RecurrencePolicySchedule $oldRecurrencePolicySchedule + */ + public function setOldRecurrencePolicySchedule(?RecurrencePolicySchedule $oldRecurrencePolicySchedule): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessageBuilder.php new file mode 100644 index 00000000000..a63cb8815e5 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessageBuilder.php @@ -0,0 +1,457 @@ + + */ +final class RecurringOrderScheduleSetMessageBuilder 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|RecurrencePolicySchedule|RecurrencePolicyScheduleBuilder + */ + private $recurrencePolicySchedule; + + /** + + * @var null|RecurrencePolicySchedule|RecurrencePolicyScheduleBuilder + */ + private $oldRecurrencePolicySchedule; + + /** + *

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

Schedule of the Recurring Order after the Set Schedule update action.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getRecurrencePolicySchedule() + { + return $this->recurrencePolicySchedule instanceof RecurrencePolicyScheduleBuilder ? $this->recurrencePolicySchedule->build() : $this->recurrencePolicySchedule; + } + + /** + *

Schedule of the Recurring Order before the Set Schedule update action.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getOldRecurrencePolicySchedule() + { + return $this->oldRecurrencePolicySchedule instanceof RecurrencePolicyScheduleBuilder ? $this->oldRecurrencePolicySchedule->build() : $this->oldRecurrencePolicySchedule; + } + + /** + * @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 ?RecurrencePolicySchedule $recurrencePolicySchedule + * @return $this + */ + public function withRecurrencePolicySchedule(?RecurrencePolicySchedule $recurrencePolicySchedule) + { + $this->recurrencePolicySchedule = $recurrencePolicySchedule; + + return $this; + } + + /** + * @param ?RecurrencePolicySchedule $oldRecurrencePolicySchedule + * @return $this + */ + public function withOldRecurrencePolicySchedule(?RecurrencePolicySchedule $oldRecurrencePolicySchedule) + { + $this->oldRecurrencePolicySchedule = $oldRecurrencePolicySchedule; + + 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 withRecurrencePolicySchedule() instead + * @return $this + */ + public function withRecurrencePolicyScheduleBuilder(?RecurrencePolicyScheduleBuilder $recurrencePolicySchedule) + { + $this->recurrencePolicySchedule = $recurrencePolicySchedule; + + return $this; + } + + /** + * @deprecated use withOldRecurrencePolicySchedule() instead + * @return $this + */ + public function withOldRecurrencePolicyScheduleBuilder(?RecurrencePolicyScheduleBuilder $oldRecurrencePolicySchedule) + { + $this->oldRecurrencePolicySchedule = $oldRecurrencePolicySchedule; + + return $this; + } + + public function build(): RecurringOrderScheduleSetMessage + { + return new RecurringOrderScheduleSetMessageModel( + $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->recurrencePolicySchedule instanceof RecurrencePolicyScheduleBuilder ? $this->recurrencePolicySchedule->build() : $this->recurrencePolicySchedule, + $this->oldRecurrencePolicySchedule instanceof RecurrencePolicyScheduleBuilder ? $this->oldRecurrencePolicySchedule->build() : $this->oldRecurrencePolicySchedule + ); + } + + public static function of(): RecurringOrderScheduleSetMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessageCollection.php new file mode 100644 index 00000000000..acb529ec0ca --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderScheduleSetMessage current() + * @method RecurringOrderScheduleSetMessage end() + * @method RecurringOrderScheduleSetMessage at($offset) + */ +class RecurringOrderScheduleSetMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderScheduleSetMessage $value + * @psalm-param RecurringOrderScheduleSetMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderScheduleSetMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderScheduleSetMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderScheduleSetMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderScheduleSetMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderScheduleSetMessage $data */ + $data = RecurringOrderScheduleSetMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessageModel.php new file mode 100644 index 00000000000..c24046fd7a8 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessageModel.php @@ -0,0 +1,530 @@ +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->recurrencePolicySchedule = $recurrencePolicySchedule; + $this->oldRecurrencePolicySchedule = $oldRecurrencePolicySchedule; + $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; + } + + /** + *

Schedule of the Recurring Order after the Set Schedule update action.

+ * + * + * @return null|RecurrencePolicySchedule + */ + public function getRecurrencePolicySchedule() + { + if (is_null($this->recurrencePolicySchedule)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRENCE_POLICY_SCHEDULE); + if (is_null($data)) { + return null; + } + $className = RecurrencePolicyScheduleModel::resolveDiscriminatorClass($data); + $this->recurrencePolicySchedule = $className::of($data); + } + + return $this->recurrencePolicySchedule; + } + + /** + *

Schedule of the Recurring Order before the Set Schedule update action.

+ * + * + * @return null|RecurrencePolicySchedule + */ + public function getOldRecurrencePolicySchedule() + { + if (is_null($this->oldRecurrencePolicySchedule)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_OLD_RECURRENCE_POLICY_SCHEDULE); + if (is_null($data)) { + return null; + } + $className = RecurrencePolicyScheduleModel::resolveDiscriminatorClass($data); + $this->oldRecurrencePolicySchedule = $className::of($data); + } + + return $this->oldRecurrencePolicySchedule; + } + + + /** + * @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 ?RecurrencePolicySchedule $recurrencePolicySchedule + */ + public function setRecurrencePolicySchedule(?RecurrencePolicySchedule $recurrencePolicySchedule): void + { + $this->recurrencePolicySchedule = $recurrencePolicySchedule; + } + + /** + * @param ?RecurrencePolicySchedule $oldRecurrencePolicySchedule + */ + public function setOldRecurrencePolicySchedule(?RecurrencePolicySchedule $oldRecurrencePolicySchedule): void + { + $this->oldRecurrencePolicySchedule = $oldRecurrencePolicySchedule; + } + + + #[\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/RecurringOrderScheduleSetMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayload.php new file mode 100644 index 00000000000..1484a511f96 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayload.php @@ -0,0 +1,45 @@ +Schedule of the Recurring Order after the Set Schedule update action.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getRecurrencePolicySchedule(); + + /** + *

Schedule of the Recurring Order before the Set Schedule update action.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getOldRecurrencePolicySchedule(); + + /** + * @param ?RecurrencePolicySchedule $recurrencePolicySchedule + */ + public function setRecurrencePolicySchedule(?RecurrencePolicySchedule $recurrencePolicySchedule): void; + + /** + * @param ?RecurrencePolicySchedule $oldRecurrencePolicySchedule + */ + public function setOldRecurrencePolicySchedule(?RecurrencePolicySchedule $oldRecurrencePolicySchedule): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayloadBuilder.php new file mode 100644 index 00000000000..92bfdcec565 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayloadBuilder.php @@ -0,0 +1,115 @@ + + */ +final class RecurringOrderScheduleSetMessagePayloadBuilder implements Builder +{ + /** + + * @var null|RecurrencePolicySchedule|RecurrencePolicyScheduleBuilder + */ + private $recurrencePolicySchedule; + + /** + + * @var null|RecurrencePolicySchedule|RecurrencePolicyScheduleBuilder + */ + private $oldRecurrencePolicySchedule; + + /** + *

Schedule of the Recurring Order after the Set Schedule update action.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getRecurrencePolicySchedule() + { + return $this->recurrencePolicySchedule instanceof RecurrencePolicyScheduleBuilder ? $this->recurrencePolicySchedule->build() : $this->recurrencePolicySchedule; + } + + /** + *

Schedule of the Recurring Order before the Set Schedule update action.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getOldRecurrencePolicySchedule() + { + return $this->oldRecurrencePolicySchedule instanceof RecurrencePolicyScheduleBuilder ? $this->oldRecurrencePolicySchedule->build() : $this->oldRecurrencePolicySchedule; + } + + /** + * @param ?RecurrencePolicySchedule $recurrencePolicySchedule + * @return $this + */ + public function withRecurrencePolicySchedule(?RecurrencePolicySchedule $recurrencePolicySchedule) + { + $this->recurrencePolicySchedule = $recurrencePolicySchedule; + + return $this; + } + + /** + * @param ?RecurrencePolicySchedule $oldRecurrencePolicySchedule + * @return $this + */ + public function withOldRecurrencePolicySchedule(?RecurrencePolicySchedule $oldRecurrencePolicySchedule) + { + $this->oldRecurrencePolicySchedule = $oldRecurrencePolicySchedule; + + return $this; + } + + /** + * @deprecated use withRecurrencePolicySchedule() instead + * @return $this + */ + public function withRecurrencePolicyScheduleBuilder(?RecurrencePolicyScheduleBuilder $recurrencePolicySchedule) + { + $this->recurrencePolicySchedule = $recurrencePolicySchedule; + + return $this; + } + + /** + * @deprecated use withOldRecurrencePolicySchedule() instead + * @return $this + */ + public function withOldRecurrencePolicyScheduleBuilder(?RecurrencePolicyScheduleBuilder $oldRecurrencePolicySchedule) + { + $this->oldRecurrencePolicySchedule = $oldRecurrencePolicySchedule; + + return $this; + } + + public function build(): RecurringOrderScheduleSetMessagePayload + { + return new RecurringOrderScheduleSetMessagePayloadModel( + $this->recurrencePolicySchedule instanceof RecurrencePolicyScheduleBuilder ? $this->recurrencePolicySchedule->build() : $this->recurrencePolicySchedule, + $this->oldRecurrencePolicySchedule instanceof RecurrencePolicyScheduleBuilder ? $this->oldRecurrencePolicySchedule->build() : $this->oldRecurrencePolicySchedule + ); + } + + public static function of(): RecurringOrderScheduleSetMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayloadCollection.php new file mode 100644 index 00000000000..d52fdbd0b46 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderScheduleSetMessagePayload current() + * @method RecurringOrderScheduleSetMessagePayload end() + * @method RecurringOrderScheduleSetMessagePayload at($offset) + */ +class RecurringOrderScheduleSetMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderScheduleSetMessagePayload $value + * @psalm-param RecurringOrderScheduleSetMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderScheduleSetMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderScheduleSetMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderScheduleSetMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderScheduleSetMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderScheduleSetMessagePayload $data */ + $data = RecurringOrderScheduleSetMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayloadModel.php new file mode 100644 index 00000000000..3ff86dec0a8 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderScheduleSetMessagePayloadModel.php @@ -0,0 +1,133 @@ +recurrencePolicySchedule = $recurrencePolicySchedule; + $this->oldRecurrencePolicySchedule = $oldRecurrencePolicySchedule; + $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; + } + + /** + *

Schedule of the Recurring Order after the Set Schedule update action.

+ * + * + * @return null|RecurrencePolicySchedule + */ + public function getRecurrencePolicySchedule() + { + if (is_null($this->recurrencePolicySchedule)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRENCE_POLICY_SCHEDULE); + if (is_null($data)) { + return null; + } + $className = RecurrencePolicyScheduleModel::resolveDiscriminatorClass($data); + $this->recurrencePolicySchedule = $className::of($data); + } + + return $this->recurrencePolicySchedule; + } + + /** + *

Schedule of the Recurring Order before the Set Schedule update action.

+ * + * + * @return null|RecurrencePolicySchedule + */ + public function getOldRecurrencePolicySchedule() + { + if (is_null($this->oldRecurrencePolicySchedule)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_OLD_RECURRENCE_POLICY_SCHEDULE); + if (is_null($data)) { + return null; + } + $className = RecurrencePolicyScheduleModel::resolveDiscriminatorClass($data); + $this->oldRecurrencePolicySchedule = $className::of($data); + } + + return $this->oldRecurrencePolicySchedule; + } + + + /** + * @param ?RecurrencePolicySchedule $recurrencePolicySchedule + */ + public function setRecurrencePolicySchedule(?RecurrencePolicySchedule $recurrencePolicySchedule): void + { + $this->recurrencePolicySchedule = $recurrencePolicySchedule; + } + + /** + * @param ?RecurrencePolicySchedule $oldRecurrencePolicySchedule + */ + public function setOldRecurrencePolicySchedule(?RecurrencePolicySchedule $oldRecurrencePolicySchedule): void + { + $this->oldRecurrencePolicySchedule = $oldRecurrencePolicySchedule; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessage.php new file mode 100644 index 00000000000..8fdc1dbd9fd --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessage.php @@ -0,0 +1,45 @@ +Start date and time of the Recurring Order after the Set Starts At update action.

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

Start date and time of the Recurring Order before the Set Starts At update action.

+ * + + * @return null|DateTimeImmutable + */ + public function getOldStartsAt(); + + /** + * @param ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void; + + /** + * @param ?DateTimeImmutable $oldStartsAt + */ + public function setOldStartsAt(?DateTimeImmutable $oldStartsAt): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessageBuilder.php new file mode 100644 index 00000000000..fb23ea7037e --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessageBuilder.php @@ -0,0 +1,433 @@ + + */ +final class RecurringOrderStartsAtSetMessageBuilder 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 ?DateTimeImmutable + */ + private $startsAt; + + /** + + * @var ?DateTimeImmutable + */ + private $oldStartsAt; + + /** + *

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

Start date and time of the Recurring Order after the Set Starts At update action.

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

Start date and time of the Recurring Order before the Set Starts At update action.

+ * + + * @return null|DateTimeImmutable + */ + public function getOldStartsAt() + { + return $this->oldStartsAt; + } + + /** + * @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 ?DateTimeImmutable $startsAt + * @return $this + */ + public function withStartsAt(?DateTimeImmutable $startsAt) + { + $this->startsAt = $startsAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $oldStartsAt + * @return $this + */ + public function withOldStartsAt(?DateTimeImmutable $oldStartsAt) + { + $this->oldStartsAt = $oldStartsAt; + + 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(): RecurringOrderStartsAtSetMessage + { + return new RecurringOrderStartsAtSetMessageModel( + $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->startsAt, + $this->oldStartsAt + ); + } + + public static function of(): RecurringOrderStartsAtSetMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessageCollection.php new file mode 100644 index 00000000000..b4eab0b17e1 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderStartsAtSetMessage current() + * @method RecurringOrderStartsAtSetMessage end() + * @method RecurringOrderStartsAtSetMessage at($offset) + */ +class RecurringOrderStartsAtSetMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderStartsAtSetMessage $value + * @psalm-param RecurringOrderStartsAtSetMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderStartsAtSetMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderStartsAtSetMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderStartsAtSetMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderStartsAtSetMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderStartsAtSetMessage $data */ + $data = RecurringOrderStartsAtSetMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessageModel.php new file mode 100644 index 00000000000..7a744ebc508 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessageModel.php @@ -0,0 +1,542 @@ +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->startsAt = $startsAt; + $this->oldStartsAt = $oldStartsAt; + $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; + } + + /** + *

Start date and time of the Recurring Order after the Set Starts At update action.

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

Start date and time of the Recurring Order before the Set Starts At update action.

+ * + * + * @return null|DateTimeImmutable + */ + public function getOldStartsAt() + { + if (is_null($this->oldStartsAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_OLD_STARTS_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->oldStartsAt = $data; + } + + return $this->oldStartsAt; + } + + + /** + * @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 ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void + { + $this->startsAt = $startsAt; + } + + /** + * @param ?DateTimeImmutable $oldStartsAt + */ + public function setOldStartsAt(?DateTimeImmutable $oldStartsAt): void + { + $this->oldStartsAt = $oldStartsAt; + } + + + #[\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[RecurringOrderStartsAtSetMessage::FIELD_STARTS_AT]) && $data[RecurringOrderStartsAtSetMessage::FIELD_STARTS_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderStartsAtSetMessage::FIELD_STARTS_AT] = $data[RecurringOrderStartsAtSetMessage::FIELD_STARTS_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrderStartsAtSetMessage::FIELD_OLD_STARTS_AT]) && $data[RecurringOrderStartsAtSetMessage::FIELD_OLD_STARTS_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderStartsAtSetMessage::FIELD_OLD_STARTS_AT] = $data[RecurringOrderStartsAtSetMessage::FIELD_OLD_STARTS_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayload.php new file mode 100644 index 00000000000..6f11429752c --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayload.php @@ -0,0 +1,45 @@ +Start date and time of the Recurring Order after the Set Starts At update action.

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

Start date and time of the Recurring Order before the Set Starts At update action.

+ * + + * @return null|DateTimeImmutable + */ + public function getOldStartsAt(); + + /** + * @param ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void; + + /** + * @param ?DateTimeImmutable $oldStartsAt + */ + public function setOldStartsAt(?DateTimeImmutable $oldStartsAt): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayloadBuilder.php new file mode 100644 index 00000000000..07fff0f3a29 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayloadBuilder.php @@ -0,0 +1,93 @@ + + */ +final class RecurringOrderStartsAtSetMessagePayloadBuilder implements Builder +{ + /** + + * @var ?DateTimeImmutable + */ + private $startsAt; + + /** + + * @var ?DateTimeImmutable + */ + private $oldStartsAt; + + /** + *

Start date and time of the Recurring Order after the Set Starts At update action.

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

Start date and time of the Recurring Order before the Set Starts At update action.

+ * + + * @return null|DateTimeImmutable + */ + public function getOldStartsAt() + { + return $this->oldStartsAt; + } + + /** + * @param ?DateTimeImmutable $startsAt + * @return $this + */ + public function withStartsAt(?DateTimeImmutable $startsAt) + { + $this->startsAt = $startsAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $oldStartsAt + * @return $this + */ + public function withOldStartsAt(?DateTimeImmutable $oldStartsAt) + { + $this->oldStartsAt = $oldStartsAt; + + return $this; + } + + + public function build(): RecurringOrderStartsAtSetMessagePayload + { + return new RecurringOrderStartsAtSetMessagePayloadModel( + $this->startsAt, + $this->oldStartsAt + ); + } + + public static function of(): RecurringOrderStartsAtSetMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayloadCollection.php new file mode 100644 index 00000000000..230f48e8980 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderStartsAtSetMessagePayload current() + * @method RecurringOrderStartsAtSetMessagePayload end() + * @method RecurringOrderStartsAtSetMessagePayload at($offset) + */ +class RecurringOrderStartsAtSetMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderStartsAtSetMessagePayload $value + * @psalm-param RecurringOrderStartsAtSetMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderStartsAtSetMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderStartsAtSetMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderStartsAtSetMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderStartsAtSetMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderStartsAtSetMessagePayload $data */ + $data = RecurringOrderStartsAtSetMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayloadModel.php new file mode 100644 index 00000000000..64ab1b451bd --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStartsAtSetMessagePayloadModel.php @@ -0,0 +1,153 @@ +startsAt = $startsAt; + $this->oldStartsAt = $oldStartsAt; + $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; + } + + /** + *

Start date and time of the Recurring Order after the Set Starts At update action.

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

Start date and time of the Recurring Order before the Set Starts At update action.

+ * + * + * @return null|DateTimeImmutable + */ + public function getOldStartsAt() + { + if (is_null($this->oldStartsAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_OLD_STARTS_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->oldStartsAt = $data; + } + + return $this->oldStartsAt; + } + + + /** + * @param ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void + { + $this->startsAt = $startsAt; + } + + /** + * @param ?DateTimeImmutable $oldStartsAt + */ + public function setOldStartsAt(?DateTimeImmutable $oldStartsAt): void + { + $this->oldStartsAt = $oldStartsAt; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[RecurringOrderStartsAtSetMessagePayload::FIELD_STARTS_AT]) && $data[RecurringOrderStartsAtSetMessagePayload::FIELD_STARTS_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderStartsAtSetMessagePayload::FIELD_STARTS_AT] = $data[RecurringOrderStartsAtSetMessagePayload::FIELD_STARTS_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrderStartsAtSetMessagePayload::FIELD_OLD_STARTS_AT]) && $data[RecurringOrderStartsAtSetMessagePayload::FIELD_OLD_STARTS_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderStartsAtSetMessagePayload::FIELD_OLD_STARTS_AT] = $data[RecurringOrderStartsAtSetMessagePayload::FIELD_OLD_STARTS_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessage.php new file mode 100644 index 00000000000..d8bfd9492e6 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessage.php @@ -0,0 +1,44 @@ +RecurringOrderState after the Set RecurringOrderState update action.

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

RecurringOrderState before the Set RecurringOrderState update action.

+ * + + * @return null|string + */ + public function getOldState(); + + /** + * @param ?string $state + */ + public function setState(?string $state): void; + + /** + * @param ?string $oldState + */ + public function setOldState(?string $oldState): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessageBuilder.php new file mode 100644 index 00000000000..189c8289427 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessageBuilder.php @@ -0,0 +1,433 @@ + + */ +final class RecurringOrderStateChangedMessageBuilder 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 $state; + + /** + + * @var ?string + */ + private $oldState; + + /** + *

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

RecurringOrderState after the Set RecurringOrderState update action.

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

RecurringOrderState before the Set RecurringOrderState update action.

+ * + + * @return null|string + */ + public function getOldState() + { + return $this->oldState; + } + + /** + * @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 $state + * @return $this + */ + public function withState(?string $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?string $oldState + * @return $this + */ + public function withOldState(?string $oldState) + { + $this->oldState = $oldState; + + 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(): RecurringOrderStateChangedMessage + { + return new RecurringOrderStateChangedMessageModel( + $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->state, + $this->oldState + ); + } + + public static function of(): RecurringOrderStateChangedMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessageCollection.php new file mode 100644 index 00000000000..88a6ab2fe55 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderStateChangedMessage current() + * @method RecurringOrderStateChangedMessage end() + * @method RecurringOrderStateChangedMessage at($offset) + */ +class RecurringOrderStateChangedMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderStateChangedMessage $value + * @psalm-param RecurringOrderStateChangedMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderStateChangedMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderStateChangedMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderStateChangedMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderStateChangedMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderStateChangedMessage $data */ + $data = RecurringOrderStateChangedMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessageModel.php new file mode 100644 index 00000000000..1e36951046b --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessageModel.php @@ -0,0 +1,526 @@ +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->state = $state; + $this->oldState = $oldState; + $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; + } + + /** + *

RecurringOrderState after the Set RecurringOrderState update action.

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

RecurringOrderState before the Set RecurringOrderState update action.

+ * + * + * @return null|string + */ + public function getOldState() + { + if (is_null($this->oldState)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_OLD_STATE); + if (is_null($data)) { + return null; + } + $this->oldState = (string) $data; + } + + return $this->oldState; + } + + + /** + * @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 $state + */ + public function setState(?string $state): void + { + $this->state = $state; + } + + /** + * @param ?string $oldState + */ + public function setOldState(?string $oldState): void + { + $this->oldState = $oldState; + } + + + #[\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/RecurringOrderStateChangedMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayload.php new file mode 100644 index 00000000000..8bb4cc2ac9d --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayload.php @@ -0,0 +1,44 @@ +RecurringOrderState after the Set RecurringOrderState update action.

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

RecurringOrderState before the Set RecurringOrderState update action.

+ * + + * @return null|string + */ + public function getOldState(); + + /** + * @param ?string $state + */ + public function setState(?string $state): void; + + /** + * @param ?string $oldState + */ + public function setOldState(?string $oldState): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayloadBuilder.php new file mode 100644 index 00000000000..8568bea05f0 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayloadBuilder.php @@ -0,0 +1,92 @@ + + */ +final class RecurringOrderStateChangedMessagePayloadBuilder implements Builder +{ + /** + + * @var ?string + */ + private $state; + + /** + + * @var ?string + */ + private $oldState; + + /** + *

RecurringOrderState after the Set RecurringOrderState update action.

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

RecurringOrderState before the Set RecurringOrderState update action.

+ * + + * @return null|string + */ + public function getOldState() + { + return $this->oldState; + } + + /** + * @param ?string $state + * @return $this + */ + public function withState(?string $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?string $oldState + * @return $this + */ + public function withOldState(?string $oldState) + { + $this->oldState = $oldState; + + return $this; + } + + + public function build(): RecurringOrderStateChangedMessagePayload + { + return new RecurringOrderStateChangedMessagePayloadModel( + $this->state, + $this->oldState + ); + } + + public static function of(): RecurringOrderStateChangedMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayloadCollection.php new file mode 100644 index 00000000000..b403c477eff --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderStateChangedMessagePayload current() + * @method RecurringOrderStateChangedMessagePayload end() + * @method RecurringOrderStateChangedMessagePayload at($offset) + */ +class RecurringOrderStateChangedMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderStateChangedMessagePayload $value + * @psalm-param RecurringOrderStateChangedMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderStateChangedMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderStateChangedMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderStateChangedMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderStateChangedMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderStateChangedMessagePayload $data */ + $data = RecurringOrderStateChangedMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayloadModel.php new file mode 100644 index 00000000000..c441f351468 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateChangedMessagePayloadModel.php @@ -0,0 +1,129 @@ +state = $state; + $this->oldState = $oldState; + $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; + } + + /** + *

RecurringOrderState after the Set RecurringOrderState update action.

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

RecurringOrderState before the Set RecurringOrderState update action.

+ * + * + * @return null|string + */ + public function getOldState() + { + if (is_null($this->oldState)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_OLD_STATE); + if (is_null($data)) { + return null; + } + $this->oldState = (string) $data; + } + + return $this->oldState; + } + + + /** + * @param ?string $state + */ + public function setState(?string $state): void + { + $this->state = $state; + } + + /** + * @param ?string $oldState + */ + public function setOldState(?string $oldState): void + { + $this->oldState = $oldState; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessage.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessage.php new file mode 100644 index 00000000000..f8b82311cbe --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessage.php @@ -0,0 +1,59 @@ +RecurringOrderState after the Transition State update action.

+ * + + * @return null|StateReference + */ + public function getState(); + + /** + *

RecurringOrderState before the Transition State update action.

+ * + + * @return null|StateReference + */ + public function getOldState(); + + /** + *

Whether State transition validations were turned off during the Transition State update action.

+ * + + * @return null|bool + */ + public function getForce(); + + /** + * @param ?StateReference $state + */ + public function setState(?StateReference $state): void; + + /** + * @param ?StateReference $oldState + */ + public function setOldState(?StateReference $oldState): void; + + /** + * @param ?bool $force + */ + public function setForce(?bool $force): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessageBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessageBuilder.php new file mode 100644 index 00000000000..89aa4c743f2 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessageBuilder.php @@ -0,0 +1,486 @@ + + */ +final class RecurringOrderStateTransitionMessageBuilder 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|StateReference|StateReferenceBuilder + */ + private $state; + + /** + + * @var null|StateReference|StateReferenceBuilder + */ + private $oldState; + + /** + + * @var ?bool + */ + private $force; + + /** + *

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

RecurringOrderState after the Transition State update action.

+ * + + * @return null|StateReference + */ + public function getState() + { + return $this->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state; + } + + /** + *

RecurringOrderState before the Transition State update action.

+ * + + * @return null|StateReference + */ + public function getOldState() + { + return $this->oldState instanceof StateReferenceBuilder ? $this->oldState->build() : $this->oldState; + } + + /** + *

Whether State transition validations were turned off during the Transition State update action.

+ * + + * @return null|bool + */ + public function getForce() + { + return $this->force; + } + + /** + * @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 ?StateReference $state + * @return $this + */ + public function withState(?StateReference $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?StateReference $oldState + * @return $this + */ + public function withOldState(?StateReference $oldState) + { + $this->oldState = $oldState; + + return $this; + } + + /** + * @param ?bool $force + * @return $this + */ + public function withForce(?bool $force) + { + $this->force = $force; + + 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 withState() instead + * @return $this + */ + public function withStateBuilder(?StateReferenceBuilder $state) + { + $this->state = $state; + + return $this; + } + + /** + * @deprecated use withOldState() instead + * @return $this + */ + public function withOldStateBuilder(?StateReferenceBuilder $oldState) + { + $this->oldState = $oldState; + + return $this; + } + + public function build(): RecurringOrderStateTransitionMessage + { + return new RecurringOrderStateTransitionMessageModel( + $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->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state, + $this->oldState instanceof StateReferenceBuilder ? $this->oldState->build() : $this->oldState, + $this->force + ); + } + + public static function of(): RecurringOrderStateTransitionMessageBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessageCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessageCollection.php new file mode 100644 index 00000000000..d6ff5dde904 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessageCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderStateTransitionMessage current() + * @method RecurringOrderStateTransitionMessage end() + * @method RecurringOrderStateTransitionMessage at($offset) + */ +class RecurringOrderStateTransitionMessageCollection extends MessageCollection +{ + /** + * @psalm-assert RecurringOrderStateTransitionMessage $value + * @psalm-param RecurringOrderStateTransitionMessage|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderStateTransitionMessageCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderStateTransitionMessage) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderStateTransitionMessage + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderStateTransitionMessage { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderStateTransitionMessage $data */ + $data = RecurringOrderStateTransitionMessageModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessageModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessageModel.php new file mode 100644 index 00000000000..193a84af4f9 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessageModel.php @@ -0,0 +1,566 @@ +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->state = $state; + $this->oldState = $oldState; + $this->force = $force; + $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; + } + + /** + *

RecurringOrderState after the Transition State update action.

+ * + * + * @return null|StateReference + */ + public function getState() + { + if (is_null($this->state)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_STATE); + if (is_null($data)) { + return null; + } + + $this->state = StateReferenceModel::of($data); + } + + return $this->state; + } + + /** + *

RecurringOrderState before the Transition State update action.

+ * + * + * @return null|StateReference + */ + public function getOldState() + { + if (is_null($this->oldState)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_OLD_STATE); + if (is_null($data)) { + return null; + } + + $this->oldState = StateReferenceModel::of($data); + } + + return $this->oldState; + } + + /** + *

Whether State transition validations were turned off during the Transition State update action.

+ * + * + * @return null|bool + */ + public function getForce() + { + if (is_null($this->force)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_FORCE); + if (is_null($data)) { + return null; + } + $this->force = (bool) $data; + } + + return $this->force; + } + + + /** + * @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 ?StateReference $state + */ + public function setState(?StateReference $state): void + { + $this->state = $state; + } + + /** + * @param ?StateReference $oldState + */ + public function setOldState(?StateReference $oldState): void + { + $this->oldState = $oldState; + } + + /** + * @param ?bool $force + */ + public function setForce(?bool $force): void + { + $this->force = $force; + } + + + #[\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/RecurringOrderStateTransitionMessagePayload.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayload.php new file mode 100644 index 00000000000..527f94c7260 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayload.php @@ -0,0 +1,59 @@ +RecurringOrderState after the Transition State update action.

+ * + + * @return null|StateReference + */ + public function getState(); + + /** + *

RecurringOrderState before the Transition State update action.

+ * + + * @return null|StateReference + */ + public function getOldState(); + + /** + *

Whether State transition validations were turned off during the Transition State update action.

+ * + + * @return null|bool + */ + public function getForce(); + + /** + * @param ?StateReference $state + */ + public function setState(?StateReference $state): void; + + /** + * @param ?StateReference $oldState + */ + public function setOldState(?StateReference $oldState): void; + + /** + * @param ?bool $force + */ + public function setForce(?bool $force): void; +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayloadBuilder.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayloadBuilder.php new file mode 100644 index 00000000000..f100a6e511f --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayloadBuilder.php @@ -0,0 +1,144 @@ + + */ +final class RecurringOrderStateTransitionMessagePayloadBuilder implements Builder +{ + /** + + * @var null|StateReference|StateReferenceBuilder + */ + private $state; + + /** + + * @var null|StateReference|StateReferenceBuilder + */ + private $oldState; + + /** + + * @var ?bool + */ + private $force; + + /** + *

RecurringOrderState after the Transition State update action.

+ * + + * @return null|StateReference + */ + public function getState() + { + return $this->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state; + } + + /** + *

RecurringOrderState before the Transition State update action.

+ * + + * @return null|StateReference + */ + public function getOldState() + { + return $this->oldState instanceof StateReferenceBuilder ? $this->oldState->build() : $this->oldState; + } + + /** + *

Whether State transition validations were turned off during the Transition State update action.

+ * + + * @return null|bool + */ + public function getForce() + { + return $this->force; + } + + /** + * @param ?StateReference $state + * @return $this + */ + public function withState(?StateReference $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?StateReference $oldState + * @return $this + */ + public function withOldState(?StateReference $oldState) + { + $this->oldState = $oldState; + + return $this; + } + + /** + * @param ?bool $force + * @return $this + */ + public function withForce(?bool $force) + { + $this->force = $force; + + return $this; + } + + /** + * @deprecated use withState() instead + * @return $this + */ + public function withStateBuilder(?StateReferenceBuilder $state) + { + $this->state = $state; + + return $this; + } + + /** + * @deprecated use withOldState() instead + * @return $this + */ + public function withOldStateBuilder(?StateReferenceBuilder $oldState) + { + $this->oldState = $oldState; + + return $this; + } + + public function build(): RecurringOrderStateTransitionMessagePayload + { + return new RecurringOrderStateTransitionMessagePayloadModel( + $this->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state, + $this->oldState instanceof StateReferenceBuilder ? $this->oldState->build() : $this->oldState, + $this->force + ); + } + + public static function of(): RecurringOrderStateTransitionMessagePayloadBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayloadCollection.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayloadCollection.php new file mode 100644 index 00000000000..593cc9475ff --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayloadCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderStateTransitionMessagePayload current() + * @method RecurringOrderStateTransitionMessagePayload end() + * @method RecurringOrderStateTransitionMessagePayload at($offset) + */ +class RecurringOrderStateTransitionMessagePayloadCollection extends MessagePayloadCollection +{ + /** + * @psalm-assert RecurringOrderStateTransitionMessagePayload $value + * @psalm-param RecurringOrderStateTransitionMessagePayload|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderStateTransitionMessagePayloadCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderStateTransitionMessagePayload) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderStateTransitionMessagePayload + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderStateTransitionMessagePayload { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderStateTransitionMessagePayload $data */ + $data = RecurringOrderStateTransitionMessagePayloadModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayloadModel.php b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayloadModel.php new file mode 100644 index 00000000000..32c2cc0f393 --- /dev/null +++ b/lib/commercetools-api/src/Models/Message/RecurringOrderStateTransitionMessagePayloadModel.php @@ -0,0 +1,169 @@ +state = $state; + $this->oldState = $oldState; + $this->force = $force; + $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; + } + + /** + *

RecurringOrderState after the Transition State update action.

+ * + * + * @return null|StateReference + */ + public function getState() + { + if (is_null($this->state)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_STATE); + if (is_null($data)) { + return null; + } + + $this->state = StateReferenceModel::of($data); + } + + return $this->state; + } + + /** + *

RecurringOrderState before the Transition State update action.

+ * + * + * @return null|StateReference + */ + public function getOldState() + { + if (is_null($this->oldState)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_OLD_STATE); + if (is_null($data)) { + return null; + } + + $this->oldState = StateReferenceModel::of($data); + } + + return $this->oldState; + } + + /** + *

Whether State transition validations were turned off during the Transition State update action.

+ * + * + * @return null|bool + */ + public function getForce() + { + if (is_null($this->force)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_FORCE); + if (is_null($data)) { + return null; + } + $this->force = (bool) $data; + } + + return $this->force; + } + + + /** + * @param ?StateReference $state + */ + public function setState(?StateReference $state): void + { + $this->state = $state; + } + + /** + * @param ?StateReference $oldState + */ + public function setOldState(?StateReference $oldState): void + { + $this->oldState = $oldState; + } + + /** + * @param ?bool $force + */ + public function setForce(?bool $force): void + { + $this->force = $force; + } +} diff --git a/lib/commercetools-api/src/Models/Order/Order.php b/lib/commercetools-api/src/Models/Order/Order.php index 2a0c6c8ebe8..a606fb206c3 100644 --- a/lib/commercetools-api/src/Models/Order/Order.php +++ b/lib/commercetools-api/src/Models/Order/Order.php @@ -30,6 +30,7 @@ use Commercetools\Api\Models\CustomerGroup\CustomerGroupReference; use Commercetools\Api\Models\OrderEdit\StagedOrder; use Commercetools\Api\Models\Quote\QuoteReference; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReference; use Commercetools\Api\Models\State\StateReference; use Commercetools\Api\Models\Store\StoreKeyReference; use Commercetools\Api\Models\Type\CustomFields; @@ -76,6 +77,7 @@ interface Order extends BaseResource public const FIELD_ORIGIN = 'origin'; public const FIELD_CART = 'cart'; public const FIELD_QUOTE = 'quote'; + public const FIELD_RECURRING_ORDER = 'recurringOrder'; public const FIELD_ORDER_STATE = 'orderState'; public const FIELD_SHIPMENT_STATE = 'shipmentState'; public const FIELD_PAYMENT_STATE = 'paymentState'; @@ -424,6 +426,14 @@ public function getCart(); */ public function getQuote(); + /** + *

Reference to the RecurringOrder that generated this Order.

+ * + + * @return null|RecurringOrderReference + */ + public function getRecurringOrder(); + /** *

Current status of the Order.

* @@ -734,6 +744,11 @@ public function setCart(?CartReference $cart): void; */ public function setQuote(?QuoteReference $quote): void; + /** + * @param ?RecurringOrderReference $recurringOrder + */ + public function setRecurringOrder(?RecurringOrderReference $recurringOrder): void; + /** * @param ?string $orderState */ diff --git a/lib/commercetools-api/src/Models/Order/OrderBuilder.php b/lib/commercetools-api/src/Models/Order/OrderBuilder.php index b09331fd716..cc0aee88c3c 100644 --- a/lib/commercetools-api/src/Models/Order/OrderBuilder.php +++ b/lib/commercetools-api/src/Models/Order/OrderBuilder.php @@ -45,6 +45,8 @@ use Commercetools\Api\Models\OrderEdit\StagedOrderBuilder; use Commercetools\Api\Models\Quote\QuoteReference; use Commercetools\Api\Models\Quote\QuoteReferenceBuilder; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReference; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReferenceBuilder; use Commercetools\Api\Models\State\StateReference; use Commercetools\Api\Models\State\StateReferenceBuilder; use Commercetools\Api\Models\Store\StoreKeyReference; @@ -310,6 +312,12 @@ final class OrderBuilder implements Builder */ private $quote; + /** + + * @var null|RecurringOrderReference|RecurringOrderReferenceBuilder + */ + private $recurringOrder; + /** * @var ?string @@ -856,6 +864,17 @@ public function getQuote() return $this->quote instanceof QuoteReferenceBuilder ? $this->quote->build() : $this->quote; } + /** + *

Reference to the RecurringOrder that generated this Order.

+ * + + * @return null|RecurringOrderReference + */ + public function getRecurringOrder() + { + return $this->recurringOrder instanceof RecurringOrderReferenceBuilder ? $this->recurringOrder->build() : $this->recurringOrder; + } + /** *

Current status of the Order.

* @@ -1442,6 +1461,17 @@ public function withQuote(?QuoteReference $quote) return $this; } + /** + * @param ?RecurringOrderReference $recurringOrder + * @return $this + */ + public function withRecurringOrder(?RecurringOrderReference $recurringOrder) + { + $this->recurringOrder = $recurringOrder; + + return $this; + } + /** * @param ?string $orderState * @return $this @@ -1739,6 +1769,17 @@ public function withQuoteBuilder(?QuoteReferenceBuilder $quote) return $this; } + /** + * @deprecated use withRecurringOrder() instead + * @return $this + */ + public function withRecurringOrderBuilder(?RecurringOrderReferenceBuilder $recurringOrder) + { + $this->recurringOrder = $recurringOrder; + + return $this; + } + /** * @deprecated use withState() instead * @return $this @@ -1838,6 +1879,7 @@ public function build(): Order $this->origin, $this->cart instanceof CartReferenceBuilder ? $this->cart->build() : $this->cart, $this->quote instanceof QuoteReferenceBuilder ? $this->quote->build() : $this->quote, + $this->recurringOrder instanceof RecurringOrderReferenceBuilder ? $this->recurringOrder->build() : $this->recurringOrder, $this->orderState, $this->shipmentState, $this->paymentState, diff --git a/lib/commercetools-api/src/Models/Order/OrderModel.php b/lib/commercetools-api/src/Models/Order/OrderModel.php index 5ff70123162..06f21cdde0e 100644 --- a/lib/commercetools-api/src/Models/Order/OrderModel.php +++ b/lib/commercetools-api/src/Models/Order/OrderModel.php @@ -45,6 +45,8 @@ use Commercetools\Api\Models\OrderEdit\StagedOrderModel; use Commercetools\Api\Models\Quote\QuoteReference; use Commercetools\Api\Models\Quote\QuoteReferenceModel; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReference; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReferenceModel; use Commercetools\Api\Models\State\StateReference; use Commercetools\Api\Models\State\StateReferenceModel; use Commercetools\Api\Models\Store\StoreKeyReference; @@ -309,6 +311,12 @@ final class OrderModel extends JsonObjectModel implements Order */ protected $quote; + /** + * + * @var ?RecurringOrderReference + */ + protected $recurringOrder; + /** * * @var ?string @@ -427,6 +435,7 @@ public function __construct( ?string $origin = null, ?CartReference $cart = null, ?QuoteReference $quote = null, + ?RecurringOrderReference $recurringOrder = null, ?string $orderState = null, ?string $shipmentState = null, ?string $paymentState = null, @@ -481,6 +490,7 @@ public function __construct( $this->origin = $origin; $this->cart = $cart; $this->quote = $quote; + $this->recurringOrder = $recurringOrder; $this->orderState = $orderState; $this->shipmentState = $shipmentState; $this->paymentState = $paymentState; @@ -1361,6 +1371,27 @@ public function getQuote() return $this->quote; } + /** + *

Reference to the RecurringOrder that generated this Order.

+ * + * + * @return null|RecurringOrderReference + */ + public function getRecurringOrder() + { + if (is_null($this->recurringOrder)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRING_ORDER); + if (is_null($data)) { + return null; + } + + $this->recurringOrder = RecurringOrderReferenceModel::of($data); + } + + return $this->recurringOrder; + } + /** *

Current status of the Order.

* @@ -1942,6 +1973,14 @@ public function setQuote(?QuoteReference $quote): void $this->quote = $quote; } + /** + * @param ?RecurringOrderReference $recurringOrder + */ + public function setRecurringOrder(?RecurringOrderReference $recurringOrder): void + { + $this->recurringOrder = $recurringOrder; + } + /** * @param ?string $orderState */ diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemAction.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemAction.php index 4f4b8b58779..ed8e515361d 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemAction.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemAction.php @@ -13,6 +13,7 @@ use Commercetools\Api\Models\Common\LocalizedString; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Order\StagedOrderUpdateAction; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraft; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifier; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; @@ -30,6 +31,7 @@ interface StagedOrderAddCustomLineItemAction extends StagedOrderUpdateAction public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; public const FIELD_PRICE_MODE = 'priceMode'; public const FIELD_CUSTOM = 'custom'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; /** *

Money value of the Custom Line Item. The value can be negative.

@@ -115,6 +117,14 @@ public function getPriceMode(); */ public function getCustom(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + /** * @param ?Money $money */ @@ -164,4 +174,9 @@ public function setPriceMode(?string $priceMode): void; * @param ?CustomFieldsDraft $custom */ public function setCustom(?CustomFieldsDraft $custom): void; + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void; } diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemActionBuilder.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemActionBuilder.php index 27dab9cbd7b..572a67c6a44 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemActionBuilder.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemActionBuilder.php @@ -18,6 +18,8 @@ use Commercetools\Api\Models\Common\MoneyBuilder; use Commercetools\Api\Models\Order\StagedOrderUpdateAction; use Commercetools\Api\Models\Order\StagedOrderUpdateActionBuilder; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraftBuilder; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifier; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifierBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; @@ -94,6 +96,12 @@ final class StagedOrderAddCustomLineItemActionBuilder implements Builder */ private $custom; + /** + + * @var null|CustomLineItemRecurrenceInfoDraft|CustomLineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + /** *

Money value of the Custom Line Item. The value can be negative.

* @@ -208,6 +216,17 @@ public function getCustom() return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom; } + /** + *

Recurring Order and frequency data.

+ * + + * @return null|CustomLineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + /** * @param ?Money $money * @return $this @@ -318,6 +337,17 @@ public function withCustom(?CustomFieldsDraft $custom) return $this; } + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withMoney() instead * @return $this @@ -384,6 +414,17 @@ public function withCustomBuilder(?CustomFieldsDraftBuilder $custom) return $this; } + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?CustomLineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + public function build(): StagedOrderAddCustomLineItemAction { return new StagedOrderAddCustomLineItemActionModel( @@ -396,7 +437,8 @@ public function build(): StagedOrderAddCustomLineItemAction $this->externalTaxRate instanceof ExternalTaxRateDraftBuilder ? $this->externalTaxRate->build() : $this->externalTaxRate, $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails, $this->priceMode, - $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom + $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom, + $this->recurrenceInfo instanceof CustomLineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo ); } diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemActionModel.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemActionModel.php index 518322da13d..428c7397276 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemActionModel.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddCustomLineItemActionModel.php @@ -18,6 +18,8 @@ use Commercetools\Api\Models\Common\MoneyModel; use Commercetools\Api\Models\Order\StagedOrderUpdateAction; use Commercetools\Api\Models\Order\StagedOrderUpdateActionModel; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\CustomLineItemRecurrenceInfoDraftModel; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifier; use Commercetools\Api\Models\TaxCategory\TaxCategoryResourceIdentifierModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; @@ -100,6 +102,12 @@ final class StagedOrderAddCustomLineItemActionModel extends JsonObjectModel impl */ protected $custom; + /** + * + * @var ?CustomLineItemRecurrenceInfoDraft + */ + protected $recurrenceInfo; + /** * @psalm-suppress MissingParamType @@ -115,6 +123,7 @@ public function __construct( ?ItemShippingDetailsDraft $shippingDetails = null, ?string $priceMode = null, ?CustomFieldsDraft $custom = null, + ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo = null, ?string $action = null ) { $this->money = $money; @@ -127,6 +136,7 @@ public function __construct( $this->shippingDetails = $shippingDetails; $this->priceMode = $priceMode; $this->custom = $custom; + $this->recurrenceInfo = $recurrenceInfo; $this->action = $action ?? self::DISCRIMINATOR_VALUE; } @@ -358,6 +368,27 @@ public function getCustom() return $this->custom; } + /** + *

Recurring Order and frequency data.

+ * + * + * @return null|CustomLineItemRecurrenceInfoDraft + */ + 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 = CustomLineItemRecurrenceInfoDraftModel::of($data); + } + + return $this->recurrenceInfo; + } + /** * @param ?Money $money @@ -438,4 +469,12 @@ public function setCustom(?CustomFieldsDraft $custom): void { $this->custom = $custom; } + + /** + * @param ?CustomLineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?CustomLineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } } diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemAction.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemAction.php index f57cea3dc7e..0f0a076492b 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemAction.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemAction.php @@ -14,6 +14,7 @@ use Commercetools\Api\Models\Channel\ChannelResourceIdentifier; use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Order\StagedOrderUpdateAction; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\Base\JsonObject; @@ -35,6 +36,7 @@ interface StagedOrderAddLineItemAction extends StagedOrderUpdateAction public const FIELD_INVENTORY_MODE = 'inventoryMode'; public const FIELD_SHIPPING_DETAILS = 'shippingDetails'; public const FIELD_CUSTOM = 'custom'; + public const FIELD_RECURRENCE_INFO = 'recurrenceInfo'; /** *

User-defined unique identifier of the LineItem.

@@ -158,6 +160,14 @@ public function getShippingDetails(); */ public function getCustom(); + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo(); + /** * @param ?string $key */ @@ -227,4 +237,9 @@ public function setShippingDetails(?ItemShippingDetailsDraft $shippingDetails): * @param ?CustomFieldsDraft $custom */ public function setCustom(?CustomFieldsDraft $custom): void; + + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void; } diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemActionBuilder.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemActionBuilder.php index 8681811b496..9faeeb572f3 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemActionBuilder.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemActionBuilder.php @@ -20,6 +20,8 @@ use Commercetools\Api\Models\Common\MoneyBuilder; use Commercetools\Api\Models\Order\StagedOrderUpdateAction; use Commercetools\Api\Models\Order\StagedOrderUpdateActionBuilder; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftBuilder; use Commercetools\Base\Builder; @@ -119,6 +121,12 @@ final class StagedOrderAddLineItemActionBuilder implements Builder */ private $custom; + /** + + * @var null|LineItemRecurrenceInfoDraft|LineItemRecurrenceInfoDraftBuilder + */ + private $recurrenceInfo; + /** *

User-defined unique identifier of the LineItem.

* @@ -283,6 +291,17 @@ public function getCustom() return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom; } + /** + *

Recurring Order and frequency data.

+ * + + * @return null|LineItemRecurrenceInfoDraft + */ + public function getRecurrenceInfo() + { + return $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo; + } + /** * @param ?string $key * @return $this @@ -437,6 +456,17 @@ public function withCustom(?CustomFieldsDraft $custom) return $this; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + * @return $this + */ + public function withRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + /** * @deprecated use withDistributionChannel() instead * @return $this @@ -514,6 +544,17 @@ public function withCustomBuilder(?CustomFieldsDraftBuilder $custom) return $this; } + /** + * @deprecated use withRecurrenceInfo() instead + * @return $this + */ + public function withRecurrenceInfoBuilder(?LineItemRecurrenceInfoDraftBuilder $recurrenceInfo) + { + $this->recurrenceInfo = $recurrenceInfo; + + return $this; + } + public function build(): StagedOrderAddLineItemAction { return new StagedOrderAddLineItemActionModel( @@ -530,7 +571,8 @@ public function build(): StagedOrderAddLineItemAction $this->externalTaxRate instanceof ExternalTaxRateDraftBuilder ? $this->externalTaxRate->build() : $this->externalTaxRate, $this->inventoryMode, $this->shippingDetails instanceof ItemShippingDetailsDraftBuilder ? $this->shippingDetails->build() : $this->shippingDetails, - $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom + $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom, + $this->recurrenceInfo instanceof LineItemRecurrenceInfoDraftBuilder ? $this->recurrenceInfo->build() : $this->recurrenceInfo ); } diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemActionModel.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemActionModel.php index 1d2a21ef8f0..819539f6a9e 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemActionModel.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderAddLineItemActionModel.php @@ -20,6 +20,8 @@ use Commercetools\Api\Models\Common\MoneyModel; use Commercetools\Api\Models\Order\StagedOrderUpdateAction; use Commercetools\Api\Models\Order\StagedOrderUpdateActionModel; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraft; +use Commercetools\Api\Models\RecurringOrder\LineItemRecurrenceInfoDraftModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftModel; use Commercetools\Base\DateTimeImmutableCollection; @@ -125,6 +127,12 @@ final class StagedOrderAddLineItemActionModel extends JsonObjectModel implements */ protected $custom; + /** + * + * @var ?LineItemRecurrenceInfoDraft + */ + protected $recurrenceInfo; + /** * @psalm-suppress MissingParamType @@ -144,6 +152,7 @@ public function __construct( ?string $inventoryMode = null, ?ItemShippingDetailsDraft $shippingDetails = null, ?CustomFieldsDraft $custom = null, + ?LineItemRecurrenceInfoDraft $recurrenceInfo = null, ?string $action = null ) { $this->key = $key; @@ -160,6 +169,7 @@ public function __construct( $this->inventoryMode = $inventoryMode; $this->shippingDetails = $shippingDetails; $this->custom = $custom; + $this->recurrenceInfo = $recurrenceInfo; $this->action = $action ?? self::DISCRIMINATOR_VALUE; } @@ -482,6 +492,27 @@ public function getCustom() return $this->custom; } + /** + *

Recurring Order and frequency data.

+ * + * + * @return null|LineItemRecurrenceInfoDraft + */ + 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 = LineItemRecurrenceInfoDraftModel::of($data); + } + + return $this->recurrenceInfo; + } + /** * @param ?string $key @@ -595,6 +626,14 @@ public function setCustom(?CustomFieldsDraft $custom): void $this->custom = $custom; } + /** + * @param ?LineItemRecurrenceInfoDraft $recurrenceInfo + */ + public function setRecurrenceInfo(?LineItemRecurrenceInfoDraft $recurrenceInfo): void + { + $this->recurrenceInfo = $recurrenceInfo; + } + #[\ReturnTypeWillChange] public function jsonSerialize() diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderBuilder.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderBuilder.php index 9a1539619d0..eb8da7e8f9b 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderBuilder.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderBuilder.php @@ -47,6 +47,8 @@ use Commercetools\Api\Models\Order\SyncInfoCollection; use Commercetools\Api\Models\Quote\QuoteReference; use Commercetools\Api\Models\Quote\QuoteReferenceBuilder; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReference; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReferenceBuilder; use Commercetools\Api\Models\State\StateReference; use Commercetools\Api\Models\State\StateReferenceBuilder; use Commercetools\Api\Models\Store\StoreKeyReference; @@ -312,6 +314,12 @@ final class StagedOrderBuilder implements Builder */ private $quote; + /** + + * @var null|RecurringOrderReference|RecurringOrderReferenceBuilder + */ + private $recurringOrder; + /** * @var ?string @@ -858,6 +866,17 @@ public function getQuote() return $this->quote instanceof QuoteReferenceBuilder ? $this->quote->build() : $this->quote; } + /** + *

Reference to the RecurringOrder that generated this Order.

+ * + + * @return null|RecurringOrderReference + */ + public function getRecurringOrder() + { + return $this->recurringOrder instanceof RecurringOrderReferenceBuilder ? $this->recurringOrder->build() : $this->recurringOrder; + } + /** *

Current status of the Order.

* @@ -1444,6 +1463,17 @@ public function withQuote(?QuoteReference $quote) return $this; } + /** + * @param ?RecurringOrderReference $recurringOrder + * @return $this + */ + public function withRecurringOrder(?RecurringOrderReference $recurringOrder) + { + $this->recurringOrder = $recurringOrder; + + return $this; + } + /** * @param ?string $orderState * @return $this @@ -1741,6 +1771,17 @@ public function withQuoteBuilder(?QuoteReferenceBuilder $quote) return $this; } + /** + * @deprecated use withRecurringOrder() instead + * @return $this + */ + public function withRecurringOrderBuilder(?RecurringOrderReferenceBuilder $recurringOrder) + { + $this->recurringOrder = $recurringOrder; + + return $this; + } + /** * @deprecated use withState() instead * @return $this @@ -1840,6 +1881,7 @@ public function build(): StagedOrder $this->origin, $this->cart instanceof CartReferenceBuilder ? $this->cart->build() : $this->cart, $this->quote instanceof QuoteReferenceBuilder ? $this->quote->build() : $this->quote, + $this->recurringOrder instanceof RecurringOrderReferenceBuilder ? $this->recurringOrder->build() : $this->recurringOrder, $this->orderState, $this->shipmentState, $this->paymentState, diff --git a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderModel.php b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderModel.php index 467e85dc09c..16785272b42 100644 --- a/lib/commercetools-api/src/Models/OrderEdit/StagedOrderModel.php +++ b/lib/commercetools-api/src/Models/OrderEdit/StagedOrderModel.php @@ -47,6 +47,8 @@ use Commercetools\Api\Models\Order\SyncInfoCollection; use Commercetools\Api\Models\Quote\QuoteReference; use Commercetools\Api\Models\Quote\QuoteReferenceModel; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReference; +use Commercetools\Api\Models\RecurringOrder\RecurringOrderReferenceModel; use Commercetools\Api\Models\State\StateReference; use Commercetools\Api\Models\State\StateReferenceModel; use Commercetools\Api\Models\Store\StoreKeyReference; @@ -311,6 +313,12 @@ final class StagedOrderModel extends JsonObjectModel implements StagedOrder */ protected $quote; + /** + * + * @var ?RecurringOrderReference + */ + protected $recurringOrder; + /** * * @var ?string @@ -429,6 +437,7 @@ public function __construct( ?string $origin = null, ?CartReference $cart = null, ?QuoteReference $quote = null, + ?RecurringOrderReference $recurringOrder = null, ?string $orderState = null, ?string $shipmentState = null, ?string $paymentState = null, @@ -483,6 +492,7 @@ public function __construct( $this->origin = $origin; $this->cart = $cart; $this->quote = $quote; + $this->recurringOrder = $recurringOrder; $this->orderState = $orderState; $this->shipmentState = $shipmentState; $this->paymentState = $paymentState; @@ -1363,6 +1373,27 @@ public function getQuote() return $this->quote; } + /** + *

Reference to the RecurringOrder that generated this Order.

+ * + * + * @return null|RecurringOrderReference + */ + public function getRecurringOrder() + { + if (is_null($this->recurringOrder)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRING_ORDER); + if (is_null($data)) { + return null; + } + + $this->recurringOrder = RecurringOrderReferenceModel::of($data); + } + + return $this->recurringOrder; + } + /** *

Current status of the Order.

* @@ -1944,6 +1975,14 @@ public function setQuote(?QuoteReference $quote): void $this->quote = $quote; } + /** + * @param ?RecurringOrderReference $recurringOrder + */ + public function setRecurringOrder(?RecurringOrderReference $recurringOrder): void + { + $this->recurringOrder = $recurringOrder; + } + /** * @param ?string $orderState */ diff --git a/lib/commercetools-api/src/Models/Product/ProductVariant.php b/lib/commercetools-api/src/Models/Product/ProductVariant.php index d662d9682be..1f63305a2d7 100644 --- a/lib/commercetools-api/src/Models/Product/ProductVariant.php +++ b/lib/commercetools-api/src/Models/Product/ProductVariant.php @@ -30,6 +30,7 @@ interface ProductVariant extends JsonObject public const FIELD_IS_MATCHING_VARIANT = 'isMatchingVariant'; public const FIELD_SCOPED_PRICE = 'scopedPrice'; public const FIELD_SCOPED_PRICE_DISCOUNTED = 'scopedPriceDiscounted'; + public const FIELD_RECURRENCE_PRICES = 'recurrencePrices'; /** *

A unique, sequential identifier of the Product Variant within the Product.

@@ -136,6 +137,15 @@ public function getScopedPrice(); */ 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 */ @@ -195,4 +205,9 @@ 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-api/src/Models/Product/ProductVariantBuilder.php b/lib/commercetools-api/src/Models/Product/ProductVariantBuilder.php index 139eb7ab99e..8d47f4bcc54 100644 --- a/lib/commercetools-api/src/Models/Product/ProductVariantBuilder.php +++ b/lib/commercetools-api/src/Models/Product/ProductVariantBuilder.php @@ -99,6 +99,12 @@ final class ProductVariantBuilder implements Builder */ private $scopedPriceDiscounted; + /** + + * @var ?PriceCollection + */ + private $recurrencePrices; + /** *

A unique, sequential identifier of the Product Variant within the Product.

* @@ -240,6 +246,18 @@ 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 @@ -372,6 +390,17 @@ public function withScopedPriceDiscounted(?bool $scopedPriceDiscounted) return $this; } + /** + * @param ?PriceCollection $recurrencePrices + * @return $this + */ + public function withRecurrencePrices(?PriceCollection $recurrencePrices) + { + $this->recurrencePrices = $recurrencePrices; + + return $this; + } + /** * @deprecated use withPrice() instead * @return $this @@ -419,7 +448,8 @@ public function build(): ProductVariant $this->availability instanceof ProductVariantAvailabilityBuilder ? $this->availability->build() : $this->availability, $this->isMatchingVariant, $this->scopedPrice instanceof ScopedPriceBuilder ? $this->scopedPrice->build() : $this->scopedPrice, - $this->scopedPriceDiscounted + $this->scopedPriceDiscounted, + $this->recurrencePrices ); } diff --git a/lib/commercetools-api/src/Models/Product/ProductVariantModel.php b/lib/commercetools-api/src/Models/Product/ProductVariantModel.php index 7daceee73f0..bb05bfecbfe 100644 --- a/lib/commercetools-api/src/Models/Product/ProductVariantModel.php +++ b/lib/commercetools-api/src/Models/Product/ProductVariantModel.php @@ -98,6 +98,12 @@ final class ProductVariantModel extends JsonObjectModel implements ProductVarian */ protected $scopedPriceDiscounted; + /** + * + * @var ?PriceCollection + */ + protected $recurrencePrices; + /** * @psalm-suppress MissingParamType @@ -114,7 +120,8 @@ public function __construct( ?ProductVariantAvailability $availability = null, ?bool $isMatchingVariant = null, ?ScopedPrice $scopedPrice = null, - ?bool $scopedPriceDiscounted = null + ?bool $scopedPriceDiscounted = null, + ?PriceCollection $recurrencePrices = null ) { $this->id = $id; $this->sku = $sku; @@ -128,6 +135,7 @@ public function __construct( $this->isMatchingVariant = $isMatchingVariant; $this->scopedPrice = $scopedPrice; $this->scopedPriceDiscounted = $scopedPriceDiscounted; + $this->recurrencePrices = $recurrencePrices; } /** @@ -382,6 +390,27 @@ 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() + { + 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 @@ -478,4 +507,12 @@ 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-api/src/Models/RecurrencePolicy/DayOfMonthSchedule.php b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthSchedule.php new file mode 100644 index 00000000000..16fcc1940c2 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthSchedule.php @@ -0,0 +1,37 @@ +The day of the month when the Recurring Order is created. + * If the value is greater than the number of days in a given month, the order is created on the last day of the month.

+ * + + * @return null|int + */ + public function getDay(); + + /** + * @param ?int $day + */ + public function setDay(?int $day): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleBuilder.php new file mode 100644 index 00000000000..3fd3cc3fb05 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleBuilder.php @@ -0,0 +1,64 @@ + + */ +final class DayOfMonthScheduleBuilder implements Builder +{ + /** + + * @var ?int + */ + private $day; + + /** + *

The day of the month when the Recurring Order is created. + * If the value is greater than the number of days in a given month, the order is created on the last day of the month.

+ * + + * @return null|int + */ + public function getDay() + { + return $this->day; + } + + /** + * @param ?int $day + * @return $this + */ + public function withDay(?int $day) + { + $this->day = $day; + + return $this; + } + + + public function build(): DayOfMonthSchedule + { + return new DayOfMonthScheduleModel( + $this->day + ); + } + + public static function of(): DayOfMonthScheduleBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleCollection.php new file mode 100644 index 00000000000..7fe536fe9ac --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleCollection.php @@ -0,0 +1,56 @@ + + * @method DayOfMonthSchedule current() + * @method DayOfMonthSchedule end() + * @method DayOfMonthSchedule at($offset) + */ +class DayOfMonthScheduleCollection extends RecurrencePolicyScheduleCollection +{ + /** + * @psalm-assert DayOfMonthSchedule $value + * @psalm-param DayOfMonthSchedule|stdClass $value + * @throws InvalidArgumentException + * + * @return DayOfMonthScheduleCollection + */ + public function add($value) + { + if (!$value instanceof DayOfMonthSchedule) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?DayOfMonthSchedule + */ + protected function mapper() + { + return function (?int $index): ?DayOfMonthSchedule { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var DayOfMonthSchedule $data */ + $data = DayOfMonthScheduleModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraft.php b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraft.php new file mode 100644 index 00000000000..506e5380ad0 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraft.php @@ -0,0 +1,37 @@ +The day of the month when the Recurring Order should be created. + * If the value is greater than the number of days in a given month, the order will be created on the last day of the month.

+ * + + * @return null|int + */ + public function getDay(); + + /** + * @param ?int $day + */ + public function setDay(?int $day): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraftBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraftBuilder.php new file mode 100644 index 00000000000..c6e4aea54e4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraftBuilder.php @@ -0,0 +1,64 @@ + + */ +final class DayOfMonthScheduleDraftBuilder implements Builder +{ + /** + + * @var ?int + */ + private $day; + + /** + *

The day of the month when the Recurring Order should be created. + * If the value is greater than the number of days in a given month, the order will be created on the last day of the month.

+ * + + * @return null|int + */ + public function getDay() + { + return $this->day; + } + + /** + * @param ?int $day + * @return $this + */ + public function withDay(?int $day) + { + $this->day = $day; + + return $this; + } + + + public function build(): DayOfMonthScheduleDraft + { + return new DayOfMonthScheduleDraftModel( + $this->day + ); + } + + public static function of(): DayOfMonthScheduleDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraftCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraftCollection.php new file mode 100644 index 00000000000..29f72f42d7e --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraftCollection.php @@ -0,0 +1,56 @@ + + * @method DayOfMonthScheduleDraft current() + * @method DayOfMonthScheduleDraft end() + * @method DayOfMonthScheduleDraft at($offset) + */ +class DayOfMonthScheduleDraftCollection extends RecurrencePolicyScheduleDraftCollection +{ + /** + * @psalm-assert DayOfMonthScheduleDraft $value + * @psalm-param DayOfMonthScheduleDraft|stdClass $value + * @throws InvalidArgumentException + * + * @return DayOfMonthScheduleDraftCollection + */ + public function add($value) + { + if (!$value instanceof DayOfMonthScheduleDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?DayOfMonthScheduleDraft + */ + protected function mapper() + { + return function (?int $index): ?DayOfMonthScheduleDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var DayOfMonthScheduleDraft $data */ + $data = DayOfMonthScheduleDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraftModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraftModel.php new file mode 100644 index 00000000000..fb6e87c4fec --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleDraftModel.php @@ -0,0 +1,93 @@ +day = $day; + $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; + } + + /** + *

The day of the month when the Recurring Order should be created. + * If the value is greater than the number of days in a given month, the order will be created on the last day of the month.

+ * + * + * @return null|int + */ + public function getDay() + { + if (is_null($this->day)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_DAY); + if (is_null($data)) { + return null; + } + $this->day = (int) $data; + } + + return $this->day; + } + + + /** + * @param ?int $day + */ + public function setDay(?int $day): void + { + $this->day = $day; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleModel.php new file mode 100644 index 00000000000..b35b14117d8 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/DayOfMonthScheduleModel.php @@ -0,0 +1,94 @@ +day = $day; + $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; + } + + /** + *

The day of the month when the Recurring Order is created. + * If the value is greater than the number of days in a given month, the order is created on the last day of the month.

+ * + * + * @return null|int + */ + public function getDay() + { + if (is_null($this->day)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_DAY); + if (is_null($data)) { + return null; + } + $this->day = (int) $data; + } + + return $this->day; + } + + + /** + * @param ?int $day + */ + public function setDay(?int $day): void + { + $this->day = $day; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicy.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicy.php new file mode 100644 index 00000000000..4d8c631c24c --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicy.php @@ -0,0 +1,157 @@ +Unique identifier of the RecurrencePolicy.

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

Current version of the RecurrencePolicy.

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

User-defined unique identifier of the RecurrencePolicy.

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

Name of the RecurrencePolicy.

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

Description of the RecurrencePolicy.

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

Schedule of the RecurrencePolicy.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getSchedule(); + + /** + *

Date and time (UTC) the RecurrencePolicy was initially created.

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

IDs and references that created the RecurrencePolicy.

+ * + + * @return null|CreatedBy + */ + public function getCreatedBy(); + + /** + *

Date and time (UTC) the RecurrencePolicy was last updated.

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

IDs and references that last modified the RecurrencePolicy.

+ * + + * @return null|LastModifiedBy + */ + public function getLastModifiedBy(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void; + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?LocalizedString $name + */ + public function setName(?LocalizedString $name): void; + + /** + * @param ?LocalizedString $description + */ + public function setDescription(?LocalizedString $description): void; + + /** + * @param ?RecurrencePolicySchedule $schedule + */ + public function setSchedule(?RecurrencePolicySchedule $schedule): void; + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void; + + /** + * @param ?CreatedBy $createdBy + */ + public function setCreatedBy(?CreatedBy $createdBy): void; + + /** + * @param ?DateTimeImmutable $lastModifiedAt + */ + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void; + + /** + * @param ?LastModifiedBy $lastModifiedBy + */ + public function setLastModifiedBy(?LastModifiedBy $lastModifiedBy): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyBuilder.php new file mode 100644 index 00000000000..70612c77fc1 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyBuilder.php @@ -0,0 +1,387 @@ + + */ +final class RecurrencePolicyBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?int + */ + private $version; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var ?DateTimeImmutable + */ + private $lastModifiedAt; + + /** + + * @var ?string + */ + private $key; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $name; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $description; + + /** + + * @var null|RecurrencePolicySchedule|RecurrencePolicyScheduleBuilder + */ + private $schedule; + + /** + + * @var null|CreatedBy|CreatedByBuilder + */ + private $createdBy; + + /** + + * @var null|LastModifiedBy|LastModifiedByBuilder + */ + private $lastModifiedBy; + + /** + *

Unique identifier of the RecurrencePolicy.

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

Current version of the RecurrencePolicy.

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

Date and time (UTC) the RecurrencePolicy was initially created.

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

Date and time (UTC) the RecurrencePolicy was last updated.

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

User-defined unique identifier of the RecurrencePolicy.

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

Name of the RecurrencePolicy.

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

Description of the RecurrencePolicy.

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

Schedule of the RecurrencePolicy.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getSchedule() + { + return $this->schedule instanceof RecurrencePolicyScheduleBuilder ? $this->schedule->build() : $this->schedule; + } + + /** + *

IDs and references that created the RecurrencePolicy.

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

IDs and references that last modified the RecurrencePolicy.

+ * + + * @return null|LastModifiedBy + */ + public function getLastModifiedBy() + { + return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy; + } + + /** + * @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 ?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 ?LocalizedString $description + * @return $this + */ + public function withDescription(?LocalizedString $description) + { + $this->description = $description; + + return $this; + } + + /** + * @param ?RecurrencePolicySchedule $schedule + * @return $this + */ + public function withSchedule(?RecurrencePolicySchedule $schedule) + { + $this->schedule = $schedule; + + return $this; + } + + /** + * @param ?CreatedBy $createdBy + * @return $this + */ + public function withCreatedBy(?CreatedBy $createdBy) + { + $this->createdBy = $createdBy; + + return $this; + } + + /** + * @param ?LastModifiedBy $lastModifiedBy + * @return $this + */ + public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy) + { + $this->lastModifiedBy = $lastModifiedBy; + + return $this; + } + + /** + * @deprecated use withName() instead + * @return $this + */ + public function withNameBuilder(?LocalizedStringBuilder $name) + { + $this->name = $name; + + return $this; + } + + /** + * @deprecated use withDescription() instead + * @return $this + */ + public function withDescriptionBuilder(?LocalizedStringBuilder $description) + { + $this->description = $description; + + return $this; + } + + /** + * @deprecated use withSchedule() instead + * @return $this + */ + public function withScheduleBuilder(?RecurrencePolicyScheduleBuilder $schedule) + { + $this->schedule = $schedule; + + return $this; + } + + /** + * @deprecated use withCreatedBy() instead + * @return $this + */ + public function withCreatedByBuilder(?CreatedByBuilder $createdBy) + { + $this->createdBy = $createdBy; + + return $this; + } + + /** + * @deprecated use withLastModifiedBy() instead + * @return $this + */ + public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy) + { + $this->lastModifiedBy = $lastModifiedBy; + + return $this; + } + + public function build(): RecurrencePolicy + { + return new RecurrencePolicyModel( + $this->id, + $this->version, + $this->createdAt, + $this->lastModifiedAt, + $this->key, + $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name, + $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description, + $this->schedule instanceof RecurrencePolicyScheduleBuilder ? $this->schedule->build() : $this->schedule, + $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy, + $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy + ); + } + + public static function of(): RecurrencePolicyBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyCollection.php new file mode 100644 index 00000000000..85d05e0bce5 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicy current() + * @method RecurrencePolicy end() + * @method RecurrencePolicy at($offset) + */ +class RecurrencePolicyCollection extends BaseResourceCollection +{ + /** + * @psalm-assert RecurrencePolicy $value + * @psalm-param RecurrencePolicy|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicyCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicy) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicy + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicy { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicy $data */ + $data = RecurrencePolicyModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraft.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraft.php new file mode 100644 index 00000000000..f9abf56b82b --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraft.php @@ -0,0 +1,73 @@ +User-defined unique identifier for the RecurrencePolicy.

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

Name of the RecurrencePolicy.

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

Description of the RecurrencePolicy.

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

Schedule where the recurrence is defined.

+ * + + * @return null|RecurrencePolicyScheduleDraft + */ + public function getSchedule(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?LocalizedString $name + */ + public function setName(?LocalizedString $name): void; + + /** + * @param ?LocalizedString $description + */ + public function setDescription(?LocalizedString $description): void; + + /** + * @param ?RecurrencePolicyScheduleDraft $schedule + */ + public function setSchedule(?RecurrencePolicyScheduleDraft $schedule): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraftBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraftBuilder.php new file mode 100644 index 00000000000..985b5f22db1 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraftBuilder.php @@ -0,0 +1,184 @@ + + */ +final class RecurrencePolicyDraftBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $name; + + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $description; + + /** + + * @var null|RecurrencePolicyScheduleDraft|RecurrencePolicyScheduleDraftBuilder + */ + private $schedule; + + /** + *

User-defined unique identifier for the RecurrencePolicy.

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

Name of the RecurrencePolicy.

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

Description of the RecurrencePolicy.

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

Schedule where the recurrence is defined.

+ * + + * @return null|RecurrencePolicyScheduleDraft + */ + public function getSchedule() + { + return $this->schedule instanceof RecurrencePolicyScheduleDraftBuilder ? $this->schedule->build() : $this->schedule; + } + + /** + * @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 ?LocalizedString $description + * @return $this + */ + public function withDescription(?LocalizedString $description) + { + $this->description = $description; + + return $this; + } + + /** + * @param ?RecurrencePolicyScheduleDraft $schedule + * @return $this + */ + public function withSchedule(?RecurrencePolicyScheduleDraft $schedule) + { + $this->schedule = $schedule; + + return $this; + } + + /** + * @deprecated use withName() instead + * @return $this + */ + public function withNameBuilder(?LocalizedStringBuilder $name) + { + $this->name = $name; + + return $this; + } + + /** + * @deprecated use withDescription() instead + * @return $this + */ + public function withDescriptionBuilder(?LocalizedStringBuilder $description) + { + $this->description = $description; + + return $this; + } + + /** + * @deprecated use withSchedule() instead + * @return $this + */ + public function withScheduleBuilder(?RecurrencePolicyScheduleDraftBuilder $schedule) + { + $this->schedule = $schedule; + + return $this; + } + + public function build(): RecurrencePolicyDraft + { + return new RecurrencePolicyDraftModel( + $this->key, + $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name, + $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description, + $this->schedule instanceof RecurrencePolicyScheduleDraftBuilder ? $this->schedule->build() : $this->schedule + ); + } + + public static function of(): RecurrencePolicyDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraftCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraftCollection.php new file mode 100644 index 00000000000..4dfa348c9b1 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraftCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicyDraft current() + * @method RecurrencePolicyDraft end() + * @method RecurrencePolicyDraft at($offset) + */ +class RecurrencePolicyDraftCollection extends MapperSequence +{ + /** + * @psalm-assert RecurrencePolicyDraft $value + * @psalm-param RecurrencePolicyDraft|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicyDraftCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicyDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicyDraft + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicyDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicyDraft $data */ + $data = RecurrencePolicyDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraftModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraftModel.php new file mode 100644 index 00000000000..05a9eef6498 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyDraftModel.php @@ -0,0 +1,179 @@ +key = $key; + $this->name = $name; + $this->description = $description; + $this->schedule = $schedule; + } + + /** + *

User-defined unique identifier for the RecurrencePolicy.

+ * + * + * @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 RecurrencePolicy.

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

Description of the RecurrencePolicy.

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

Schedule where the recurrence is defined.

+ * + * + * @return null|RecurrencePolicyScheduleDraft + */ + public function getSchedule() + { + if (is_null($this->schedule)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SCHEDULE); + if (is_null($data)) { + return null; + } + $className = RecurrencePolicyScheduleDraftModel::resolveDiscriminatorClass($data); + $this->schedule = $className::of($data); + } + + return $this->schedule; + } + + + /** + * @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 ?LocalizedString $description + */ + public function setDescription(?LocalizedString $description): void + { + $this->description = $description; + } + + /** + * @param ?RecurrencePolicyScheduleDraft $schedule + */ + public function setSchedule(?RecurrencePolicyScheduleDraft $schedule): void + { + $this->schedule = $schedule; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyModel.php new file mode 100644 index 00000000000..655e10e9a01 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyModel.php @@ -0,0 +1,427 @@ +id = $id; + $this->version = $version; + $this->createdAt = $createdAt; + $this->lastModifiedAt = $lastModifiedAt; + $this->key = $key; + $this->name = $name; + $this->description = $description; + $this->schedule = $schedule; + $this->createdBy = $createdBy; + $this->lastModifiedBy = $lastModifiedBy; + } + + /** + *

Unique identifier of the 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; + } + + /** + *

Current version of the RecurrencePolicy.

+ * + * + * @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 RecurrencePolicy was initially created.

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

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

User-defined unique identifier of the RecurrencePolicy.

+ * + * + * @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 RecurrencePolicy.

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

Description of the RecurrencePolicy.

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

Schedule of the RecurrencePolicy.

+ * + * + * @return null|RecurrencePolicySchedule + */ + public function getSchedule() + { + if (is_null($this->schedule)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SCHEDULE); + if (is_null($data)) { + return null; + } + $className = RecurrencePolicyScheduleModel::resolveDiscriminatorClass($data); + $this->schedule = $className::of($data); + } + + return $this->schedule; + } + + /** + *

IDs and references that created the RecurrencePolicy.

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

IDs and references that last modified the RecurrencePolicy.

+ * + * + * @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; + } + + + /** + * @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 ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?LocalizedString $name + */ + public function setName(?LocalizedString $name): void + { + $this->name = $name; + } + + /** + * @param ?LocalizedString $description + */ + public function setDescription(?LocalizedString $description): void + { + $this->description = $description; + } + + /** + * @param ?RecurrencePolicySchedule $schedule + */ + public function setSchedule(?RecurrencePolicySchedule $schedule): void + { + $this->schedule = $schedule; + } + + /** + * @param ?CreatedBy $createdBy + */ + public function setCreatedBy(?CreatedBy $createdBy): void + { + $this->createdBy = $createdBy; + } + + /** + * @param ?LastModifiedBy $lastModifiedBy + */ + public function setLastModifiedBy(?LastModifiedBy $lastModifiedBy): void + { + $this->lastModifiedBy = $lastModifiedBy; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[RecurrencePolicy::FIELD_CREATED_AT]) && $data[RecurrencePolicy::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[RecurrencePolicy::FIELD_CREATED_AT] = $data[RecurrencePolicy::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurrencePolicy::FIELD_LAST_MODIFIED_AT]) && $data[RecurrencePolicy::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) { + $data[RecurrencePolicy::FIELD_LAST_MODIFIED_AT] = $data[RecurrencePolicy::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponse.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponse.php new file mode 100644 index 00000000000..9829e68d85c --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponse.php @@ -0,0 +1,90 @@ +Number of results requested.

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

Number of elements skipped.

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

Actual number of results returned.

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

Total number of results matching the query. + * This number is an estimation that is not strongly consistent. + * This field is returned by default. + * For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. + * When the results are filtered with a Query Predicate, total is subject to a limit.

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

RecurrencePolicies matching the query.

+ * + + * @return null|RecurrencePolicyCollection + */ + public function getResults(); + + /** + * @param ?int $limit + */ + public function setLimit(?int $limit): void; + + /** + * @param ?int $offset + */ + public function setOffset(?int $offset): void; + + /** + * @param ?int $count + */ + public function setCount(?int $count): void; + + /** + * @param ?int $total + */ + public function setTotal(?int $total): void; + + /** + * @param ?RecurrencePolicyCollection $results + */ + public function setResults(?RecurrencePolicyCollection $results): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponseBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponseBuilder.php new file mode 100644 index 00000000000..4b2353175f2 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponseBuilder.php @@ -0,0 +1,183 @@ + + */ +final class RecurrencePolicyPagedQueryResponseBuilder implements Builder +{ + /** + + * @var ?int + */ + private $limit; + + /** + + * @var ?int + */ + private $offset; + + /** + + * @var ?int + */ + private $count; + + /** + + * @var ?int + */ + private $total; + + /** + + * @var ?RecurrencePolicyCollection + */ + private $results; + + /** + *

Number of results requested.

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

Number of elements skipped.

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

Actual number of results returned.

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

Total number of results matching the query. + * This number is an estimation that is not strongly consistent. + * This field is returned by default. + * For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. + * When the results are filtered with a Query Predicate, total is subject to a limit.

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

RecurrencePolicies matching the query.

+ * + + * @return null|RecurrencePolicyCollection + */ + public function getResults() + { + return $this->results; + } + + /** + * @param ?int $limit + * @return $this + */ + public function withLimit(?int $limit) + { + $this->limit = $limit; + + return $this; + } + + /** + * @param ?int $offset + * @return $this + */ + public function withOffset(?int $offset) + { + $this->offset = $offset; + + return $this; + } + + /** + * @param ?int $count + * @return $this + */ + public function withCount(?int $count) + { + $this->count = $count; + + return $this; + } + + /** + * @param ?int $total + * @return $this + */ + public function withTotal(?int $total) + { + $this->total = $total; + + return $this; + } + + /** + * @param ?RecurrencePolicyCollection $results + * @return $this + */ + public function withResults(?RecurrencePolicyCollection $results) + { + $this->results = $results; + + return $this; + } + + + public function build(): RecurrencePolicyPagedQueryResponse + { + return new RecurrencePolicyPagedQueryResponseModel( + $this->limit, + $this->offset, + $this->count, + $this->total, + $this->results + ); + } + + public static function of(): RecurrencePolicyPagedQueryResponseBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponseCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponseCollection.php new file mode 100644 index 00000000000..36ed738ec6e --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponseCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicyPagedQueryResponse current() + * @method RecurrencePolicyPagedQueryResponse end() + * @method RecurrencePolicyPagedQueryResponse at($offset) + */ +class RecurrencePolicyPagedQueryResponseCollection extends MapperSequence +{ + /** + * @psalm-assert RecurrencePolicyPagedQueryResponse $value + * @psalm-param RecurrencePolicyPagedQueryResponse|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicyPagedQueryResponseCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicyPagedQueryResponse) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicyPagedQueryResponse + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicyPagedQueryResponse { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicyPagedQueryResponse $data */ + $data = RecurrencePolicyPagedQueryResponseModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponseModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponseModel.php new file mode 100644 index 00000000000..5370a412084 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyPagedQueryResponseModel.php @@ -0,0 +1,214 @@ +limit = $limit; + $this->offset = $offset; + $this->count = $count; + $this->total = $total; + $this->results = $results; + } + + /** + *

Number of results requested.

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

Number of elements skipped.

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

Actual number of results returned.

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

Total number of results matching the query. + * This number is an estimation that is not strongly consistent. + * This field is returned by default. + * For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. + * When the results are filtered with a Query Predicate, total is subject to a limit.

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

RecurrencePolicies matching the query.

+ * + * + * @return null|RecurrencePolicyCollection + */ + public function getResults() + { + if (is_null($this->results)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_RESULTS); + if (is_null($data)) { + return null; + } + $this->results = RecurrencePolicyCollection::fromArray($data); + } + + return $this->results; + } + + + /** + * @param ?int $limit + */ + public function setLimit(?int $limit): void + { + $this->limit = $limit; + } + + /** + * @param ?int $offset + */ + public function setOffset(?int $offset): void + { + $this->offset = $offset; + } + + /** + * @param ?int $count + */ + public function setCount(?int $count): void + { + $this->count = $count; + } + + /** + * @param ?int $total + */ + public function setTotal(?int $total): void + { + $this->total = $total; + } + + /** + * @param ?RecurrencePolicyCollection $results + */ + public function setResults(?RecurrencePolicyCollection $results): void + { + $this->results = $results; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReference.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReference.php new file mode 100644 index 00000000000..542c7164439 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReference.php @@ -0,0 +1,45 @@ +Contains the representation of the expanded RecurrencePolicy. + * Only present in responses to requests with Reference Expansion for RecurrencePolicies.

+ * + + * @return null|RecurrencePolicy + */ + public function getObj(); + + /** + *

Unique identifier of the referenced RecurrencePolicy.

+ * + + * @return null|string + */ + public function getId(); + + /** + * @param ?RecurrencePolicy $obj + */ + public function setObj(?RecurrencePolicy $obj): void; + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReferenceBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReferenceBuilder.php new file mode 100644 index 00000000000..043e82e4987 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReferenceBuilder.php @@ -0,0 +1,105 @@ + + */ +final class RecurrencePolicyReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var null|RecurrencePolicy|RecurrencePolicyBuilder + */ + private $obj; + + /** + *

Unique identifier of the referenced RecurrencePolicy.

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

Contains the representation of the expanded RecurrencePolicy. + * Only present in responses to requests with Reference Expansion for RecurrencePolicies.

+ * + + * @return null|RecurrencePolicy + */ + public function getObj() + { + return $this->obj instanceof RecurrencePolicyBuilder ? $this->obj->build() : $this->obj; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?RecurrencePolicy $obj + * @return $this + */ + public function withObj(?RecurrencePolicy $obj) + { + $this->obj = $obj; + + return $this; + } + + /** + * @deprecated use withObj() instead + * @return $this + */ + public function withObjBuilder(?RecurrencePolicyBuilder $obj) + { + $this->obj = $obj; + + return $this; + } + + public function build(): RecurrencePolicyReference + { + return new RecurrencePolicyReferenceModel( + $this->id, + $this->obj instanceof RecurrencePolicyBuilder ? $this->obj->build() : $this->obj + ); + } + + public static function of(): RecurrencePolicyReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReferenceCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReferenceCollection.php new file mode 100644 index 00000000000..519539a6a05 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/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-api/src/Models/RecurrencePolicy/RecurrencePolicyReferenceModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReferenceModel.php new file mode 100644 index 00000000000..1aa99080d9c --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyReferenceModel.php @@ -0,0 +1,135 @@ +id = $id; + $this->obj = $obj; + $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; + } + + /** + *

Contains the representation of the expanded RecurrencePolicy. + * Only present in responses to requests with Reference Expansion for RecurrencePolicies.

+ * + * + * @return null|RecurrencePolicy + */ + public function getObj() + { + if (is_null($this->obj)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_OBJ); + if (is_null($data)) { + return null; + } + + $this->obj = RecurrencePolicyModel::of($data); + } + + return $this->obj; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?RecurrencePolicy $obj + */ + public function setObj(?RecurrencePolicy $obj): void + { + $this->obj = $obj; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifier.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifier.php new file mode 100644 index 00000000000..6aaeb9cc4da --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifier.php @@ -0,0 +1,42 @@ +Unique identifier of the referenced RecurrencePolicy. Required if key is absent.

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

User-defined unique identifier of the referenced RecurrencePolicy. 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-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifierBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifierBuilder.php new file mode 100644 index 00000000000..88ca46a9d2c --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifierBuilder.php @@ -0,0 +1,94 @@ + + */ +final class RecurrencePolicyResourceIdentifierBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $key; + + /** + *

Unique identifier of the referenced RecurrencePolicy. Required if key is absent.

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

User-defined unique identifier of the referenced RecurrencePolicy. Required if id is absent.

+ * + + * @return null|string + */ + public function getKey() + { + return $this->key; + } + + /** + * @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; + } + + + public function build(): RecurrencePolicyResourceIdentifier + { + return new RecurrencePolicyResourceIdentifierModel( + $this->id, + $this->key + ); + } + + public static function of(): RecurrencePolicyResourceIdentifierBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifierCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifierCollection.php new file mode 100644 index 00000000000..afd194d1f4e --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifierCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicyResourceIdentifier current() + * @method RecurrencePolicyResourceIdentifier end() + * @method RecurrencePolicyResourceIdentifier at($offset) + */ +class RecurrencePolicyResourceIdentifierCollection extends ResourceIdentifierCollection +{ + /** + * @psalm-assert RecurrencePolicyResourceIdentifier $value + * @psalm-param RecurrencePolicyResourceIdentifier|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicyResourceIdentifierCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicyResourceIdentifier) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicyResourceIdentifier + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicyResourceIdentifier { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicyResourceIdentifier $data */ + $data = RecurrencePolicyResourceIdentifierModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifierModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifierModel.php new file mode 100644 index 00000000000..1aefbf5d100 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyResourceIdentifierModel.php @@ -0,0 +1,133 @@ +id = $id; + $this->key = $key; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Type of referenced resource. If given, it must match the expected ReferenceTypeId of the 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. 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; + } + + /** + *

User-defined unique identifier of the referenced RecurrencePolicy. 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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySchedule.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySchedule.php new file mode 100644 index 00000000000..6dc416c9ca7 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySchedule.php @@ -0,0 +1,24 @@ + + */ +final class RecurrencePolicyScheduleBuilder implements Builder +{ + public function build(): RecurrencePolicySchedule + { + return new RecurrencePolicyScheduleModel( + ); + } + + public static function of(): RecurrencePolicyScheduleBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleCollection.php new file mode 100644 index 00000000000..35e52030e64 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method RecurrencePolicySchedule current() + * @method RecurrencePolicySchedule end() + * @method RecurrencePolicySchedule at($offset) + */ +class RecurrencePolicyScheduleCollection extends MapperSequence +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicyScheduleCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicySchedule) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicySchedule { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = RecurrencePolicyScheduleModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleDraft.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleDraft.php new file mode 100644 index 00000000000..419f726dd1d --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleDraft.php @@ -0,0 +1,24 @@ + + */ +final class RecurrencePolicyScheduleDraftBuilder implements Builder +{ + public function build(): RecurrencePolicyScheduleDraft + { + return new RecurrencePolicyScheduleDraftModel( + ); + } + + public static function of(): RecurrencePolicyScheduleDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleDraftCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleDraftCollection.php new file mode 100644 index 00000000000..7473de24440 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleDraftCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method RecurrencePolicyScheduleDraft current() + * @method RecurrencePolicyScheduleDraft end() + * @method RecurrencePolicyScheduleDraft at($offset) + */ +class RecurrencePolicyScheduleDraftCollection extends MapperSequence +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicyScheduleDraftCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicyScheduleDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicyScheduleDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = RecurrencePolicyScheduleDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleDraftModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleDraftModel.php new file mode 100644 index 00000000000..7f8612dd580 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleDraftModel.php @@ -0,0 +1,94 @@ + > + * + */ + private static $discriminatorClasses = [ + 'standard' => StandardScheduleDraftModel::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 = RecurrencePolicyScheduleDraft::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 = RecurrencePolicyScheduleDraftModel::class; + return $type; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleModel.php new file mode 100644 index 00000000000..4526f4052df --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyScheduleModel.php @@ -0,0 +1,95 @@ + > + * + */ + private static $discriminatorClasses = [ + 'dayOfMonth' => DayOfMonthScheduleModel::class, + 'standard' => StandardScheduleModel::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 = RecurrencePolicySchedule::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 = RecurrencePolicyScheduleModel::class; + return $type; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionAction.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionAction.php new file mode 100644 index 00000000000..c7320c450df --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionAction.php @@ -0,0 +1,32 @@ +Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|LocalizedString + */ + public function getDescription(); + + /** + * @param ?LocalizedString $description + */ + public function setDescription(?LocalizedString $description): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionActionBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionActionBuilder.php new file mode 100644 index 00000000000..244ee30042d --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionActionBuilder.php @@ -0,0 +1,76 @@ + + */ +final class RecurrencePolicySetDescriptionActionBuilder implements Builder +{ + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $description; + + /** + *

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|LocalizedString + */ + public function getDescription() + { + return $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description; + } + + /** + * @param ?LocalizedString $description + * @return $this + */ + public function withDescription(?LocalizedString $description) + { + $this->description = $description; + + return $this; + } + + /** + * @deprecated use withDescription() instead + * @return $this + */ + public function withDescriptionBuilder(?LocalizedStringBuilder $description) + { + $this->description = $description; + + return $this; + } + + public function build(): RecurrencePolicySetDescriptionAction + { + return new RecurrencePolicySetDescriptionActionModel( + $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description + ); + } + + public static function of(): RecurrencePolicySetDescriptionActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionActionCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionActionCollection.php new file mode 100644 index 00000000000..240476c79f0 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicySetDescriptionAction current() + * @method RecurrencePolicySetDescriptionAction end() + * @method RecurrencePolicySetDescriptionAction at($offset) + */ +class RecurrencePolicySetDescriptionActionCollection extends RecurrencePolicyUpdateActionCollection +{ + /** + * @psalm-assert RecurrencePolicySetDescriptionAction $value + * @psalm-param RecurrencePolicySetDescriptionAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicySetDescriptionActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicySetDescriptionAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicySetDescriptionAction + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicySetDescriptionAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicySetDescriptionAction $data */ + $data = RecurrencePolicySetDescriptionActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionActionModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionActionModel.php new file mode 100644 index 00000000000..11f600c68c3 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetDescriptionActionModel.php @@ -0,0 +1,97 @@ +description = $description; + $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; + } + + /** + *

Value to set. + * If empty, any existing value will be removed.

+ * + * + * @return null|LocalizedString + */ + public function getDescription() + { + if (is_null($this->description)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_DESCRIPTION); + if (is_null($data)) { + return null; + } + + $this->description = LocalizedStringModel::of($data); + } + + return $this->description; + } + + + /** + * @param ?LocalizedString $description + */ + public function setDescription(?LocalizedString $description): void + { + $this->description = $description; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyAction.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyAction.php new file mode 100644 index 00000000000..c77622c14e0 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyAction.php @@ -0,0 +1,31 @@ +Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|string + */ + public function getKey(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyActionBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyActionBuilder.php new file mode 100644 index 00000000000..b10d2924292 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyActionBuilder.php @@ -0,0 +1,64 @@ + + */ +final class RecurrencePolicySetKeyActionBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + *

Value to set. + * If empty, any existing value will be removed.

+ * + + * @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(): RecurrencePolicySetKeyAction + { + return new RecurrencePolicySetKeyActionModel( + $this->key + ); + } + + public static function of(): RecurrencePolicySetKeyActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyActionCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyActionCollection.php new file mode 100644 index 00000000000..e5a1127d7c4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicySetKeyAction current() + * @method RecurrencePolicySetKeyAction end() + * @method RecurrencePolicySetKeyAction at($offset) + */ +class RecurrencePolicySetKeyActionCollection extends RecurrencePolicyUpdateActionCollection +{ + /** + * @psalm-assert RecurrencePolicySetKeyAction $value + * @psalm-param RecurrencePolicySetKeyAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicySetKeyActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicySetKeyAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicySetKeyAction + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicySetKeyAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicySetKeyAction $data */ + $data = RecurrencePolicySetKeyActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyActionModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyActionModel.php new file mode 100644 index 00000000000..f43de448aa8 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetKeyActionModel.php @@ -0,0 +1,94 @@ +key = $key; + $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; + } + + /** + *

Value to set. + * If empty, any existing value will be removed.

+ * + * + * @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-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameAction.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameAction.php new file mode 100644 index 00000000000..e74be9b03a7 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameAction.php @@ -0,0 +1,32 @@ +Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|LocalizedString + */ + public function getName(); + + /** + * @param ?LocalizedString $name + */ + public function setName(?LocalizedString $name): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameActionBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameActionBuilder.php new file mode 100644 index 00000000000..e8869b24995 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameActionBuilder.php @@ -0,0 +1,76 @@ + + */ +final class RecurrencePolicySetNameActionBuilder implements Builder +{ + /** + + * @var null|LocalizedString|LocalizedStringBuilder + */ + private $name; + + /** + *

Value to set. + * If empty, any existing value will be removed.

+ * + + * @return null|LocalizedString + */ + public function getName() + { + return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name; + } + + /** + * @param ?LocalizedString $name + * @return $this + */ + public function withName(?LocalizedString $name) + { + $this->name = $name; + + return $this; + } + + /** + * @deprecated use withName() instead + * @return $this + */ + public function withNameBuilder(?LocalizedStringBuilder $name) + { + $this->name = $name; + + return $this; + } + + public function build(): RecurrencePolicySetNameAction + { + return new RecurrencePolicySetNameActionModel( + $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name + ); + } + + public static function of(): RecurrencePolicySetNameActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameActionCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameActionCollection.php new file mode 100644 index 00000000000..b806da00777 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicySetNameAction current() + * @method RecurrencePolicySetNameAction end() + * @method RecurrencePolicySetNameAction at($offset) + */ +class RecurrencePolicySetNameActionCollection extends RecurrencePolicyUpdateActionCollection +{ + /** + * @psalm-assert RecurrencePolicySetNameAction $value + * @psalm-param RecurrencePolicySetNameAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicySetNameActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicySetNameAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicySetNameAction + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicySetNameAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicySetNameAction $data */ + $data = RecurrencePolicySetNameActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameActionModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameActionModel.php new file mode 100644 index 00000000000..e7f68777300 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetNameActionModel.php @@ -0,0 +1,97 @@ +name = $name; + $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; + } + + /** + *

Value to set. + * If empty, any existing value will be removed.

+ * + * + * @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; + } + + + /** + * @param ?LocalizedString $name + */ + public function setName(?LocalizedString $name): void + { + $this->name = $name; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleAction.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleAction.php new file mode 100644 index 00000000000..7e8891e6437 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleAction.php @@ -0,0 +1,30 @@ +Schedule where the recurrence is defined.

+ * + + * @return null|RecurrencePolicyScheduleDraft + */ + public function getSchedule(); + + /** + * @param ?RecurrencePolicyScheduleDraft $schedule + */ + public function setSchedule(?RecurrencePolicyScheduleDraft $schedule): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleActionBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleActionBuilder.php new file mode 100644 index 00000000000..baca7beade3 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleActionBuilder.php @@ -0,0 +1,73 @@ + + */ +final class RecurrencePolicySetScheduleActionBuilder implements Builder +{ + /** + + * @var null|RecurrencePolicyScheduleDraft|RecurrencePolicyScheduleDraftBuilder + */ + private $schedule; + + /** + *

Schedule where the recurrence is defined.

+ * + + * @return null|RecurrencePolicyScheduleDraft + */ + public function getSchedule() + { + return $this->schedule instanceof RecurrencePolicyScheduleDraftBuilder ? $this->schedule->build() : $this->schedule; + } + + /** + * @param ?RecurrencePolicyScheduleDraft $schedule + * @return $this + */ + public function withSchedule(?RecurrencePolicyScheduleDraft $schedule) + { + $this->schedule = $schedule; + + return $this; + } + + /** + * @deprecated use withSchedule() instead + * @return $this + */ + public function withScheduleBuilder(?RecurrencePolicyScheduleDraftBuilder $schedule) + { + $this->schedule = $schedule; + + return $this; + } + + public function build(): RecurrencePolicySetScheduleAction + { + return new RecurrencePolicySetScheduleActionModel( + $this->schedule instanceof RecurrencePolicyScheduleDraftBuilder ? $this->schedule->build() : $this->schedule + ); + } + + public static function of(): RecurrencePolicySetScheduleActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleActionCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleActionCollection.php new file mode 100644 index 00000000000..7115645ebbf --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicySetScheduleAction current() + * @method RecurrencePolicySetScheduleAction end() + * @method RecurrencePolicySetScheduleAction at($offset) + */ +class RecurrencePolicySetScheduleActionCollection extends RecurrencePolicyUpdateActionCollection +{ + /** + * @psalm-assert RecurrencePolicySetScheduleAction $value + * @psalm-param RecurrencePolicySetScheduleAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicySetScheduleActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicySetScheduleAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicySetScheduleAction + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicySetScheduleAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicySetScheduleAction $data */ + $data = RecurrencePolicySetScheduleActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleActionModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleActionModel.php new file mode 100644 index 00000000000..2c3330e84c0 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicySetScheduleActionModel.php @@ -0,0 +1,94 @@ +schedule = $schedule; + $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; + } + + /** + *

Schedule where the recurrence is defined.

+ * + * + * @return null|RecurrencePolicyScheduleDraft + */ + public function getSchedule() + { + if (is_null($this->schedule)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SCHEDULE); + if (is_null($data)) { + return null; + } + $className = RecurrencePolicyScheduleDraftModel::resolveDiscriminatorClass($data); + $this->schedule = $className::of($data); + } + + return $this->schedule; + } + + + /** + * @param ?RecurrencePolicyScheduleDraft $schedule + */ + public function setSchedule(?RecurrencePolicyScheduleDraft $schedule): void + { + $this->schedule = $schedule; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdate.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdate.php new file mode 100644 index 00000000000..31d6d527238 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdate.php @@ -0,0 +1,45 @@ +Expected version of the RecurrencePolicy on which the changes should be applied. + * If the expected version does not match the actual version, a ConcurrentModification error will be returned.

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

Update actions to be performed on the RecurrencePolicy.

+ * + + * @return null|RecurrencePolicyUpdateActionCollection + */ + public function getActions(); + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void; + + /** + * @param ?RecurrencePolicyUpdateActionCollection $actions + */ + public function setActions(?RecurrencePolicyUpdateActionCollection $actions): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateAction.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateAction.php new file mode 100644 index 00000000000..52bdebe7a10 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateAction.php @@ -0,0 +1,24 @@ + + */ +final class RecurrencePolicyUpdateActionBuilder implements Builder +{ + public function build(): RecurrencePolicyUpdateAction + { + return new RecurrencePolicyUpdateActionModel( + ); + } + + public static function of(): RecurrencePolicyUpdateActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateActionCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateActionCollection.php new file mode 100644 index 00000000000..de0b4220944 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateActionCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method RecurrencePolicyUpdateAction current() + * @method RecurrencePolicyUpdateAction end() + * @method RecurrencePolicyUpdateAction at($offset) + */ +class RecurrencePolicyUpdateActionCollection extends MapperSequence +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicyUpdateActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicyUpdateAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicyUpdateAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = RecurrencePolicyUpdateActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateActionModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateActionModel.php new file mode 100644 index 00000000000..d7b92207303 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateActionModel.php @@ -0,0 +1,97 @@ + > + * + */ + private static $discriminatorClasses = [ + 'setDescription' => RecurrencePolicySetDescriptionActionModel::class, + 'setKey' => RecurrencePolicySetKeyActionModel::class, + 'setName' => RecurrencePolicySetNameActionModel::class, + 'setSchedule' => RecurrencePolicySetScheduleActionModel::class, + ]; + + /** + * @psalm-suppress MissingParamType + */ + public function __construct( + ?string $action = null + ) { + $this->action = $action; + } + + /** + * + * @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; + } + + + + + + /** + * @psalm-param stdClass|array $value + * @psalm-return class-string + */ + public static function resolveDiscriminatorClass($value): string + { + $fieldName = RecurrencePolicyUpdateAction::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 = RecurrencePolicyUpdateActionModel::class; + return $type; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateBuilder.php new file mode 100644 index 00000000000..fdc87088d9b --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateBuilder.php @@ -0,0 +1,93 @@ + + */ +final class RecurrencePolicyUpdateBuilder implements Builder +{ + /** + + * @var ?int + */ + private $version; + + /** + + * @var ?RecurrencePolicyUpdateActionCollection + */ + private $actions; + + /** + *

Expected version of the RecurrencePolicy on which the changes should be applied. + * If the expected version does not match the actual version, a ConcurrentModification error will be returned.

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

Update actions to be performed on the RecurrencePolicy.

+ * + + * @return null|RecurrencePolicyUpdateActionCollection + */ + public function getActions() + { + return $this->actions; + } + + /** + * @param ?int $version + * @return $this + */ + public function withVersion(?int $version) + { + $this->version = $version; + + return $this; + } + + /** + * @param ?RecurrencePolicyUpdateActionCollection $actions + * @return $this + */ + public function withActions(?RecurrencePolicyUpdateActionCollection $actions) + { + $this->actions = $actions; + + return $this; + } + + + public function build(): RecurrencePolicyUpdate + { + return new RecurrencePolicyUpdateModel( + $this->version, + $this->actions + ); + } + + public static function of(): RecurrencePolicyUpdateBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateCollection.php new file mode 100644 index 00000000000..ed6a6397b06 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateCollection.php @@ -0,0 +1,56 @@ + + * @method RecurrencePolicyUpdate current() + * @method RecurrencePolicyUpdate end() + * @method RecurrencePolicyUpdate at($offset) + */ +class RecurrencePolicyUpdateCollection extends MapperSequence +{ + /** + * @psalm-assert RecurrencePolicyUpdate $value + * @psalm-param RecurrencePolicyUpdate|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurrencePolicyUpdateCollection + */ + public function add($value) + { + if (!$value instanceof RecurrencePolicyUpdate) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurrencePolicyUpdate + */ + protected function mapper() + { + return function (?int $index): ?RecurrencePolicyUpdate { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurrencePolicyUpdate $data */ + $data = RecurrencePolicyUpdateModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateModel.php new file mode 100644 index 00000000000..f67561414c7 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/RecurrencePolicyUpdateModel.php @@ -0,0 +1,103 @@ +version = $version; + $this->actions = $actions; + } + + /** + *

Expected version of the RecurrencePolicy on which the changes should be applied. + * If the expected version does not match the actual version, a ConcurrentModification error will be returned.

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

Update actions to be performed on the RecurrencePolicy.

+ * + * + * @return null|RecurrencePolicyUpdateActionCollection + */ + public function getActions() + { + if (is_null($this->actions)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ACTIONS); + if (is_null($data)) { + return null; + } + $this->actions = RecurrencePolicyUpdateActionCollection::fromArray($data); + } + + return $this->actions; + } + + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void + { + $this->version = $version; + } + + /** + * @param ?RecurrencePolicyUpdateActionCollection $actions + */ + public function setActions(?RecurrencePolicyUpdateActionCollection $actions): void + { + $this->actions = $actions; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/StandardSchedule.php b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardSchedule.php new file mode 100644 index 00000000000..f2cad0f1a46 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardSchedule.php @@ -0,0 +1,44 @@ +Number of intervals between orders.

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

Interval of this schedule.

+ * + + * @return null|string + */ + public function getIntervalUnit(); + + /** + * @param ?int $value + */ + public function setValue(?int $value): void; + + /** + * @param ?string $intervalUnit + */ + public function setIntervalUnit(?string $intervalUnit): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleBuilder.php new file mode 100644 index 00000000000..6d45f9e3875 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleBuilder.php @@ -0,0 +1,92 @@ + + */ +final class StandardScheduleBuilder implements Builder +{ + /** + + * @var ?int + */ + private $value; + + /** + + * @var ?string + */ + private $intervalUnit; + + /** + *

Number of intervals between orders.

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

Interval of this schedule.

+ * + + * @return null|string + */ + public function getIntervalUnit() + { + return $this->intervalUnit; + } + + /** + * @param ?int $value + * @return $this + */ + public function withValue(?int $value) + { + $this->value = $value; + + return $this; + } + + /** + * @param ?string $intervalUnit + * @return $this + */ + public function withIntervalUnit(?string $intervalUnit) + { + $this->intervalUnit = $intervalUnit; + + return $this; + } + + + public function build(): StandardSchedule + { + return new StandardScheduleModel( + $this->value, + $this->intervalUnit + ); + } + + public static function of(): StandardScheduleBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleCollection.php new file mode 100644 index 00000000000..1623a4587b1 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleCollection.php @@ -0,0 +1,56 @@ + + * @method StandardSchedule current() + * @method StandardSchedule end() + * @method StandardSchedule at($offset) + */ +class StandardScheduleCollection extends RecurrencePolicyScheduleCollection +{ + /** + * @psalm-assert StandardSchedule $value + * @psalm-param StandardSchedule|stdClass $value + * @throws InvalidArgumentException + * + * @return StandardScheduleCollection + */ + public function add($value) + { + if (!$value instanceof StandardSchedule) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?StandardSchedule + */ + protected function mapper() + { + return function (?int $index): ?StandardSchedule { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var StandardSchedule $data */ + $data = StandardScheduleModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraft.php b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraft.php new file mode 100644 index 00000000000..38d20d96682 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraft.php @@ -0,0 +1,44 @@ +Number of intervals between orders.

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

Interval for this schedule.

+ * + + * @return null|string + */ + public function getIntervalUnit(); + + /** + * @param ?int $value + */ + public function setValue(?int $value): void; + + /** + * @param ?string $intervalUnit + */ + public function setIntervalUnit(?string $intervalUnit): void; +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraftBuilder.php b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraftBuilder.php new file mode 100644 index 00000000000..fab0b1ce377 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraftBuilder.php @@ -0,0 +1,92 @@ + + */ +final class StandardScheduleDraftBuilder implements Builder +{ + /** + + * @var ?int + */ + private $value; + + /** + + * @var ?string + */ + private $intervalUnit; + + /** + *

Number of intervals between orders.

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

Interval for this schedule.

+ * + + * @return null|string + */ + public function getIntervalUnit() + { + return $this->intervalUnit; + } + + /** + * @param ?int $value + * @return $this + */ + public function withValue(?int $value) + { + $this->value = $value; + + return $this; + } + + /** + * @param ?string $intervalUnit + * @return $this + */ + public function withIntervalUnit(?string $intervalUnit) + { + $this->intervalUnit = $intervalUnit; + + return $this; + } + + + public function build(): StandardScheduleDraft + { + return new StandardScheduleDraftModel( + $this->value, + $this->intervalUnit + ); + } + + public static function of(): StandardScheduleDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraftCollection.php b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraftCollection.php new file mode 100644 index 00000000000..46ea0d63a8c --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraftCollection.php @@ -0,0 +1,56 @@ + + * @method StandardScheduleDraft current() + * @method StandardScheduleDraft end() + * @method StandardScheduleDraft at($offset) + */ +class StandardScheduleDraftCollection extends RecurrencePolicyScheduleDraftCollection +{ + /** + * @psalm-assert StandardScheduleDraft $value + * @psalm-param StandardScheduleDraft|stdClass $value + * @throws InvalidArgumentException + * + * @return StandardScheduleDraftCollection + */ + public function add($value) + { + if (!$value instanceof StandardScheduleDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?StandardScheduleDraft + */ + protected function mapper() + { + return function (?int $index): ?StandardScheduleDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var StandardScheduleDraft $data */ + $data = StandardScheduleDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraftModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraftModel.php new file mode 100644 index 00000000000..47eb8862a39 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleDraftModel.php @@ -0,0 +1,129 @@ +value = $value; + $this->intervalUnit = $intervalUnit; + $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; + } + + /** + *

Number of intervals between orders.

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

Interval for this schedule.

+ * + * + * @return null|string + */ + public function getIntervalUnit() + { + if (is_null($this->intervalUnit)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_INTERVAL_UNIT); + if (is_null($data)) { + return null; + } + $this->intervalUnit = (string) $data; + } + + return $this->intervalUnit; + } + + + /** + * @param ?int $value + */ + public function setValue(?int $value): void + { + $this->value = $value; + } + + /** + * @param ?string $intervalUnit + */ + public function setIntervalUnit(?string $intervalUnit): void + { + $this->intervalUnit = $intervalUnit; + } +} diff --git a/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleModel.php b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleModel.php new file mode 100644 index 00000000000..535823efebd --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurrencePolicy/StandardScheduleModel.php @@ -0,0 +1,129 @@ +value = $value; + $this->intervalUnit = $intervalUnit; + $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; + } + + /** + *

Number of intervals between orders.

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

Interval of this schedule.

+ * + * + * @return null|string + */ + public function getIntervalUnit() + { + if (is_null($this->intervalUnit)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_INTERVAL_UNIT); + if (is_null($data)) { + return null; + } + $this->intervalUnit = (string) $data; + } + + return $this->intervalUnit; + } + + + /** + * @param ?int $value + */ + public function setValue(?int $value): void + { + $this->value = $value; + } + + /** + * @param ?string $intervalUnit + */ + public function setIntervalUnit(?string $intervalUnit): void + { + $this->intervalUnit = $intervalUnit; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/Counter.php b/lib/commercetools-api/src/Models/RecurringOrder/Counter.php new file mode 100644 index 00000000000..13676798f28 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/Counter.php @@ -0,0 +1,59 @@ +Number of Orders that will be skipped.

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

Number of Orders that were already skipped.

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

Date and time (UTC) when the last Order creation was skipped.

+ * + + * @return null|DateTimeImmutable + */ + public function getLastSkippedAt(); + + /** + * @param ?int $totalToSkip + */ + public function setTotalToSkip(?int $totalToSkip): void; + + /** + * @param ?int $skipped + */ + public function setSkipped(?int $skipped): void; + + /** + * @param ?DateTimeImmutable $lastSkippedAt + */ + public function setLastSkippedAt(?DateTimeImmutable $lastSkippedAt): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CounterBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/CounterBuilder.php new file mode 100644 index 00000000000..6362a720b74 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CounterBuilder.php @@ -0,0 +1,122 @@ + + */ +final class CounterBuilder implements Builder +{ + /** + + * @var ?int + */ + private $totalToSkip; + + /** + + * @var ?int + */ + private $skipped; + + /** + + * @var ?DateTimeImmutable + */ + private $lastSkippedAt; + + /** + *

Number of Orders that will be skipped.

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

Number of Orders that were already skipped.

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

Date and time (UTC) when the last Order creation was skipped.

+ * + + * @return null|DateTimeImmutable + */ + public function getLastSkippedAt() + { + return $this->lastSkippedAt; + } + + /** + * @param ?int $totalToSkip + * @return $this + */ + public function withTotalToSkip(?int $totalToSkip) + { + $this->totalToSkip = $totalToSkip; + + return $this; + } + + /** + * @param ?int $skipped + * @return $this + */ + public function withSkipped(?int $skipped) + { + $this->skipped = $skipped; + + return $this; + } + + /** + * @param ?DateTimeImmutable $lastSkippedAt + * @return $this + */ + public function withLastSkippedAt(?DateTimeImmutable $lastSkippedAt) + { + $this->lastSkippedAt = $lastSkippedAt; + + return $this; + } + + + public function build(): Counter + { + return new CounterModel( + $this->totalToSkip, + $this->skipped, + $this->lastSkippedAt + ); + } + + public static function of(): CounterBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CounterCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/CounterCollection.php new file mode 100644 index 00000000000..57bb0e7fbf7 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CounterCollection.php @@ -0,0 +1,56 @@ + + * @method Counter current() + * @method Counter end() + * @method Counter at($offset) + */ +class CounterCollection extends SkipConfigurationCollection +{ + /** + * @psalm-assert Counter $value + * @psalm-param Counter|stdClass $value + * @throws InvalidArgumentException + * + * @return CounterCollection + */ + public function add($value) + { + if (!$value instanceof Counter) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?Counter + */ + protected function mapper() + { + return function (?int $index): ?Counter { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var Counter $data */ + $data = CounterModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CounterDraft.php b/lib/commercetools-api/src/Models/RecurringOrder/CounterDraft.php new file mode 100644 index 00000000000..40fd9fb6667 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CounterDraft.php @@ -0,0 +1,30 @@ +Number of Orders that will be skipped.

+ * + + * @return null|int + */ + public function getTotalToSkip(); + + /** + * @param ?int $totalToSkip + */ + public function setTotalToSkip(?int $totalToSkip): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CounterDraftBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/CounterDraftBuilder.php new file mode 100644 index 00000000000..c0ee47105a4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CounterDraftBuilder.php @@ -0,0 +1,63 @@ + + */ +final class CounterDraftBuilder implements Builder +{ + /** + + * @var ?int + */ + private $totalToSkip; + + /** + *

Number of Orders that will be skipped.

+ * + + * @return null|int + */ + public function getTotalToSkip() + { + return $this->totalToSkip; + } + + /** + * @param ?int $totalToSkip + * @return $this + */ + public function withTotalToSkip(?int $totalToSkip) + { + $this->totalToSkip = $totalToSkip; + + return $this; + } + + + public function build(): CounterDraft + { + return new CounterDraftModel( + $this->totalToSkip + ); + } + + public static function of(): CounterDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CounterDraftCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/CounterDraftCollection.php new file mode 100644 index 00000000000..4d4341b0228 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CounterDraftCollection.php @@ -0,0 +1,56 @@ + + * @method CounterDraft current() + * @method CounterDraft end() + * @method CounterDraft at($offset) + */ +class CounterDraftCollection extends SkipConfigurationDraftCollection +{ + /** + * @psalm-assert CounterDraft $value + * @psalm-param CounterDraft|stdClass $value + * @throws InvalidArgumentException + * + * @return CounterDraftCollection + */ + public function add($value) + { + if (!$value instanceof CounterDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CounterDraft + */ + protected function mapper() + { + return function (?int $index): ?CounterDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CounterDraft $data */ + $data = CounterDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CounterDraftModel.php b/lib/commercetools-api/src/Models/RecurringOrder/CounterDraftModel.php new file mode 100644 index 00000000000..00c0ed1445a --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CounterDraftModel.php @@ -0,0 +1,93 @@ +totalToSkip = $totalToSkip; + $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; + } + + /** + *

Number of Orders that will be skipped.

+ * + * + * @return null|int + */ + public function getTotalToSkip() + { + if (is_null($this->totalToSkip)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_TOTAL_TO_SKIP); + if (is_null($data)) { + return null; + } + $this->totalToSkip = (int) $data; + } + + return $this->totalToSkip; + } + + + /** + * @param ?int $totalToSkip + */ + public function setTotalToSkip(?int $totalToSkip): void + { + $this->totalToSkip = $totalToSkip; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CounterModel.php b/lib/commercetools-api/src/Models/RecurringOrder/CounterModel.php new file mode 100644 index 00000000000..3b7fb0f03e5 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CounterModel.php @@ -0,0 +1,181 @@ +totalToSkip = $totalToSkip; + $this->skipped = $skipped; + $this->lastSkippedAt = $lastSkippedAt; + $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; + } + + /** + *

Number of Orders that will be skipped.

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

Number of Orders that were already skipped.

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

Date and time (UTC) when the last Order creation was skipped.

+ * + * + * @return null|DateTimeImmutable + */ + public function getLastSkippedAt() + { + if (is_null($this->lastSkippedAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LAST_SKIPPED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->lastSkippedAt = $data; + } + + return $this->lastSkippedAt; + } + + + /** + * @param ?int $totalToSkip + */ + public function setTotalToSkip(?int $totalToSkip): void + { + $this->totalToSkip = $totalToSkip; + } + + /** + * @param ?int $skipped + */ + public function setSkipped(?int $skipped): void + { + $this->skipped = $skipped; + } + + /** + * @param ?DateTimeImmutable $lastSkippedAt + */ + public function setLastSkippedAt(?DateTimeImmutable $lastSkippedAt): void + { + $this->lastSkippedAt = $lastSkippedAt; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[Counter::FIELD_LAST_SKIPPED_AT]) && $data[Counter::FIELD_LAST_SKIPPED_AT] instanceof \DateTimeImmutable) { + $data[Counter::FIELD_LAST_SKIPPED_AT] = $data[Counter::FIELD_LAST_SKIPPED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfo.php b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfo.php new file mode 100644 index 00000000000..2ff0c87f683 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/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-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoBuilder.php new file mode 100644 index 00000000000..741f9ae7de6 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoBuilder.php @@ -0,0 +1,75 @@ + + */ +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-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoCollection.php new file mode 100644 index 00000000000..b6137f4fb37 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/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-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraft.php b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraft.php new file mode 100644 index 00000000000..a403ad3c674 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraft.php @@ -0,0 +1,31 @@ +ResourceIdentifier to a RecurrencePolicy.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy(); + + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraftBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraftBuilder.php new file mode 100644 index 00000000000..6c15ef51477 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraftBuilder.php @@ -0,0 +1,75 @@ + + */ +final class CustomLineItemRecurrenceInfoDraftBuilder implements Builder +{ + /** + + * @var null|RecurrencePolicyResourceIdentifier|RecurrencePolicyResourceIdentifierBuilder + */ + private $recurrencePolicy; + + /** + *

ResourceIdentifier to a RecurrencePolicy.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy() + { + return $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy; + } + + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + + /** + * @deprecated use withRecurrencePolicy() instead + * @return $this + */ + public function withRecurrencePolicyBuilder(?RecurrencePolicyResourceIdentifierBuilder $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + + public function build(): CustomLineItemRecurrenceInfoDraft + { + return new CustomLineItemRecurrenceInfoDraftModel( + $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy + ); + } + + public static function of(): CustomLineItemRecurrenceInfoDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraftCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraftCollection.php new file mode 100644 index 00000000000..4dc934d3ae4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraftCollection.php @@ -0,0 +1,56 @@ + + * @method CustomLineItemRecurrenceInfoDraft current() + * @method CustomLineItemRecurrenceInfoDraft end() + * @method CustomLineItemRecurrenceInfoDraft at($offset) + */ +class CustomLineItemRecurrenceInfoDraftCollection extends MapperSequence +{ + /** + * @psalm-assert CustomLineItemRecurrenceInfoDraft $value + * @psalm-param CustomLineItemRecurrenceInfoDraft|stdClass $value + * @throws InvalidArgumentException + * + * @return CustomLineItemRecurrenceInfoDraftCollection + */ + public function add($value) + { + if (!$value instanceof CustomLineItemRecurrenceInfoDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?CustomLineItemRecurrenceInfoDraft + */ + protected function mapper() + { + return function (?int $index): ?CustomLineItemRecurrenceInfoDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var CustomLineItemRecurrenceInfoDraft $data */ + $data = CustomLineItemRecurrenceInfoDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraftModel.php b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraftModel.php new file mode 100644 index 00000000000..512b848fde6 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoDraftModel.php @@ -0,0 +1,69 @@ +recurrencePolicy = $recurrencePolicy; + } + + /** + *

ResourceIdentifier to a RecurrencePolicy.

+ * + * + * @return null|RecurrencePolicyResourceIdentifier + */ + 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 = RecurrencePolicyResourceIdentifierModel::of($data); + } + + return $this->recurrencePolicy; + } + + + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void + { + $this->recurrencePolicy = $recurrencePolicy; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoModel.php b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoModel.php new file mode 100644 index 00000000000..a44251a1928 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/CustomLineItemRecurrenceInfoModel.php @@ -0,0 +1,69 @@ +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-api/src/Models/RecurringOrder/LineItemRecurrenceInfo.php b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfo.php new file mode 100644 index 00000000000..db50eb5684a --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/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-api/src/Models/RecurringOrder/LineItemRecurrenceInfoBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoBuilder.php new file mode 100644 index 00000000000..79b3b7f797d --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoBuilder.php @@ -0,0 +1,104 @@ + + */ +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-api/src/Models/RecurringOrder/LineItemRecurrenceInfoCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoCollection.php new file mode 100644 index 00000000000..45360f5d458 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/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-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraft.php b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraft.php new file mode 100644 index 00000000000..86d1372fb12 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraft.php @@ -0,0 +1,45 @@ +ResourceIdentifier to a RecurrencePolicy.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy(); + + /** + *

Determines how the price of a line item will be selected during order creation.

+ * + + * @return null|string + */ + public function getPriceSelectionMode(); + + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void; + + /** + * @param ?string $priceSelectionMode + */ + public function setPriceSelectionMode(?string $priceSelectionMode): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraftBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraftBuilder.php new file mode 100644 index 00000000000..4826f2759da --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraftBuilder.php @@ -0,0 +1,104 @@ + + */ +final class LineItemRecurrenceInfoDraftBuilder implements Builder +{ + /** + + * @var null|RecurrencePolicyResourceIdentifier|RecurrencePolicyResourceIdentifierBuilder + */ + private $recurrencePolicy; + + /** + + * @var ?string + */ + private $priceSelectionMode; + + /** + *

ResourceIdentifier to a RecurrencePolicy.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy() + { + return $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy; + } + + /** + *

Determines how the price of a line item will be selected during order creation.

+ * + + * @return null|string + */ + public function getPriceSelectionMode() + { + return $this->priceSelectionMode; + } + + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyResourceIdentifier $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(?RecurrencePolicyResourceIdentifierBuilder $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + + public function build(): LineItemRecurrenceInfoDraft + { + return new LineItemRecurrenceInfoDraftModel( + $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy, + $this->priceSelectionMode + ); + } + + public static function of(): LineItemRecurrenceInfoDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraftCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraftCollection.php new file mode 100644 index 00000000000..a4c64965caf --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraftCollection.php @@ -0,0 +1,56 @@ + + * @method LineItemRecurrenceInfoDraft current() + * @method LineItemRecurrenceInfoDraft end() + * @method LineItemRecurrenceInfoDraft at($offset) + */ +class LineItemRecurrenceInfoDraftCollection extends MapperSequence +{ + /** + * @psalm-assert LineItemRecurrenceInfoDraft $value + * @psalm-param LineItemRecurrenceInfoDraft|stdClass $value + * @throws InvalidArgumentException + * + * @return LineItemRecurrenceInfoDraftCollection + */ + public function add($value) + { + if (!$value instanceof LineItemRecurrenceInfoDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?LineItemRecurrenceInfoDraft + */ + protected function mapper() + { + return function (?int $index): ?LineItemRecurrenceInfoDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var LineItemRecurrenceInfoDraft $data */ + $data = LineItemRecurrenceInfoDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraftModel.php b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraftModel.php new file mode 100644 index 00000000000..d6694d7b701 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoDraftModel.php @@ -0,0 +1,105 @@ +recurrencePolicy = $recurrencePolicy; + $this->priceSelectionMode = $priceSelectionMode; + } + + /** + *

ResourceIdentifier to a RecurrencePolicy.

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

Determines 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 ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void + { + $this->recurrencePolicy = $recurrencePolicy; + } + + /** + * @param ?string $priceSelectionMode + */ + public function setPriceSelectionMode(?string $priceSelectionMode): void + { + $this->priceSelectionMode = $priceSelectionMode; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoModel.php b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoModel.php new file mode 100644 index 00000000000..6de09ac8ecb --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/LineItemRecurrenceInfoModel.php @@ -0,0 +1,105 @@ +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-api/src/Models/RecurringOrder/RecurringOrder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrder.php new file mode 100644 index 00000000000..a8498f39f01 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrder.php @@ -0,0 +1,347 @@ +Unique identifier of the RecurringOrder.

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

User-defined unique identifier of the RecurringOrder.

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

Current version of the RecurringOrder.

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

Reference to the Cart for a RecurringOrder. + * The referenced Cart will have the RecurringOrder CartOrigin.

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

Reference to the original Order that generated this RecurringOrder.

+ * + + * @return null|OrderReference + */ + public function getOriginOrder(); + + /** + *

Date and time (UTC) when the RecurringOrder starts creating new Orders.

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

Date and time (UTC) when the RecurringOrder resumes creating Orders after being unpaused.

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

Date and time (UTC) when the RecurringOrder expires.

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

Date and time (UTC) when the last Order was created from this RecurringOrder.

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

Date and time (UTC) when the next Order will be created from this RecurringOrder.

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

Information about current and future skips for this RecurringOrder.

+ * + + * @return null|SkipConfiguration + */ + public function getSkipConfiguration(); + + /** + *

Reference to a Store.

+ * + + * @return null|StoreKeyReference + */ + public function getStore(); + + /** + *

Reference to the Business Unit that the RecurringOrder belongs to.

+ * + + * @return null|BusinessUnitKeyReference + */ + public function getBusinessUnit(); + + /** + *

State of the RecurringOrder in a custom workflow.

+ * + + * @return null|StateReference + */ + public function getState(); + + /** + *

Current state of the RecurringOrder.

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

Schedule of the RecurringOrder.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getSchedule(); + + /** + *

The Customer that the RecurringOrder belongs to.

+ * + + * @return null|CustomerReference + */ + public function getCustomer(); + + /** + *

Email address of the Customer that the RecurringOrder belongs to.

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

Custom Fields of the RecurringOrder.

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

Date and time (UTC) when the RecurringOrder was created.

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

Date and time (UTC) when the RecurringOrder was last updated.

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

IDs and references that last modified the RecurringOrder.

+ * + + * @return null|LastModifiedBy + */ + public function getLastModifiedBy(); + + /** + *

IDs and references that created the RecurringOrder.

+ * + + * @return null|CreatedBy + */ + public function getCreatedBy(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void; + + /** + * @param ?CartReference $cart + */ + public function setCart(?CartReference $cart): void; + + /** + * @param ?OrderReference $originOrder + */ + public function setOriginOrder(?OrderReference $originOrder): void; + + /** + * @param ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void; + + /** + * @param ?DateTimeImmutable $resumesAt + */ + public function setResumesAt(?DateTimeImmutable $resumesAt): void; + + /** + * @param ?DateTimeImmutable $expiresAt + */ + public function setExpiresAt(?DateTimeImmutable $expiresAt): void; + + /** + * @param ?DateTimeImmutable $lastOrderAt + */ + public function setLastOrderAt(?DateTimeImmutable $lastOrderAt): void; + + /** + * @param ?DateTimeImmutable $nextOrderAt + */ + public function setNextOrderAt(?DateTimeImmutable $nextOrderAt): void; + + /** + * @param ?SkipConfiguration $skipConfiguration + */ + public function setSkipConfiguration(?SkipConfiguration $skipConfiguration): void; + + /** + * @param ?StoreKeyReference $store + */ + public function setStore(?StoreKeyReference $store): void; + + /** + * @param ?BusinessUnitKeyReference $businessUnit + */ + public function setBusinessUnit(?BusinessUnitKeyReference $businessUnit): void; + + /** + * @param ?StateReference $state + */ + public function setState(?StateReference $state): void; + + /** + * @param ?string $recurringOrderState + */ + public function setRecurringOrderState(?string $recurringOrderState): void; + + /** + * @param ?RecurrencePolicySchedule $schedule + */ + public function setSchedule(?RecurrencePolicySchedule $schedule): void; + + /** + * @param ?CustomerReference $customer + */ + public function setCustomer(?CustomerReference $customer): void; + + /** + * @param ?string $customerEmail + */ + public function setCustomerEmail(?string $customerEmail): void; + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void; + + /** + * @param ?DateTimeImmutable $createdAt + */ + public function setCreatedAt(?DateTimeImmutable $createdAt): void; + + /** + * @param ?DateTimeImmutable $lastModifiedAt + */ + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void; + + /** + * @param ?LastModifiedBy $lastModifiedBy + */ + public function setLastModifiedBy(?LastModifiedBy $lastModifiedBy): void; + + /** + * @param ?CreatedBy $createdBy + */ + public function setCreatedBy(?CreatedBy $createdBy): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActive.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActive.php new file mode 100644 index 00000000000..865929fc506 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActive.php @@ -0,0 +1,31 @@ +If set, the Recurring Order will automatically resume at the date and time (UTC) specified.

+ * + + * @return null|DateTimeImmutable + */ + public function getResumesAt(); + + /** + * @param ?DateTimeImmutable $resumesAt + */ + public function setResumesAt(?DateTimeImmutable $resumesAt): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActiveBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActiveBuilder.php new file mode 100644 index 00000000000..dc3c5d106c9 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActiveBuilder.php @@ -0,0 +1,64 @@ + + */ +final class RecurringOrderActiveBuilder implements Builder +{ + /** + + * @var ?DateTimeImmutable + */ + private $resumesAt; + + /** + *

If set, the Recurring Order will automatically resume at the date and time (UTC) specified.

+ * + + * @return null|DateTimeImmutable + */ + public function getResumesAt() + { + return $this->resumesAt; + } + + /** + * @param ?DateTimeImmutable $resumesAt + * @return $this + */ + public function withResumesAt(?DateTimeImmutable $resumesAt) + { + $this->resumesAt = $resumesAt; + + return $this; + } + + + public function build(): RecurringOrderActive + { + return new RecurringOrderActiveModel( + $this->resumesAt + ); + } + + public static function of(): RecurringOrderActiveBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActiveCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActiveCollection.php new file mode 100644 index 00000000000..8ad20420974 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActiveCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderActive current() + * @method RecurringOrderActive end() + * @method RecurringOrderActive at($offset) + */ +class RecurringOrderActiveCollection extends RecurringOrderStateDraftCollection +{ + /** + * @psalm-assert RecurringOrderActive $value + * @psalm-param RecurringOrderActive|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderActiveCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderActive) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderActive + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderActive { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderActive $data */ + $data = RecurringOrderActiveModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActiveModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActiveModel.php new file mode 100644 index 00000000000..fdc74469f30 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderActiveModel.php @@ -0,0 +1,109 @@ +resumesAt = $resumesAt; + $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; + } + + /** + *

If set, the Recurring Order will automatically resume at the date and time (UTC) specified.

+ * + * + * @return null|DateTimeImmutable + */ + public function getResumesAt() + { + if (is_null($this->resumesAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_RESUMES_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->resumesAt = $data; + } + + return $this->resumesAt; + } + + + /** + * @param ?DateTimeImmutable $resumesAt + */ + public function setResumesAt(?DateTimeImmutable $resumesAt): void + { + $this->resumesAt = $resumesAt; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[RecurringOrderActive::FIELD_RESUMES_AT]) && $data[RecurringOrderActive::FIELD_RESUMES_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderActive::FIELD_RESUMES_AT] = $data[RecurringOrderActive::FIELD_RESUMES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderBuilder.php new file mode 100644 index 00000000000..e30b789b02e --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderBuilder.php @@ -0,0 +1,845 @@ + + */ +final class RecurringOrderBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?int + */ + private $version; + + /** + + * @var ?DateTimeImmutable + */ + private $createdAt; + + /** + + * @var ?DateTimeImmutable + */ + private $lastModifiedAt; + + /** + + * @var ?string + */ + private $key; + + /** + + * @var null|CartReference|CartReferenceBuilder + */ + private $cart; + + /** + + * @var null|OrderReference|OrderReferenceBuilder + */ + private $originOrder; + + /** + + * @var ?DateTimeImmutable + */ + private $startsAt; + + /** + + * @var ?DateTimeImmutable + */ + private $resumesAt; + + /** + + * @var ?DateTimeImmutable + */ + private $expiresAt; + + /** + + * @var ?DateTimeImmutable + */ + private $lastOrderAt; + + /** + + * @var ?DateTimeImmutable + */ + private $nextOrderAt; + + /** + + * @var null|SkipConfiguration|SkipConfigurationBuilder + */ + private $skipConfiguration; + + /** + + * @var null|StoreKeyReference|StoreKeyReferenceBuilder + */ + private $store; + + /** + + * @var null|BusinessUnitKeyReference|BusinessUnitKeyReferenceBuilder + */ + private $businessUnit; + + /** + + * @var null|StateReference|StateReferenceBuilder + */ + private $state; + + /** + + * @var ?string + */ + private $recurringOrderState; + + /** + + * @var null|RecurrencePolicySchedule|RecurrencePolicyScheduleBuilder + */ + private $schedule; + + /** + + * @var null|CustomerReference|CustomerReferenceBuilder + */ + private $customer; + + /** + + * @var ?string + */ + private $customerEmail; + + /** + + * @var null|CustomFields|CustomFieldsBuilder + */ + private $custom; + + /** + + * @var null|LastModifiedBy|LastModifiedByBuilder + */ + private $lastModifiedBy; + + /** + + * @var null|CreatedBy|CreatedByBuilder + */ + private $createdBy; + + /** + *

Unique identifier of the RecurringOrder.

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

Current version of the RecurringOrder.

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

Date and time (UTC) when the RecurringOrder was created.

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

Date and time (UTC) when the RecurringOrder was last updated.

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

User-defined unique identifier of the RecurringOrder.

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

Reference to the Cart for a RecurringOrder. + * The referenced Cart will have the RecurringOrder CartOrigin.

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

Reference to the original Order that generated this RecurringOrder.

+ * + + * @return null|OrderReference + */ + public function getOriginOrder() + { + return $this->originOrder instanceof OrderReferenceBuilder ? $this->originOrder->build() : $this->originOrder; + } + + /** + *

Date and time (UTC) when the RecurringOrder starts creating new Orders.

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

Date and time (UTC) when the RecurringOrder resumes creating Orders after being unpaused.

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

Date and time (UTC) when the RecurringOrder expires.

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

Date and time (UTC) when the last Order was created from this RecurringOrder.

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

Date and time (UTC) when the next Order will be created from this RecurringOrder.

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

Information about current and future skips for this RecurringOrder.

+ * + + * @return null|SkipConfiguration + */ + public function getSkipConfiguration() + { + return $this->skipConfiguration instanceof SkipConfigurationBuilder ? $this->skipConfiguration->build() : $this->skipConfiguration; + } + + /** + *

Reference to a Store.

+ * + + * @return null|StoreKeyReference + */ + public function getStore() + { + return $this->store instanceof StoreKeyReferenceBuilder ? $this->store->build() : $this->store; + } + + /** + *

Reference to the Business Unit that the RecurringOrder belongs to.

+ * + + * @return null|BusinessUnitKeyReference + */ + public function getBusinessUnit() + { + return $this->businessUnit instanceof BusinessUnitKeyReferenceBuilder ? $this->businessUnit->build() : $this->businessUnit; + } + + /** + *

State of the RecurringOrder in a custom workflow.

+ * + + * @return null|StateReference + */ + public function getState() + { + return $this->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state; + } + + /** + *

Current state of the RecurringOrder.

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

Schedule of the RecurringOrder.

+ * + + * @return null|RecurrencePolicySchedule + */ + public function getSchedule() + { + return $this->schedule instanceof RecurrencePolicyScheduleBuilder ? $this->schedule->build() : $this->schedule; + } + + /** + *

The Customer that the RecurringOrder belongs to.

+ * + + * @return null|CustomerReference + */ + public function getCustomer() + { + return $this->customer instanceof CustomerReferenceBuilder ? $this->customer->build() : $this->customer; + } + + /** + *

Email address of the Customer that the RecurringOrder belongs to.

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

Custom Fields of the RecurringOrder.

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

IDs and references that last modified the RecurringOrder.

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

IDs and references that created the RecurringOrder.

+ * + + * @return null|CreatedBy + */ + public function getCreatedBy() + { + return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy; + } + + /** + * @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 ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?CartReference $cart + * @return $this + */ + public function withCart(?CartReference $cart) + { + $this->cart = $cart; + + return $this; + } + + /** + * @param ?OrderReference $originOrder + * @return $this + */ + public function withOriginOrder(?OrderReference $originOrder) + { + $this->originOrder = $originOrder; + + return $this; + } + + /** + * @param ?DateTimeImmutable $startsAt + * @return $this + */ + public function withStartsAt(?DateTimeImmutable $startsAt) + { + $this->startsAt = $startsAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $resumesAt + * @return $this + */ + public function withResumesAt(?DateTimeImmutable $resumesAt) + { + $this->resumesAt = $resumesAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $expiresAt + * @return $this + */ + public function withExpiresAt(?DateTimeImmutable $expiresAt) + { + $this->expiresAt = $expiresAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $lastOrderAt + * @return $this + */ + public function withLastOrderAt(?DateTimeImmutable $lastOrderAt) + { + $this->lastOrderAt = $lastOrderAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $nextOrderAt + * @return $this + */ + public function withNextOrderAt(?DateTimeImmutable $nextOrderAt) + { + $this->nextOrderAt = $nextOrderAt; + + return $this; + } + + /** + * @param ?SkipConfiguration $skipConfiguration + * @return $this + */ + public function withSkipConfiguration(?SkipConfiguration $skipConfiguration) + { + $this->skipConfiguration = $skipConfiguration; + + return $this; + } + + /** + * @param ?StoreKeyReference $store + * @return $this + */ + public function withStore(?StoreKeyReference $store) + { + $this->store = $store; + + return $this; + } + + /** + * @param ?BusinessUnitKeyReference $businessUnit + * @return $this + */ + public function withBusinessUnit(?BusinessUnitKeyReference $businessUnit) + { + $this->businessUnit = $businessUnit; + + return $this; + } + + /** + * @param ?StateReference $state + * @return $this + */ + public function withState(?StateReference $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?string $recurringOrderState + * @return $this + */ + public function withRecurringOrderState(?string $recurringOrderState) + { + $this->recurringOrderState = $recurringOrderState; + + return $this; + } + + /** + * @param ?RecurrencePolicySchedule $schedule + * @return $this + */ + public function withSchedule(?RecurrencePolicySchedule $schedule) + { + $this->schedule = $schedule; + + return $this; + } + + /** + * @param ?CustomerReference $customer + * @return $this + */ + public function withCustomer(?CustomerReference $customer) + { + $this->customer = $customer; + + return $this; + } + + /** + * @param ?string $customerEmail + * @return $this + */ + public function withCustomerEmail(?string $customerEmail) + { + $this->customerEmail = $customerEmail; + + return $this; + } + + /** + * @param ?CustomFields $custom + * @return $this + */ + public function withCustom(?CustomFields $custom) + { + $this->custom = $custom; + + 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; + } + + /** + * @deprecated use withCart() instead + * @return $this + */ + public function withCartBuilder(?CartReferenceBuilder $cart) + { + $this->cart = $cart; + + return $this; + } + + /** + * @deprecated use withOriginOrder() instead + * @return $this + */ + public function withOriginOrderBuilder(?OrderReferenceBuilder $originOrder) + { + $this->originOrder = $originOrder; + + return $this; + } + + /** + * @deprecated use withSkipConfiguration() instead + * @return $this + */ + public function withSkipConfigurationBuilder(?SkipConfigurationBuilder $skipConfiguration) + { + $this->skipConfiguration = $skipConfiguration; + + return $this; + } + + /** + * @deprecated use withStore() instead + * @return $this + */ + public function withStoreBuilder(?StoreKeyReferenceBuilder $store) + { + $this->store = $store; + + return $this; + } + + /** + * @deprecated use withBusinessUnit() instead + * @return $this + */ + public function withBusinessUnitBuilder(?BusinessUnitKeyReferenceBuilder $businessUnit) + { + $this->businessUnit = $businessUnit; + + return $this; + } + + /** + * @deprecated use withState() instead + * @return $this + */ + public function withStateBuilder(?StateReferenceBuilder $state) + { + $this->state = $state; + + return $this; + } + + /** + * @deprecated use withSchedule() instead + * @return $this + */ + public function withScheduleBuilder(?RecurrencePolicyScheduleBuilder $schedule) + { + $this->schedule = $schedule; + + return $this; + } + + /** + * @deprecated use withCustomer() instead + * @return $this + */ + public function withCustomerBuilder(?CustomerReferenceBuilder $customer) + { + $this->customer = $customer; + + return $this; + } + + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsBuilder $custom) + { + $this->custom = $custom; + + 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; + } + + public function build(): RecurringOrder + { + return new RecurringOrderModel( + $this->id, + $this->version, + $this->createdAt, + $this->lastModifiedAt, + $this->key, + $this->cart instanceof CartReferenceBuilder ? $this->cart->build() : $this->cart, + $this->originOrder instanceof OrderReferenceBuilder ? $this->originOrder->build() : $this->originOrder, + $this->startsAt, + $this->resumesAt, + $this->expiresAt, + $this->lastOrderAt, + $this->nextOrderAt, + $this->skipConfiguration instanceof SkipConfigurationBuilder ? $this->skipConfiguration->build() : $this->skipConfiguration, + $this->store instanceof StoreKeyReferenceBuilder ? $this->store->build() : $this->store, + $this->businessUnit instanceof BusinessUnitKeyReferenceBuilder ? $this->businessUnit->build() : $this->businessUnit, + $this->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state, + $this->recurringOrderState, + $this->schedule instanceof RecurrencePolicyScheduleBuilder ? $this->schedule->build() : $this->schedule, + $this->customer instanceof CustomerReferenceBuilder ? $this->customer->build() : $this->customer, + $this->customerEmail, + $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, + $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy, + $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy + ); + } + + public static function of(): RecurringOrderBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceled.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceled.php new file mode 100644 index 00000000000..4e222fb3651 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceled.php @@ -0,0 +1,30 @@ +The reason for the cancelation.

+ * + + * @return null|string + */ + public function getReason(); + + /** + * @param ?string $reason + */ + public function setReason(?string $reason): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceledBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceledBuilder.php new file mode 100644 index 00000000000..f43706baacd --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceledBuilder.php @@ -0,0 +1,63 @@ + + */ +final class RecurringOrderCanceledBuilder implements Builder +{ + /** + + * @var ?string + */ + private $reason; + + /** + *

The reason for the cancelation.

+ * + + * @return null|string + */ + public function getReason() + { + return $this->reason; + } + + /** + * @param ?string $reason + * @return $this + */ + public function withReason(?string $reason) + { + $this->reason = $reason; + + return $this; + } + + + public function build(): RecurringOrderCanceled + { + return new RecurringOrderCanceledModel( + $this->reason + ); + } + + public static function of(): RecurringOrderCanceledBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceledCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceledCollection.php new file mode 100644 index 00000000000..5af097dc67d --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceledCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderCanceled current() + * @method RecurringOrderCanceled end() + * @method RecurringOrderCanceled at($offset) + */ +class RecurringOrderCanceledCollection extends RecurringOrderStateDraftCollection +{ + /** + * @psalm-assert RecurringOrderCanceled $value + * @psalm-param RecurringOrderCanceled|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCanceledCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderCanceled) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderCanceled + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderCanceled { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderCanceled $data */ + $data = RecurringOrderCanceledModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceledModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceledModel.php new file mode 100644 index 00000000000..9cc9a4582fa --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCanceledModel.php @@ -0,0 +1,93 @@ +reason = $reason; + $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; + } + + /** + *

The reason for the cancelation.

+ * + * + * @return null|string + */ + public function getReason() + { + if (is_null($this->reason)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_REASON); + if (is_null($data)) { + return null; + } + $this->reason = (string) $data; + } + + return $this->reason; + } + + + /** + * @param ?string $reason + */ + public function setReason(?string $reason): void + { + $this->reason = $reason; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCollection.php new file mode 100644 index 00000000000..c76e75ba165 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrder current() + * @method RecurringOrder end() + * @method RecurringOrder at($offset) + */ +class RecurringOrderCollection extends BaseResourceCollection +{ + /** + * @psalm-assert RecurringOrder $value + * @psalm-param RecurringOrder|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrder) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrder + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrder { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrder $data */ + $data = RecurringOrderModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraft.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraft.php new file mode 100644 index 00000000000..3918a0d5242 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraft.php @@ -0,0 +1,104 @@ +User-defined unique identifier of the RecurringOrder.

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

ResourceIdentifier to the Cart from which the RecurringOrder is created.

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

Current version of the referenced Cart.

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

Date and time (UTC) when the RecurringOrder will start.

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

State for the RecurringOrder in a custom workflow.

+ * + + * @return null|StateResourceIdentifier + */ + public function getState(); + + /** + *

Custom Fields for the RecurringOrder.

+ * + + * @return null|CustomFieldsDraft + */ + public function getCustom(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; + + /** + * @param ?CartResourceIdentifier $cart + */ + public function setCart(?CartResourceIdentifier $cart): void; + + /** + * @param ?int $cartVersion + */ + public function setCartVersion(?int $cartVersion): void; + + /** + * @param ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void; + + /** + * @param ?StateResourceIdentifier $state + */ + public function setState(?StateResourceIdentifier $state): void; + + /** + * @param ?CustomFieldsDraft $custom + */ + public function setCustom(?CustomFieldsDraft $custom): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraftBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraftBuilder.php new file mode 100644 index 00000000000..2fc1e4e4c80 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraftBuilder.php @@ -0,0 +1,247 @@ + + */ +final class RecurringOrderDraftBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + + * @var null|CartResourceIdentifier|CartResourceIdentifierBuilder + */ + private $cart; + + /** + + * @var ?int + */ + private $cartVersion; + + /** + + * @var ?DateTimeImmutable + */ + private $startsAt; + + /** + + * @var null|StateResourceIdentifier|StateResourceIdentifierBuilder + */ + private $state; + + /** + + * @var null|CustomFieldsDraft|CustomFieldsDraftBuilder + */ + private $custom; + + /** + *

User-defined unique identifier of the RecurringOrder.

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

ResourceIdentifier to the Cart from which the RecurringOrder is created.

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

Current version of the referenced Cart.

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

Date and time (UTC) when the RecurringOrder will start.

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

State for the RecurringOrder in a custom workflow.

+ * + + * @return null|StateResourceIdentifier + */ + public function getState() + { + return $this->state instanceof StateResourceIdentifierBuilder ? $this->state->build() : $this->state; + } + + /** + *

Custom Fields for the RecurringOrder.

+ * + + * @return null|CustomFieldsDraft + */ + public function getCustom() + { + return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom; + } + + /** + * @param ?string $key + * @return $this + */ + public function withKey(?string $key) + { + $this->key = $key; + + return $this; + } + + /** + * @param ?CartResourceIdentifier $cart + * @return $this + */ + public function withCart(?CartResourceIdentifier $cart) + { + $this->cart = $cart; + + return $this; + } + + /** + * @param ?int $cartVersion + * @return $this + */ + public function withCartVersion(?int $cartVersion) + { + $this->cartVersion = $cartVersion; + + return $this; + } + + /** + * @param ?DateTimeImmutable $startsAt + * @return $this + */ + public function withStartsAt(?DateTimeImmutable $startsAt) + { + $this->startsAt = $startsAt; + + return $this; + } + + /** + * @param ?StateResourceIdentifier $state + * @return $this + */ + public function withState(?StateResourceIdentifier $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?CustomFieldsDraft $custom + * @return $this + */ + public function withCustom(?CustomFieldsDraft $custom) + { + $this->custom = $custom; + + return $this; + } + + /** + * @deprecated use withCart() instead + * @return $this + */ + public function withCartBuilder(?CartResourceIdentifierBuilder $cart) + { + $this->cart = $cart; + + return $this; + } + + /** + * @deprecated use withState() instead + * @return $this + */ + public function withStateBuilder(?StateResourceIdentifierBuilder $state) + { + $this->state = $state; + + return $this; + } + + /** + * @deprecated use withCustom() instead + * @return $this + */ + public function withCustomBuilder(?CustomFieldsDraftBuilder $custom) + { + $this->custom = $custom; + + return $this; + } + + public function build(): RecurringOrderDraft + { + return new RecurringOrderDraftModel( + $this->key, + $this->cart instanceof CartResourceIdentifierBuilder ? $this->cart->build() : $this->cart, + $this->cartVersion, + $this->startsAt, + $this->state instanceof StateResourceIdentifierBuilder ? $this->state->build() : $this->state, + $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom + ); + } + + public static function of(): RecurringOrderDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraftCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraftCollection.php new file mode 100644 index 00000000000..3fb1c74eb8a --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraftCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderDraft current() + * @method RecurringOrderDraft end() + * @method RecurringOrderDraft at($offset) + */ +class RecurringOrderDraftCollection extends MapperSequence +{ + /** + * @psalm-assert RecurringOrderDraft $value + * @psalm-param RecurringOrderDraft|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderDraftCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderDraft + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderDraft $data */ + $data = RecurringOrderDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraftModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraftModel.php new file mode 100644 index 00000000000..667f5fce76d --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderDraftModel.php @@ -0,0 +1,271 @@ +key = $key; + $this->cart = $cart; + $this->cartVersion = $cartVersion; + $this->startsAt = $startsAt; + $this->state = $state; + $this->custom = $custom; + } + + /** + *

User-defined unique identifier of the RecurringOrder.

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

ResourceIdentifier to the Cart from which the RecurringOrder is created.

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

Current version of the referenced Cart.

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

Date and time (UTC) when the RecurringOrder will start.

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

State for the RecurringOrder in a custom workflow.

+ * + * + * @return null|StateResourceIdentifier + */ + public function getState() + { + if (is_null($this->state)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_STATE); + if (is_null($data)) { + return null; + } + + $this->state = StateResourceIdentifierModel::of($data); + } + + return $this->state; + } + + /** + *

Custom Fields for the RecurringOrder.

+ * + * + * @return null|CustomFieldsDraft + */ + 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 = CustomFieldsDraftModel::of($data); + } + + return $this->custom; + } + + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?CartResourceIdentifier $cart + */ + public function setCart(?CartResourceIdentifier $cart): void + { + $this->cart = $cart; + } + + /** + * @param ?int $cartVersion + */ + public function setCartVersion(?int $cartVersion): void + { + $this->cartVersion = $cartVersion; + } + + /** + * @param ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void + { + $this->startsAt = $startsAt; + } + + /** + * @param ?StateResourceIdentifier $state + */ + public function setState(?StateResourceIdentifier $state): void + { + $this->state = $state; + } + + /** + * @param ?CustomFieldsDraft $custom + */ + public function setCustom(?CustomFieldsDraft $custom): void + { + $this->custom = $custom; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[RecurringOrderDraft::FIELD_STARTS_AT]) && $data[RecurringOrderDraft::FIELD_STARTS_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderDraft::FIELD_STARTS_AT] = $data[RecurringOrderDraft::FIELD_STARTS_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderExpired.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderExpired.php new file mode 100644 index 00000000000..5f535b529b4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderExpired.php @@ -0,0 +1,16 @@ + + */ +final class RecurringOrderExpiredBuilder implements Builder +{ + public function build(): RecurringOrderExpired + { + return new RecurringOrderExpiredModel( + ); + } + + public static function of(): RecurringOrderExpiredBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderExpiredCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderExpiredCollection.php new file mode 100644 index 00000000000..c1cf5e06d59 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderExpiredCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderExpired current() + * @method RecurringOrderExpired end() + * @method RecurringOrderExpired at($offset) + */ +class RecurringOrderExpiredCollection extends RecurringOrderStateDraftCollection +{ + /** + * @psalm-assert RecurringOrderExpired $value + * @psalm-param RecurringOrderExpired|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderExpiredCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderExpired) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderExpired + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderExpired { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderExpired $data */ + $data = RecurringOrderExpiredModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderExpiredModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderExpiredModel.php new file mode 100644 index 00000000000..ef114f8c545 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderExpiredModel.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/RecurringOrder/RecurringOrderModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderModel.php new file mode 100644 index 00000000000..0856e9a9816 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderModel.php @@ -0,0 +1,956 @@ +id = $id; + $this->version = $version; + $this->createdAt = $createdAt; + $this->lastModifiedAt = $lastModifiedAt; + $this->key = $key; + $this->cart = $cart; + $this->originOrder = $originOrder; + $this->startsAt = $startsAt; + $this->resumesAt = $resumesAt; + $this->expiresAt = $expiresAt; + $this->lastOrderAt = $lastOrderAt; + $this->nextOrderAt = $nextOrderAt; + $this->skipConfiguration = $skipConfiguration; + $this->store = $store; + $this->businessUnit = $businessUnit; + $this->state = $state; + $this->recurringOrderState = $recurringOrderState; + $this->schedule = $schedule; + $this->customer = $customer; + $this->customerEmail = $customerEmail; + $this->custom = $custom; + $this->lastModifiedBy = $lastModifiedBy; + $this->createdBy = $createdBy; + } + + /** + *

Unique identifier of the RecurringOrder.

+ * + * + * @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 RecurringOrder.

+ * + * + * @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) when the RecurringOrder was created.

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

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

User-defined unique identifier of the RecurringOrder.

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

Reference to the Cart for a RecurringOrder. + * The referenced Cart will have the RecurringOrder CartOrigin.

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

Reference to the original Order that generated this RecurringOrder.

+ * + * + * @return null|OrderReference + */ + public function getOriginOrder() + { + if (is_null($this->originOrder)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_ORIGIN_ORDER); + if (is_null($data)) { + return null; + } + + $this->originOrder = OrderReferenceModel::of($data); + } + + return $this->originOrder; + } + + /** + *

Date and time (UTC) when the RecurringOrder starts creating new Orders.

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

Date and time (UTC) when the RecurringOrder resumes creating Orders after being unpaused.

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

Date and time (UTC) when the RecurringOrder expires.

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

Date and time (UTC) when the last Order was created from this RecurringOrder.

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

Date and time (UTC) when the next Order will be created from this RecurringOrder.

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

Information about current and future skips for this RecurringOrder.

+ * + * + * @return null|SkipConfiguration + */ + public function getSkipConfiguration() + { + if (is_null($this->skipConfiguration)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SKIP_CONFIGURATION); + if (is_null($data)) { + return null; + } + $className = SkipConfigurationModel::resolveDiscriminatorClass($data); + $this->skipConfiguration = $className::of($data); + } + + return $this->skipConfiguration; + } + + /** + *

Reference to a Store.

+ * + * + * @return null|StoreKeyReference + */ + public function getStore() + { + if (is_null($this->store)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_STORE); + if (is_null($data)) { + return null; + } + + $this->store = StoreKeyReferenceModel::of($data); + } + + return $this->store; + } + + /** + *

Reference to the Business Unit that the RecurringOrder belongs to.

+ * + * + * @return null|BusinessUnitKeyReference + */ + public function getBusinessUnit() + { + if (is_null($this->businessUnit)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_BUSINESS_UNIT); + if (is_null($data)) { + return null; + } + + $this->businessUnit = BusinessUnitKeyReferenceModel::of($data); + } + + return $this->businessUnit; + } + + /** + *

State of the RecurringOrder in a custom workflow.

+ * + * + * @return null|StateReference + */ + public function getState() + { + if (is_null($this->state)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_STATE); + if (is_null($data)) { + return null; + } + + $this->state = StateReferenceModel::of($data); + } + + return $this->state; + } + + /** + *

Current state of the RecurringOrder.

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

Schedule of the RecurringOrder.

+ * + * + * @return null|RecurrencePolicySchedule + */ + public function getSchedule() + { + if (is_null($this->schedule)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SCHEDULE); + if (is_null($data)) { + return null; + } + $className = RecurrencePolicyScheduleModel::resolveDiscriminatorClass($data); + $this->schedule = $className::of($data); + } + + return $this->schedule; + } + + /** + *

The Customer that the RecurringOrder belongs to.

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

Email address of the Customer that the RecurringOrder belongs to.

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

Custom Fields of the RecurringOrder.

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

IDs and references that last modified the RecurringOrder.

+ * + * + * @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 RecurringOrder.

+ * + * + * @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; + } + + + /** + * @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 ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } + + /** + * @param ?CartReference $cart + */ + public function setCart(?CartReference $cart): void + { + $this->cart = $cart; + } + + /** + * @param ?OrderReference $originOrder + */ + public function setOriginOrder(?OrderReference $originOrder): void + { + $this->originOrder = $originOrder; + } + + /** + * @param ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void + { + $this->startsAt = $startsAt; + } + + /** + * @param ?DateTimeImmutable $resumesAt + */ + public function setResumesAt(?DateTimeImmutable $resumesAt): void + { + $this->resumesAt = $resumesAt; + } + + /** + * @param ?DateTimeImmutable $expiresAt + */ + public function setExpiresAt(?DateTimeImmutable $expiresAt): void + { + $this->expiresAt = $expiresAt; + } + + /** + * @param ?DateTimeImmutable $lastOrderAt + */ + public function setLastOrderAt(?DateTimeImmutable $lastOrderAt): void + { + $this->lastOrderAt = $lastOrderAt; + } + + /** + * @param ?DateTimeImmutable $nextOrderAt + */ + public function setNextOrderAt(?DateTimeImmutable $nextOrderAt): void + { + $this->nextOrderAt = $nextOrderAt; + } + + /** + * @param ?SkipConfiguration $skipConfiguration + */ + public function setSkipConfiguration(?SkipConfiguration $skipConfiguration): void + { + $this->skipConfiguration = $skipConfiguration; + } + + /** + * @param ?StoreKeyReference $store + */ + public function setStore(?StoreKeyReference $store): void + { + $this->store = $store; + } + + /** + * @param ?BusinessUnitKeyReference $businessUnit + */ + public function setBusinessUnit(?BusinessUnitKeyReference $businessUnit): void + { + $this->businessUnit = $businessUnit; + } + + /** + * @param ?StateReference $state + */ + public function setState(?StateReference $state): void + { + $this->state = $state; + } + + /** + * @param ?string $recurringOrderState + */ + public function setRecurringOrderState(?string $recurringOrderState): void + { + $this->recurringOrderState = $recurringOrderState; + } + + /** + * @param ?RecurrencePolicySchedule $schedule + */ + public function setSchedule(?RecurrencePolicySchedule $schedule): void + { + $this->schedule = $schedule; + } + + /** + * @param ?CustomerReference $customer + */ + public function setCustomer(?CustomerReference $customer): void + { + $this->customer = $customer; + } + + /** + * @param ?string $customerEmail + */ + public function setCustomerEmail(?string $customerEmail): void + { + $this->customerEmail = $customerEmail; + } + + /** + * @param ?CustomFields $custom + */ + public function setCustom(?CustomFields $custom): void + { + $this->custom = $custom; + } + + /** + * @param ?LastModifiedBy $lastModifiedBy + */ + public function setLastModifiedBy(?LastModifiedBy $lastModifiedBy): void + { + $this->lastModifiedBy = $lastModifiedBy; + } + + /** + * @param ?CreatedBy $createdBy + */ + public function setCreatedBy(?CreatedBy $createdBy): void + { + $this->createdBy = $createdBy; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[RecurringOrder::FIELD_CREATED_AT]) && $data[RecurringOrder::FIELD_CREATED_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrder::FIELD_CREATED_AT] = $data[RecurringOrder::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrder::FIELD_LAST_MODIFIED_AT]) && $data[RecurringOrder::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrder::FIELD_LAST_MODIFIED_AT] = $data[RecurringOrder::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrder::FIELD_STARTS_AT]) && $data[RecurringOrder::FIELD_STARTS_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrder::FIELD_STARTS_AT] = $data[RecurringOrder::FIELD_STARTS_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrder::FIELD_RESUMES_AT]) && $data[RecurringOrder::FIELD_RESUMES_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrder::FIELD_RESUMES_AT] = $data[RecurringOrder::FIELD_RESUMES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrder::FIELD_EXPIRES_AT]) && $data[RecurringOrder::FIELD_EXPIRES_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrder::FIELD_EXPIRES_AT] = $data[RecurringOrder::FIELD_EXPIRES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrder::FIELD_LAST_ORDER_AT]) && $data[RecurringOrder::FIELD_LAST_ORDER_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrder::FIELD_LAST_ORDER_AT] = $data[RecurringOrder::FIELD_LAST_ORDER_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[RecurringOrder::FIELD_NEXT_ORDER_AT]) && $data[RecurringOrder::FIELD_NEXT_ORDER_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrder::FIELD_NEXT_ORDER_AT] = $data[RecurringOrder::FIELD_NEXT_ORDER_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponse.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponse.php new file mode 100644 index 00000000000..f2052603769 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponse.php @@ -0,0 +1,90 @@ +Number of results requested.

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

Number of elements skipped.

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

Actual number of results returned.

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

Total number of results matching the query. + * This number is an estimation that is not strongly consistent. + * This field is returned by default. + * For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. + * When the results are filtered with a Query Predicate, total is subject to a limit.

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

RecurringOrders matching the query.

+ * + + * @return null|RecurringOrderCollection + */ + public function getResults(); + + /** + * @param ?int $limit + */ + public function setLimit(?int $limit): void; + + /** + * @param ?int $offset + */ + public function setOffset(?int $offset): void; + + /** + * @param ?int $count + */ + public function setCount(?int $count): void; + + /** + * @param ?int $total + */ + public function setTotal(?int $total): void; + + /** + * @param ?RecurringOrderCollection $results + */ + public function setResults(?RecurringOrderCollection $results): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponseBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponseBuilder.php new file mode 100644 index 00000000000..049900475b5 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponseBuilder.php @@ -0,0 +1,183 @@ + + */ +final class RecurringOrderPagedQueryResponseBuilder implements Builder +{ + /** + + * @var ?int + */ + private $limit; + + /** + + * @var ?int + */ + private $offset; + + /** + + * @var ?int + */ + private $count; + + /** + + * @var ?int + */ + private $total; + + /** + + * @var ?RecurringOrderCollection + */ + private $results; + + /** + *

Number of results requested.

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

Number of elements skipped.

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

Actual number of results returned.

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

Total number of results matching the query. + * This number is an estimation that is not strongly consistent. + * This field is returned by default. + * For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. + * When the results are filtered with a Query Predicate, total is subject to a limit.

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

RecurringOrders matching the query.

+ * + + * @return null|RecurringOrderCollection + */ + public function getResults() + { + return $this->results; + } + + /** + * @param ?int $limit + * @return $this + */ + public function withLimit(?int $limit) + { + $this->limit = $limit; + + return $this; + } + + /** + * @param ?int $offset + * @return $this + */ + public function withOffset(?int $offset) + { + $this->offset = $offset; + + return $this; + } + + /** + * @param ?int $count + * @return $this + */ + public function withCount(?int $count) + { + $this->count = $count; + + return $this; + } + + /** + * @param ?int $total + * @return $this + */ + public function withTotal(?int $total) + { + $this->total = $total; + + return $this; + } + + /** + * @param ?RecurringOrderCollection $results + * @return $this + */ + public function withResults(?RecurringOrderCollection $results) + { + $this->results = $results; + + return $this; + } + + + public function build(): RecurringOrderPagedQueryResponse + { + return new RecurringOrderPagedQueryResponseModel( + $this->limit, + $this->offset, + $this->count, + $this->total, + $this->results + ); + } + + public static function of(): RecurringOrderPagedQueryResponseBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponseCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponseCollection.php new file mode 100644 index 00000000000..cc5b06bb2d6 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponseCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderPagedQueryResponse current() + * @method RecurringOrderPagedQueryResponse end() + * @method RecurringOrderPagedQueryResponse at($offset) + */ +class RecurringOrderPagedQueryResponseCollection extends MapperSequence +{ + /** + * @psalm-assert RecurringOrderPagedQueryResponse $value + * @psalm-param RecurringOrderPagedQueryResponse|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderPagedQueryResponseCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderPagedQueryResponse) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderPagedQueryResponse + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderPagedQueryResponse { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderPagedQueryResponse $data */ + $data = RecurringOrderPagedQueryResponseModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponseModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponseModel.php new file mode 100644 index 00000000000..842fb55205b --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPagedQueryResponseModel.php @@ -0,0 +1,214 @@ +limit = $limit; + $this->offset = $offset; + $this->count = $count; + $this->total = $total; + $this->results = $results; + } + + /** + *

Number of results requested.

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

Number of elements skipped.

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

Actual number of results returned.

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

Total number of results matching the query. + * This number is an estimation that is not strongly consistent. + * This field is returned by default. + * For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. + * When the results are filtered with a Query Predicate, total is subject to a limit.

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

RecurringOrders matching the query.

+ * + * + * @return null|RecurringOrderCollection + */ + public function getResults() + { + if (is_null($this->results)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_RESULTS); + if (is_null($data)) { + return null; + } + $this->results = RecurringOrderCollection::fromArray($data); + } + + return $this->results; + } + + + /** + * @param ?int $limit + */ + public function setLimit(?int $limit): void + { + $this->limit = $limit; + } + + /** + * @param ?int $offset + */ + public function setOffset(?int $offset): void + { + $this->offset = $offset; + } + + /** + * @param ?int $count + */ + public function setCount(?int $count): void + { + $this->count = $count; + } + + /** + * @param ?int $total + */ + public function setTotal(?int $total): void + { + $this->total = $total; + } + + /** + * @param ?RecurringOrderCollection $results + */ + public function setResults(?RecurringOrderCollection $results): void + { + $this->results = $results; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPaused.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPaused.php new file mode 100644 index 00000000000..94d8c5c08d0 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPaused.php @@ -0,0 +1,16 @@ + + */ +final class RecurringOrderPausedBuilder implements Builder +{ + public function build(): RecurringOrderPaused + { + return new RecurringOrderPausedModel( + ); + } + + public static function of(): RecurringOrderPausedBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPausedCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPausedCollection.php new file mode 100644 index 00000000000..389c55b493d --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPausedCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderPaused current() + * @method RecurringOrderPaused end() + * @method RecurringOrderPaused at($offset) + */ +class RecurringOrderPausedCollection extends RecurringOrderStateDraftCollection +{ + /** + * @psalm-assert RecurringOrderPaused $value + * @psalm-param RecurringOrderPaused|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderPausedCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderPaused) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderPaused + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderPaused { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderPaused $data */ + $data = RecurringOrderPausedModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPausedModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPausedModel.php new file mode 100644 index 00000000000..77edb55285c --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderPausedModel.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/RecurringOrder/RecurringOrderReference.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReference.php new file mode 100644 index 00000000000..4f4f0d89af3 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReference.php @@ -0,0 +1,45 @@ +Contains the representation of the expanded RecurringOrder. + * Only present in responses to requests with Reference Expansion for RecurringOrders.

+ * + + * @return null|RecurringOrder + */ + public function getObj(); + + /** + *

Unique identifier of the referenced RecurringOrder.

+ * + + * @return null|string + */ + public function getId(); + + /** + * @param ?RecurringOrder $obj + */ + public function setObj(?RecurringOrder $obj): void; + + /** + * @param ?string $id + */ + public function setId(?string $id): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReferenceBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReferenceBuilder.php new file mode 100644 index 00000000000..302d8443949 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReferenceBuilder.php @@ -0,0 +1,105 @@ + + */ +final class RecurringOrderReferenceBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var null|RecurringOrder|RecurringOrderBuilder + */ + private $obj; + + /** + *

Unique identifier of the referenced RecurringOrder.

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

Contains the representation of the expanded RecurringOrder. + * Only present in responses to requests with Reference Expansion for RecurringOrders.

+ * + + * @return null|RecurringOrder + */ + public function getObj() + { + return $this->obj instanceof RecurringOrderBuilder ? $this->obj->build() : $this->obj; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?RecurringOrder $obj + * @return $this + */ + public function withObj(?RecurringOrder $obj) + { + $this->obj = $obj; + + return $this; + } + + /** + * @deprecated use withObj() instead + * @return $this + */ + public function withObjBuilder(?RecurringOrderBuilder $obj) + { + $this->obj = $obj; + + return $this; + } + + public function build(): RecurringOrderReference + { + return new RecurringOrderReferenceModel( + $this->id, + $this->obj instanceof RecurringOrderBuilder ? $this->obj->build() : $this->obj + ); + } + + public static function of(): RecurringOrderReferenceBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReferenceCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReferenceCollection.php new file mode 100644 index 00000000000..539c4df64c2 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReferenceCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderReference current() + * @method RecurringOrderReference end() + * @method RecurringOrderReference at($offset) + */ +class RecurringOrderReferenceCollection extends ReferenceCollection +{ + /** + * @psalm-assert RecurringOrderReference $value + * @psalm-param RecurringOrderReference|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderReferenceCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderReference) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderReference + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderReference { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderReference $data */ + $data = RecurringOrderReferenceModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReferenceModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReferenceModel.php new file mode 100644 index 00000000000..9f9cf582bd9 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderReferenceModel.php @@ -0,0 +1,135 @@ +id = $id; + $this->obj = $obj; + $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 RecurringOrder.

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

Contains the representation of the expanded RecurringOrder. + * Only present in responses to requests with Reference Expansion for RecurringOrders.

+ * + * + * @return null|RecurringOrder + */ + public function getObj() + { + if (is_null($this->obj)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_OBJ); + if (is_null($data)) { + return null; + } + + $this->obj = RecurringOrderModel::of($data); + } + + return $this->obj; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?RecurringOrder $obj + */ + public function setObj(?RecurringOrder $obj): void + { + $this->obj = $obj; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifier.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifier.php new file mode 100644 index 00000000000..cfc9fda2394 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifier.php @@ -0,0 +1,42 @@ +Unique identifier of the referenced RecurringOrder. Required if key is absent.

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

User-defined unique identifier of the referenced RecurringOrder. 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-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifierBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifierBuilder.php new file mode 100644 index 00000000000..4e872eac3c4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifierBuilder.php @@ -0,0 +1,94 @@ + + */ +final class RecurringOrderResourceIdentifierBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?string + */ + private $key; + + /** + *

Unique identifier of the referenced RecurringOrder. Required if key is absent.

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

User-defined unique identifier of the referenced RecurringOrder. Required if id is absent.

+ * + + * @return null|string + */ + public function getKey() + { + return $this->key; + } + + /** + * @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; + } + + + public function build(): RecurringOrderResourceIdentifier + { + return new RecurringOrderResourceIdentifierModel( + $this->id, + $this->key + ); + } + + public static function of(): RecurringOrderResourceIdentifierBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifierCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifierCollection.php new file mode 100644 index 00000000000..6efc824ee39 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifierCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderResourceIdentifier current() + * @method RecurringOrderResourceIdentifier end() + * @method RecurringOrderResourceIdentifier at($offset) + */ +class RecurringOrderResourceIdentifierCollection extends ResourceIdentifierCollection +{ + /** + * @psalm-assert RecurringOrderResourceIdentifier $value + * @psalm-param RecurringOrderResourceIdentifier|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderResourceIdentifierCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderResourceIdentifier) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderResourceIdentifier + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderResourceIdentifier { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderResourceIdentifier $data */ + $data = RecurringOrderResourceIdentifierModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifierModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifierModel.php new file mode 100644 index 00000000000..27cad21f7d4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderResourceIdentifierModel.php @@ -0,0 +1,133 @@ +id = $id; + $this->key = $key; + $this->typeId = $typeId ?? self::DISCRIMINATOR_VALUE; + } + + /** + *

Type of referenced resource. If given, it must match the expected ReferenceTypeId of the 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 RecurringOrder. 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; + } + + /** + *

User-defined unique identifier of the referenced RecurringOrder. 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; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?string $key + */ + public function setKey(?string $key): void + { + $this->key = $key; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldAction.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldAction.php new file mode 100644 index 00000000000..30070732453 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldAction.php @@ -0,0 +1,46 @@ +Name of the Custom Field.

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

If value is absent or null, this field will be removed if it exists. + * Removing a field that does not exist returns an InvalidOperation error. + * If value is provided, it is set for the field defined by name.

+ * + + * @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-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldActionBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldActionBuilder.php new file mode 100644 index 00000000000..2260f8bd939 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldActionBuilder.php @@ -0,0 +1,94 @@ + + */ +final class RecurringOrderSetCustomFieldActionBuilder implements Builder +{ + /** + + * @var ?string + */ + private $name; + + /** + + * @var null|mixed|mixed + */ + private $value; + + /** + *

Name of the Custom Field.

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

If value is absent or null, this field will be removed if it exists. + * Removing a field that does not exist returns an InvalidOperation error. + * If value is provided, it is set for the field defined by name.

+ * + + * @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(): RecurringOrderSetCustomFieldAction + { + return new RecurringOrderSetCustomFieldActionModel( + $this->name, + $this->value + ); + } + + public static function of(): RecurringOrderSetCustomFieldActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldActionCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldActionCollection.php new file mode 100644 index 00000000000..cff341fdded --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderSetCustomFieldAction current() + * @method RecurringOrderSetCustomFieldAction end() + * @method RecurringOrderSetCustomFieldAction at($offset) + */ +class RecurringOrderSetCustomFieldActionCollection extends RecurringOrderUpdateActionCollection +{ + /** + * @psalm-assert RecurringOrderSetCustomFieldAction $value + * @psalm-param RecurringOrderSetCustomFieldAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderSetCustomFieldActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderSetCustomFieldAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderSetCustomFieldAction + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderSetCustomFieldAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderSetCustomFieldAction $data */ + $data = RecurringOrderSetCustomFieldActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldActionModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldActionModel.php new file mode 100644 index 00000000000..f986f88781a --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomFieldActionModel.php @@ -0,0 +1,131 @@ +name = $name; + $this->value = $value; + $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; + } + + /** + *

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

If value is absent or null, this field will be removed if it exists. + * Removing a field that does not exist returns an InvalidOperation error. + * If value is provided, it is set for the field defined by name.

+ * + * + * @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-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeAction.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeAction.php new file mode 100644 index 00000000000..6d67de6fdcd --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeAction.php @@ -0,0 +1,47 @@ +Defines the Type that extends the RecurringOrder with Custom Fields. + * If absent, any existing Type and Custom Fields are removed from the RecurringOrder.

+ * + + * @return null|TypeResourceIdentifier + */ + public function getType(); + + /** + *

Sets the Custom Fields fields for the RecurringOrder.

+ * + + * @return null|FieldContainer + */ + public function getFields(); + + /** + * @param ?TypeResourceIdentifier $type + */ + public function setType(?TypeResourceIdentifier $type): void; + + /** + * @param ?FieldContainer $fields + */ + public function setFields(?FieldContainer $fields): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeActionBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeActionBuilder.php new file mode 100644 index 00000000000..702034e2682 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeActionBuilder.php @@ -0,0 +1,118 @@ + + */ +final class RecurringOrderSetCustomTypeActionBuilder implements Builder +{ + /** + + * @var null|TypeResourceIdentifier|TypeResourceIdentifierBuilder + */ + private $type; + + /** + + * @var null|FieldContainer|FieldContainerBuilder + */ + private $fields; + + /** + *

Defines the Type that extends the RecurringOrder with Custom Fields. + * If absent, any existing Type and Custom Fields are removed from the RecurringOrder.

+ * + + * @return null|TypeResourceIdentifier + */ + public function getType() + { + return $this->type instanceof TypeResourceIdentifierBuilder ? $this->type->build() : $this->type; + } + + /** + *

Sets the Custom Fields fields for the RecurringOrder.

+ * + + * @return null|FieldContainer + */ + public function getFields() + { + return $this->fields instanceof FieldContainerBuilder ? $this->fields->build() : $this->fields; + } + + /** + * @param ?TypeResourceIdentifier $type + * @return $this + */ + public function withType(?TypeResourceIdentifier $type) + { + $this->type = $type; + + return $this; + } + + /** + * @param ?FieldContainer $fields + * @return $this + */ + public function withFields(?FieldContainer $fields) + { + $this->fields = $fields; + + return $this; + } + + /** + * @deprecated use withType() instead + * @return $this + */ + public function withTypeBuilder(?TypeResourceIdentifierBuilder $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(): RecurringOrderSetCustomTypeAction + { + return new RecurringOrderSetCustomTypeActionModel( + $this->type instanceof TypeResourceIdentifierBuilder ? $this->type->build() : $this->type, + $this->fields instanceof FieldContainerBuilder ? $this->fields->build() : $this->fields + ); + } + + public static function of(): RecurringOrderSetCustomTypeActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeActionCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeActionCollection.php new file mode 100644 index 00000000000..326de18b654 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderSetCustomTypeAction current() + * @method RecurringOrderSetCustomTypeAction end() + * @method RecurringOrderSetCustomTypeAction at($offset) + */ +class RecurringOrderSetCustomTypeActionCollection extends RecurringOrderUpdateActionCollection +{ + /** + * @psalm-assert RecurringOrderSetCustomTypeAction $value + * @psalm-param RecurringOrderSetCustomTypeAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderSetCustomTypeActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderSetCustomTypeAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderSetCustomTypeAction + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderSetCustomTypeAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderSetCustomTypeAction $data */ + $data = RecurringOrderSetCustomTypeActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeActionModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeActionModel.php new file mode 100644 index 00000000000..d0d7682cecf --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetCustomTypeActionModel.php @@ -0,0 +1,136 @@ +type = $type; + $this->fields = $fields; + $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; + } + + /** + *

Defines the Type that extends the RecurringOrder with Custom Fields. + * If absent, any existing Type and Custom Fields are removed from the RecurringOrder.

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

Sets the Custom Fields fields for the RecurringOrder.

+ * + * + * @return null|FieldContainer + */ + public function getFields() + { + if (is_null($this->fields)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_FIELDS); + if (is_null($data)) { + return null; + } + + $this->fields = FieldContainerModel::of($data); + } + + return $this->fields; + } + + + /** + * @param ?TypeResourceIdentifier $type + */ + public function setType(?TypeResourceIdentifier $type): void + { + $this->type = $type; + } + + /** + * @param ?FieldContainer $fields + */ + public function setFields(?FieldContainer $fields): void + { + $this->fields = $fields; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyAction.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyAction.php new file mode 100644 index 00000000000..955594ee272 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyAction.php @@ -0,0 +1,31 @@ +Value to set. + * If empty, any existing key will be removed.

+ * + + * @return null|string + */ + public function getKey(); + + /** + * @param ?string $key + */ + public function setKey(?string $key): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyActionBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyActionBuilder.php new file mode 100644 index 00000000000..c350127914c --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyActionBuilder.php @@ -0,0 +1,64 @@ + + */ +final class RecurringOrderSetKeyActionBuilder implements Builder +{ + /** + + * @var ?string + */ + private $key; + + /** + *

Value to set. + * If empty, any existing key will be removed.

+ * + + * @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(): RecurringOrderSetKeyAction + { + return new RecurringOrderSetKeyActionModel( + $this->key + ); + } + + public static function of(): RecurringOrderSetKeyActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyActionCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyActionCollection.php new file mode 100644 index 00000000000..75a1a989f24 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderSetKeyAction current() + * @method RecurringOrderSetKeyAction end() + * @method RecurringOrderSetKeyAction at($offset) + */ +class RecurringOrderSetKeyActionCollection extends RecurringOrderUpdateActionCollection +{ + /** + * @psalm-assert RecurringOrderSetKeyAction $value + * @psalm-param RecurringOrderSetKeyAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderSetKeyActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderSetKeyAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderSetKeyAction + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderSetKeyAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderSetKeyAction $data */ + $data = RecurringOrderSetKeyActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyActionModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyActionModel.php new file mode 100644 index 00000000000..479c0e04e05 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetKeyActionModel.php @@ -0,0 +1,94 @@ +key = $key; + $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; + } + + /** + *

Value to set. + * If empty, any existing key will be removed.

+ * + * + * @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-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationAction.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationAction.php new file mode 100644 index 00000000000..fb276ab581f --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationAction.php @@ -0,0 +1,45 @@ +Configuration for skipping the next orders of the Recurring Order.

+ * + + * @return null|SkipConfigurationDraft + */ + public function getSkipConfiguration(); + + /** + *

Date and time (UTC) the Recurring Order will resume and start to generate new orders.

+ * + + * @return null|DateTimeImmutable + */ + public function getUpdatedExpiresAt(); + + /** + * @param ?SkipConfigurationDraft $skipConfiguration + */ + public function setSkipConfiguration(?SkipConfigurationDraft $skipConfiguration): void; + + /** + * @param ?DateTimeImmutable $updatedExpiresAt + */ + public function setUpdatedExpiresAt(?DateTimeImmutable $updatedExpiresAt): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationActionBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationActionBuilder.php new file mode 100644 index 00000000000..e711b0aa44a --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationActionBuilder.php @@ -0,0 +1,103 @@ + + */ +final class RecurringOrderSetOrderSkipConfigurationActionBuilder implements Builder +{ + /** + + * @var null|SkipConfigurationDraft|SkipConfigurationDraftBuilder + */ + private $skipConfiguration; + + /** + + * @var ?DateTimeImmutable + */ + private $updatedExpiresAt; + + /** + *

Configuration for skipping the next orders of the Recurring Order.

+ * + + * @return null|SkipConfigurationDraft + */ + public function getSkipConfiguration() + { + return $this->skipConfiguration instanceof SkipConfigurationDraftBuilder ? $this->skipConfiguration->build() : $this->skipConfiguration; + } + + /** + *

Date and time (UTC) the Recurring Order will resume and start to generate new orders.

+ * + + * @return null|DateTimeImmutable + */ + public function getUpdatedExpiresAt() + { + return $this->updatedExpiresAt; + } + + /** + * @param ?SkipConfigurationDraft $skipConfiguration + * @return $this + */ + public function withSkipConfiguration(?SkipConfigurationDraft $skipConfiguration) + { + $this->skipConfiguration = $skipConfiguration; + + return $this; + } + + /** + * @param ?DateTimeImmutable $updatedExpiresAt + * @return $this + */ + public function withUpdatedExpiresAt(?DateTimeImmutable $updatedExpiresAt) + { + $this->updatedExpiresAt = $updatedExpiresAt; + + return $this; + } + + /** + * @deprecated use withSkipConfiguration() instead + * @return $this + */ + public function withSkipConfigurationBuilder(?SkipConfigurationDraftBuilder $skipConfiguration) + { + $this->skipConfiguration = $skipConfiguration; + + return $this; + } + + public function build(): RecurringOrderSetOrderSkipConfigurationAction + { + return new RecurringOrderSetOrderSkipConfigurationActionModel( + $this->skipConfiguration instanceof SkipConfigurationDraftBuilder ? $this->skipConfiguration->build() : $this->skipConfiguration, + $this->updatedExpiresAt + ); + } + + public static function of(): RecurringOrderSetOrderSkipConfigurationActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationActionCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationActionCollection.php new file mode 100644 index 00000000000..a2a59600fcb --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderSetOrderSkipConfigurationAction current() + * @method RecurringOrderSetOrderSkipConfigurationAction end() + * @method RecurringOrderSetOrderSkipConfigurationAction at($offset) + */ +class RecurringOrderSetOrderSkipConfigurationActionCollection extends RecurringOrderUpdateActionCollection +{ + /** + * @psalm-assert RecurringOrderSetOrderSkipConfigurationAction $value + * @psalm-param RecurringOrderSetOrderSkipConfigurationAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderSetOrderSkipConfigurationActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderSetOrderSkipConfigurationAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderSetOrderSkipConfigurationAction + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderSetOrderSkipConfigurationAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderSetOrderSkipConfigurationAction $data */ + $data = RecurringOrderSetOrderSkipConfigurationActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationActionModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationActionModel.php new file mode 100644 index 00000000000..0d386111724 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetOrderSkipConfigurationActionModel.php @@ -0,0 +1,146 @@ +skipConfiguration = $skipConfiguration; + $this->updatedExpiresAt = $updatedExpiresAt; + $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; + } + + /** + *

Configuration for skipping the next orders of the Recurring Order.

+ * + * + * @return null|SkipConfigurationDraft + */ + public function getSkipConfiguration() + { + if (is_null($this->skipConfiguration)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_SKIP_CONFIGURATION); + if (is_null($data)) { + return null; + } + $className = SkipConfigurationDraftModel::resolveDiscriminatorClass($data); + $this->skipConfiguration = $className::of($data); + } + + return $this->skipConfiguration; + } + + /** + *

Date and time (UTC) the Recurring Order will resume and start to generate new orders.

+ * + * + * @return null|DateTimeImmutable + */ + public function getUpdatedExpiresAt() + { + if (is_null($this->updatedExpiresAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_UPDATED_EXPIRES_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->updatedExpiresAt = $data; + } + + return $this->updatedExpiresAt; + } + + + /** + * @param ?SkipConfigurationDraft $skipConfiguration + */ + public function setSkipConfiguration(?SkipConfigurationDraft $skipConfiguration): void + { + $this->skipConfiguration = $skipConfiguration; + } + + /** + * @param ?DateTimeImmutable $updatedExpiresAt + */ + public function setUpdatedExpiresAt(?DateTimeImmutable $updatedExpiresAt): void + { + $this->updatedExpiresAt = $updatedExpiresAt; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[RecurringOrderSetOrderSkipConfigurationAction::FIELD_UPDATED_EXPIRES_AT]) && $data[RecurringOrderSetOrderSkipConfigurationAction::FIELD_UPDATED_EXPIRES_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderSetOrderSkipConfigurationAction::FIELD_UPDATED_EXPIRES_AT] = $data[RecurringOrderSetOrderSkipConfigurationAction::FIELD_UPDATED_EXPIRES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleAction.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleAction.php new file mode 100644 index 00000000000..a90ae2e1d0e --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleAction.php @@ -0,0 +1,31 @@ +Value to set.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy(); + + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleActionBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleActionBuilder.php new file mode 100644 index 00000000000..cb5e9ddf1d9 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleActionBuilder.php @@ -0,0 +1,75 @@ + + */ +final class RecurringOrderSetScheduleActionBuilder implements Builder +{ + /** + + * @var null|RecurrencePolicyResourceIdentifier|RecurrencePolicyResourceIdentifierBuilder + */ + private $recurrencePolicy; + + /** + *

Value to set.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy() + { + return $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy; + } + + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + + /** + * @deprecated use withRecurrencePolicy() instead + * @return $this + */ + public function withRecurrencePolicyBuilder(?RecurrencePolicyResourceIdentifierBuilder $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + + public function build(): RecurringOrderSetScheduleAction + { + return new RecurringOrderSetScheduleActionModel( + $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy + ); + } + + public static function of(): RecurringOrderSetScheduleActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleActionCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleActionCollection.php new file mode 100644 index 00000000000..4ff3c446c82 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderSetScheduleAction current() + * @method RecurringOrderSetScheduleAction end() + * @method RecurringOrderSetScheduleAction at($offset) + */ +class RecurringOrderSetScheduleActionCollection extends RecurringOrderUpdateActionCollection +{ + /** + * @psalm-assert RecurringOrderSetScheduleAction $value + * @psalm-param RecurringOrderSetScheduleAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderSetScheduleActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderSetScheduleAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderSetScheduleAction + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderSetScheduleAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderSetScheduleAction $data */ + $data = RecurringOrderSetScheduleActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleActionModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleActionModel.php new file mode 100644 index 00000000000..0c0549cc2d9 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetScheduleActionModel.php @@ -0,0 +1,96 @@ +recurrencePolicy = $recurrencePolicy; + $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; + } + + /** + *

Value to set.

+ * + * + * @return null|RecurrencePolicyResourceIdentifier + */ + 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 = RecurrencePolicyResourceIdentifierModel::of($data); + } + + return $this->recurrencePolicy; + } + + + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void + { + $this->recurrencePolicy = $recurrencePolicy; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtAction.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtAction.php new file mode 100644 index 00000000000..89fb11ef553 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtAction.php @@ -0,0 +1,31 @@ +Date and time (UTC) the Recurring Order should be started. The date and time must be in the future.

+ * + + * @return null|DateTimeImmutable + */ + public function getStartsAt(); + + /** + * @param ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtActionBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtActionBuilder.php new file mode 100644 index 00000000000..b1bb15adcf4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtActionBuilder.php @@ -0,0 +1,64 @@ + + */ +final class RecurringOrderSetStartsAtActionBuilder implements Builder +{ + /** + + * @var ?DateTimeImmutable + */ + private $startsAt; + + /** + *

Date and time (UTC) the Recurring Order should be started. The date and time must be in the future.

+ * + + * @return null|DateTimeImmutable + */ + public function getStartsAt() + { + return $this->startsAt; + } + + /** + * @param ?DateTimeImmutable $startsAt + * @return $this + */ + public function withStartsAt(?DateTimeImmutable $startsAt) + { + $this->startsAt = $startsAt; + + return $this; + } + + + public function build(): RecurringOrderSetStartsAtAction + { + return new RecurringOrderSetStartsAtActionModel( + $this->startsAt + ); + } + + public static function of(): RecurringOrderSetStartsAtActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtActionCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtActionCollection.php new file mode 100644 index 00000000000..3e37b7ec4a4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderSetStartsAtAction current() + * @method RecurringOrderSetStartsAtAction end() + * @method RecurringOrderSetStartsAtAction at($offset) + */ +class RecurringOrderSetStartsAtActionCollection extends RecurringOrderUpdateActionCollection +{ + /** + * @psalm-assert RecurringOrderSetStartsAtAction $value + * @psalm-param RecurringOrderSetStartsAtAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderSetStartsAtActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderSetStartsAtAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderSetStartsAtAction + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderSetStartsAtAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderSetStartsAtAction $data */ + $data = RecurringOrderSetStartsAtActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtActionModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtActionModel.php new file mode 100644 index 00000000000..53cc18796b2 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStartsAtActionModel.php @@ -0,0 +1,109 @@ +startsAt = $startsAt; + $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; + } + + /** + *

Date and time (UTC) the Recurring Order should be started. The date and time must be in the future.

+ * + * + * @return null|DateTimeImmutable + */ + public function getStartsAt() + { + if (is_null($this->startsAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_STARTS_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->startsAt = $data; + } + + return $this->startsAt; + } + + + /** + * @param ?DateTimeImmutable $startsAt + */ + public function setStartsAt(?DateTimeImmutable $startsAt): void + { + $this->startsAt = $startsAt; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[RecurringOrderSetStartsAtAction::FIELD_STARTS_AT]) && $data[RecurringOrderSetStartsAtAction::FIELD_STARTS_AT] instanceof \DateTimeImmutable) { + $data[RecurringOrderSetStartsAtAction::FIELD_STARTS_AT] = $data[RecurringOrderSetStartsAtAction::FIELD_STARTS_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateAction.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateAction.php new file mode 100644 index 00000000000..e2ad9fa53be --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateAction.php @@ -0,0 +1,30 @@ +New state of the RecurringOrder.

+ * + + * @return null|RecurringOrderStateDraft + */ + public function getRecurringOrderState(); + + /** + * @param ?RecurringOrderStateDraft $recurringOrderState + */ + public function setRecurringOrderState(?RecurringOrderStateDraft $recurringOrderState): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateActionBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateActionBuilder.php new file mode 100644 index 00000000000..cef5a0da40f --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateActionBuilder.php @@ -0,0 +1,73 @@ + + */ +final class RecurringOrderSetStateActionBuilder implements Builder +{ + /** + + * @var null|RecurringOrderStateDraft|RecurringOrderStateDraftBuilder + */ + private $recurringOrderState; + + /** + *

New state of the RecurringOrder.

+ * + + * @return null|RecurringOrderStateDraft + */ + public function getRecurringOrderState() + { + return $this->recurringOrderState instanceof RecurringOrderStateDraftBuilder ? $this->recurringOrderState->build() : $this->recurringOrderState; + } + + /** + * @param ?RecurringOrderStateDraft $recurringOrderState + * @return $this + */ + public function withRecurringOrderState(?RecurringOrderStateDraft $recurringOrderState) + { + $this->recurringOrderState = $recurringOrderState; + + return $this; + } + + /** + * @deprecated use withRecurringOrderState() instead + * @return $this + */ + public function withRecurringOrderStateBuilder(?RecurringOrderStateDraftBuilder $recurringOrderState) + { + $this->recurringOrderState = $recurringOrderState; + + return $this; + } + + public function build(): RecurringOrderSetStateAction + { + return new RecurringOrderSetStateActionModel( + $this->recurringOrderState instanceof RecurringOrderStateDraftBuilder ? $this->recurringOrderState->build() : $this->recurringOrderState + ); + } + + public static function of(): RecurringOrderSetStateActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateActionCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateActionCollection.php new file mode 100644 index 00000000000..2dc0b331bb7 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderSetStateAction current() + * @method RecurringOrderSetStateAction end() + * @method RecurringOrderSetStateAction at($offset) + */ +class RecurringOrderSetStateActionCollection extends RecurringOrderUpdateActionCollection +{ + /** + * @psalm-assert RecurringOrderSetStateAction $value + * @psalm-param RecurringOrderSetStateAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderSetStateActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderSetStateAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderSetStateAction + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderSetStateAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderSetStateAction $data */ + $data = RecurringOrderSetStateActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateActionModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateActionModel.php new file mode 100644 index 00000000000..f4e174b0835 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderSetStateActionModel.php @@ -0,0 +1,94 @@ +recurringOrderState = $recurringOrderState; + $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; + } + + /** + *

New state of the RecurringOrder.

+ * + * + * @return null|RecurringOrderStateDraft + */ + public function getRecurringOrderState() + { + if (is_null($this->recurringOrderState)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_RECURRING_ORDER_STATE); + if (is_null($data)) { + return null; + } + $className = RecurringOrderStateDraftModel::resolveDiscriminatorClass($data); + $this->recurringOrderState = $className::of($data); + } + + return $this->recurringOrderState; + } + + + /** + * @param ?RecurringOrderStateDraft $recurringOrderState + */ + public function setRecurringOrderState(?RecurringOrderStateDraft $recurringOrderState): void + { + $this->recurringOrderState = $recurringOrderState; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderStateDraft.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderStateDraft.php new file mode 100644 index 00000000000..1b998612872 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderStateDraft.php @@ -0,0 +1,24 @@ + + */ +final class RecurringOrderStateDraftBuilder implements Builder +{ + public function build(): RecurringOrderStateDraft + { + return new RecurringOrderStateDraftModel( + ); + } + + public static function of(): RecurringOrderStateDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderStateDraftCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderStateDraftCollection.php new file mode 100644 index 00000000000..9ed84252392 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderStateDraftCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method RecurringOrderStateDraft current() + * @method RecurringOrderStateDraft end() + * @method RecurringOrderStateDraft at($offset) + */ +class RecurringOrderStateDraftCollection extends MapperSequence +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderStateDraftCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderStateDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderStateDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = RecurringOrderStateDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderStateDraftModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderStateDraftModel.php new file mode 100644 index 00000000000..693cad67a84 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderStateDraftModel.php @@ -0,0 +1,97 @@ + > + * + */ + private static $discriminatorClasses = [ + 'active' => RecurringOrderActiveModel::class, + 'canceled' => RecurringOrderCanceledModel::class, + 'expired' => RecurringOrderExpiredModel::class, + 'paused' => RecurringOrderPausedModel::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 = RecurringOrderStateDraft::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 = RecurringOrderStateDraftModel::class; + return $type; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateAction.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateAction.php new file mode 100644 index 00000000000..eeb8696ea32 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateAction.php @@ -0,0 +1,46 @@ +Value to set. + * If there is no State yet, the new State must be an initial State.

+ * + + * @return null|StateResourceIdentifier + */ + public function getState(); + + /** + *

Set to true to turn off validation.

+ * + + * @return null|bool + */ + public function getForce(); + + /** + * @param ?StateResourceIdentifier $state + */ + public function setState(?StateResourceIdentifier $state): void; + + /** + * @param ?bool $force + */ + public function setForce(?bool $force): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateActionBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateActionBuilder.php new file mode 100644 index 00000000000..2825315bc31 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateActionBuilder.php @@ -0,0 +1,105 @@ + + */ +final class RecurringOrderTransitionStateActionBuilder implements Builder +{ + /** + + * @var null|StateResourceIdentifier|StateResourceIdentifierBuilder + */ + private $state; + + /** + + * @var ?bool + */ + private $force; + + /** + *

Value to set. + * If there is no State yet, the new State must be an initial State.

+ * + + * @return null|StateResourceIdentifier + */ + public function getState() + { + return $this->state instanceof StateResourceIdentifierBuilder ? $this->state->build() : $this->state; + } + + /** + *

Set to true to turn off validation.

+ * + + * @return null|bool + */ + public function getForce() + { + return $this->force; + } + + /** + * @param ?StateResourceIdentifier $state + * @return $this + */ + public function withState(?StateResourceIdentifier $state) + { + $this->state = $state; + + return $this; + } + + /** + * @param ?bool $force + * @return $this + */ + public function withForce(?bool $force) + { + $this->force = $force; + + return $this; + } + + /** + * @deprecated use withState() instead + * @return $this + */ + public function withStateBuilder(?StateResourceIdentifierBuilder $state) + { + $this->state = $state; + + return $this; + } + + public function build(): RecurringOrderTransitionStateAction + { + return new RecurringOrderTransitionStateActionModel( + $this->state instanceof StateResourceIdentifierBuilder ? $this->state->build() : $this->state, + $this->force + ); + } + + public static function of(): RecurringOrderTransitionStateActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateActionCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateActionCollection.php new file mode 100644 index 00000000000..e590a6502f8 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateActionCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderTransitionStateAction current() + * @method RecurringOrderTransitionStateAction end() + * @method RecurringOrderTransitionStateAction at($offset) + */ +class RecurringOrderTransitionStateActionCollection extends RecurringOrderUpdateActionCollection +{ + /** + * @psalm-assert RecurringOrderTransitionStateAction $value + * @psalm-param RecurringOrderTransitionStateAction|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderTransitionStateActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderTransitionStateAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderTransitionStateAction + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderTransitionStateAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderTransitionStateAction $data */ + $data = RecurringOrderTransitionStateActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateActionModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateActionModel.php new file mode 100644 index 00000000000..f7e96ff4cba --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderTransitionStateActionModel.php @@ -0,0 +1,133 @@ +state = $state; + $this->force = $force; + $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; + } + + /** + *

Value to set. + * If there is no State yet, the new State must be an initial State.

+ * + * + * @return null|StateResourceIdentifier + */ + public function getState() + { + if (is_null($this->state)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_STATE); + if (is_null($data)) { + return null; + } + + $this->state = StateResourceIdentifierModel::of($data); + } + + return $this->state; + } + + /** + *

Set to true to turn off validation.

+ * + * + * @return null|bool + */ + public function getForce() + { + if (is_null($this->force)) { + /** @psalm-var ?bool $data */ + $data = $this->raw(self::FIELD_FORCE); + if (is_null($data)) { + return null; + } + $this->force = (bool) $data; + } + + return $this->force; + } + + + /** + * @param ?StateResourceIdentifier $state + */ + public function setState(?StateResourceIdentifier $state): void + { + $this->state = $state; + } + + /** + * @param ?bool $force + */ + public function setForce(?bool $force): void + { + $this->force = $force; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdate.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdate.php new file mode 100644 index 00000000000..ad8639dc288 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdate.php @@ -0,0 +1,45 @@ +Expected version of the RecurringOrder on which the changes should be applied. + * If the expected version does not match the actual version, a ConcurrentModification error will be returned.

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

Update actions to be performed on the RecurringOrder.

+ * + + * @return null|RecurringOrderUpdateActionCollection + */ + public function getActions(); + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void; + + /** + * @param ?RecurringOrderUpdateActionCollection $actions + */ + public function setActions(?RecurringOrderUpdateActionCollection $actions): void; +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateAction.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateAction.php new file mode 100644 index 00000000000..9074e058d97 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateAction.php @@ -0,0 +1,24 @@ + + */ +final class RecurringOrderUpdateActionBuilder implements Builder +{ + public function build(): RecurringOrderUpdateAction + { + return new RecurringOrderUpdateActionModel( + ); + } + + public static function of(): RecurringOrderUpdateActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateActionCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateActionCollection.php new file mode 100644 index 00000000000..5439559d3a4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateActionCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method RecurringOrderUpdateAction current() + * @method RecurringOrderUpdateAction end() + * @method RecurringOrderUpdateAction at($offset) + */ +class RecurringOrderUpdateActionCollection extends MapperSequence +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderUpdateActionCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderUpdateAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderUpdateAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = RecurringOrderUpdateActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateActionModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateActionModel.php new file mode 100644 index 00000000000..7837dcfb268 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateActionModel.php @@ -0,0 +1,101 @@ + > + * + */ + private static $discriminatorClasses = [ + 'setCustomField' => RecurringOrderSetCustomFieldActionModel::class, + 'setCustomType' => RecurringOrderSetCustomTypeActionModel::class, + 'setKey' => RecurringOrderSetKeyActionModel::class, + 'setOrderSkipConfiguration' => RecurringOrderSetOrderSkipConfigurationActionModel::class, + 'setRecurringOrderState' => RecurringOrderSetStateActionModel::class, + 'setSchedule' => RecurringOrderSetScheduleActionModel::class, + 'setStartsAt' => RecurringOrderSetStartsAtActionModel::class, + 'transitionState' => RecurringOrderTransitionStateActionModel::class, + ]; + + /** + * @psalm-suppress MissingParamType + */ + public function __construct( + ?string $action = null + ) { + $this->action = $action; + } + + /** + * + * @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; + } + + + + + + /** + * @psalm-param stdClass|array $value + * @psalm-return class-string + */ + public static function resolveDiscriminatorClass($value): string + { + $fieldName = RecurringOrderUpdateAction::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 = RecurringOrderUpdateActionModel::class; + return $type; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateBuilder.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateBuilder.php new file mode 100644 index 00000000000..c78a3a5a2b3 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateBuilder.php @@ -0,0 +1,93 @@ + + */ +final class RecurringOrderUpdateBuilder implements Builder +{ + /** + + * @var ?int + */ + private $version; + + /** + + * @var ?RecurringOrderUpdateActionCollection + */ + private $actions; + + /** + *

Expected version of the RecurringOrder on which the changes should be applied. + * If the expected version does not match the actual version, a ConcurrentModification error will be returned.

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

Update actions to be performed on the RecurringOrder.

+ * + + * @return null|RecurringOrderUpdateActionCollection + */ + public function getActions() + { + return $this->actions; + } + + /** + * @param ?int $version + * @return $this + */ + public function withVersion(?int $version) + { + $this->version = $version; + + return $this; + } + + /** + * @param ?RecurringOrderUpdateActionCollection $actions + * @return $this + */ + public function withActions(?RecurringOrderUpdateActionCollection $actions) + { + $this->actions = $actions; + + return $this; + } + + + public function build(): RecurringOrderUpdate + { + return new RecurringOrderUpdateModel( + $this->version, + $this->actions + ); + } + + public static function of(): RecurringOrderUpdateBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateCollection.php new file mode 100644 index 00000000000..25e63c65138 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateCollection.php @@ -0,0 +1,56 @@ + + * @method RecurringOrderUpdate current() + * @method RecurringOrderUpdate end() + * @method RecurringOrderUpdate at($offset) + */ +class RecurringOrderUpdateCollection extends MapperSequence +{ + /** + * @psalm-assert RecurringOrderUpdate $value + * @psalm-param RecurringOrderUpdate|stdClass $value + * @throws InvalidArgumentException + * + * @return RecurringOrderUpdateCollection + */ + public function add($value) + { + if (!$value instanceof RecurringOrderUpdate) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?RecurringOrderUpdate + */ + protected function mapper() + { + return function (?int $index): ?RecurringOrderUpdate { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var RecurringOrderUpdate $data */ + $data = RecurringOrderUpdateModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateModel.php b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateModel.php new file mode 100644 index 00000000000..533ed2013e8 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/RecurringOrderUpdateModel.php @@ -0,0 +1,103 @@ +version = $version; + $this->actions = $actions; + } + + /** + *

Expected version of the RecurringOrder on which the changes should be applied. + * If the expected version does not match the actual version, a ConcurrentModification error will be returned.

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

Update actions to be performed on the RecurringOrder.

+ * + * + * @return null|RecurringOrderUpdateActionCollection + */ + public function getActions() + { + if (is_null($this->actions)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_ACTIONS); + if (is_null($data)) { + return null; + } + $this->actions = RecurringOrderUpdateActionCollection::fromArray($data); + } + + return $this->actions; + } + + + /** + * @param ?int $version + */ + public function setVersion(?int $version): void + { + $this->version = $version; + } + + /** + * @param ?RecurringOrderUpdateActionCollection $actions + */ + public function setActions(?RecurringOrderUpdateActionCollection $actions): void + { + $this->actions = $actions; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/SkipConfiguration.php b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfiguration.php new file mode 100644 index 00000000000..7d7e838e691 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfiguration.php @@ -0,0 +1,24 @@ + + */ +final class SkipConfigurationBuilder implements Builder +{ + public function build(): SkipConfiguration + { + return new SkipConfigurationModel( + ); + } + + public static function of(): SkipConfigurationBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationCollection.php new file mode 100644 index 00000000000..8c1c43ee453 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method SkipConfiguration current() + * @method SkipConfiguration end() + * @method SkipConfiguration at($offset) + */ +class SkipConfigurationCollection extends MapperSequence +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return SkipConfigurationCollection + */ + public function add($value) + { + if (!$value instanceof SkipConfiguration) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?SkipConfiguration { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = SkipConfigurationModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationDraft.php b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationDraft.php new file mode 100644 index 00000000000..641b67209c8 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationDraft.php @@ -0,0 +1,24 @@ + + */ +final class SkipConfigurationDraftBuilder implements Builder +{ + public function build(): SkipConfigurationDraft + { + return new SkipConfigurationDraftModel( + ); + } + + public static function of(): SkipConfigurationDraftBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationDraftCollection.php b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationDraftCollection.php new file mode 100644 index 00000000000..282b542beb6 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationDraftCollection.php @@ -0,0 +1,60 @@ + + * @psalm-method T current() + * @psalm-method T end() + * @psalm-method T at($offset) + * @method SkipConfigurationDraft current() + * @method SkipConfigurationDraft end() + * @method SkipConfigurationDraft at($offset) + */ +class SkipConfigurationDraftCollection extends MapperSequence +{ + /** + * @psalm-assert T $value + * @psalm-param T|stdClass $value + * @throws InvalidArgumentException + * + * @return SkipConfigurationDraftCollection + */ + public function add($value) + { + if (!$value instanceof SkipConfigurationDraft) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?T + */ + protected function mapper() + { + return function (?int $index): ?SkipConfigurationDraft { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var T $data */ + $data = SkipConfigurationDraftModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationDraftModel.php b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationDraftModel.php new file mode 100644 index 00000000000..e9c741cd4f4 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationDraftModel.php @@ -0,0 +1,94 @@ + > + * + */ + private static $discriminatorClasses = [ + 'counter' => CounterDraftModel::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 = SkipConfigurationDraft::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 = SkipConfigurationDraftModel::class; + return $type; + } +} diff --git a/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationModel.php b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationModel.php new file mode 100644 index 00000000000..3595a574e09 --- /dev/null +++ b/lib/commercetools-api/src/Models/RecurringOrder/SkipConfigurationModel.php @@ -0,0 +1,94 @@ + > + * + */ + private static $discriminatorClasses = [ + 'counter' => CounterModel::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 = SkipConfiguration::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 = SkipConfigurationModel::class; + return $type; + } +} diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePrice.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePrice.php index f170f04733c..1f4ad72fea2 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePrice.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePrice.php @@ -16,6 +16,7 @@ use Commercetools\Api\Models\Common\PriceTierCollection; use Commercetools\Api\Models\Common\TypedMoney; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReference; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReference; use Commercetools\Api\Models\Type\CustomFields; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\Base\JsonObject; @@ -38,6 +39,7 @@ interface StandalonePrice extends BaseResource public const FIELD_CUSTOM = 'custom'; public const FIELD_STAGED = 'staged'; public const FIELD_ACTIVE = 'active'; + public const FIELD_RECURRENCE_POLICY = 'recurrencePolicy'; /** *

Unique identifier of the StandalonePrice.

@@ -194,6 +196,14 @@ public function getStaged(); */ public function getActive(); + /** + *

RecurrencePolicy for which this Price is valid.

+ * + + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy(); + /** * @param ?string $id */ @@ -288,4 +298,9 @@ public function setStaged(?StagedStandalonePrice $staged): void; * @param ?bool $active */ public function setActive(?bool $active): void; + + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy): void; } diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceBuilder.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceBuilder.php index adad8f97266..c5b68c10619 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceBuilder.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceBuilder.php @@ -23,6 +23,8 @@ use Commercetools\Api\Models\Common\TypedMoneyBuilder; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReference; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReferenceBuilder; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReference; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReferenceBuilder; use Commercetools\Api\Models\Type\CustomFields; use Commercetools\Api\Models\Type\CustomFieldsBuilder; use Commercetools\Base\Builder; @@ -152,6 +154,12 @@ final class StandalonePriceBuilder implements Builder */ private $active; + /** + + * @var null|RecurrencePolicyReference|RecurrencePolicyReferenceBuilder + */ + private $recurrencePolicy; + /** *

Unique identifier of the StandalonePrice.

* @@ -364,6 +372,17 @@ public function getActive() return $this->active; } + /** + *

RecurrencePolicy for which this Price is valid.

+ * + + * @return null|RecurrencePolicyReference + */ + public function getRecurrencePolicy() + { + return $this->recurrencePolicy instanceof RecurrencePolicyReferenceBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy; + } + /** * @param ?string $id * @return $this @@ -573,6 +592,17 @@ public function withActive(?bool $active) return $this; } + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + /** * @deprecated use withLastModifiedBy() instead * @return $this @@ -661,6 +691,17 @@ public function withStagedBuilder(?StagedStandalonePriceBuilder $staged) return $this; } + /** + * @deprecated use withRecurrencePolicy() instead + * @return $this + */ + public function withRecurrencePolicyBuilder(?RecurrencePolicyReferenceBuilder $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + public function build(): StandalonePrice { return new StandalonePriceModel( @@ -682,7 +723,8 @@ public function build(): StandalonePrice $this->discounted instanceof DiscountedPriceBuilder ? $this->discounted->build() : $this->discounted, $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom, $this->staged instanceof StagedStandalonePriceBuilder ? $this->staged->build() : $this->staged, - $this->active + $this->active, + $this->recurrencePolicy instanceof RecurrencePolicyReferenceBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy ); } diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraft.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraft.php index 3e3ab222f58..78fa7121db8 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraft.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraft.php @@ -13,6 +13,7 @@ use Commercetools\Api\Models\Common\Money; use Commercetools\Api\Models\Common\PriceTierDraftCollection; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifier; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifier; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Base\DateTimeImmutableCollection; use Commercetools\Base\JsonObject; @@ -31,6 +32,7 @@ interface StandalonePriceDraft extends JsonObject public const FIELD_TIERS = 'tiers'; public const FIELD_DISCOUNTED = 'discounted'; public const FIELD_CUSTOM = 'custom'; + public const FIELD_RECURRENCE_POLICY = 'recurrencePolicy'; public const FIELD_STAGED = 'staged'; public const FIELD_ACTIVE = 'active'; @@ -125,6 +127,14 @@ public function getDiscounted(); */ public function getCustom(); + /** + *

RecurrencePolicy for which this Price is valid.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy(); + /** *

Staged changes for the StandalonePrice.

* @@ -196,6 +206,11 @@ public function setDiscounted(?DiscountedPriceDraft $discounted): void; */ public function setCustom(?CustomFieldsDraft $custom): void; + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void; + /** * @param ?StagedPriceDraft $staged */ diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraftBuilder.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraftBuilder.php index 50afe265ea0..2f74d1803e1 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraftBuilder.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraftBuilder.php @@ -17,6 +17,8 @@ use Commercetools\Api\Models\Common\PriceTierDraftCollection; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifier; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifierBuilder; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifier; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifierBuilder; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftBuilder; use Commercetools\Base\Builder; @@ -98,6 +100,12 @@ final class StandalonePriceDraftBuilder implements Builder */ private $custom; + /** + + * @var null|RecurrencePolicyResourceIdentifier|RecurrencePolicyResourceIdentifierBuilder + */ + private $recurrencePolicy; + /** * @var null|StagedPriceDraft|StagedPriceDraftBuilder @@ -234,6 +242,17 @@ public function getCustom() return $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom; } + /** + *

RecurrencePolicy for which this Price is valid.

+ * + + * @return null|RecurrencePolicyResourceIdentifier + */ + public function getRecurrencePolicy() + { + return $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy; + } + /** *

Staged changes for the StandalonePrice.

* @@ -377,6 +396,17 @@ public function withCustom(?CustomFieldsDraft $custom) return $this; } + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + * @return $this + */ + public function withRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + /** * @param ?StagedPriceDraft $staged * @return $this @@ -454,6 +484,17 @@ public function withCustomBuilder(?CustomFieldsDraftBuilder $custom) return $this; } + /** + * @deprecated use withRecurrencePolicy() instead + * @return $this + */ + public function withRecurrencePolicyBuilder(?RecurrencePolicyResourceIdentifierBuilder $recurrencePolicy) + { + $this->recurrencePolicy = $recurrencePolicy; + + return $this; + } + /** * @deprecated use withStaged() instead * @return $this @@ -479,6 +520,7 @@ public function build(): StandalonePriceDraft $this->tiers, $this->discounted instanceof DiscountedPriceDraftBuilder ? $this->discounted->build() : $this->discounted, $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom, + $this->recurrencePolicy instanceof RecurrencePolicyResourceIdentifierBuilder ? $this->recurrencePolicy->build() : $this->recurrencePolicy, $this->staged instanceof StagedPriceDraftBuilder ? $this->staged->build() : $this->staged, $this->active ); diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraftModel.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraftModel.php index 8c66f931853..1175926c377 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraftModel.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceDraftModel.php @@ -17,6 +17,8 @@ use Commercetools\Api\Models\Common\PriceTierDraftCollection; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifier; use Commercetools\Api\Models\CustomerGroup\CustomerGroupResourceIdentifierModel; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifier; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyResourceIdentifierModel; use Commercetools\Api\Models\Type\CustomFieldsDraft; use Commercetools\Api\Models\Type\CustomFieldsDraftModel; use Commercetools\Base\DateTimeImmutableCollection; @@ -97,6 +99,12 @@ final class StandalonePriceDraftModel extends JsonObjectModel implements Standal */ protected $custom; + /** + * + * @var ?RecurrencePolicyResourceIdentifier + */ + protected $recurrencePolicy; + /** * * @var ?StagedPriceDraft @@ -125,6 +133,7 @@ public function __construct( ?PriceTierDraftCollection $tiers = null, ?DiscountedPriceDraft $discounted = null, ?CustomFieldsDraft $custom = null, + ?RecurrencePolicyResourceIdentifier $recurrencePolicy = null, ?StagedPriceDraft $staged = null, ?bool $active = null ) { @@ -139,6 +148,7 @@ public function __construct( $this->tiers = $tiers; $this->discounted = $discounted; $this->custom = $custom; + $this->recurrencePolicy = $recurrencePolicy; $this->staged = $staged; $this->active = $active; } @@ -379,6 +389,27 @@ public function getCustom() return $this->custom; } + /** + *

RecurrencePolicy for which this Price is valid.

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

Staged changes for the StandalonePrice.

* @@ -509,6 +540,14 @@ public function setCustom(?CustomFieldsDraft $custom): void $this->custom = $custom; } + /** + * @param ?RecurrencePolicyResourceIdentifier $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyResourceIdentifier $recurrencePolicy): void + { + $this->recurrencePolicy = $recurrencePolicy; + } + /** * @param ?StagedPriceDraft $staged */ diff --git a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceModel.php b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceModel.php index 65e89a927c7..16924968778 100644 --- a/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceModel.php +++ b/lib/commercetools-api/src/Models/StandalonePrice/StandalonePriceModel.php @@ -23,6 +23,8 @@ use Commercetools\Api\Models\Common\TypedMoneyModel; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReference; use Commercetools\Api\Models\CustomerGroup\CustomerGroupReferenceModel; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReference; +use Commercetools\Api\Models\RecurrencePolicy\RecurrencePolicyReferenceModel; use Commercetools\Api\Models\Type\CustomFields; use Commercetools\Api\Models\Type\CustomFieldsModel; use Commercetools\Base\DateTimeImmutableCollection; @@ -151,6 +153,12 @@ final class StandalonePriceModel extends JsonObjectModel implements StandalonePr */ protected $active; + /** + * + * @var ?RecurrencePolicyReference + */ + protected $recurrencePolicy; + /** * @psalm-suppress MissingParamType @@ -174,7 +182,8 @@ public function __construct( ?DiscountedPrice $discounted = null, ?CustomFields $custom = null, ?StagedStandalonePrice $staged = null, - ?bool $active = null + ?bool $active = null, + ?RecurrencePolicyReference $recurrencePolicy = null ) { $this->id = $id; $this->version = $version; @@ -195,6 +204,7 @@ public function __construct( $this->custom = $custom; $this->staged = $staged; $this->active = $active; + $this->recurrencePolicy = $recurrencePolicy; } /** @@ -604,6 +614,27 @@ public function getActive() return $this->active; } + /** + *

RecurrencePolicy 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 @@ -757,6 +788,14 @@ public function setActive(?bool $active): void $this->active = $active; } + /** + * @param ?RecurrencePolicyReference $recurrencePolicy + */ + public function setRecurrencePolicy(?RecurrencePolicyReference $recurrencePolicy): void + { + $this->recurrencePolicy = $recurrencePolicy; + } + #[\ReturnTypeWillChange] public function jsonSerialize() diff --git a/references.txt b/references.txt index 729762a6a90..08ff3d3c708 100644 --- a/references.txt +++ b/references.txt @@ -452,3 +452,4 @@ bb49fa04d50e4e0267846c7d805ae8ebc254bdea 5d1789f6ec176cc91feb28ec808cb7513fe1d5a8 abbf4db007d9786e969fde88cf80cfc117f80c42 84839875c7243dce1c079f4b0a2b782c24c5810f +d3b533e464972120900c1294eeee384fc0c33231