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

Commit 780dc03

Browse files
author
Barbara Palumbo
committed
Merge branch 'php-mantainance2' of https://github.com/commercetools/commercetools-php-sdk into php-mantainance2
2 parents fcee638 + 7b7cf2f commit 780dc03

File tree

48 files changed

+1144
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1144
-42
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
- "7.3"
9191
- "7.4"
9292
- "8.0"
93+
- "8.1"
9394

9495
dependencies:
9596
- lowest

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
},
4343
"require-dev": {
4444
"guzzlehttp/guzzle": "^7.0 || ^6.0",
45-
"phpunit/phpunit": "^9.0",
45+
"phpunit/phpunit": "9.5.10",
4646
"phpspec/prophecy-phpunit": "^2.0",
47-
"symplify/easy-coding-standard-prefixed": "8.3.48 || 9.2.23",
47+
"symplify/easy-coding-standard": "10.0.2",
4848
"doctrine/cache": "^1.6 || ^2.0",
4949
"monolog/monolog": "^1.12 || ^2.0",
5050
"symfony/yaml": "^4.0 || ^3.4.38 || ^5.0",

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;
@@ -98,6 +100,28 @@ public function removeZone($action = null)
98100
return $this;
99101
}
100102

103+
/**
104+
* @link https://docs.commercetools.com/api/projects/shippingMethods#set-customfield
105+
* @param ShippingMethodSetCustomFieldAction|callable $action
106+
* @return $this
107+
*/
108+
public function setCustomField($action = null)
109+
{
110+
$this->addAction($this->resolveAction(ShippingMethodSetCustomFieldAction::class, $action));
111+
return $this;
112+
}
113+
114+
/**
115+
* @link https://docs.commercetools.com/api/projects/shippingMethods#set-customtype
116+
* @param ShippingMethodSetCustomTypeAction|callable $action
117+
* @return $this
118+
*/
119+
public function setCustomType($action = null)
120+
{
121+
$this->addAction($this->resolveAction(ShippingMethodSetCustomTypeAction::class, $action));
122+
return $this;
123+
}
124+
101125
/**
102126
* @link https://docs.commercetools.com/http-api-projects-shippingMethods.html#set-description
103127
* @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;
@@ -639,6 +640,17 @@ public function setLineItemCustomType($action = null)
639640
return $this;
640641
}
641642

643+
/**
644+
*
645+
* @param StagedOrderSetLineItemDistributionChannelAction|callable $action
646+
* @return $this
647+
*/
648+
public function setLineItemDistributionChannel($action = null)
649+
{
650+
$this->addAction($this->resolveAction(StagedOrderSetLineItemDistributionChannelAction::class, $action));
651+
return $this;
652+
}
653+
642654
/**
643655
*
644656
* @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/Helper/Annotate/AnnotationGenerator.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function getJsonObjects(\RegexIterator $phpFiles)
9292
$jsonObjects = [];
9393
foreach ($phpFiles as $phpFile) {
9494
$class = $this->getClassName($phpFile->getRealPath());
95-
if (strpos($class, 'Core\\Helper') > 0) {
95+
if ($class != null && strpos($class, 'Core\\Helper') > 0) {
9696
continue;
9797
}
9898

@@ -112,7 +112,7 @@ protected function getCollectionObjects(\RegexIterator $phpFiles)
112112
$collectionObjects = [];
113113
foreach ($phpFiles as $phpFile) {
114114
$class = $this->getClassName($phpFile->getRealPath());
115-
if (strpos($class, 'Core\\Helper') > 0) {
115+
if ($class != null && strpos($class, 'Core\\Helper') > 0) {
116116
continue;
117117
}
118118

@@ -132,7 +132,7 @@ protected function getRequestObjects(\RegexIterator $phpFiles)
132132
$requestObjects = [];
133133
foreach ($phpFiles as $phpFile) {
134134
$class = $this->getClassName($phpFile->getRealPath());
135-
if (strpos($class, 'Core\\Helper') > 0) {
135+
if ($class != null && strpos($class, 'Core\\Helper') > 0) {
136136
continue;
137137
}
138138

@@ -152,7 +152,7 @@ protected function getRequestDomainObjects(\RegexIterator $phpFiles)
152152
$requestObjects = [];
153153
foreach ($phpFiles as $phpFile) {
154154
$class = $this->getClassName($phpFile->getRealPath());
155-
if (strpos($class, 'Core\\Helper') > 0) {
155+
if ($class != null && strpos($class, 'Core\\Helper') > 0) {
156156
continue;
157157
}
158158

@@ -164,10 +164,10 @@ protected function getRequestDomainObjects(\RegexIterator $phpFiles)
164164
) {
165165
$namespaceParts = explode("\\", $class->getNamespaceName());
166166
$domain = $namespaceParts[count($namespaceParts) - 1];
167-
if (strpos($class, 'ProductProjection') > 0) {
167+
if ($class != null && strpos($class, 'ProductProjection') > 0) {
168168
$domain = 'ProductProjections';
169169
}
170-
if (strpos($class, 'ProductsSuggest') > 0) {
170+
if ($class != null && strpos($class, 'ProductsSuggest') > 0) {
171171
$domain = 'ProductProjections';
172172
}
173173
$requestObjects[$domain][] = $class->getName();
@@ -183,7 +183,7 @@ protected function getUpdateObjects(\RegexIterator $phpFiles)
183183
$actions = [];
184184
foreach ($phpFiles as $phpFile) {
185185
$class = $this->getClassName($phpFile->getRealPath());
186-
if (strpos($class, 'Core\\Helper') > 0) {
186+
if ($class != null && strpos($class, 'Core\\Helper') > 0) {
187187
continue;
188188
}
189189

0 commit comments

Comments
 (0)