[API] Use POST action to add new item to cart

This commit is contained in:
Łukasz Chruściel 2021-09-14 16:45:09 +02:00
parent 219294afbe
commit 27d0121541
No known key found for this signature in database
GPG key ID: 049A1D51AA3B039C
4 changed files with 9 additions and 4 deletions

View file

@ -21,6 +21,8 @@
sylius_api:
product_image_prefix: 'media/image'
```
1. The method of the `/shop/orders/{tokenValue}/items` endpoint has been changed from `PATCH` to `POST`
1. `Sylius\Bundle\ApiBundle\View\CartShippingMethodInterface` and `Sylius\Bundle\ApiBundle\View\CartShippingMethod` have been removed.

View file

@ -187,7 +187,7 @@ final class CartContext implements Context
$tokenValue = $this->pickupCart();
$request = Request::customItemAction('shop', 'orders', $tokenValue, HttpRequest::METHOD_PATCH, 'items');
$request = Request::customItemAction('shop', 'orders', $tokenValue, HttpRequest::METHOD_POST, 'items');
$request->updateContent([
'productCode' => $productData['code'],
@ -678,7 +678,7 @@ final class CartContext implements Context
{
$tokenValue = $tokenValue ?? $this->pickupCart();
$request = Request::customItemAction('shop', 'orders', $tokenValue, HttpRequest::METHOD_PATCH, 'items');
$request = Request::customItemAction('shop', 'orders', $tokenValue, HttpRequest::METHOD_POST, 'items');
$request->updateContent([
'productVariant' => $this->iriConverter->getIriFromItem($this->productVariantResolver->getVariant($product)),
@ -692,7 +692,7 @@ final class CartContext implements Context
{
$tokenValue = $tokenValue ?? $this->pickupCart();
$request = Request::customItemAction('shop', 'orders', $tokenValue, HttpRequest::METHOD_PATCH, 'items');
$request = Request::customItemAction('shop', 'orders', $tokenValue, HttpRequest::METHOD_POST, 'items');
$request->updateContent([
'productVariant' => $this->iriConverter->getIriFromItem($productVariant),

View file

@ -92,7 +92,7 @@
</itemOperation>
<itemOperation name="shop_add_item">
<attribute name="method">PATCH</attribute>
<attribute name="method">POST</attribute>
<attribute name="path">/shop/orders/{tokenValue}/items</attribute>
<attribute name="messenger">input</attribute>
<attribute name="input">Sylius\Bundle\ApiBundle\Command\Cart\AddItemToCart</attribute>

View file

@ -58,6 +58,9 @@
<argument>%api_platform.swagger.versions%</argument>
</service>
<!-- TODO: Remove after bumping to Api Platform 3.0 -->
<service id="api_platform.action.post_item" alias="api_platform.action.placeholder" public="true" />
<service id="Sylius\Bundle\ApiBundle\PropertyInfo\Extractor\EmptyPropertyListExtractor">
<tag name="property_info.list_extractor" priority="-2000" />
</service>