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

Commit a91eee3

Browse files
authored
Merge pull request #678 from commercetools/php-maintainance
2 parents 99d0ade + a79250f commit a91eee3

36 files changed

+1105
-29
lines changed

src/Core/Builder/Request/CartRequestBuilder.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
use Commercetools\Core\Request\Carts\CartByCustomerIdGetRequest;
66
use Commercetools\Core\Request\Carts\CartByIdGetRequest;
7+
use Commercetools\Core\Request\Carts\CartByKeyGetRequest;
78
use Commercetools\Core\Request\Carts\CartCreateRequest;
89
use Commercetools\Core\Model\Cart\CartDraft;
9-
use Commercetools\Core\Request\Carts\CartDeleteRequest;
10+
use Commercetools\Core\Request\Carts\CartDeleteByKeyRequest;
1011
use Commercetools\Core\Model\Cart\Cart;
12+
use Commercetools\Core\Request\Carts\CartDeleteRequest;
1113
use Commercetools\Core\Request\Carts\CartQueryRequest;
1214
use Commercetools\Core\Request\Carts\CartReplicateRequest;
15+
use Commercetools\Core\Request\Carts\CartUpdateByKeyRequest;
1316
use Commercetools\Core\Request\Carts\CartUpdateRequest;
1417

1518
class CartRequestBuilder
@@ -37,6 +40,17 @@ public function getById($id)
3740
return $request;
3841
}
3942

43+
/**
44+
* @link https://docs.commercetools.com/api/projects/carts#get-a-cart-by-key
45+
* @param string $key
46+
* @return CartByKeyGetRequest
47+
*/
48+
public function getByKey($key)
49+
{
50+
$request = CartByKeyGetRequest::ofKey($key);
51+
return $request;
52+
}
53+
4054
/**
4155
* @link https://docs.commercetools.com/http-api-projects-carts.html#create-cart
4256
* @param CartDraft $cartDraft
@@ -48,6 +62,17 @@ public function create(CartDraft $cartDraft)
4862
return $request;
4963
}
5064

65+
/**
66+
* @link https://docs.commercetools.com/api/projects/carts#delete-a-cart-by-key
67+
* @param Cart $cart
68+
* @return CartDeleteByKeyRequest
69+
*/
70+
public function deleteByKey(Cart $cart)
71+
{
72+
$request = CartDeleteByKeyRequest::ofKeyAndVersion($cart->getKey(), $cart->getVersion());
73+
return $request;
74+
}
75+
5176
/**
5277
* @link https://docs.commercetools.com/http-api-projects-carts.html#delete-cart
5378
* @param Cart $cart
@@ -81,6 +106,17 @@ public function replicate($cartId)
81106
return $request;
82107
}
83108

109+
/**
110+
* @link https://docs.commercetools.com/api/projects/carts#update-a-cart-by-key
111+
* @param Cart $cart
112+
* @return CartUpdateByKeyRequest
113+
*/
114+
public function updateByKey(Cart $cart)
115+
{
116+
$request = CartUpdateByKeyRequest::ofKeyAndVersion($cart->getKey(), $cart->getVersion());
117+
return $request;
118+
}
119+
84120
/**
85121
* @link https://docs.commercetools.com/http-api-projects-carts.html#update-cart
86122
* @param Cart $cart

src/Core/Builder/Request/CustomerRequestBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// phpcs:disable Generic.Files.LineLength
33
namespace Commercetools\Core\Builder\Request;
44

5+
use Commercetools\Core\Model\Cart\CartReference;
56
use Commercetools\Core\Request\Customers\CustomerByEmailTokenGetRequest;
67
use Commercetools\Core\Request\Customers\CustomerByIdGetRequest;
78
use Commercetools\Core\Request\Customers\CustomerByKeyGetRequest;
@@ -129,7 +130,7 @@ public function createEmailVerificationToken(Customer $customer, $ttlMinutes)
129130
* @param string $email
130131
* @param string $password
131132
* @param bool $updateProductData
132-
* @param string $anonymousCartId
133+
* @param CartReference|string $anonymousCartId
133134
* @return CustomerLoginRequest
134135
*/
135136
public function login($email, $password, $updateProductData = false, $anonymousCartId = null)

src/Core/Builder/Request/OrderRequestBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// phpcs:disable Generic.Files.LineLength
33
namespace Commercetools\Core\Builder\Request;
44

5+
use Commercetools\Core\Model\Cart\CartReference;
56
use Commercetools\Core\Request\Orders\OrderByIdGetRequest;
67
use Commercetools\Core\Request\Orders\OrderByOrderNumberGetRequest;
78
use Commercetools\Core\Request\Orders\OrderCreateFromCartRequest;
@@ -47,7 +48,7 @@ public function getByOrderNumber($orderNumber)
4748
*/
4849
public function createFromCart(Cart $cart)
4950
{
50-
$request = OrderCreateFromCartRequest::ofCartIdAndVersion($cart->getId(), $cart->getVersion());
51+
$request = OrderCreateFromCartRequest::ofCartAndVersion(CartReference::ofId($cart->getId()), $cart->getVersion());
5152
return $request;
5253
}
5354

