Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit b42424a

Browse files
committed
feat(Me): add MeCartDeleteRequest
1 parent b263181 commit b42424a

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

src/Core/Builder/Request/MeCartRequestBuilder.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Commercetools\Core\Request\Me\MeActiveCartRequest;
1111
use Commercetools\Core\Request\Me\MeCartByIdRequest;
1212
use Commercetools\Core\Request\Me\MeCartCreateRequest;
13+
use Commercetools\Core\Request\Me\MeCartDeleteRequest;
1314
use Commercetools\Core\Request\Me\MeCartQueryRequest;
1415
use Commercetools\Core\Request\Me\MeCartUpdateRequest;
1516

@@ -57,4 +58,13 @@ public function create(MyCartDraft $cartDraft)
5758
{
5859
return MeCartCreateRequest::ofDraft($cartDraft);
5960
}
61+
62+
/**
63+
* @param Cart $cart
64+
* @return MeCartDeleteRequest
65+
*/
66+
public function delete(Cart $cart)
67+
{
68+
return MeCartDeleteRequest::ofIdAndVersion($cart->getId(), $cart->getVersion());
69+
}
6070
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
*/
4+
5+
namespace Commercetools\Core\Request\Me;
6+
7+
use Commercetools\Core\Model\Cart\Cart;
8+
use Commercetools\Core\Model\Common\Context;
9+
use Commercetools\Core\Request\AbstractDeleteRequest;
10+
use Commercetools\Core\Request\InStores\InStoreRequestDecorator;
11+
use Commercetools\Core\Request\InStores\InStoreTrait;
12+
use Commercetools\Core\Response\ApiResponseInterface;
13+
use Commercetools\Core\Model\MapperInterface;
14+
15+
/**
16+
* @package Commercetools\Core\Request\Me
17+
* @link https://docs.commercetools.com/http-api-projects-me-carts#delete-cart
18+
* @method Cart mapResponse(ApiResponseInterface $response)
19+
* @method Cart mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
20+
* @method MeCartDeleteRequest|InStoreRequestDecorator inStore($storeKey)
21+
*/
22+
class MeCartDeleteRequest extends AbstractDeleteRequest
23+
{
24+
use InStoreTrait;
25+
26+
protected $resultClass = Cart::class;
27+
28+
/**
29+
* @param string $id
30+
* @param int $version
31+
* @param Context $context
32+
*/
33+
public function __construct($id, $version, Context $context = null)
34+
{
35+
parent::__construct(MeCartsEndpoint::endpoint(), $id, $version, $context);
36+
}
37+
38+
/**
39+
* @param string $id
40+
* @param int $version
41+
* @param Context $context
42+
* @return static
43+
*/
44+
public static function ofIdAndVersion($id, $version, Context $context = null)
45+
{
46+
return new static($id, $version, $context);
47+
}
48+
}

src/Core/Request/Me/MeDeleteRequest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use Commercetools\Core\Model\Common\Context;
99
use Commercetools\Core\Request\AbstractDeleteRequest;
1010
use Commercetools\Core\Model\Customer\Customer;
11-
use Commercetools\Core\Request\InStores\InStoreRequestDecorator;
12-
use Commercetools\Core\Request\InStores\InStoreTrait;
1311
use Commercetools\Core\Response\ApiResponseInterface;
1412
use Commercetools\Core\Model\MapperInterface;
1513

@@ -18,12 +16,9 @@
1816
* @link https://docs.commercetools.com/http-api-projects-me-profile.html#delete-customer
1917
* @method Customer mapResponse(ApiResponseInterface $response)
2018
* @method Customer mapFromResponse(ApiResponseInterface $response, MapperInterface $mapper = null)
21-
* @method MeDeleteRequest|InStoreRequestDecorator inStore($storeKey)
2219
*/
2320
class MeDeleteRequest extends AbstractDeleteRequest
2421
{
25-
use InStoreTrait;
26-
2722
protected $resultClass = Customer::class;
2823

2924
/**

0 commit comments

Comments
 (0)