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

Commit 0ee68c2

Browse files
committed
Merge branch 'release/v2.17.0'
2 parents 1e3420d + ed08958 commit 0ee68c2

File tree

133 files changed

+4681
-154
lines changed

Some content is hidden

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

133 files changed

+4681
-154
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @commercetools/clients-sdk-team
1+
* @commercetools/clients-team
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Add Issues to project
2+
on:
3+
issues:
4+
types:
5+
- opened
6+
jobs:
7+
add_issues:
8+
uses: commercetools/clients-automation/.github/workflows/workflow_issues_pr_to_project.yml@v1
9+
with:
10+
node_id: ${{ github.event.issue.node_id }}
11+
org: commercetools
12+
project: 32
13+
repository: ${{ github.event.repository.name }}
14+
login: ${{ github.event.issue.user.login }}
15+
secrets:
16+
token: ${{ secrets.PROJECT_TOKEN }}

.github/workflows/ci.yml

Lines changed: 6 additions & 9 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
@@ -165,22 +166,22 @@ jobs:
165166
php7.4-composer-highest-
166167
167168
- name: Install highest dependencies with composer
169+
run: composer update --no-ansi --no-interaction --no-progress --no-suggest
170+
171+
- name: Run integration tests with phpunit for push
168172
if: github.event_name != 'pull_request'
169173
env:
170174
COMMERCETOOLS_CLIENT_ID: ${{ secrets.COMMERCETOOLS_CLIENT_ID }}
171175
COMMERCETOOLS_CLIENT_SECRET: ${{ secrets.COMMERCETOOLS_CLIENT_SECRET }}
172176
COMMERCETOOLS_PROJECT: ${{ secrets.COMMERCETOOLS_PROJECT }}
173-
run: composer update --no-ansi --no-interaction --no-progress --no-suggest
177+
run: vendor/bin/phpunit --coverage-clover=coverage.xml
174178

175-
- name: Install highest dependencies with composer for PR
179+
- name: Run integration tests with phpunit for PR
176180
if: github.event_name == 'pull_request'
177181
env:
178182
COMMERCETOOLS_CLIENT_ID: ${{ secrets.PR_COMMERCETOOLS_CLIENT_ID }}
179183
COMMERCETOOLS_CLIENT_SECRET: ${{ secrets.PR_COMMERCETOOLS_CLIENT_SECRET }}
180184
COMMERCETOOLS_PROJECT: ${{ secrets.PR_COMMERCETOOLS_PROJECT }}
181-
run: composer update --no-ansi --no-interaction --no-progress --no-suggest
182-
183-
- name: Run integration tests with phpunit
184185
run: vendor/bin/phpunit --coverage-clover=coverage.xml
185186

186187
- name: Send code coverage report to Codecov.io
@@ -208,10 +209,6 @@ jobs:
208209
ini-values: assert.exception=1, zend.assertions=1, apc.enabled=1, apc.enable_cli=1
209210

210211
- name: Install dependencies with composer
211-
env:
212-
COMMERCETOOLS_CLIENT_ID: ${{ secrets.COMMERCETOOLS_CLIENT_ID }}
213-
COMMERCETOOLS_CLIENT_SECRET: ${{ secrets.COMMERCETOOLS_CLIENT_SECRET }}
214-
COMMERCETOOLS_PROJECT: ${{ secrets.COMMERCETOOLS_PROJECT }}
215212
run: composer install --no-ansi --no-interaction --no-progress --no-suggest --no-dev
216213