src/Core/Builder/Update/CartsActionBuilder.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@
4444
use Commercetools\Core\Request\Carts\Command\CartSetDeleteDaysAfterLastModificationAction;
4545
use Commercetools\Core\Request\Carts\Command\CartSetItemShippingAddressCustomFieldAction;
4646
use Commercetools\Core\Request\Carts\Command\CartSetItemShippingAddressCustomTypeAction;
47+
use Commercetools\Core\Request\Carts\Command\CartSetKeyAction;
4748
use Commercetools\Core\Request\Carts\Command\CartSetLineItemCustomFieldAction;
4849
use Commercetools\Core\Request\Carts\Command\CartSetLineItemCustomTypeAction;
50+
use Commercetools\Core\Request\Carts\Command\CartSetLineItemDistributionChannelAction;
4951
use Commercetools\Core\Request\Carts\Command\CartSetLineItemPriceAction;
5052
use Commercetools\Core\Request\Carts\Command\CartSetLineItemShippingDetailsAction;
5153
use Commercetools\Core\Request\Carts\Command\CartSetLineItemTaxAmountAction;
@@ -506,6 +508,17 @@ public function setItemShippingAddressCustomType($action = null)
506508
return $this;
507509
}
508510

511+
/**
512+
* @link https://docs.commercetools.com/api/projects/carts#set-key-
513+
* @param CartSetKeyAction|callable $action
514+
* @return $this
515+
*/
516+
public function setKey($action = null)
517+
{
518+
$this->addAction($this->resolveAction(CartSetKeyAction::class, $action));
519+
return $this;
520+
}
521+
509522
/**
510523
* @link https://docs.commercetools.com/http-api-projects-carts.html#set-lineitem-customfield
511524
* @param CartSetLineItemCustomFieldAction|callable $action
@@ -528,6 +541,17 @@ public function setLineItemCustomType($action = null)
528541
return $this;
529542
}
530543

544+
/**
545+
*
546+
* @param CartSetLineItemDistributionChannelAction|callable $action
547+
* @return $this
548+
*/
549+
public function setLineItemDistributionChannel($action = null)
550+
{
551+
$this->addAction($this->resolveAction(CartSetLineItemDistributionChannelAction::class, $action));
552+
return $this;
553+
}
554+
531555
/**
532556
* @link https://docs.commercetools.com/http-api-projects-carts.html#set-lineitem-totalprice
533557
* @param CartSetLineItemPriceAction|callable $action

src/Core/Builder/Update/ShippingMethodsActionBuilder.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Commercetools\Core\Request\ShippingMethods\Command\ShippingMethodChangeTaxCategoryAction;
1212
use Commercetools\Core\Request\ShippingMethods\Command\ShippingMethodRemoveShippingRateAction;
1313
use Commercetools\Core\Request\ShippingMethods\Command\ShippingMethodRemoveZoneAction;
14+
use Commercetools\Core\Request\ShippingMethods\Command\ShippingMethodSetCustomFieldAction;
15+
use Commercetools\Core\Request\ShippingMethods\Command\ShippingMethodSetCustomTypeAction;
1416
use Commercetools\Core\Request\ShippingMethods\Command\ShippingMethodSetDescriptionAction;
1517
use Commercetools\Core\Request\ShippingMethods\Command\ShippingMethodSetKeyAction;
1618
use Commercetools\Core\Request\ShippingMethods\Command\ShippingMethodSetLocalizedDescriptionAction;
@@ -97,6 +99,28 @@ public function removeZone($action = null)
9799
return $this;
98100
}
99101

102+
/**
103+
* @link https://docs.commercetools.com/api/projects/shippingMethods#set-customfield
104+
* @param ShippingMethodSetCustomFieldAction|callable $action
105+
* @return $this
106+
*/
107+
public function setCustomField($action = null)
108+
{
109+
$this->addAction($this->resolveAction(ShippingMethodSetCustomFieldAction::class, $action));
110+
return $this;
111+
}
112+
113+
/**
114+
* @link https://docs.commercetools.com/api/projects/shippingMethods#set-customtype
115+
* @param ShippingMethodSetCustomTypeAction|callable $action
116+
* @return $this
117+
*/
118+
public function setCustomType($action = null)
119+
{
120+
$this->addAction($this->resolveAction(ShippingMethodSetCustomTypeAction::class, $action));
121+
return $this;
122+
}
123+
100124
/**
101125
* @link https://docs.commercetools.com/http-api-projects-shippingMethods.html#set-description
102126
* @param ShippingMethodSetDescriptionAction|callable $action

src/Core/Builder/Update/StagedOrderActionBuilder.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
use Commercetools\Core\Request\OrderEdits\StagedOrder\Command\StagedOrderSetItemShippingAddressCustomTypeAction;
5555
use Commercetools\Core\Request\OrderEdits\StagedOrder\Command\StagedOrderSetLineItemCustomFieldAction;
5656
use Commercetools\Core\Request\OrderEdits\StagedOrder\Command\StagedOrderSetLineItemCustomTypeAction;
57+
use Commercetools\Core\Request\OrderEdits\StagedOrder\Command\StagedOrderSetLineItemDistributionChannelAction;
5758
use Commercetools\Core\Request\OrderEdits\StagedOrder\Command\StagedOrderSetLineItemPriceAction;
5859
use Commercetools\Core\Request\OrderEdits\StagedOrder\Command\StagedOrderSetLineItemShippingDetailsAction;
5960
use Commercetools\Core\Request\OrderEdits\StagedOrder\Command\StagedOrderSetLineItemTaxAmountAction;
@@ -638,6 +639,17 @@ public function setLineItemCustomType($action = null)
638639
return $this;
639640
}
640641

642+
/**
643+
*
644+
* @param StagedOrderSetLineItemDistributionChannelAction|callable $action
645+
* @return $this
646+
*/
647+
public function setLineItemDistributionChannel($action = null)
648+
{
649+
$this->addAction($this->resolveAction(StagedOrderSetLineItemDistributionChannelAction::class, $action));
650+
return $this;
651+
}
652+
641653
/**
642654
*
643655
* @param StagedOrderSetLineItemPriceAction|callable $action
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
4+
namespace Commercetools\Core\Error;
5+
6+
/**
7+
* @package Commercetools\Core\Error
8+
*
9+
* @method string getCode()
10+
* @method QueryTimedOutError setCode(string $code = null)
11+
* @method string getMessage()
12+
* @method QueryTimedOutError setMessage(string $message = null)
13+
*/
14+
class QueryTimedOutError extends ApiError
15+
{
16+
const CODE = 'QueryTimedOut';
17+
18+
public function fieldDefinitions()
19+
{
20+
$definitions = parent::fieldDefinitions();
21+
22+
return $definitions;
23+
}
24+
}

