From d0ef11b8f4ddc3d1ae8002666c193b3d16587082 Mon Sep 17 00:00:00 2001 From: Johann Date: Wed, 6 Apr 2022 12:24:37 +0200 Subject: [PATCH] Add v1.14.0 --- CHANGELOG.md | 27 +++- composer.json | 2 +- src/Mirakl/MCI/Common/Domain/Attribute.php | 78 +++++----- .../Common/Domain/AttributeProductFeed.php | 11 ++ .../AttributeProductFeedCollection.php | 20 +++ ...tProductFeedValidationStatusCollection.php | 20 +++ .../ProductFeed/ChannelCollection.php | 20 +++ .../ProductFeed/ProductFeedCollection.php | 20 +++ .../ProductFeedImportErrorCollection.php | 20 +++ ...ProductFeedImportGlobalErrorCollection.php | 20 +++ .../ProductFeedImportItemCollection.php | 20 +++ .../ProductFeedImportReportItemCollection.php | 20 +++ ...ctDataSheetProductFeedValidationStatus.php | 13 ++ .../Product/ProductDataSheetValidation.php | 21 +++ .../ProductDataSheetValidationStatus.php | 9 ++ .../Domain/Product/ProductImportStatus.php | 15 +- .../ProductImportWithTransformationStatus.php | 8 +- .../MCI/Common/Domain/ProductFeed/Channel.php | 11 ++ .../ImportProductFeedOperation.php | 8 + .../Common/Domain/ProductFeed/ProductFeed.php | 32 ++++ .../ProductFeed/ProductFeedImportError.php | 13 ++ .../ProductFeedImportGlobalError.php | 5 + .../ProductFeed/ProductFeedImportItem.php | 30 ++++ .../ProductFeedImportReportItem.php | 20 +++ .../ProductFeedImportReportStatus.php | 8 + .../Product/AbstractProductImportRequest.php | 12 ++ .../AbstractGetProductFeedsRequest.php | 44 ++++++ .../Request/Product/ProductImportRequest.php | 8 +- .../ShippingPriceByZoneAndTypeCollection.php | 13 ++ .../ProductMeasurementCollection.php | 20 +++ .../Shop/ShopApplicableTaxCollection.php | 20 +++ .../Common/Domain/Message/Thread/Thread.php | 3 + .../Thread/ThreadCustomerOrganization.php | 13 ++ .../Domain/Offer/AbstractExportOffer.php | 131 ++++++++++++++-- .../MMP/Common/Domain/Offer/AbstractOffer.php | 142 +++++++++--------- .../Domain/Offer/Shipping/DeliveryTime.php | 13 ++ .../Shipping/ShippingPriceByZoneAndType.php | 28 ++++ .../Order/AbstractCustomerOrganization.php | 24 +++ .../MMP/Common/Domain/Order/AbstractOrder.php | 3 + .../Domain/Order/AbstractOrderCustomer.php | 3 + .../Domain/Order/CustomerOrganization.php | 26 ++++ .../Order/CustomerOrganizationAddress.php | 23 +++ .../Common/Domain/Order/OrderReferences.php | 13 ++ .../Common/Domain/Payment/PaymentWorkflow.php | 36 ++++- .../Measurement/ProductMeasurement.php | 5 +- .../MMP/Common/Domain/Shipment/Shipment.php | 4 + .../Shipping/ShippingTypeWithDescription.php | 9 ++ .../MMP/Common/Domain/Shop/AbstractShop.php | 6 + .../Common/Domain/Shop/Bank/PaymentInfo.php | 8 +- .../Domain/Shop/Bank/UkBankAccountInfo.php | 18 +++ .../Common/Domain/Shop/ShopApplicableTax.php | 13 ++ .../Offer/AbstractOffersExportFileRequest.php | 22 ++- .../Order/AbstractGetOrdersRequest.php | 22 ++- .../AbstractGetOffersOnProductsRequest.php | 16 ++ .../Order/Importer/OfferImportCollection.php | 20 +++ .../Domain/Offer/Importer/ImportOrigin.php | 13 ++ .../Domain/Offer/Importer/ImportStatus.php | 3 + .../Domain/Offer/Importer/OfferImport.php | 11 ++ .../Offer/Importer/OfferImportResult.php | 1 + .../Importer/AbstractOffersImportsRequest.php | 51 +++++++ src/Mirakl/MMP/Shop/Client/ShopApiClient.php | 10 ++ .../Order/Update/UpdateOrderCollection.php | 20 +++ .../Update/UpdatedOrderAndErrorCollection.php | 20 +++ .../Order/ShopOrderAdditionalContact.php | 7 + .../Shop/Domain/Order/ShopOrderCustomer.php | 8 +- .../Shop/Domain/Order/Update/UpdateOrder.php | 20 +++ .../Domain/Order/Update/UpdateReferences.php | 11 ++ .../Shop/Domain/Order/Update/UpdatedOrder.php | 18 +++ .../Order/Update/UpdatedOrderAndError.php | 24 +++ .../Domain/Order/Update/UpdatedReferences.php | 11 ++ .../Domain/Product/Offer/OfferOnProduct.php | 88 +++++------ src/Mirakl/MMP/Shop/Domain/Reason.php | 14 +- .../Domain/Shop/Update/UpdateShopAccount.php | 51 +++++++ .../Shop/Update/UpdateShopAccountAddress.php | 69 +++++++++ .../Update/UpdateShopAccountProDetails.php | 15 ++ .../Shop/Domain/Shop/UpdatedShopAccount.php | 7 + .../Shop/Domain/Shop/UpdatedShopAndError.php | 22 +++ .../Offer/Importer/OffersImportsRequest.php | 40 +++++ .../Request/Offer/UpdateOffersRequest.php | 2 + .../Order/Update/UpdateOrdersRequest.php | 77 ++++++++++ .../Shop/Request/Reason/GetReasonsRequest.php | 42 ++++++ .../Request/Reason/GetTypeReasonsRequest.php | 3 + .../Request/Shop/UpdateAccountRequest.php | 105 +++++++++++++ 83 files changed, 1755 insertions(+), 197 deletions(-) create mode 100644 src/Mirakl/MCI/Common/Domain/AttributeProductFeed.php create mode 100644 src/Mirakl/MCI/Common/Domain/Collection/AttributeProductFeedCollection.php create mode 100644 src/Mirakl/MCI/Common/Domain/Collection/Product/ProductDataSheetProductFeedValidationStatusCollection.php create mode 100644 src/Mirakl/MCI/Common/Domain/Collection/ProductFeed/ChannelCollection.php create mode 100644 src/Mirakl/MCI/Common/Domain/Collection/ProductFeed/ProductFeedCollection.php create mode 100644 src/Mirakl/MCI/Common/Domain/Collection/ProductFeed/ProductFeedImportErrorCollection.php create mode 100644 src/Mirakl/MCI/Common/Domain/Collection/ProductFeed/ProductFeedImportGlobalErrorCollection.php create mode 100644 src/Mirakl/MCI/Common/Domain/Collection/ProductFeed/ProductFeedImportItemCollection.php create mode 100644 src/Mirakl/MCI/Common/Domain/Collection/ProductFeed/ProductFeedImportReportItemCollection.php create mode 100644 src/Mirakl/MCI/Common/Domain/Product/ProductDataSheetProductFeedValidationStatus.php create mode 100644 src/Mirakl/MCI/Common/Domain/Product/ProductDataSheetValidation.php create mode 100644 src/Mirakl/MCI/Common/Domain/Product/ProductDataSheetValidationStatus.php create mode 100644 src/Mirakl/MCI/Common/Domain/ProductFeed/Channel.php create mode 100644 src/Mirakl/MCI/Common/Domain/ProductFeed/ImportProductFeedOperation.php create mode 100644 src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeed.php create mode 100644 src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportError.php create mode 100644 src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportGlobalError.php create mode 100644 src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportItem.php create mode 100644 src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportReportItem.php create mode 100644 src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportReportStatus.php create mode 100644 src/Mirakl/MCI/Common/Request/ProductFeed/AbstractGetProductFeedsRequest.php create mode 100644 src/Mirakl/MMP/Common/Domain/Collection/Offer/Shipping/ShippingPriceByZoneAndTypeCollection.php create mode 100644 src/Mirakl/MMP/Common/Domain/Collection/Product/Measurement/ProductMeasurementCollection.php create mode 100644 src/Mirakl/MMP/Common/Domain/Collection/Shop/ShopApplicableTaxCollection.php create mode 100644 src/Mirakl/MMP/Common/Domain/Message/Thread/ThreadCustomerOrganization.php create mode 100644 src/Mirakl/MMP/Common/Domain/Offer/Shipping/DeliveryTime.php create mode 100644 src/Mirakl/MMP/Common/Domain/Offer/Shipping/ShippingPriceByZoneAndType.php create mode 100644 src/Mirakl/MMP/Common/Domain/Order/AbstractCustomerOrganization.php create mode 100644 src/Mirakl/MMP/Common/Domain/Order/CustomerOrganization.php create mode 100644 src/Mirakl/MMP/Common/Domain/Order/CustomerOrganizationAddress.php create mode 100644 src/Mirakl/MMP/Common/Domain/Order/OrderReferences.php create mode 100644 src/Mirakl/MMP/Common/Domain/Shop/Bank/UkBankAccountInfo.php create mode 100644 src/Mirakl/MMP/Common/Domain/Shop/ShopApplicableTax.php create mode 100644 src/Mirakl/MMP/OperatorShop/Domain/Collection/Order/Importer/OfferImportCollection.php create mode 100644 src/Mirakl/MMP/OperatorShop/Domain/Offer/Importer/ImportOrigin.php create mode 100644 src/Mirakl/MMP/OperatorShop/Domain/Offer/Importer/OfferImport.php create mode 100644 src/Mirakl/MMP/OperatorShop/Request/Offer/Importer/AbstractOffersImportsRequest.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Collection/Order/Update/UpdateOrderCollection.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Collection/Order/Update/UpdatedOrderAndErrorCollection.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Order/ShopOrderAdditionalContact.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Order/Update/UpdateOrder.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Order/Update/UpdateReferences.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Order/Update/UpdatedOrder.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Order/Update/UpdatedOrderAndError.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Order/Update/UpdatedReferences.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccount.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccountAddress.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccountProDetails.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Shop/UpdatedShopAccount.php create mode 100644 src/Mirakl/MMP/Shop/Domain/Shop/UpdatedShopAndError.php create mode 100644 src/Mirakl/MMP/Shop/Request/Offer/Importer/OffersImportsRequest.php create mode 100644 src/Mirakl/MMP/Shop/Request/Order/Update/UpdateOrdersRequest.php create mode 100644 src/Mirakl/MMP/Shop/Request/Reason/GetReasonsRequest.php create mode 100644 src/Mirakl/MMP/Shop/Request/Shop/UpdateAccountRequest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 1728094..7284c29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,29 @@ # Changelog -## v1.13.6 - 2021-08-12 -### Fixes -- Fix parameter order_tax_mode not working in GetOrdersRequest.php +## v1.14.0 - 2021-12-23 +### Features +- Add product feeds APIs (PF01, PF02, PF03 and PF11) +- Add API A02 to update shop information +- Open RE01 to shops and deprecate RE02 +- Add API OF04 for operator and shop roles +- Add OR06 API to confirm orders taxes +- Add 'operator_format' parameter to API P41 +- Add fulfillment center code in API (offer) +- Add measurement field to OF51 +- Add applicable_taxes in A01 and S20 output +- Add the PAY_ON_SHIPMENT order workflow +- Add offers shipping prices by type and zone to P11 and OF51 +- Add commissionnable flag and filter in OR11 / P11 / OF51 +- Add API OR04 for the shop role + order references in API OR01, OR04 and OR11 +- Add mandatoryTracking clickAndCollect and deliveryByOperator in SH12 +- Add suspension_type in A01, S20, S06 and S07 APIs +- Add createDate and lastUpdatedDate on ST01 & ST11 +- Support UK bank format for seller payout +- Add customer organization & additional contacts in OR01, OR11, OR04, M11, M10 + +## v1.13.7 - 2021-10-26 +### Fixes +- Fix parameter order_tax_mode not working in GetHierarchiesRequest when calling OR11 API ## v1.13.6 - 2021-08-12 ### Fixes diff --git a/composer.json b/composer.json index e33007b..2dd42e0 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mirakl/sdk-php-shop", "description": "Mirakl provides a PHP SDK that wraps the Mirakl REST APIs in a lightweight library. This enables you to develop a fast, flexible and custom integration for your existing e-commerce solution.", "type": "library", - "version": "1.13.7", + "version": "1.14.0", "license": "proprietary", "authors": [ { diff --git a/src/Mirakl/MCI/Common/Domain/Attribute.php b/src/Mirakl/MCI/Common/Domain/Attribute.php index 0b2508d..c63d8ca 100644 --- a/src/Mirakl/MCI/Common/Domain/Attribute.php +++ b/src/Mirakl/MCI/Common/Domain/Attribute.php @@ -3,46 +3,51 @@ use Mirakl\Core\Domain\MiraklObject; use Mirakl\MCI\Common\Domain\Collection\AttributeParameterCollection; +use Mirakl\MCI\Common\Domain\Collection\AttributeProductFeedCollection; use Mirakl\MCI\Common\Domain\Collection\AttributeRoleCollection; use Mirakl\MCI\Common\Domain\Collection\ValueTranslationCollection; /** - * @method string getCode() - * @method $this setCode(string $code) - * @method string getDefaultValue() @deprecated Please use getTypeParameters() instead. - * @method $this setDefaultValue(string $defaultValue) @deprecated Please use setTypeParameters() instead. - * @method string getDescription() - * @method $this setDescription(string $description) - * @method ValueTranslationCollection getDescriptionTranslations() - * @method string getExample() - * @method $this setExample(string $example) - * @method string getHierarchyCode() - * @method $this setHierarchyCode(string $hierarchyCode) - * @method string getLabel() - * @method $this setLabel(string $label) - * @method ValueTranslationCollection getLabelTranslations() - * @method bool getRequired() - * @method $this setRequired(bool $required) - * @method string getRequirementLevel() - * @method $this setRequirementLevel(bool $requirementLevel) - * @method bool isRequired() - * @method AttributeRoleCollection getRoles() - * @method $this setRoles(AttributeRoleCollection $roles) - * @method string getType() - * @method $this setType(string $type) - * @method string getTypeParameter() @deprecated Please use getTypeParameters() instead. - * @method $this setTypeParameter(string $typeParameter) @deprecated Please use setTypeParameters() instead. - * @method AttributeParameterCollection getTypeParameters() - * @method $this setTypeParameters(AttributeParameterCollection $typeParameters) - * @method string getTransformations() - * @method $this setTransformations(string $transformations) - * @method string getUniqueCode() - * @method $this setUniqueCode(string $uniqueCode) - * @method string getValidations() - * @method $this setValidations(string $validations) - * @method bool getVariant() - * @method $this setVariant(bool $variant) - * @method bool isVariant() + * @method string getCode() + * @method $this setCode(string $code) + * @method string getDefaultValue() @deprecated Please use getTypeParameters() instead. + * @method $this setDefaultValue(string $defaultValue) @deprecated Please use setTypeParameters() instead. + * @method string getDescription() + * @method $this setDescription(string $description) + * @method ValueTranslationCollection getDescriptionTranslations() + * @method $this setDescriptionTranslations(ValueTranslationCollection $descriptionTranslations) + * @method string getExample() + * @method $this setExample(string $example) + * @method string getHierarchyCode() + * @method $this setHierarchyCode(string $hierarchyCode) + * @method string getLabel() + * @method $this setLabel(string $label) + * @method ValueTranslationCollection getLabelTranslations() + * @method $this setLabelTranslations(ValueTranslationCollection $labelTranslations) + * @method AttributeProductFeedCollection getProductFeeds() + * @method $this setProductFeeds(AttributeProductFeedCollection $productFeeds) + * @method bool getRequired() + * @method $this setRequired(bool $required) + * @method string getRequirementLevel() + * @method $this setRequirementLevel(bool $requirementLevel) + * @method bool isRequired() + * @method AttributeRoleCollection getRoles() + * @method $this setRoles(AttributeRoleCollection $roles) + * @method string getType() + * @method $this setType(string $type) + * @method string getTypeParameter() @deprecated Please use getTypeParameters() instead. + * @method $this setTypeParameter(string $typeParameter) @deprecated Please use setTypeParameters() instead. + * @method AttributeParameterCollection getTypeParameters() + * @method $this setTypeParameters(AttributeParameterCollection $typeParameters) + * @method string getTransformations() + * @method $this setTransformations(string $transformations) + * @method string getUniqueCode() + * @method $this setUniqueCode(string $uniqueCode) + * @method string getValidations() + * @method $this setValidations(string $validations) + * @method bool getVariant() + * @method $this setVariant(bool $variant) + * @method bool isVariant() */ class Attribute extends MiraklObject { @@ -54,5 +59,6 @@ class Attribute extends MiraklObject 'label_translations' => [ValueTranslationCollection::class, 'create'], 'roles' => [AttributeRoleCollection::class, 'create'], 'type_parameters' => [AttributeParameterCollection::class, 'create'], + 'product_feeds' => [AttributeProductFeedCollection::class, 'create'], ]; } \ No newline at end of file diff --git a/src/Mirakl/MCI/Common/Domain/AttributeProductFeed.php b/src/Mirakl/MCI/Common/Domain/AttributeProductFeed.php new file mode 100644 index 0000000..7306609 --- /dev/null +++ b/src/Mirakl/MCI/Common/Domain/AttributeProductFeed.php @@ -0,0 +1,11 @@ + [ProductFeeds::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MCI/Common/Domain/Product/ProductDataSheetValidationStatus.php b/src/Mirakl/MCI/Common/Domain/Product/ProductDataSheetValidationStatus.php new file mode 100644 index 0000000..5c307ad --- /dev/null +++ b/src/Mirakl/MCI/Common/Domain/Product/ProductDataSheetValidationStatus.php @@ -0,0 +1,9 @@ + [ChannelCollection::class, 'create'], + 'description_translations' => [ValueTranslationCollection::class, 'create'], + 'label_translations' => [ValueTranslationCollection::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportError.php b/src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportError.php new file mode 100644 index 0000000..ed697b4 --- /dev/null +++ b/src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportError.php @@ -0,0 +1,13 @@ + [ValueTranslationCollection::class, 'create'], + 'label_translations' => [ValueTranslationCollection::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportReportItem.php b/src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportReportItem.php new file mode 100644 index 0000000..324b730 --- /dev/null +++ b/src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportReportItem.php @@ -0,0 +1,20 @@ + [Errors::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportReportStatus.php b/src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportReportStatus.php new file mode 100644 index 0000000..e9b69e1 --- /dev/null +++ b/src/Mirakl/MCI/Common/Domain/ProductFeed/ProductFeedImportReportStatus.php @@ -0,0 +1,8 @@ +setCode($code); + } + } + + /** + * @inheritdoc + */ + public function getResponseDecorator() + { + return ProductFeedCollection::decorator('product_feeds'); + } +} \ No newline at end of file diff --git a/src/Mirakl/MCI/Shop/Request/Product/ProductImportRequest.php b/src/Mirakl/MCI/Shop/Request/Product/ProductImportRequest.php index 117bf35..5290c72 100644 --- a/src/Mirakl/MCI/Shop/Request/Product/ProductImportRequest.php +++ b/src/Mirakl/MCI/Shop/Request/Product/ProductImportRequest.php @@ -14,9 +14,15 @@ * * $api = new ShopApiClient('API_URL', 'API_KEY', 'SHOP_ID'); * $request = new ProductImportRequest(new \SplFileObject('/path/to/file.csv')); + * * $result = $api->importProducts($request); * // $result => @see \Mirakl\MCI\Common\Domain\Product\ProductImportTracking * */ class ProductImportRequest extends AbstractProductImportRequest -{} \ No newline at end of file +{ + /** + * @var array + */ + public $bodyParams = ['operator_format']; +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Common/Domain/Collection/Offer/Shipping/ShippingPriceByZoneAndTypeCollection.php b/src/Mirakl/MMP/Common/Domain/Collection/Offer/Shipping/ShippingPriceByZoneAndTypeCollection.php new file mode 100644 index 0000000..b78335e --- /dev/null +++ b/src/Mirakl/MMP/Common/Domain/Collection/Offer/Shipping/ShippingPriceByZoneAndTypeCollection.php @@ -0,0 +1,13 @@ + [ThreadParticipantCollection::class, 'create'], 'entities' => [ThreadEntityCollection::class, 'create'], 'metadata' => [ThreadMetadata::class, 'create'], + 'customer_organization' => [ThreadCustomerOrganization::class, 'create'], ]; } \ No newline at end of file diff --git a/src/Mirakl/MMP/Common/Domain/Message/Thread/ThreadCustomerOrganization.php b/src/Mirakl/MMP/Common/Domain/Message/Thread/ThreadCustomerOrganization.php new file mode 100644 index 0000000..b0defa5 --- /dev/null +++ b/src/Mirakl/MMP/Common/Domain/Message/Thread/ThreadCustomerOrganization.php @@ -0,0 +1,13 @@ + 'discount_ranges', ]; + /** + * @param array $data + */ + public function __construct(array $data = []) + { + static::$dataTypes['measurements'] = [ProductMeasurementCollection::class, 'create']; + parent::__construct($data); + } + /** * Return origin price directly from offer to keep backwards compatibility * @@ -133,6 +149,75 @@ protected function getOfferPricingData($data, $channelCode = null) return $offerPricing; } + /** + * @param array $data + * @return array + */ + protected function getOfferShippingPricingData(array $data) + { + // Collect shipping prices by type and zone + $shippingPricesByZoneAndType = []; + foreach ($data as $key => $value) { + $key = trim($key); + + preg_match('/^shipping-price\[zone=(.+),method=(.+)\]$/', $key, $matches); + + if (empty($matches[1]) || empty($matches[2])) { + continue; + } + + list (, $shippingZone, $shippingType) = $matches; + + $shippingPriceByZoneAndType = new ShippingPriceByZoneAndType(); + $shippingPriceByZoneAndType->setCode($shippingType); + $shippingPriceByZoneAndType->setShippingZoneCode($shippingZone); + $shippingPriceByZoneAndType->setShippingPriceUnit($value); + + $deliveryTime = new DeliveryTime(); + + $deliveryMinDaysColumn = sprintf('delivery-time-earliest-days[zone=%s,method=%s]', $shippingZone, $shippingType); + if (isset($data[$deliveryMinDaysColumn])) { + $deliveryTime->setEarliestDays($data[$deliveryMinDaysColumn]); + } + + $deliveryMaxDaysColumn = sprintf('delivery-time-latest-days[zone=%s,method=%s]', $shippingZone, $shippingType); + if (isset($data[$deliveryMaxDaysColumn])) { + $deliveryTime->setLatestDays($data[$deliveryMaxDaysColumn]); + } + + $shippingPriceByZoneAndType->setDeliveryTime($deliveryTime); + + $shippingPricesByZoneAndType[] = $shippingPriceByZoneAndType; + } + + return $shippingPricesByZoneAndType; + } + + /** + * @param array $data + * @return array + */ + protected function getOfferMeasurements(array $data) + { + // Collect measurements data + $measurements = []; + foreach ($data as $key => $value) { + if ($key !== 'measurement-units' || empty($value)) { + continue; + } + $measurementsData = explode(ProductMeasurement::UNIT_SEPARATOR, $value); + foreach ($measurementsData as $measurementData) { + list ($unit, $totalMeasurementOfProduct) = explode(ProductMeasurement::QUANTITY_SEPARATOR, $measurementData); + $measurement = new ProductMeasurement(); + $measurement->setUnit($unit); + $measurement->setTotalMeasurementOfProduct($totalMeasurementOfProduct); + $measurements[] = $measurement; + } + } + + return $measurements; + } + /** * @inheritdoc */ @@ -154,6 +239,20 @@ public function setData($key, $value = null) } $this->setAllPrices($allPrices); + $shippingTypes = new ShippingPriceByZoneAndTypeCollection(); + foreach ($this->getOfferShippingPricingData($key) as $shippingPriceByZoneAndType) { + $shippingTypes->add($shippingPriceByZoneAndType); + } + + $this->setShippingTypes($shippingTypes); + + $measurementsCollection = new ProductMeasurementCollection(); + foreach ($this->getOfferMeasurements($key) as $measurement) { + $measurementsCollection->add($measurement); + } + + $this->setMeasurements($measurementsCollection); + return $this; } } diff --git a/src/Mirakl/MMP/Common/Domain/Offer/AbstractOffer.php b/src/Mirakl/MMP/Common/Domain/Offer/AbstractOffer.php index a665119..f8d33f4 100644 --- a/src/Mirakl/MMP/Common/Domain/Offer/AbstractOffer.php +++ b/src/Mirakl/MMP/Common/Domain/Offer/AbstractOffer.php @@ -5,69 +5,75 @@ use Mirakl\MMP\Common\Domain\Category\LogisticClass; use Mirakl\MMP\Common\Domain\Collection\AdditionalFieldValueCollection; use Mirakl\MMP\Common\Domain\Collection\Offer\Price\OfferPricesCollection; +use Mirakl\MMP\Common\Domain\Collection\Offer\Shipping\ShippingPriceByZoneAndTypeCollection; use Mirakl\MMP\Common\Domain\Discount; +use Mirakl\MMP\Common\Domain\Fulfillment\Fulfillment; use Mirakl\MMP\Common\Domain\Offer\Price\OfferPricing; /** - * @method bool getActive() - * @method $this setActive(bool $active) - * @method bool isActive() - * @method bool getAllowQuoteRequests() - * @method $this setAllowQuoteRequests(bool $allowQuoteRequests) - * @method OfferPricesCollection getAllPrices() - * @method $this setAllPrices(array|OfferPricesCollection $Prices) - * @method OfferPricing getApplicablePricing() - * @method $this setApplicablePricing(array|OfferPricing $Prices) - * @method OfferAvailability getAvailability() - * @method $this setAvailability(array|OfferAvailability $availability) - * @method AdditionalFieldValueCollection getAdditionalFields() - * @method $this setAdditionalFields(array|AdditionalFieldValueCollection $additionalFields) - * @method array getChannels() - * @method string getCurrencyIsoCode() - * @method $this setCurrencyIsoCode(string $currencyIsoCode) - * @method string getDescription() - * @method $this setDescription(string $description) - * @method Discount getDiscount() - * @method int getFavoriteRank() - * @method $this setFavoriteRank(int $favoriteRank) - * @method array getInactivityReasons() - * @method $this setInactivityReasons(array $inactivityReasons) - * @method int getLeadtimeToShip() (in days) - * @method $this setLeadtimeToShip(int $leadtimeToShip) - * @method LogisticClass getLogisticClass() - * @method $this setLogisticClass(array|LogisticClass $logisticClass) - * @method int getMaxOrderQuantity() - * @method $this setMaxOrderQuantity(int $maxOrderQuantity) - * @method int getMinOrderQuantity() - * @method $this setMinOrderQuantity(int $minOrderQuantity) - * @method int getPackageQuantity() - * @method $this setPackageQuantity(int $packageQuantity) - * @method int getMinQuantityAlert() - * @method $this setMinQuantityAlert(int $minQuantityAlert) - * @method OfferMinimumShipping getMinShipping() - * @method $this setMinShipping(array|OfferMinimumShipping $minShipping) - * @method string getOfferId() - * @method $this setOfferId(string $id) - * @method bool getPremium() - * @method $this setPremium(bool $flag) - * @method bool isPremium() - * @method bool getProfessional() - * @method $this setProfessional(bool $flag) - * @method bool isProfessional() - * @method float getPrice() - * @method $this setPrice(float $price) - * @method string getPriceAdditionalInfo() - * @method $this setPriceAdditionalInfo(string $priceAdditionalInfo) - * @method ProductInfoWithRefs getProduct() - * @method $this setProduct(array|ProductInfoWithRefs $productInfoWithRefs) - * @method string getProductTaxCode() - * @method $this setProductTaxCode(string $productTaxCode) - * @method int getQuantity() - * @method $this setQuantity(int $quantity) - * @method string getStateCode() - * @method $this setStateCode(string $stateCode) - * @method float getTotalPrice() - * @method $this setTotalPrice(float $totalPrice) + * @method bool getActive() + * @method $this setActive(bool $active) + * @method bool isActive() + * @method bool getAllowQuoteRequests() + * @method $this setAllowQuoteRequests(bool $allowQuoteRequests) + * @method OfferPricesCollection getAllPrices() + * @method $this setAllPrices(array|OfferPricesCollection $Prices) + * @method OfferPricing getApplicablePricing() + * @method $this setApplicablePricing(array|OfferPricing $Prices) + * @method OfferAvailability getAvailability() + * @method $this setAvailability(array|OfferAvailability $availability) + * @method AdditionalFieldValueCollection getAdditionalFields() + * @method $this setAdditionalFields(array|AdditionalFieldValueCollection $additionalFields) + * @method array getChannels() + * @method string getCurrencyIsoCode() + * @method $this setCurrencyIsoCode(string $currencyIsoCode) + * @method string getDescription() + * @method $this setDescription(string $description) + * @method Discount getDiscount() + * @method int getFavoriteRank() + * @method $this setFavoriteRank(int $favoriteRank) + * @method Fulfillment getFulfillment() + * @method $this setFulfillment(Fulfillment $fulfillment) + * @method array getInactivityReasons() + * @method $this setInactivityReasons(array $inactivityReasons) + * @method int getLeadtimeToShip() (in days) + * @method $this setLeadtimeToShip(int $leadtimeToShip) + * @method LogisticClass getLogisticClass() + * @method $this setLogisticClass(array|LogisticClass $logisticClass) + * @method int getMaxOrderQuantity() + * @method $this setMaxOrderQuantity(int $maxOrderQuantity) + * @method int getMinOrderQuantity() + * @method $this setMinOrderQuantity(int $minOrderQuantity) + * @method int getPackageQuantity() + * @method $this setPackageQuantity(int $packageQuantity) + * @method int getMinQuantityAlert() + * @method $this setMinQuantityAlert(int $minQuantityAlert) + * @method OfferMinimumShipping getMinShipping() + * @method $this setMinShipping(array|OfferMinimumShipping $minShipping) + * @method string getOfferId() + * @method $this setOfferId(string $id) + * @method bool getPremium() + * @method $this setPremium(bool $flag) + * @method bool isPremium() + * @method bool getProfessional() + * @method $this setProfessional(bool $flag) + * @method bool isProfessional() + * @method float getPrice() + * @method $this setPrice(float $price) + * @method string getPriceAdditionalInfo() + * @method $this setPriceAdditionalInfo(string $priceAdditionalInfo) + * @method ProductInfoWithRefs getProduct() + * @method $this setProduct(array|ProductInfoWithRefs $productInfoWithRefs) + * @method string getProductTaxCode() + * @method $this setProductTaxCode(string $productTaxCode) + * @method int getQuantity() + * @method $this setQuantity(int $quantity) + * @method string getStateCode() + * @method $this setStateCode(string $stateCode) + * @method float getTotalPrice() + * @method $this setTotalPrice(float $totalPrice) + * @method ShippingPriceByZoneAndTypeCollection getShippingTypes() + * @method $this setShippingTypes(ShippingPriceByZoneAndTypeCollection $shippingPricesByZoneAndType) */ abstract class AbstractOffer extends MiraklObject { @@ -97,14 +103,16 @@ abstract class AbstractOffer extends MiraklObject * @var array */ protected static $dataTypes = [ - 'additional_fields' => [AdditionalFieldValueCollection::class, 'create'], - 'availability' => [OfferAvailability::class, 'create'], - 'discount' => [Discount::class, 'create'], - 'logistic_class' => [LogisticClass::class, 'create'], - 'min_shipping' => [OfferMinimumShipping::class, 'create'], - 'product' => [ProductInfoWithRefs::class, 'create'], - 'all_prices' => [OfferPricesCollection::class, 'create'], - 'applicable_pricing' => [OfferPricing::class, 'create'], + 'additional_fields' => [AdditionalFieldValueCollection::class, 'create'], + 'availability' => [OfferAvailability::class, 'create'], + 'discount' => [Discount::class, 'create'], + 'logistic_class' => [LogisticClass::class, 'create'], + 'min_shipping' => [OfferMinimumShipping::class, 'create'], + 'product' => [ProductInfoWithRefs::class, 'create'], + 'all_prices' => [OfferPricesCollection::class, 'create'], + 'applicable_pricing' => [OfferPricing::class, 'create'], + 'shipping_types' => [ShippingPriceByZoneAndTypeCollection::class, 'create'], + 'fulfillment' => [Fulfillment::class, 'create'], ]; /** diff --git a/src/Mirakl/MMP/Common/Domain/Offer/Shipping/DeliveryTime.php b/src/Mirakl/MMP/Common/Domain/Offer/Shipping/DeliveryTime.php new file mode 100644 index 0000000..ca527b6 --- /dev/null +++ b/src/Mirakl/MMP/Common/Domain/Offer/Shipping/DeliveryTime.php @@ -0,0 +1,13 @@ + [DeliveryTime::class, 'create'] + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Common/Domain/Order/AbstractCustomerOrganization.php b/src/Mirakl/MMP/Common/Domain/Order/AbstractCustomerOrganization.php new file mode 100644 index 0000000..03517b3 --- /dev/null +++ b/src/Mirakl/MMP/Common/Domain/Order/AbstractCustomerOrganization.php @@ -0,0 +1,24 @@ + [CustomerOrganizationAddress::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Common/Domain/Order/AbstractOrder.php b/src/Mirakl/MMP/Common/Domain/Order/AbstractOrder.php index 415cd82..5801f57 100644 --- a/src/Mirakl/MMP/Common/Domain/Order/AbstractOrder.php +++ b/src/Mirakl/MMP/Common/Domain/Order/AbstractOrder.php @@ -55,6 +55,8 @@ * @method $this setPromotions(array|OrderPromotionsSummary $promotions) * @method string getQuoteId() * @method $this setQuoteId(string $quoteId) + * @method OrderReferences getReferences() + * @method $this setReferences(array|OrderReferences $references) * @method OrderShipping getShipping() * @method $this setShipping(array|OrderShipping $shipping) * @method \DateTime getShippingDeadline() @@ -104,5 +106,6 @@ abstract class AbstractOrder extends MiraklObject 'promotions' => [OrderPromotionsSummary::class, 'create'], 'shipping' => [OrderShipping::class, 'create'], 'status' => [OrderStatus::class, 'create'], + 'references' => [OrderReferences::class, 'create'], ]; } \ No newline at end of file diff --git a/src/Mirakl/MMP/Common/Domain/Order/AbstractOrderCustomer.php b/src/Mirakl/MMP/Common/Domain/Order/AbstractOrderCustomer.php index 777cb93..fc56735 100644 --- a/src/Mirakl/MMP/Common/Domain/Order/AbstractOrderCustomer.php +++ b/src/Mirakl/MMP/Common/Domain/Order/AbstractOrderCustomer.php @@ -6,6 +6,8 @@ /** * @method CustomerBillingAddress getBillingAddress() * @method $this setBillingAddress(array|CustomerBillingAddress $billingAddress) + * @method CustomerOrganization getOrganization() + * @method $this setOrganization(array|CustomerOrganization $organization) */ abstract class AbstractOrderCustomer extends AbstractCustomer { @@ -14,5 +16,6 @@ abstract class AbstractOrderCustomer extends AbstractCustomer */ protected static $dataTypes = [ 'billing_address' => [CustomerBillingAddress::class, 'create'], + 'organization' => [CustomerOrganization::class, 'create'], ]; } \ No newline at end of file diff --git a/src/Mirakl/MMP/Common/Domain/Order/CustomerOrganization.php b/src/Mirakl/MMP/Common/Domain/Order/CustomerOrganization.php new file mode 100644 index 0000000..20ea67d --- /dev/null +++ b/src/Mirakl/MMP/Common/Domain/Order/CustomerOrganization.php @@ -0,0 +1,26 @@ +getOrganizationId(); + } + + /** + * @param string $id + * @return $this + */ + public function setId($id) + { + return $this->setOrganizationId($id); + } +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Common/Domain/Order/CustomerOrganizationAddress.php b/src/Mirakl/MMP/Common/Domain/Order/CustomerOrganizationAddress.php new file mode 100644 index 0000000..05edb28 --- /dev/null +++ b/src/Mirakl/MMP/Common/Domain/Order/CustomerOrganizationAddress.php @@ -0,0 +1,23 @@ + [ShippingInfo::class, 'create'], 'kyc' => [ShopKyc::class, 'create'], 'shop_stats' => [ShopStats::class, 'create'], + 'applicable_taxes' => [ShopApplicableTaxCollection::class, 'create'], ]; } \ No newline at end of file diff --git a/src/Mirakl/MMP/Common/Domain/Shop/Bank/PaymentInfo.php b/src/Mirakl/MMP/Common/Domain/Shop/Bank/PaymentInfo.php index 8f41290..455f1f0 100644 --- a/src/Mirakl/MMP/Common/Domain/Shop/Bank/PaymentInfo.php +++ b/src/Mirakl/MMP/Common/Domain/Shop/Bank/PaymentInfo.php @@ -4,7 +4,7 @@ use Mirakl\Core\Domain\MiraklObject; /** - * Payment information that would be use to generate the invoice and the payment voucher info file + * Payment information that would be used to generate the invoice and the payment voucher info file * * @method string getOwner() * @method $this setOwner(string $owner) @@ -16,6 +16,9 @@ class PaymentInfo extends MiraklObject */ public static $type = ''; + /** + * @inheritdoc + */ public function __construct(array $data = []) { parent::__construct($data); @@ -68,6 +71,9 @@ public static function factory(array $info) case ThaiBankAccountInfo::$type: $info = new ThaiBankAccountInfo($info); break; + case UkBankAccountInfo::$type: + $info = new UkBankAccountInfo($info); + break; default: $info = new PaymentInfo($info); } diff --git a/src/Mirakl/MMP/Common/Domain/Shop/Bank/UkBankAccountInfo.php b/src/Mirakl/MMP/Common/Domain/Shop/Bank/UkBankAccountInfo.php new file mode 100644 index 0000000..b973cdb --- /dev/null +++ b/src/Mirakl/MMP/Common/Domain/Shop/Bank/UkBankAccountInfo.php @@ -0,0 +1,18 @@ +setLastRequestDate($lastRequestDate); } } + + /** + * @inheritdoc + */ + public function getQueryParams() + { + $params = parent::getQueryParams(); + if (isset($params['shipping_zones'])) { + $params['shipping_zones'] = \Mirakl\tuples_to_query_param($this->getShippingZones()); + } + + return $params; + } } \ No newline at end of file diff --git a/src/Mirakl/MMP/Common/Request/Order/AbstractGetOrdersRequest.php b/src/Mirakl/MMP/Common/Request/Order/AbstractGetOrdersRequest.php index 811268a..d2f291d 100644 --- a/src/Mirakl/MMP/Common/Request/Order/AbstractGetOrdersRequest.php +++ b/src/Mirakl/MMP/Common/Request/Order/AbstractGetOrdersRequest.php @@ -13,22 +13,26 @@ * Sort by creation date, order identifier, shop name and then by index of the order line * This API uses pagination by default and will return 10 orders * - * @method array getChannelCodes() - * @method $this setChannelCodes(array $channelCodes) + * @method string[] getChannelCodes() + * @method $this setChannelCodes(string[] $channelCodes) * @method bool getCustomerDebited() * @method $this setCustomerDebited(bool $customerDebited) * @method \DateTime getEndUpdateDate() * @method $this setEndUpdateDate(\DateTime $endUpdateDate) - * @method array getFulfillmentCenterCodes() - * @method $this setFulfillmentCenterCodes(array $fulfillmentCenterCode) + * @method string[] getFulfillmentCenterCodes() + * @method $this setFulfillmentCenterCodes(string[] $fulfillmentCenterCodes) * @method bool getHasIncident() * @method $this setHasIncident(bool $hasIncident) * @method bool getOnlyNullChannel() * @method $this setOnlyNullChannel(bool $onlyNullChannel) - * @method array getOrderIds() - * @method $this setOrderIds(array $ids) - * @method array getOrderStates() - * @method $this setOrderStates(array $orderStates) + * @method string[] getOrderIds() + * @method $this setOrderIds(string[] $ids) + * @method string[] getOrderReferencesForCustomer() + * @method $this setOrderReferencesForCustomer(string[] $orderReferencesForCustomer) + * @method string[] getOrderReferencesForSeller() + * @method $this setOrderReferencesForSeller(string[] $orderReferencesForSeller) + * @method string[] getOrderStates() + * @method $this setOrderStates(string[] $orderStates) * @method string getOrderTaxMode() * @method $this setOrderTaxMode(string $orderTaxMode) * @method string getPaymentWorkflow() @@ -63,6 +67,8 @@ abstract class AbstractGetOrdersRequest extends AbstractRequest 'order_tax_mode', 'payment_workflow', 'start_update_date', + 'order_references_for_customer', + 'order_references_for_seller', ]; /** diff --git a/src/Mirakl/MMP/Common/Request/Product/Offer/AbstractGetOffersOnProductsRequest.php b/src/Mirakl/MMP/Common/Request/Product/Offer/AbstractGetOffersOnProductsRequest.php index c331c33..d31cdcc 100644 --- a/src/Mirakl/MMP/Common/Request/Product/Offer/AbstractGetOffersOnProductsRequest.php +++ b/src/Mirakl/MMP/Common/Request/Product/Offer/AbstractGetOffersOnProductsRequest.php @@ -25,6 +25,8 @@ * @method $this setPricingChannelCode(string $pricingChannelCode) * @method array getProductIds() * @method $this setProductIds(array $productIds) + * @method array getShippingZones() + * @method $this setShippingZones(array $shippingZones) */ abstract class AbstractGetOffersOnProductsRequest extends AbstractRequest { @@ -69,5 +71,19 @@ public function __construct(array $productIds = null, array $offerStateCodes = n 'all_channels', 'product_references', 'pricing_channel_code', + 'shipping_zones' ]; + + /** + * @inheriDoc + */ + public function getQueryParams() + { + $params = parent::getQueryParams(); + if (isset($params['shipping_zones'])) { + $params['shipping_zones'] = \Mirakl\tuples_to_query_param($this->getShippingZones()); + } + + return $params; + } } diff --git a/src/Mirakl/MMP/OperatorShop/Domain/Collection/Order/Importer/OfferImportCollection.php b/src/Mirakl/MMP/OperatorShop/Domain/Collection/Order/Importer/OfferImportCollection.php new file mode 100644 index 0000000..3c94d28 --- /dev/null +++ b/src/Mirakl/MMP/OperatorShop/Domain/Collection/Order/Importer/OfferImportCollection.php @@ -0,0 +1,20 @@ + [ShopCustomerShippingAddress::class, 'create'], + 'shipping_address' => [ShopCustomerShippingAddress::class, 'create'], + 'accounting_contact' => [ShopOrderAdditionalContact::class, 'create'], + 'delivery_contact' => [ShopOrderAdditionalContact::class, 'create'], ]; } \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdateOrder.php b/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdateOrder.php new file mode 100644 index 0000000..d62ff34 --- /dev/null +++ b/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdateOrder.php @@ -0,0 +1,20 @@ + [UpdateReferences::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdateReferences.php b/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdateReferences.php new file mode 100644 index 0000000..f66e161 --- /dev/null +++ b/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdateReferences.php @@ -0,0 +1,11 @@ + [UpdatedReferences::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdatedOrderAndError.php b/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdatedOrderAndError.php new file mode 100644 index 0000000..471f9dd --- /dev/null +++ b/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdatedOrderAndError.php @@ -0,0 +1,24 @@ + [ErrorCollection::class, 'create'], + 'updated' => [UpdatedOrder::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdatedReferences.php b/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdatedReferences.php new file mode 100644 index 0000000..d837ad4 --- /dev/null +++ b/src/Mirakl/MMP/Shop/Domain/Order/Update/UpdatedReferences.php @@ -0,0 +1,11 @@ + [OfferMinimumShipping::class, 'create'], - 'product' => [ProductInfoWithRefs::class, 'create'], - 'all_prices' => [OfferPricesCollection::class, 'create'], - 'applicable_pricing' => [OfferPricing::class, 'create'], + 'min_shipping' => [OfferMinimumShipping::class, 'create'], + 'product' => [ProductInfoWithRefs::class, 'create'], + 'all_prices' => [OfferPricesCollection::class, 'create'], + 'applicable_pricing' => [OfferPricing::class, 'create'], + 'shipping_types' => [ShippingPriceByZoneAndTypeCollection::class, 'create'], ]; /** diff --git a/src/Mirakl/MMP/Shop/Domain/Reason.php b/src/Mirakl/MMP/Shop/Domain/Reason.php index 61b754f..3e912b3 100644 --- a/src/Mirakl/MMP/Shop/Domain/Reason.php +++ b/src/Mirakl/MMP/Shop/Domain/Reason.php @@ -8,6 +8,18 @@ * @method $this setCode(string $code) * @method string getLabel() * @method $this setLabel(string $label) + * @method bool getShopRight() + * @method $this setShopRight(bool $flag) + * @method bool isShopRight() + * @method string getType() + * @method $this setType(string $type) */ class Reason extends MiraklObject -{} \ No newline at end of file +{ + /** + * @var array + */ + protected static $mapping = [ + 'is_shop_right' => 'shop_right', + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccount.php b/src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccount.php new file mode 100644 index 0000000..95b81ae --- /dev/null +++ b/src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccount.php @@ -0,0 +1,51 @@ + [UpdateShopAccountAddress::class, 'create'], + 'pro_details' => [UpdateShopAccountProDetails::class, 'create'], + 'payment_info' => [PaymentInfo::class, 'factory'], + 'shop_additional_fields' => [AdditionalFieldValueCollection::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccountAddress.php b/src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccountAddress.php new file mode 100644 index 0000000..31a8759 --- /dev/null +++ b/src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccountAddress.php @@ -0,0 +1,69 @@ + 'street1', + 'street_2' => 'street2', + ]; + + /** + * @return string + */ + public function getStreet1() + { + return $this->getData('street1'); + } + + /** + * @param string $street1 + * @return $this + */ + public function setStreet1($street1) + { + return $this->setData('street1', $street1); + } + + /** + * @return string + */ + public function getStreet2() + { + return $this->getData('street2'); + } + + /** + * @param string $street2 + * @return $this + */ + public function setStreet2($street2) + { + return $this->setData('street2', $street2); + } +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccountProDetails.php b/src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccountProDetails.php new file mode 100644 index 0000000..bf36940 --- /dev/null +++ b/src/Mirakl/MMP/Shop/Domain/Shop/Update/UpdateShopAccountProDetails.php @@ -0,0 +1,15 @@ + [ErrorCollection::class, 'create'], + 'updated' => [UpdatedShopAccount::class, 'create'], + ]; +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Request/Offer/Importer/OffersImportsRequest.php b/src/Mirakl/MMP/Shop/Request/Offer/Importer/OffersImportsRequest.php new file mode 100644 index 0000000..463a7f0 --- /dev/null +++ b/src/Mirakl/MMP/Shop/Request/Offer/Importer/OffersImportsRequest.php @@ -0,0 +1,40 @@ + + * use Mirakl\MMP\Shop\Client\ShopApiClient; + * use Mirakl\MMP\Shop\Request\Offer\Importer\OffersImportsRequest; + * use Mirakl\MMP\OperatorShop\Domain\Offer\Importer\ImportMode; + * use Mirakl\MMP\OperatorShop\Domain\Offer\Importer\ImportOrigin; + * + * $api = new ShopApiClient('API_URL', 'API_KEY', 'SHOP_ID'); + * + * $request = new OffersImportsRequest(); + * $request->setOrigins([ImportOrigin::API, ImportOrigin::FRONT]); + * $request->setMode(ImportMode::PARTIAL_UPDATE); + * + * $result = $api->getOffersImports($request); + * // $result => @see \Mirakl\MMP\Common\Domain\Collection\SeekableCollection + * + * // Loop on collection with $result->getCollection() + * $collection = $result->getCollection(); + * // $collection => @see \Mirakl\MMP\OperatorShop\Domain\Collection\Order\Importer\OfferImportCollection + * + * // Get next results with token from response: + * $request = new OffersImportsRequest(); + * $request->setPageToken($result->getNextPageToken()); + * $result = $api->getOffersImports($request); + * var_dump($result); // @see \Mirakl\MMP\Common\Domain\Collection\SeekableCollection + * + * // See also previous token: @see \Mirakl\MMP\Common\Domain\Collection\SeekableCollection::getPreviousPageToken() + * + */ +class OffersImportsRequest extends AbstractOffersImportsRequest +{} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Request/Offer/UpdateOffersRequest.php b/src/Mirakl/MMP/Shop/Request/Offer/UpdateOffersRequest.php index e9f0180..e27add8 100644 --- a/src/Mirakl/MMP/Shop/Request/Offer/UpdateOffersRequest.php +++ b/src/Mirakl/MMP/Shop/Request/Offer/UpdateOffersRequest.php @@ -5,7 +5,9 @@ /** * (OF24) Update offers + * * Example: + * * * use Mirakl\MMP\Shop\Client\ShopApiClient; * use Mirakl\MMP\Shop\Request\Offer\UpdateOffersRequest; diff --git a/src/Mirakl/MMP/Shop/Request/Order/Update/UpdateOrdersRequest.php b/src/Mirakl/MMP/Shop/Request/Order/Update/UpdateOrdersRequest.php new file mode 100644 index 0000000..b8dc412 --- /dev/null +++ b/src/Mirakl/MMP/Shop/Request/Order/Update/UpdateOrdersRequest.php @@ -0,0 +1,77 @@ + + * use Mirakl\MMP\Shop\Client\ShopApiClient; + * use Mirakl\MMP\Shop\Domain\Collection\Order\Update\UpdateOrderCollection; + * use Mirakl\MMP\Shop\Domain\Order\Update\UpdateOrder; + * use Mirakl\MMP\Shop\Request\Order\Update\UpdateOrdersRequest; + * + * $api = new ShopApiClient('API_URL', 'API_KEY', 'SHOP_ID'); + * + * $updateOrder = new UpdateOrder(); + * $updateOrder->setOrderId('ORDER_ID_1'); + * + * $collection = new UpdateOrderCollection(); + * $collection->add($updateOrder); + * + * $request = new UpdateOrdersRequest($collection); + * + * $result = $api->updateOrders($request); + * + * // $result => @see \Mirakl\MMP\Shop\Domain\Collection\Order\Update\UpdatedOrderAndErrorCollection + * + */ +class UpdateOrdersRequest extends AbstractRequest +{ + /** + * @var string + */ + protected $method = 'PUT'; + + /** + * @var string + */ + protected $endpoint = '/orders'; + + /** + * @var array + */ + public $bodyParams = ['orders']; + + /** + * @var array + */ + protected static $dataTypes = [ + 'orders' => [UpdateOrderCollection::class, 'create'], + ]; + + /** + * @param array|UpdateOrderCollection $orders + */ + public function __construct($orders) + { + parent::__construct(); + $this->setOrders($orders); + } + + /** + * @inheritdoc + */ + public function getResponseDecorator() + { + return UpdatedOrderAndErrorCollection::decorator('updated_orders'); + } +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Request/Reason/GetReasonsRequest.php b/src/Mirakl/MMP/Shop/Request/Reason/GetReasonsRequest.php new file mode 100644 index 0000000..7812012 --- /dev/null +++ b/src/Mirakl/MMP/Shop/Request/Reason/GetReasonsRequest.php @@ -0,0 +1,42 @@ + + * use Mirakl\MMP\Shop\Client\ShopApiClient; + * use Mirakl\MMP\Shop\Request\Reason\GetReasonsRequest; + * + * $api = new ShopApiClient('API_URL', 'API_KEY', 'SHOP_ID'); + * + * $request = new GetReasonsRequest(); + * $result = $api->getReasons($request); + * // $result => @see \Mirakl\MMP\Shop\Domain\Collection\Reason\ReasonCollection + * + */ +class GetReasonsRequest extends AbstractRequest +{ + use LocalizableTrait; + + /** + * @var string + */ + protected $endpoint = '/reasons'; + + /** + * @inheritdoc + */ + public function getResponseDecorator() + { + return ReasonCollection::decorator('reasons'); + } +} \ No newline at end of file diff --git a/src/Mirakl/MMP/Shop/Request/Reason/GetTypeReasonsRequest.php b/src/Mirakl/MMP/Shop/Request/Reason/GetTypeReasonsRequest.php index 9d29ec6..e7e6fc5 100644 --- a/src/Mirakl/MMP/Shop/Request/Reason/GetTypeReasonsRequest.php +++ b/src/Mirakl/MMP/Shop/Request/Reason/GetTypeReasonsRequest.php @@ -10,6 +10,9 @@ * (RE02) Get reasons by type configured on the platform * Used for incident opening, refunds... * + * @deprecated Use RE01 instead + * @see \Mirakl\MMP\Shop\Request\Reason\GetReasonsRequest + * * @method string getReasonType() * @method $this setReasonType(string $reasonType) * diff --git a/src/Mirakl/MMP/Shop/Request/Shop/UpdateAccountRequest.php b/src/Mirakl/MMP/Shop/Request/Shop/UpdateAccountRequest.php new file mode 100644 index 0000000..c8c4c34 --- /dev/null +++ b/src/Mirakl/MMP/Shop/Request/Shop/UpdateAccountRequest.php @@ -0,0 +1,105 @@ + + * use Mirakl\MMP\Shop\Client\ShopApiClient; + * use Mirakl\MMP\Shop\Domain\Shop\Update\UpdateShopAccount; + * use Mirakl\MMP\Shop\Request\Shop\UpdateAccountRequest; + * + * $api = new ShopApiClient('API_URL', 'API_KEY', 'SHOP_ID'); + * + * $updateShopAccount = new UpdateShopAccount([ + * 'shop_name' => 'Acme Shop', + * 'description' => 'This is the description of this shop', + * 'web_site' => 'https://example.com', + * 'email' => 'my-store@example.com', + * 'is_professional' => true, + * 'channels' => ['US'], + * 'address' => [ + * 'firstname' => 'John', + * 'lastname' => 'Doe', + * 'phone' => '213-509-6996', + * 'phone_secondary' => '213-509-6995', + * 'state' => 'Manhattan', + * 'street1' => '30, Prince Street', + * 'street2' => '1st floor', + * 'city' => 'New York', + * 'zip_code' => '10012', + * 'country' => 'USA', + * ], + * 'pro_details' => [ + * 'corporate_name' => 'Mirakl Inc.', + * 'identification_number' => 'SDFIZEHF239', + * 'tax_identification_number' => 'FRIEZOF03', + * ], + * 'payment_info' => [ + * '@type' => 'IBAN', + * 'bank_name' => 'Acme Bank', + * 'bic' => 'AGRIFRPPXX2', + * 'iban' => 'FR7210096000507396196831A89', + * 'owner' => 'Super Shop', + * ], + * 'shop_additional_fields' => [ + * [ + * 'code' => 'field_1', + * 'value' => 'Lorem ipsum dolor sit amet', + * ] + * ], + * ]); + * + * $request = new UpdateAccountRequest($updateShopAccount); + * + * $result = $client->updateAccount($request); + * + * // $result => @see \Mirakl\MMP\Shop\Domain\Shop\UpdatedShopAndError + * + * + * @method UpdateShopAccount getUpdateShopAccount() + * @method $this setUpdateShopAccount(UpdateShopAccount|array $updateShopAccount) + */ +class UpdateAccountRequest extends AbstractRequest +{ + /** + * @var string + */ + protected $method = 'PUT'; + + /** + * @var string + */ + protected $endpoint = '/account'; + + /** + * @param UpdateShopAccount|array $updateShopAccount + */ + public function __construct($updateShopAccount) + { + parent::__construct(); + $this->setUpdateShopAccount($updateShopAccount); + } + + /** + * @inheritdoc + */ + public function getBodyParams() + { + return $this->getUpdateShopAccount()->toArray(); + } + + /** + * @inheritdoc + */ + public function getResponseDecorator() + { + return UpdatedShopAndError::decorator(); + } +} \ No newline at end of file