From cb05b584c9913ff974543c061c56c5c8afbe3cbf Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@ebay.com> Date: Wed, 28 Oct 2015 12:10:02 +0200 Subject: [PATCH] MAGETWO-44589: [Github] Make API jsonapi compliant --- app/code/Magento/Checkout/etc/webapi.xml | 10 +- .../web/js/model/resource-url-manager.js | 2 +- ...GuestShippingMethodManagementInterface.php | 25 -- .../Api/ShippingMethodManagementInterface.php | 25 -- .../GuestShippingAddressManagement.php | 4 +- ...uestShippingAddressManagementInterface.php | 2 +- .../GuestShippingMethodManagement.php | 3 +- ...GuestShippingMethodManagementInterface.php | 34 ++ .../Quote/Model/ShippingAddressManagement.php | 3 +- .../ShippingAddressManagementInterface.php | 2 +- .../Quote/Model/ShippingMethodManagement.php | 3 +- .../ShippingMethodManagementInterface.php | 34 ++ .../GuestShippingAddressManagementTest.php | 4 +- app/code/Magento/Quote/etc/di.xml | 6 +- app/code/Magento/Quote/etc/webapi.xml | 90 ----- .../GuestShippingAddressManagementTest.php | 244 ------------- .../Api/GuestShippingMethodManagementTest.php | 217 ----------- .../Api/ShippingAddressManagementTest.php | 345 ------------------ .../Api/ShippingMethodManagementTest.php | 255 ------------- .../Test/Handler/OrderInjectable/Webapi.php | 60 +-- setup/performance-toolkit/benchmark.jmx | 2 +- 21 files changed, 127 insertions(+), 1243 deletions(-) rename app/code/Magento/Quote/{Api => Model/GuestCart}/GuestShippingAddressManagementInterface.php (96%) create mode 100644 app/code/Magento/Quote/Model/GuestCart/GuestShippingMethodManagementInterface.php rename app/code/Magento/Quote/{Api => Model}/ShippingAddressManagementInterface.php (97%) create mode 100644 app/code/Magento/Quote/Model/ShippingMethodManagementInterface.php delete mode 100644 dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php delete mode 100644 dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php diff --git a/app/code/Magento/Checkout/etc/webapi.xml b/app/code/Magento/Checkout/etc/webapi.xml index f0312ec1776..7b3b2864aa0 100644 --- a/app/code/Magento/Checkout/etc/webapi.xml +++ b/app/code/Magento/Checkout/etc/webapi.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd"> <!-- Managing shipping guest information --> - <route url="/V1/carts/:cartId/shipping-information" method="POST"> + <route url="/V1/guest-carts/:cartId/shipping-information" method="POST"> <service class="Magento\Checkout\Api\GuestShippingInformationManagementInterface" method="saveAddressInformation"/> <resources> <resource ref="anonymous" /> @@ -27,6 +27,14 @@ </data> </route> + <!-- Managing shipping information--> + <route url="/V1/carts/:cartId/shipping-information" method="POST"> + <service class="Magento\Checkout\Api\ShippingInformationManagementInterface" method="saveAddressInformation"/> + <resources> + <resource ref="Magento_Cart::manage" /> + </resources> + </route> + <!-- Managing totals information --> <route url="/V1/carts/:cartId/totals-information" method="POST"> <service class="Magento\Checkout\Api\TotalsInformationManagementInterface" method="calculate"/> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/resource-url-manager.js b/app/code/Magento/Checkout/view/frontend/web/js/model/resource-url-manager.js index cc67ebb0788..33407345ab5 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/resource-url-manager.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/resource-url-manager.js @@ -69,7 +69,7 @@ define( getUrlForSetShippingInformation: function(quote) { var params = (this.getCheckoutMethod() == 'guest') ? {cartId: quote.getQuoteId()} : {}; var urls = { - 'guest': '/carts/:cartId/shipping-information', + 'guest': '/guest-carts/:cartId/shipping-information', 'customer': '/carts/mine/shipping-information' }; return this.getUrl(urls, params); diff --git a/app/code/Magento/Quote/Api/GuestShippingMethodManagementInterface.php b/app/code/Magento/Quote/Api/GuestShippingMethodManagementInterface.php index 29c4a07ca8d..883a7b4e1ac 100644 --- a/app/code/Magento/Quote/Api/GuestShippingMethodManagementInterface.php +++ b/app/code/Magento/Quote/Api/GuestShippingMethodManagementInterface.php @@ -11,31 +11,6 @@ namespace Magento\Quote\Api; */ interface GuestShippingMethodManagementInterface { - /** - * Set the carrier and shipping methods codes for a specified cart. - * - * @param string $cartId The shopping cart ID. - * @param string $carrierCode The carrier code. - * @param string $methodCode The shipping method code. - * @return bool - * @throws \Magento\Framework\Exception\InputException The shipping method is not valid for an empty cart. - * @throws \Magento\Framework\Exception\CouldNotSaveException The shipping method could not be saved. - * @throws \Magento\Framework\Exception\StateException The billing or shipping address is not set. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart contains only virtual products - * so the shipping method does not apply. - */ - public function set($cartId, $carrierCode, $methodCode); - - /** - * Return selected shipping method for a specified quote. - * - * @param string $cartId The shopping cart ID. - * @return \Magento\Quote\Api\Data\ShippingMethodInterface Shipping method. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified shopping cart does not exist. - * @throws \Magento\Framework\Exception\StateException The shipping address is not set. - */ - public function get($cartId); - /** * List applicable shipping methods for a specified quote. * diff --git a/app/code/Magento/Quote/Api/ShippingMethodManagementInterface.php b/app/code/Magento/Quote/Api/ShippingMethodManagementInterface.php index e9edbf4241f..41aa4e5719f 100644 --- a/app/code/Magento/Quote/Api/ShippingMethodManagementInterface.php +++ b/app/code/Magento/Quote/Api/ShippingMethodManagementInterface.php @@ -11,21 +11,6 @@ namespace Magento\Quote\Api; */ interface ShippingMethodManagementInterface { - /** - * Sets the carrier and shipping methods codes for a specified cart. - * - * @param int $cartId The shopping cart ID. - * @param string $carrierCode The carrier code. - * @param string $methodCode The shipping method code. - * @return bool - * @throws \Magento\Framework\Exception\InputException The shipping method is not valid for an empty cart. - * @throws \Magento\Framework\Exception\CouldNotSaveException The shipping method could not be saved. - * @throws \Magento\Framework\Exception\StateException The billing or shipping address is not set. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart contains only virtual products - * so the shipping method does not apply. - */ - public function set($cartId, $carrierCode, $methodCode); - /** * Estimate shipping * @@ -44,16 +29,6 @@ interface ShippingMethodManagementInterface */ public function estimateByAddressId($cartId, $addressId); - /** - * Returns selected shipping method for a specified quote. - * - * @param int $cartId The shopping cart ID. - * @return \Magento\Quote\Api\Data\ShippingMethodInterface Shipping method. - * @throws \Magento\Framework\Exception\NoSuchEntityException The specified shopping cart does not exist. - * @throws \Magento\Framework\Exception\StateException The shipping address is not set. - */ - public function get($cartId); - /** * Lists applicable shipping methods for a specified quote. * diff --git a/app/code/Magento/Quote/Model/GuestCart/GuestShippingAddressManagement.php b/app/code/Magento/Quote/Model/GuestCart/GuestShippingAddressManagement.php index 789466d1e04..8180e372a9c 100644 --- a/app/code/Magento/Quote/Model/GuestCart/GuestShippingAddressManagement.php +++ b/app/code/Magento/Quote/Model/GuestCart/GuestShippingAddressManagement.php @@ -5,10 +5,10 @@ */ namespace Magento\Quote\Model\GuestCart; -use Magento\Quote\Api\GuestShippingAddressManagementInterface; +use Magento\Quote\Model\GuestCart\GuestShippingAddressManagementInterface; use Magento\Quote\Model\QuoteIdMask; use Magento\Quote\Model\QuoteIdMaskFactory; -use Magento\Quote\Api\ShippingAddressManagementInterface; +use Magento\Quote\Model\ShippingAddressManagementInterface; /** * Shipping address management class for guest carts. diff --git a/app/code/Magento/Quote/Api/GuestShippingAddressManagementInterface.php b/app/code/Magento/Quote/Model/GuestCart/GuestShippingAddressManagementInterface.php similarity index 96% rename from app/code/Magento/Quote/Api/GuestShippingAddressManagementInterface.php rename to app/code/Magento/Quote/Model/GuestCart/GuestShippingAddressManagementInterface.php index 79207e8af1b..fd405429345 100644 --- a/app/code/Magento/Quote/Api/GuestShippingAddressManagementInterface.php +++ b/app/code/Magento/Quote/Model/GuestCart/GuestShippingAddressManagementInterface.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Quote\Api; +namespace Magento\Quote\Model\GuestCart; /** * Shipping address management interface for guest carts. diff --git a/app/code/Magento/Quote/Model/GuestCart/GuestShippingMethodManagement.php b/app/code/Magento/Quote/Model/GuestCart/GuestShippingMethodManagement.php index 6026ff8f8da..d271aba054f 100644 --- a/app/code/Magento/Quote/Model/GuestCart/GuestShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/GuestCart/GuestShippingMethodManagement.php @@ -14,7 +14,8 @@ use Magento\Quote\Model\QuoteIdMaskFactory; /** * Shipping method management class for guest carts. */ -class GuestShippingMethodManagement implements GuestShippingMethodManagementInterface +class GuestShippingMethodManagement implements + GuestShippingMethodManagementInterface, \Magento\Quote\Model\GuestCart\GuestShippingMethodManagementInterface { /** * @var ShippingMethodManagementInterface diff --git a/app/code/Magento/Quote/Model/GuestCart/GuestShippingMethodManagementInterface.php b/app/code/Magento/Quote/Model/GuestCart/GuestShippingMethodManagementInterface.php new file mode 100644 index 00000000000..0e292dbf512 --- /dev/null +++ b/app/code/Magento/Quote/Model/GuestCart/GuestShippingMethodManagementInterface.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model\GuestCart; + +interface GuestShippingMethodManagementInterface +{ + /** + * Set the carrier and shipping methods codes for a specified cart. + * + * @param string $cartId The shopping cart ID. + * @param string $carrierCode The carrier code. + * @param string $methodCode The shipping method code. + * @return bool + * @throws \Magento\Framework\Exception\InputException The shipping method is not valid for an empty cart. + * @throws \Magento\Framework\Exception\CouldNotSaveException The shipping method could not be saved. + * @throws \Magento\Framework\Exception\StateException The billing or shipping address is not set. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart contains only virtual products + * so the shipping method does not apply. + */ + public function set($cartId, $carrierCode, $methodCode); + + /** + * Return selected shipping method for a specified quote. + * + * @param string $cartId The shopping cart ID. + * @return \Magento\Quote\Api\Data\ShippingMethodInterface Shipping method. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified shopping cart does not exist. + * @throws \Magento\Framework\Exception\StateException The shipping address is not set. + */ + public function get($cartId); +} diff --git a/app/code/Magento/Quote/Model/ShippingAddressManagement.php b/app/code/Magento/Quote/Model/ShippingAddressManagement.php index 00e1bd083ea..2726458a946 100644 --- a/app/code/Magento/Quote/Model/ShippingAddressManagement.php +++ b/app/code/Magento/Quote/Model/ShippingAddressManagement.php @@ -8,13 +8,12 @@ namespace Magento\Quote\Model; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Psr\Log\LoggerInterface as Logger; -use Magento\Quote\Api\ShippingAddressManagementInterface; /** * Quote shipping address write service object. * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ShippingAddressManagement implements ShippingAddressManagementInterface +class ShippingAddressManagement implements \Magento\Quote\Model\ShippingAddressManagementInterface { /** * Quote repository. diff --git a/app/code/Magento/Quote/Api/ShippingAddressManagementInterface.php b/app/code/Magento/Quote/Model/ShippingAddressManagementInterface.php similarity index 97% rename from app/code/Magento/Quote/Api/ShippingAddressManagementInterface.php rename to app/code/Magento/Quote/Model/ShippingAddressManagementInterface.php index be106920d34..3b810511fc7 100644 --- a/app/code/Magento/Quote/Api/ShippingAddressManagementInterface.php +++ b/app/code/Magento/Quote/Model/ShippingAddressManagementInterface.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Quote\Api; +namespace Magento\Quote\Model; /** * Interface ShippingAddressManagementInterface diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php index 6264eeab4bb..72cde562ac7 100644 --- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -15,7 +15,8 @@ use Magento\Quote\Api\ShippingMethodManagementInterface; * Shipping method read service. * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ShippingMethodManagement implements ShippingMethodManagementInterface +class ShippingMethodManagement implements + ShippingMethodManagementInterface, \Magento\Quote\Model\ShippingMethodManagementInterface { /** * Quote repository. diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagementInterface.php b/app/code/Magento/Quote/Model/ShippingMethodManagementInterface.php new file mode 100644 index 00000000000..c58dfba3cdc --- /dev/null +++ b/app/code/Magento/Quote/Model/ShippingMethodManagementInterface.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model; + +interface ShippingMethodManagementInterface +{ + /** + * Sets the carrier and shipping methods codes for a specified cart. + * + * @param int $cartId The shopping cart ID. + * @param string $carrierCode The carrier code. + * @param string $methodCode The shipping method code. + * @return bool + * @throws \Magento\Framework\Exception\InputException The shipping method is not valid for an empty cart. + * @throws \Magento\Framework\Exception\CouldNotSaveException The shipping method could not be saved. + * @throws \Magento\Framework\Exception\StateException The billing or shipping address is not set. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified cart contains only virtual products + * so the shipping method does not apply. + */ + public function set($cartId, $carrierCode, $methodCode); + + /** + * Returns selected shipping method for a specified quote. + * + * @param int $cartId The shopping cart ID. + * @return \Magento\Quote\Api\Data\ShippingMethodInterface Shipping method. + * @throws \Magento\Framework\Exception\NoSuchEntityException The specified shopping cart does not exist. + * @throws \Magento\Framework\Exception\StateException The shipping address is not set. + */ + public function get($cartId); +} diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingAddressManagementTest.php index 67e35a93bf7..f32a480cd88 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingAddressManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingAddressManagementTest.php @@ -9,7 +9,7 @@ namespace Magento\Quote\Test\Unit\Model\GuestCart; class GuestShippingAddressManagementTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Quote\Api\GuestShippingAddressManagementInterface + * @var \Magento\Quote\Model\GuestCart\GuestShippingAddressManagementInterface */ protected $model; @@ -48,7 +48,7 @@ class GuestShippingAddressManagementTest extends \PHPUnit_Framework_TestCase $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->shippingAddressManagementMock = $this->getMock( - 'Magento\Quote\Api\ShippingAddressManagementInterface', + 'Magento\Quote\Model\ShippingAddressManagementInterface', [], [], '', diff --git a/app/code/Magento/Quote/etc/di.xml b/app/code/Magento/Quote/etc/di.xml index 17cadb026c9..035be5e144c 100644 --- a/app/code/Magento/Quote/etc/di.xml +++ b/app/code/Magento/Quote/etc/di.xml @@ -9,7 +9,7 @@ <preference for="Magento\Quote\Api\ShippingMethodManagementInterface" type="Magento\Quote\Model\ShippingMethodManagement" /> <preference for="Magento\Quote\Api\Data\ShippingMethodInterface" type="Magento\Quote\Model\Cart\ShippingMethod" /> <preference for="Magento\Quote\Api\BillingAddressManagementInterface" type="Magento\Quote\Model\BillingAddressManagement" /> - <preference for="Magento\Quote\Api\ShippingAddressManagementInterface" type="Magento\Quote\Model\ShippingAddressManagement" /> + <preference for="Magento\Quote\Model\ShippingAddressManagementInterface" type="Magento\Quote\Model\ShippingAddressManagement" /> <preference for="Magento\Quote\Api\Data\AddressInterface" type="Magento\Quote\Model\Quote\Address" /> <preference for="Magento\Quote\Api\Data\CartItemInterface" type="Magento\Quote\Model\Quote\Item" /> <preference for="Magento\Quote\Api\Data\CartInterface" type="Magento\Quote\Model\Quote" /> @@ -33,7 +33,7 @@ <preference for="Magento\Quote\Api\GuestCouponManagementInterface" type="Magento\Quote\Model\GuestCart\GuestCouponManagement" /> <preference for="Magento\Quote\Api\GuestPaymentMethodManagementInterface" type="Magento\Quote\Model\GuestCart\GuestPaymentMethodManagement" /> <preference for="Magento\Quote\Api\GuestCartTotalRepositoryInterface" type="Magento\Quote\Model\GuestCart\GuestCartTotalRepository" /> - <preference for="Magento\Quote\Api\GuestShippingAddressManagementInterface" type="Magento\Quote\Model\GuestCart\GuestShippingAddressManagement" /> + <preference for="Magento\Quote\Model\GuestCart\GuestShippingAddressManagementInterface" type="Magento\Quote\Model\GuestCart\GuestShippingAddressManagement" /> <preference for="Magento\Quote\Api\GuestShippingMethodManagementInterface" type="Magento\Quote\Model\GuestCart\GuestShippingMethodManagement" /> <preference for="Magento\Quote\Api\GuestBillingAddressManagementInterface" type="Magento\Quote\Model\GuestCart\GuestBillingAddressManagement" /> <preference for="Magento\Quote\Api\GuestCartTotalManagementInterface" type="\Magento\Quote\Model\GuestCart\GuestCartTotalManagement" /> @@ -85,4 +85,6 @@ <preference for="Magento\Quote\Api\Data\TotalsAdditionalDataInterface" type="Magento\Quote\Model\Cart\TotalsAdditionalData" /> <preference for="Magento\Quote\Model\Quote\Address\CustomAttributeListInterface" type="Magento\Quote\Model\Quote\Address\CustomAttributeList" /> <preference for="Magento\Quote\Model\Quote\Address\FreeShippingInterface" type="Magento\Quote\Model\Quote\Address\FreeShipping" /> + <preference for="Magento\Quote\Model\GuestCart\GuestShippingMethodManagementInterface" type="Magento\Quote\Model\GuestCart\GuestShippingMethodManagement" /> + <preference for="Magento\Quote\Model\ShippingMethodManagementInterface" type="Magento\Quote\Model\ShippingMethodManagement" /> </config> diff --git a/app/code/Magento/Quote/etc/webapi.xml b/app/code/Magento/Quote/etc/webapi.xml index 90ca9bde6b9..49bb504c599 100644 --- a/app/code/Magento/Quote/etc/webapi.xml +++ b/app/code/Magento/Quote/etc/webapi.xml @@ -98,18 +98,6 @@ </route> <!-- Managing Cart Shipment Method --> - <route url="/V1/carts/:cartId/selected-shipping-method" method="PUT"> - <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="set"/> - <resources> - <resource ref="Magento_Cart::manage" /> - </resources> - </route> - <route url="/V1/carts/:cartId/selected-shipping-method" method="GET"> - <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="get"/> - <resources> - <resource ref="anonymous" /> - </resources> - </route> <route url="/V1/carts/:cartId/shipping-methods" method="GET"> <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="getList"/> <resources> @@ -118,24 +106,6 @@ </route> <!-- Managing My Cart Shipment Method --> - <route url="/V1/carts/mine/selected-shipping-method" method="PUT"> - <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="set"/> - <resources> - <resource ref="self" /> - </resources> - <data> - <parameter name="cartId" force="true">%cart_id%</parameter> - </data> - </route> - <route url="/V1/carts/mine/selected-shipping-method" method="GET"> - <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="get"/> - <resources> - <resource ref="self" /> - </resources> - <data> - <parameter name="cartId" force="true">%cart_id%</parameter> - </data> - </route> <route url="/V1/carts/mine/shipping-methods" method="GET"> <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="getList"/> <resources> @@ -165,18 +135,6 @@ </route> <!-- Managing Guest Cart Shipment Method --> - <route url="/V1/guest-carts/:cartId/selected-shipping-method" method="PUT"> - <service class="Magento\Quote\Api\GuestShippingMethodManagementInterface" method="set"/> - <resources> - <resource ref="anonymous" /> - </resources> - </route> - <route url="/V1/guest-carts/:cartId/selected-shipping-method" method="GET"> - <service class="Magento\Quote\Api\GuestShippingMethodManagementInterface" method="get"/> - <resources> - <resource ref="anonymous" /> - </resources> - </route> <route url="/V1/guest-carts/:cartId/shipping-methods" method="GET"> <service class="Magento\Quote\Api\GuestShippingMethodManagementInterface" method="getList"/> <resources> @@ -466,54 +424,6 @@ </data> </route> - <!-- Managing Cart Shipping address --> - <route url="/V1/carts/:cartId/shipping-address" method="GET"> - <service class="Magento\Quote\Api\ShippingAddressManagementInterface" method="get"/> - <resources> - <resource ref="Magento_Cart::manage" /> - </resources> - </route> - <route url="/V1/carts/:cartId/shipping-address" method="POST"> - <service class="Magento\Quote\Api\ShippingAddressManagementInterface" method="assign"/> - <resources> - <resource ref="Magento_Cart::manage" /> - </resources> - </route> - - <!-- Managing Guest Cart Shipping address --> - <route url="/V1/guest-carts/:cartId/shipping-address" method="GET"> - <service class="Magento\Quote\Api\GuestShippingAddressManagementInterface" method="get"/> - <resources> - <resource ref="anonymous" /> - </resources> - </route> - <route url="/V1/guest-carts/:cartId/shipping-address" method="POST"> - <service class="Magento\Quote\Api\GuestShippingAddressManagementInterface" method="assign"/> - <resources> - <resource ref="anonymous" /> - </resources> - </route> - - <!-- Managing My Cart Shipping address --> - <route url="/V1/carts/mine/shipping-address" method="GET"> - <service class="Magento\Quote\Api\ShippingAddressManagementInterface" method="get"/> - <resources> - <resource ref="self" /> - </resources> - <data> - <parameter name="cartId" force="true">%cart_id%</parameter> - </data> - </route> - <route url="/V1/carts/mine/shipping-address" method="POST"> - <service class="Magento\Quote\Api\ShippingAddressManagementInterface" method="assign"/> - <resources> - <resource ref="self" /> - </resources> - <data> - <parameter name="cartId" force="true">%cart_id%</parameter> - </data> - </route> - <!-- Managing Cart Order --> <route url="/V1/carts/:cartId/order" method="PUT"> <service class="Magento\Quote\Api\CartManagementInterface" method="placeOrder"/> diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php deleted file mode 100644 index 6ac15b22292..00000000000 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingAddressManagementTest.php +++ /dev/null @@ -1,244 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Quote\Api; - -use Magento\Quote\Api\Data\AddressInterface; -use Magento\TestFramework\TestCase\WebapiAbstract; - -class GuestShippingAddressManagementTest extends WebapiAbstract -{ - const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'quoteGuestShippingAddressManagementV1'; - const RESOURCE_PATH = '/V1/guest-carts/'; - - /** - * @var \Magento\TestFramework\ObjectManager - */ - protected $objectManager; - - protected function setUp() - { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - } - - public function tearDown() - { - $createdQuotes = ['test_order_1', 'test_order_with_virtual_product']; - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - foreach ($createdQuotes as $quoteId) { - $quote->load($quoteId, 'reserved_order_id'); - $quote->delete(); - /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->objectManager->create('Magento\Quote\Model\QuoteIdMask'); - $quoteIdMask->load($quote->getId(), 'quote_id'); - $quoteIdMask->delete(); - } - } - - protected function getQuoteMaskedId($quoteId) - { - /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->objectManager->create('Magento\Quote\Model\QuoteIdMaskFactory')->create(); - $quoteIdMask->load($quoteId, 'quote_id'); - return $quoteIdMask->getMaskedId(); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testGetAddress() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - - /** @var \Magento\Quote\Model\Quote\Address $address */ - $address = $quote->getShippingAddress(); - - $data = [ - AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), - AddressInterface::KEY_ID => (int)$address->getId(), - AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), - AddressInterface::KEY_REGION => $address->getRegion(), - AddressInterface::KEY_REGION_ID => $address->getRegionId(), - AddressInterface::KEY_REGION_CODE => $address->getRegionCode(), - AddressInterface::KEY_STREET => $address->getStreet(), - AddressInterface::KEY_COMPANY => $address->getCompany(), - AddressInterface::KEY_TELEPHONE => $address->getTelephone(), - AddressInterface::KEY_POSTCODE => $address->getPostcode(), - AddressInterface::KEY_CITY => $address->getCity(), - AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), - AddressInterface::KEY_LASTNAME => $address->getLastname(), - AddressInterface::KEY_EMAIL => $address->getEmail(), - AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), - AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), - AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook() - ]; - - $cartId = $this->getQuoteMaskedId($quote->getId()); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Get', - ], - ]; - - $requestData = ["cartId" => $cartId]; - $response = $this->_webApiCall($serviceInfo, $requestData); - - asort($data); - asort($response); - $this->assertEquals($data, $response); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php - * - * @expectedException \Exception - * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable - */ - public function testGetAddressOfQuoteWithVirtualProduct() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_with_virtual_product', 'reserved_order_id'); - $cartId = $this->getQuoteMaskedId($quote->getId()); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Get', - ], - ]; - - $this->_webApiCall($serviceInfo, ["cartId" => $cartId]); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetAddress() - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - $cartId = $this->getQuoteMaskedId($quote->getId()); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Assign', - ], - ]; - - $addressData = [ - 'firstname' => 'John', - 'lastname' => 'Smith', - 'email' => '', - 'company' => 'eBay Inc', - 'street' => ['Typical Street', 'Tiny House 18'], - 'city' => 'Big City', - 'region_id' => 12, - 'region' => 'California', - 'region_code' => 'CA', - 'postcode' => '0985432', - 'country_id' => 'US', - 'telephone' => '88776655', - 'fax' => '44332255', - ]; - $requestData = [ - "cartId" => $cartId, - 'address' => $addressData, - ]; - - $addressId = $this->_webApiCall($serviceInfo, $requestData); - - //reset $quote to reload data - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - $address = $quote->getShippingAddress(); - $address->getRegionCode(); - $savedData = $address->getData(); - $this->assertEquals($addressId, $savedData['address_id'], 'Invalid address ID'); - $this->assertEquals(0, $savedData['same_as_billing']); - //custom checks for street, region and address_type - $this->assertEquals($addressData['street'], $quote->getShippingAddress()->getStreet()); - unset($addressData['street']); - unset($addressData['email']); - - $this->assertEquals('shipping', $savedData['address_type']); - //check the rest of fields - foreach ($addressData as $key => $value) { - $this->assertEquals($value, $savedData[$key], 'Invalid value for ' . $key); - } - } - - /** - * Set address to quote with virtual products only - * - * @expectedException \Exception - * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable - * - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php - */ - public function testSetAddressForVirtualQuote() - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_with_virtual_product', 'reserved_order_id'); - $cartId = $this->getQuoteMaskedId($quote->getId()); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Assign', - ], - ]; - - $addressData = [ - 'firstname' => 'John', - 'lastname' => 'Smith', - 'email' => 'cat@dog.com', - 'company' => 'eBay Inc', - 'street' => ['Typical Street', 'Tiny House 18'], - 'city' => 'Big City', - 'region_id' => 12, - 'region' => 'California', - 'region_code' => 'CA', - 'postcode' => '0985432', - 'country_id' => 'US', - 'telephone' => '88776655', - 'fax' => '44332255', - ]; - $requestData = [ - "cartId" => $cartId, - 'address' => $addressData, - ]; - - $this->_webApiCall($serviceInfo, $requestData); - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php index 6dbbc52e76e..a5f406e30ae 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShippingMethodManagementTest.php @@ -37,203 +37,6 @@ class GuestShippingMethodManagementTest extends WebapiAbstract $this->totalsCollector = $this->objectManager->create('Magento\Quote\Model\Quote\TotalsCollector'); } - protected function getServiceInfo() - { - return [ - 'rest' => [ - 'resourcePath' => '/V1/carts/' . $this->quote->getId() . '/selected-shipping-method', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Set', - ], - ]; - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetMethod() - { - $this->quote->load('test_order_1', 'reserved_order_id'); - $serviceInfo = $this->getServiceInfo(); - - $cartId = $this->quote->getId(); - /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') - ->create(); - $quoteIdMask->load($cartId, 'quote_id'); - //Use masked cart Id - $cartId = $quoteIdMask->getMaskedId(); - $shippingAddress = $this->quote->getShippingAddress(); - $shippingAddress->setCollectShippingRates(true); - $this->totalsCollector->collectAddressTotals($this->quote, $shippingAddress); - $shippingAddress->save(); - $requestData = [ - 'cartId' => $cartId, - 'carrierCode' => 'flatrate', - 'methodCode' => 'flatrate', - ]; - $result = $this->_webApiCall($serviceInfo, $requestData); - $this->assertEquals(true, $result); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetMethodWrongMethod() - { - $expectedMessage = 'Carrier with such method not found: %1, %2'; - $this->quote->load('test_order_1', 'reserved_order_id'); - $serviceInfo = $this->getServiceInfo(); - $carrierCode = 'flatrate'; - $methodCode = 'wrongMethod'; - - $cartId = $this->quote->getId(); - /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') - ->create(); - $quoteIdMask->load($cartId, 'quote_id'); - //Use masked cart Id - $cartId = $quoteIdMask->getMaskedId(); - - $requestData = [ - 'cartId' => $cartId, - 'carrierCode' => $carrierCode, - 'methodCode' => $methodCode, - ]; - try { - $this->_webApiCall($serviceInfo, $requestData); - } catch (\SoapFault $e) { - $this->assertContains( - $expectedMessage, - $e->getMessage(), - 'SoapFault does not contain expected message.' - ); - } catch (\Exception $e) { - $errorObj = $this->processRestExceptionResult($e); - $this->assertEquals($expectedMessage, $errorObj['message']); - $this->assertEquals([$carrierCode, $methodCode], $errorObj['parameters']); - } - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php - */ - public function testSetMethodWithoutShippingAddress() - { - $this->quote->load('test_order_with_simple_product_without_address', 'reserved_order_id'); - $serviceInfo = $this->getServiceInfo(); - - $cartId = $this->quote->getId(); - /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') - ->create(); - $quoteIdMask->load($cartId, 'quote_id'); - //Use masked cart Id - $cartId = $quoteIdMask->getMaskedId(); - - $requestData = [ - 'cartId' => $cartId, - 'carrierCode' => 'flatrate', - 'methodCode' => 'flatrate', - ]; - try { - $this->_webApiCall($serviceInfo, $requestData); - } catch (\SoapFault $e) { - $message = $e->getMessage(); - } catch (\Exception $e) { - $message = json_decode($e->getMessage())->message; - } - $this->assertEquals('Shipping address is not set', $message); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_shipping_method.php - */ - public function testGetMethod() - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - - $cartId = $quote->getId(); - /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') - ->create(); - $quoteIdMask->load($cartId, 'quote_id'); - //Use masked cart Id - $cartId = $quoteIdMask->getMaskedId(); - - $shippingAddress = $quote->getShippingAddress(); - $shippingAddress->setCollectShippingRates(true); - $this->totalsCollector->collectAddressTotals($this->quote, $shippingAddress); - $shippingAddress->save(); - list($carrierCode, $methodCode) = explode('_', $shippingAddress->getShippingMethod()); - list($carrierTitle, $methodTitle) = explode(' - ', $shippingAddress->getShippingDescription()); - $data = [ - ShippingMethodInterface::KEY_CARRIER_CODE => $carrierCode, - ShippingMethodInterface::KEY_METHOD_CODE => $methodCode, - ShippingMethodInterface::KEY_CARRIER_TITLE => $carrierTitle, - ShippingMethodInterface::KEY_METHOD_TITLE => $methodTitle, - ShippingMethodInterface::KEY_SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), - ShippingMethodInterface::KEY_BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), - ShippingMethodInterface::KEY_AVAILABLE => true, - ShippingMethodInterface::KEY_ERROR_MESSAGE => null, - ]; - $requestData = ["cartId" => $cartId]; - $actual = $this->_webApiCall($this->getSelectedMethodServiceInfo($cartId), $requestData); - unset($actual[ShippingMethodInterface::KEY_PRICE_EXCL_TAX]); - unset($actual[ShippingMethodInterface::KEY_PRICE_INCL_TAX ]); - $this->assertEquals($data, $actual); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php - */ - public function testGetMethodOfVirtualCart() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $cartId = $quote->load('test_order_with_virtual_product', 'reserved_order_id')->getId(); - - /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') - ->create(); - $quoteIdMask->load($cartId, 'quote_id'); - //Use masked cart Id - $cartId = $quoteIdMask->getMaskedId(); - - $result = $this->_webApiCall($this->getSelectedMethodServiceInfo($cartId), ["cartId" => $cartId]); - $this->assertEquals([], $result); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testGetMethodOfCartWithNoShippingMethod() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $cartId = $quote->load('test_order_1', 'reserved_order_id')->getId(); - - /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ - $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Quote\Model\QuoteIdMaskFactory') - ->create(); - $quoteIdMask->load($cartId, 'quote_id'); - //Use masked cart Id - $cartId = $quoteIdMask->getMaskedId(); - - $result = $this->_webApiCall($this->getSelectedMethodServiceInfo($cartId), ["cartId" => $cartId]); - $this->assertEquals([], $result); - } - /** * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php * @@ -286,26 +89,6 @@ class GuestShippingMethodManagementTest extends WebapiAbstract $this->assertEquals($expectedData, $returnedRates); } - /** - * @param string $cartId - * @return array - * @SuppressWarnings(PHPMD.UnusedLocalVariable) - */ - protected function getSelectedMethodServiceInfo($cartId) - { - return $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/selected-shipping-method', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Get', - ], - ]; - } - /** * Service info * diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php deleted file mode 100644 index a15ea0d24fb..00000000000 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingAddressManagementTest.php +++ /dev/null @@ -1,345 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Quote\Api; - -use Magento\Quote\Api\Data\AddressInterface; -use Magento\TestFramework\TestCase\WebapiAbstract; - -class ShippingAddressManagementTest extends WebapiAbstract -{ - const SERVICE_VERSION = 'V1'; - const SERVICE_NAME = 'quoteShippingAddressManagementV1'; - const RESOURCE_PATH = '/V1/carts/'; - - /** - * @var \Magento\TestFramework\ObjectManager - */ - protected $objectManager; - - protected function setUp() - { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testGetAddress() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - - /** @var \Magento\Quote\Model\Quote\Address $address */ - $address = $quote->getShippingAddress(); - - $data = [ - AddressInterface::KEY_ID => (int)$address->getId(), - AddressInterface::KEY_REGION => $address->getRegion(), - AddressInterface::KEY_REGION_ID => $address->getRegionId(), - AddressInterface::KEY_REGION_CODE => $address->getRegionCode(), - AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), - AddressInterface::KEY_STREET => $address->getStreet(), - AddressInterface::KEY_COMPANY => $address->getCompany(), - AddressInterface::KEY_TELEPHONE => $address->getTelephone(), - AddressInterface::KEY_POSTCODE => $address->getPostcode(), - AddressInterface::KEY_CITY => $address->getCity(), - AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), - AddressInterface::KEY_LASTNAME => $address->getLastname(), - AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), - AddressInterface::KEY_EMAIL => $address->getEmail(), - AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), - AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), - AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook() - - ]; - $cartId = $quote->getId(); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $quote->getId() . '/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Get', - ], - ]; - - $requestData = ["cartId" => $cartId]; - $response = $this->_webApiCall($serviceInfo, $requestData); - - asort($data); - asort($response); - $this->assertEquals($data, $response); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php - * - * @expectedException \Exception - * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable - */ - public function testGetAddressOfQuoteWithVirtualProduct() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $cartId = $quote->load('test_order_with_virtual_product', 'reserved_order_id')->getId(); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $quote->getId() . '/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Get', - ], - ]; - - $this->_webApiCall($serviceInfo, ["cartId" => $cartId]); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetAddress() - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $quote->getId() . '/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Assign', - ], - ]; - - $addressData = [ - 'firstname' => 'John', - 'lastname' => 'Smith', - 'email' => '', - 'company' => 'eBay Inc', - 'street' => ['Typical Street', 'Tiny House 18'], - 'city' => 'Big City', - 'region_id' => 12, - 'region' => 'California', - 'region_code' => 'CA', - 'postcode' => '0985432', - 'country_id' => 'US', - 'telephone' => '88776655', - 'fax' => '44332255', - ]; - $requestData = [ - "cartId" => $quote->getId(), - 'address' => $addressData, - ]; - - $addressId = $this->_webApiCall($serviceInfo, $requestData); - - //reset $quote to reload data - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - $address = $quote->getShippingAddress(); - $address->getRegionCode(); - $savedData = $address->getData(); - $this->assertEquals($addressId, $savedData['address_id'], 'Invalid address ID'); - $this->assertEquals(0, $savedData['same_as_billing']); - //custom checks for street, region and address_type - $this->assertEquals($addressData['street'], $quote->getShippingAddress()->getStreet()); - unset($addressData['street']); - unset($addressData['email']); - - $this->assertEquals('shipping', $savedData['address_type']); - //check the rest of fields - foreach ($addressData as $key => $value) { - $this->assertEquals($value, $savedData[$key], 'Invalid value for ' . $key); - } - } - - /** - * Set address to quote with virtual products only - * - * @expectedException \Exception - * @expectedExceptionMessage Cart contains virtual product(s) only. Shipping address is not applicable - * - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php - */ - public function testSetAddressForVirtualQuote() - { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_with_virtual_product', 'reserved_order_id'); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $quote->getId() . '/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Assign', - ], - ]; - - $addressData = [ - 'firstname' => 'John', - 'lastname' => 'Smith', - 'email' => 'cat@dog.com', - 'company' => 'eBay Inc', - 'street' => ['Typical Street', 'Tiny House 18'], - 'city' => 'Big City', - 'region_id' => 12, - 'region' => 'California', - 'region_code' => 'CA', - 'postcode' => '0985432', - 'country_id' => 'US', - 'telephone' => '88776655', - 'fax' => '44332255', - ]; - $requestData = [ - "cartId" => $quote->getId(), - 'address' => $addressData, - ]; - - $this->_webApiCall($serviceInfo, $requestData); - } - - /** - * Test getting shipping address based on the customer's authentication token. - * - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testGetMyAddress() - { - $this->_markTestAsRestOnly(); - - // get customer ID token - /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ - $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' - ); - $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); - - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - - /** @var \Magento\Quote\Model\Quote\Address $address */ - $address = $quote->getShippingAddress(); - - $addressData = [ - AddressInterface::KEY_ID => (int)$address->getId(), - AddressInterface::KEY_REGION => $address->getRegion(), - AddressInterface::KEY_REGION_ID => $address->getRegionId(), - AddressInterface::KEY_REGION_CODE => $address->getRegionCode(), - AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), - AddressInterface::KEY_STREET => $address->getStreet(), - AddressInterface::KEY_COMPANY => $address->getCompany(), - AddressInterface::KEY_TELEPHONE => $address->getTelephone(), - AddressInterface::KEY_POSTCODE => $address->getPostcode(), - AddressInterface::KEY_CITY => $address->getCity(), - AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), - AddressInterface::KEY_LASTNAME => $address->getLastname(), - AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), - AddressInterface::KEY_EMAIL => $address->getEmail(), - AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), - AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), - AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook() - - ]; - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . 'mine/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - 'token' => $token - ], - ]; - - $requestData = []; - $response = $this->_webApiCall($serviceInfo, $requestData); - - asort($addressData); - asort($response); - $this->assertEquals($addressData, $response); - } - - /** - * Test setting shipping address based on the customer's authentication token. - * - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetMyAddress() - { - $this->_markTestAsRestOnly(); - - // get customer ID token - /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ - $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' - ); - $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); - - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . 'mine/shipping-address', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - 'token' => $token - ], - ]; - - $addressData = [ - 'firstname' => 'John', - 'lastname' => 'Smith', - 'company' => 'eBay Inc', - 'street' => ['Typical Street', 'Tiny House 18'], - 'city' => 'Big City', - 'region_id' => 12, - 'region' => 'California', - 'region_code' => 'CA', - 'postcode' => '0985432', - 'country_id' => 'US', - 'telephone' => '88776655', - 'fax' => '44332255', - ]; - $requestData = [ - 'address' => $addressData, - ]; - - $addressId = $this->_webApiCall($serviceInfo, $requestData); - - //reset $quote to reload data - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $quote->load('test_order_1', 'reserved_order_id'); - $address = $quote->getShippingAddress(); - $address->getRegionCode(); - $savedData = $address->getData(); - $this->assertEquals($addressId, $savedData['address_id'], 'Invalid address ID'); - $this->assertEquals(0, $savedData['same_as_billing']); - //custom checks for street, region and address_type - $this->assertEquals($addressData['street'], $quote->getShippingAddress()->getStreet()); - unset($addressData['street']); - - $this->assertEquals('shipping', $savedData['address_type']); - //check the rest of fields - foreach ($addressData as $key => $value) { - $this->assertEquals($value, $savedData[$key], 'Invalid value for ' . $key); - } - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php index a1ea0c098f3..b41207e377a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php @@ -37,241 +37,6 @@ class ShippingMethodManagementTest extends WebapiAbstract $this->totalsCollector = $this->objectManager->create('Magento\Quote\Model\Quote\TotalsCollector'); } - protected function getServiceInfo() - { - return [ - 'rest' => [ - 'resourcePath' => '/V1/carts/' . $this->quote->getId() . '/selected-shipping-method', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Set', - ], - ]; - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetMethod() - { - $this->quote->load('test_order_1', 'reserved_order_id'); - $serviceInfo = $this->getServiceInfo(); - $shippingAddress = $this->quote->getShippingAddress(); - $shippingAddress->setCollectShippingRates(true); - $this->totalsCollector->collectAddressTotals($this->quote, $shippingAddress); - $shippingAddress->save(); - $requestData = [ - 'cartId' => $this->quote->getId(), - 'carrierCode' => 'flatrate', - 'methodCode' => 'flatrate', - ]; - $result = $this->_webApiCall($serviceInfo, $requestData); - $this->assertEquals(true, $result); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetMethodWrongMethod() - { - $expectedMessage = 'Carrier with such method not found: %1, %2'; - $this->quote->load('test_order_1', 'reserved_order_id'); - $serviceInfo = $this->getServiceInfo(); - $carrierCode = 'flatrate'; - $methodCode = 'wrongMethod'; - - $requestData = [ - 'cartId' => $this->quote->getId(), - 'carrierCode' => $carrierCode, - 'methodCode' => $methodCode, - ]; - try { - $this->_webApiCall($serviceInfo, $requestData); - } catch (\SoapFault $e) { - $this->assertContains( - $expectedMessage, - $e->getMessage(), - 'SoapFault does not contain expected message.' - ); - } catch (\Exception $e) { - $errorObj = $this->processRestExceptionResult($e); - $this->assertEquals($expectedMessage, $errorObj['message']); - $this->assertEquals([$carrierCode, $methodCode], $errorObj['parameters']); - } - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php - */ - public function testSetMethodWithoutShippingAddress() - { - $this->quote->load('test_order_with_simple_product_without_address', 'reserved_order_id'); - $serviceInfo = $this->getServiceInfo(); - - $requestData = [ - 'cartId' => $this->quote->getId(), - 'carrierCode' => 'flatrate', - 'methodCode' => 'flatrate', - ]; - try { - $this->_webApiCall($serviceInfo, $requestData); - } catch (\SoapFault $e) { - $message = $e->getMessage(); - } catch (\Exception $e) { - $message = json_decode($e->getMessage())->message; - } - $this->assertEquals('Shipping address is not set', $message); - } - - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testSetMethodForMyCart() - { - $this->_markTestAsRestOnly(); - - $this->quote->load('test_order_1', 'reserved_order_id'); - - /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ - $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' - ); - $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => '/V1/carts/mine/selected-shipping-method', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, - 'token' => $token - ] - ]; - - $requestData = [ - 'cartId' => 999, - 'carrierCode' => 'flatrate', - 'methodCode' => 'flatrate', - ]; // cartId 999 will be overridden - $shippingAddress = $this->quote->getShippingAddress(); - $shippingAddress->setCollectShippingRates(true); - $this->totalsCollector->collectAddressTotals($this->quote, $shippingAddress); - $shippingAddress->save(); - $result = $this->_webApiCall($serviceInfo, $requestData); - $this->assertEquals(true, $result); - - /** @var \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagementService */ - $shippingMethodManagementService = $this->objectManager->create( - 'Magento\Quote\Api\ShippingMethodManagementInterface' - ); - $shippingMethod = $shippingMethodManagementService->get($this->quote->getId()); - - $this->assertNotNull($shippingMethod); - $this->assertEquals('flatrate', $shippingMethod->getCarrierCode()); - $this->assertEquals('flatrate', $shippingMethod->getMethodCode()); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_shipping_method.php - */ - public function testGetMethod() - { - $this->quote->load('test_order_1', 'reserved_order_id'); - - /** @var \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagementService */ - $shippingMethodManagementService = $this->objectManager->create( - 'Magento\Quote\Api\ShippingMethodManagementInterface' - ); - - $shippingAddress = $this->quote->getShippingAddress(); - $shippingAddress->setCollectShippingRates(true); - $this->totalsCollector->collectAddressTotals($this->quote, $shippingAddress); - $shippingAddress->save(); - list($carrierCode, $methodCode) = explode('_', $shippingAddress->getShippingMethod()); - list($carrierTitle, $methodTitle) = explode(' - ', $shippingAddress->getShippingDescription()); - $shippingMethod = $shippingMethodManagementService->get($this->quote->getId()); - - $data = [ - ShippingMethodInterface::KEY_CARRIER_CODE => $carrierCode, - ShippingMethodInterface::KEY_METHOD_CODE => $methodCode, - ShippingMethodInterface::KEY_CARRIER_TITLE => $carrierTitle, - ShippingMethodInterface::KEY_METHOD_TITLE => $methodTitle, - ShippingMethodInterface::KEY_BASE_SHIPPING_AMOUNT => $shippingAddress->getBaseShippingAmount(), - ShippingMethodInterface::KEY_SHIPPING_AMOUNT => $shippingAddress->getShippingAmount(), - ShippingMethodInterface::KEY_AVAILABLE => true, - ShippingMethodInterface::KEY_ERROR_MESSAGE => null, - ShippingMethodInterface::KEY_PRICE_EXCL_TAX => $shippingMethod->getPriceExclTax(), - ShippingMethodInterface::KEY_PRICE_INCL_TAX => $shippingMethod->getPriceInclTax(), - ]; - - $requestData = ["cartId" => $this->quote->getId()]; - $this->assertEquals( - $data, - $this->_webApiCall($this->getSelectedMethodServiceInfo($this->quote->getId()), $requestData) - ); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php - */ - public function testGetMethodOfVirtualCart() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $cartId = $quote->load('test_order_with_virtual_product', 'reserved_order_id')->getId(); - - $result = $this->_webApiCall($this->getSelectedMethodServiceInfo($cartId), ["cartId" => $cartId]); - $this->assertEquals([], $result); - } - - /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php - */ - public function testGetMethodOfCartWithNoShippingMethod() - { - $quote = $this->objectManager->create('Magento\Quote\Model\Quote'); - $cartId = $quote->load('test_order_1', 'reserved_order_id')->getId(); - - $result = $this->_webApiCall($this->getSelectedMethodServiceInfo($cartId), ["cartId" => $cartId]); - $this->assertEquals([], $result); - } - - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_shipping_method.php - */ - public function testGetMethodForMyCart() - { - $this->_markTestAsRestOnly(); - - $this->quote->load('test_order_1', 'reserved_order_id'); - - /** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ - $customerTokenService = $this->objectManager->create( - 'Magento\Integration\Api\CustomerTokenServiceInterface' - ); - $token = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); - - /** @var \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagementService */ - $shippingAddress = $this->quote->getShippingAddress(); - $shippingAddress->setCollectShippingRates(true); - $this->totalsCollector->collectAddressTotals($this->quote, $shippingAddress); - $shippingAddress->save(); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => '/V1/carts/mine/selected-shipping-method', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - 'token' => $token - ] - ]; - - $result = $this->_webApiCall($serviceInfo, []); - $this->assertEquals('flatrate', $result[ShippingMethodInterface::KEY_CARRIER_CODE]); - $this->assertEquals('flatrate', $result[ShippingMethodInterface::KEY_METHOD_CODE]); - } - /** * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php * @@ -359,26 +124,6 @@ class ShippingMethodManagementTest extends WebapiAbstract $this->assertEquals($expectedData, $result[0]); } - /** - * @param string $cartId - * @return array - * @SuppressWarnings(PHPMD.UnusedLocalVariable) - */ - protected function getSelectedMethodServiceInfo($cartId) - { - return $serviceInfo = [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $cartId . '/selected-shipping-method', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Get', - ], - ]; - } - /** * Service info * diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/Webapi.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/Webapi.php index bdfbc3b5d15..6e639a8a6e9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/Webapi.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/Webapi.php @@ -62,9 +62,8 @@ class Webapi extends AbstractWebapi implements OrderInjectableInterface $this->url = $_ENV['app_frontend_url'] . 'rest/V1/carts/' . (int)$this->quote; $this->setProducts($fixture); $this->setCoupon($fixture); - $this->setAddress($fixture, 'billing'); - $this->setAddress($fixture, 'shipping'); - $this->setShippingMethod($fixture); + $this->setBillingAddress($fixture); + $this->setShippingInformation($fixture); $this->setPaymentMethod($fixture); $orderId = $this->placeOrder(); @@ -101,7 +100,7 @@ class Webapi extends AbstractWebapi implements OrderInjectableInterface */ protected function setProducts(OrderInjectable $order) { - $url = $_ENV['app_frontend_url'] . 'rest/V1/carts/items'; + $url = $_ENV['app_frontend_url'] . 'rest/V1/carts/' . $this->quote . '/items'; $products = $order->getEntityId()['products']; foreach ($products as $product) { $data = [ @@ -152,26 +151,17 @@ class Webapi extends AbstractWebapi implements OrderInjectableInterface } /** - * Set address to quote. + * Set billing address to quote. * * @param OrderInjectable $order - * @param string $addressType billing|shipping * @return void * @throws \Exception */ - protected function setAddress(OrderInjectable $order, $addressType) + protected function setBillingAddress(OrderInjectable $order) { - $url = $this->url . "/$addressType-address"; - if ($addressType == 'billing') { - $address = $order->getBillingAddressId(); - } else { - if (!$order->hasData('shipping_method')) { - return; - } - $address = $order->hasData('shipping_address_id') - ? $order->getShippingAddressId() - : $order->getBillingAddressId(); - } + $url = $this->url . "/billing-address"; + $address = $order->getBillingAddressId(); + unset($address['default_billing']); unset($address['default_shipping']); foreach (array_keys($this->mappingData) as $key) { @@ -185,32 +175,48 @@ class Webapi extends AbstractWebapi implements OrderInjectableInterface $this->webapiTransport->close(); if (!is_numeric($response)) { $this->eventManager->dispatchEvent(['webapi_failed'], [$response]); - throw new \Exception("Could not set $addressType addresss to quote!"); + throw new \Exception("Could not set billing addresss to quote!"); } } /** - * Set shipping method to quote. + * Set shipping information to quote * * @param OrderInjectable $order - * @return void * @throws \Exception */ - protected function setShippingMethod(OrderInjectable $order) + protected function setShippingInformation(OrderInjectable $order) { if (!$order->hasData('shipping_method')) { return; } - $url = $this->url . '/selected-shipping-method'; + $url = $this->url . '/shipping-information'; list($carrier, $method) = explode('_', $order->getShippingMethod()); + + $address = $order->hasData('shipping_address_id') + ? $order->getShippingAddressId() + : $order->getBillingAddressId(); + + unset($address['default_billing']); + unset($address['default_shipping']); + foreach (array_keys($this->mappingData) as $key) { + if (isset($address[$key])) { + $address[$key] = $this->mappingData[$key][$address[$key]]; + } + } + $data = [ - "carrierCode" => $carrier, - "methodCode" => $method + 'addressInformation' => [ + 'shippingAddress' => $address, + 'shippingMethodCode' => $method, + 'shippingCarrierCode' => $carrier, + ] ]; - $this->webapiTransport->write($url, $data, WebapiDecorator::PUT); + + $this->webapiTransport->write($url, $data, WebapiDecorator::POST); $response = json_decode($this->webapiTransport->read(), true); $this->webapiTransport->close(); - if ($response !== true) { + if (!isset($response['payment_methods'], $response['totals'])) { $this->eventManager->dispatchEvent(['webapi_failed'], [$response]); throw new \Exception('Could not set shipping method to quote!'); } diff --git a/setup/performance-toolkit/benchmark.jmx b/setup/performance-toolkit/benchmark.jmx index af73293f01a..85dc362029b 100644 --- a/setup/performance-toolkit/benchmark.jmx +++ b/setup/performance-toolkit/benchmark.jmx @@ -5027,7 +5027,7 @@ vars.put("loadType", "Guest");</stringProp> <stringProp name="HTTPSampler.response_timeout"/> <stringProp name="HTTPSampler.protocol"/> <stringProp name="HTTPSampler.contentEncoding"/> - <stringProp name="HTTPSampler.path">${base_path}rest/default/V1/carts/${cart_id}/shipping-information</stringProp> + <stringProp name="HTTPSampler.path">${base_path}rest/default/V1/guest-carts/${cart_id}/shipping-information</stringProp> <stringProp name="HTTPSampler.method">POST</stringProp> <boolProp name="HTTPSampler.follow_redirects">true</boolProp> <boolProp name="HTTPSampler.auto_redirects">false</boolProp> -- GitLab