217214
- name: Retrieve branch name

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
# [2.17.0](https://github.com/commercetools/commercetools-php-sdk/compare/v2.16.0...v2.17.0) (2022-02-07)
2+
3+
4+
### Features
5+
6+
* **Cart:** add key in Cart ([d3f24c4](https://github.com/commercetools/commercetools-php-sdk/commit/d3f24c4b419d363fbcea10cb7f44903025d1c5c9))
7+
* **Cart:** add new field productkey ([ccd77b8](https://github.com/commercetools/commercetools-php-sdk/commit/ccd77b88d03f77e117521db6f9ce8ee78c740cfb))
8+
* **Cart:** add test for replicate cart in store ([ec6390d](https://github.com/commercetools/commercetools-php-sdk/commit/ec6390d3235ebf8df9a7b57fd8e80638918e59c5))
9+
* **Cart:** introduce more small features ([ba45fc5](https://github.com/commercetools/commercetools-php-sdk/commit/ba45fc54d3df1e5e39f296ff37866663d02442bc))
10+
* **Cart:** support new update action setLineItemSupplyChannel ([87887cb](https://github.com/commercetools/commercetools-php-sdk/commit/87887cb1e05bdc769ae1a652f7d014ee479b98ea))
11+
* **Customer:** add anonymousCart field ([4c45b41](https://github.com/commercetools/commercetools-php-sdk/commit/4c45b419573de216e34cb11b251364224b1d8f9c))
12+
* **Delivery:** add field param ([c7ad278](https://github.com/commercetools/commercetools-php-sdk/commit/c7ad278fc2dba0ac513fdbcc3a6166ef86463c85))
13+
* **Error:** add querytimeout error ([ec13853](https://github.com/commercetools/commercetools-php-sdk/commit/ec1385355be85bd9901215bd0515d9de04d70f87))
14+
* **Error:** add querytimeout error ([153cc0b](https://github.com/commercetools/commercetools-php-sdk/commit/153cc0bdd3eee9d0adff330aeefb176f4a6c0e7d))
15+
* **Head:** support Head method for products ([6a02a6b](https://github.com/commercetools/commercetools-php-sdk/commit/6a02a6be34237f46dd2424750f6e08941fd1e06e))
16+
* **Message:** add field in InventoryEntryQuantitySetMessage ([7008f32](https://github.com/commercetools/commercetools-php-sdk/commit/7008f32ae9b83c8c50b2378a59a3d68ff3f9d873))
17+
* **Message:** add new class as useProvidedIdentifiers for ContainerAndKey ([3d332fd](https://github.com/commercetools/commercetools-php-sdk/commit/3d332fd5dff35396920a67a7f6c3fb8ea5a76cb9))
18+
* **Message:** add new message for products ([1e6e5ad](https://github.com/commercetools/commercetools-php-sdk/commit/1e6e5add27a4018b7469e586c518cba21f627680))
19+
* **Message:** support oldState to OrderStateTransitionMessage and support store messages ([b56c7ed](https://github.com/commercetools/commercetools-php-sdk/commit/b56c7ed830661a7d6b81818f55926d8100576013))
20+
* **Order:** support new update actions setReturnItemCustom as for order as for order edit ([d2e3879](https://github.com/commercetools/commercetools-php-sdk/commit/d2e38793890fc018908280c2d63537b50bfdbca9))
21+
* **Order:** support setReturnInfoAction and related message ([b34aa6b](https://github.com/commercetools/commercetools-php-sdk/commit/b34aa6bfef43a311d64419b015b6d5ff54764941))
22+
* **Order:** support update actions for Order and Order Edit to SetParcelCustom ([0124793](https://github.com/commercetools/commercetools-php-sdk/commit/0124793e950f793346bcdca7b238d2ca63c555c6))
23+
* **Project:** add new actions and add customer message ([e97e521](https://github.com/commercetools/commercetools-php-sdk/commit/e97e521be1d8739f0291f5246441f02fe4f68fe4))
24+
* **Project:** fix failed test ([b8357d0](https://github.com/commercetools/commercetools-php-sdk/commit/b8357d02643e980ddab735eb0bb2050b1117e408))
25+
* **ShipingMethod:** add custom field and related action in shipping method ([5a9a3f9](https://github.com/commercetools/commercetools-php-sdk/commit/5a9a3f972781f25a744b599462834cc83ef603b8))
26+
* **ShippingMethod:** support localizedName and related action ([50dbb24](https://github.com/commercetools/commercetools-php-sdk/commit/50dbb24e08d2553fbd09b73065e36c89b5c4ddd8))
27+
* **UserAgent:** modify user agent ([aa7f055](https://github.com/commercetools/commercetools-php-sdk/commit/aa7f05537bfecd792d2feeb6cbb41d06991c010f))
28+
29+
30+
131
# [2.16.0](https://github.com/commercetools/commercetools-php-sdk/compare/v2.15.0...v2.16.0) (2021-08-02)
232

333

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# <img src="build/theme/resources/CT_cube_200px.png" width="40" align="center"></img> commercetools PHP SDK
22

3+
:warning: **This commercetools PHP SDK is in its Active Support mode currently, and is planned to be deprecated, please note the following dates.
4+
5+
| Active Support | Maintenance Support | End of Life |
6+
| --------------------- | --------------------- | --------------------- |
7+
| `28th February, 2022` | `31st August 2022.` | `1st September 2022.` |
8+
9+
We recommend to use our [PHP SDK V2](https://docs.commercetools.com/sdk/php-sdk#php-sdk-v2).
10+
311
[![Build Status](https://img.shields.io/travis/com/commercetools/commercetools-php-sdk/master.svg?style=flat-square)](https://travis-ci.com/commercetools/commercetools-php-sdk) [![Scrutinizer](https://img.shields.io/scrutinizer/g/commercetools/commercetools-php-sdk.svg?style=flat-square)](https://scrutinizer-ci.com/g/commercetools/commercetools-php-sdk/) [![Scrutinizer](https://img.shields.io/scrutinizer/coverage/g/commercetools/commercetools-php-sdk.svg?style=flat-square)](https://scrutinizer-ci.com/g/commercetools/commercetools-php-sdk/) [![Packagist](https://img.shields.io/packagist/v/commercetools/php-sdk.svg?style=flat-square)](https://packagist.org/packages/commercetools/php-sdk) [![Packagist](https://img.shields.io/packagist/dm/commercetools/php-sdk.svg?style=flat-square)](https://packagist.org/packages/commercetools/php-sdk)
412

513
The PHP SDK allows developers to build applications on the commercetools platform (technically speaking against our REST API) using PHP native interfaces, models and helpers instead of manually using the HTTP and JSON API.
@@ -252,6 +260,64 @@ $middlewares = [
252260
$config = Config::of()->setClientOptions(['middlewares' => $middlewares])
253261
```
254262

263+
#### Timeouts
264+
265+
The clients are configured to timeout by default after 60 seconds. This can be changed by setting the client options in the Config instance
266+
267+
```php
268+
$config = Config::of()->setClientOptions([
269+
'defaults' => [
270+
'timeout' => 10
271+
]
272+
])
273+
```
274+
275+
Another option is to specify the timeout per request
276+
277+
```php
278+
$request = ProductProjectionSearchRequest::of();
279+
$response = $client->execute($request, null, ['timeout' => 10]);
280+
```
281+
282+
#### Retrying
283+
284+
As a request can error in multiple ways it's possible to add a retry middleware to the client config. E.g.: Retrying in case of service unavailable errors
285+
286+
```php
287+
$config = Config::of()->setClientOptions([
288+
'defaults' => [
289+
'timeout' => 10
290+
]
291+
])
292+
$maxRetries = 3;
293+
$clientOptions = [
294+
'middlewares' => [
295+
'retry' => Middleware::retry(
296+
function ($retries, RequestInterface $request, ResponseInterface $response = null, $error = null) use ($maxRetries) {
297+
if ($response instanceof ResponseInterface && $response->getStatusCode() < 500) {
298+
return false;
299+
}
300+
if ($retries > $maxRetries) {
301+
return false;
302+
}
303+
if ($error instanceof ServiceUnavailableException) {
304+
return true;
305+
}
306+
if ($error instanceof ServerException && $error->getCode() == 503) {
307+
return true;
308+
}
309+
if ($response instanceof ResponseInterface && $response->getStatusCode() == 503) {
310+
return true;
311+
}
312+
return false;
313+
},
314+
[RetryMiddleware::class, 'exponentialDelay']
315+
)
316+
]
317+
];
318+
$config->setClientOptions($clientOptions);
319+
```
320+
255321
### Using the phar distribution
256322

257323
Since version 1.6 the SDK is also released as a PHAR. You can find them in the [releases section](https://github.com/commercetools/commercetools-php-sdk/releases) at Github.

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "commercetools/php-sdk",
33
"license": "MIT",
44
"type": "project",
5-
"description": "The commercetools PHP SDK \n The official PHP Interface to the commercetools eCommerce API",
5+
"description": "This SDK is announced to be deprecated latest by 31 August 2022, please follow more details on SDK deprecation plan https://docs.commercetools.com/api/releases/2021-08-31-announced-long-term-support-plan-for-commercetools-sdks. We recommend you to use our new SDK here https://docs.commercetools.com/sdk/php-sdk#php-sdk-v2.",
66
"homepage": "https://github.com/commercetools/commercetools-php-sdk",
77
"support": {
88
"email": "support@commercetools.com",
@@ -31,24 +31,24 @@
3131
},
3232
"require": {
3333
"php": ">=5.6",
34-
"psr/log": "^1.0",
34+
"psr/log": "^1.0 || ^2.0",
3535
"guzzlehttp/guzzle": "^7.0 || ^6.0 || ^5.3.3 ",
3636
"guzzlehttp/psr7": "^1.7 || ^2.0",
37-
"psr/cache": "^1.0 || ^2.0",
37+
"psr/cache": "^1.0 || ^2.0 || ^3.0",
3838
"psr/simple-cache": "^1.0",
3939
"cache/apcu-adapter": "^1.0 || ^0.3 || ^0.2",
4040
"paragonie/random_compat": "^2.0 || ^1.0 || ^9.99",
4141
"ext-intl": "*"
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",
50-
"symfony/yaml": "^4.0 || ^3.4.38",
51-
"symfony/stopwatch": "^4.0 || ^3.4.38",
50+
"symfony/yaml": "^4.0 || ^3.4.38 || ^5.0",
51+
"symfony/stopwatch": "^4.0 || ^3.4.38 || ^5.0",
5252
"cache/adapter-common": "^1.0",
5353
"cache/apcu-adapter": "^1.0",
5454
"cache/array-adapter": "^1.0",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commercetools-php-sdk-changelog",
3-
"version": "2.16.0",
3+
"version": "2.17.0",
44
"description": "commercetools PHP SDK changelog generator package description",
55
"homepage": "https://github.com/commercetools/commercetools-php-sdk",
66
"bugs": "https://github.com/commercetools/commercetools-php-sdk/issues",

renovate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
"labels": [
2323
"Type: Maintenance"
2424
],
25-
"ignoreDeps": []
25+
"ignoreDeps": ["symplify/easy-coding-standard-prefixed"]
2626
}

src/Core/AbstractHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
abstract class AbstractHttpClient
1616
{
17-
const VERSION = '2.16.0';
17+
const VERSION = '2.17.0';
1818

1919
/**
2020
* @var AdapterInterface

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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Commercetools\Core\Request\Customers\CustomerEmailConfirmRequest;
1515
use Commercetools\Core\Request\Customers\CustomerEmailTokenRequest;
1616
use Commercetools\Core\Request\Customers\CustomerLoginRequest;
17+
use Commercetools\Core\Model\Cart\CartReference;
1718
use Commercetools\Core\Request\Customers\CustomerPasswordChangeRequest;
1819
use Commercetools\Core\Request\Customers\CustomerPasswordResetRequest;
1920
use Commercetools\Core\Request\Customers\CustomerPasswordTokenRequest;
@@ -129,16 +130,16 @@ 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 $anonymousCart
133134
* @return CustomerLoginRequest
134135
*/
135-
public function login($email, $password, $updateProductData = false, $anonymousCartId = null)
136+
public function login($email, $password, $updateProductData = false, $anonymousCart = null)
136137
{
137138
$request = CustomerLoginRequest::ofEmailPasswordAndUpdateProductData(
138139
$email,
139140
$password,
140141
$updateProductData,
141-
$anonymousCartId
142+
$anonymousCart
142143
);
143144
return $request;
144145
}

src/Core/Builder/Request/OrderRequestBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Commercetools\Core\Request\Orders\OrderByOrderNumberGetRequest;
77
use Commercetools\Core\Request\Orders\OrderCreateFromCartRequest;
88
use Commercetools\Core\Model\Cart\Cart;
9+
use Commercetools\Core\Model\Cart\CartReference;
910
use Commercetools\Core\Request\Orders\OrderDeleteByOrderNumberRequest;
1011
use Commercetools\Core\Model\Order\Order;
1112
use Commercetools\Core\Request\Orders\OrderDeleteRequest;
@@ -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

0 commit comments

Comments
 (0)