src/Core/Model/Cart/Cart.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
* @method Cart setCreatedBy(CreatedBy $createdBy = null)
9090
* @method LastModifiedBy getLastModifiedBy()
9191
* @method Cart setLastModifiedBy(LastModifiedBy $lastModifiedBy = null)
92+
* @method string getKey()
93+
* @method Cart setKey(string $key = null)
9294
* @method CartReference getReference()
9395
*/
9496
class Cart extends Resource
@@ -113,6 +115,7 @@ public function fieldDefinitions()
113115
{
114116
return [
115117
'id' => [static::TYPE => 'string'],
118+
'key' => [static::TYPE => 'string'],
116119
'version' => [static::TYPE => 'int'],
117120
'createdAt' => [
118121
static::TYPE => DateTime::class,

src/Core/Model/Cart/CartDraft.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
* @method CartDraft setStore(StoreReference $store = null)
6767
* @method array getDiscountCodes()
6868
* @method CartDraft setDiscountCodes(array $discountCodes = null)
69+
* @method string getKey()
70+
* @method CartDraft setKey(string $key = null)
6971
*/
7072
class CartDraft extends JsonObject
7173
{
@@ -75,6 +77,7 @@ public function fieldDefinitions()
7577
{
7678
return [
7779
'currency' => [static::TYPE => 'string'],
80+
'key' => [static::TYPE => 'string'],
7881
'customerId' => [static::TYPE => 'string'],
7982
'customerEmail' => [static::TYPE => 'string'],
8083
'country' => [static::TYPE => 'string'],

src/Core/Model/Customer/CustomerDraft.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
namespace Commercetools\Core\Model\Customer;
88

9+
use Commercetools\Core\Model\Cart\CartReference;
910
use Commercetools\Core\Model\Common\Context;
1011
use Commercetools\Core\Model\Common\JsonObject;
1112
use Commercetools\Core\Model\Common\DateTimeDecorator;
1213
use Commercetools\Core\Model\Common\LocaleTrait;
14+
use Commercetools\Core\Model\Common\ResourceIdentifier;
1315
use Commercetools\Core\Model\CustomerGroup\CustomerGroupReference;
1416
use Commercetools\Core\Model\Common\AddressCollection;
1517
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
@@ -69,6 +71,8 @@
6971
* @method CustomerDraft setAnonymousId(string $anonymousId = null)
7072
* @method StoreReferenceCollection getStores()
7173
* @method CustomerDraft setStores(StoreReferenceCollection $stores = null)
74+
* @method CartReference getAnonymousCart()
75+
* @method CustomerDraft setAnonymousCart(CartReference $anonymousCart = null)
7276
*/
7377
class CustomerDraft extends JsonObject
7478
{
@@ -105,6 +109,7 @@ public function fieldDefinitions()
105109
'key' => [static::TYPE => 'string'],
106110
'anonymousId' => [static::TYPE => 'string'],
107111
'stores' => [static::TYPE => StoreReferenceCollection::class],
112+
'anonymousCart' => [static::TYPE => CartReference::class],
108113
];
109114
}
110115

0 commit comments

Comments
 (0)