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

Commit

Permalink
Merge branch 'release/v2.17.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude committed Feb 7, 2022
2 parents 1e3420d + ed08958 commit 0ee68c2
Show file tree
Hide file tree
Showing 133 changed files with 4,681 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @commercetools/clients-sdk-team
* @commercetools/clients-team
16 changes: 16 additions & 0 deletions .github/workflows/add_issues_to_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Add Issues to project
on:
issues:
types:
- opened
jobs:
add_issues:
uses: commercetools/clients-automation/.github/workflows/workflow_issues_pr_to_project.yml@v1
with:
node_id: ${{ github.event.issue.node_id }}
org: commercetools
project: 32
repository: ${{ github.event.repository.name }}
login: ${{ github.event.issue.user.login }}
secrets:
token: ${{ secrets.PROJECT_TOKEN }}
15 changes: 6 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
- "7.3"
- "7.4"
- "8.0"
- "8.1"

dependencies:
- lowest
Expand Down Expand Up @@ -165,22 +166,22 @@ jobs:
php7.4-composer-highest-
- name: Install highest dependencies with composer
run: composer update --no-ansi --no-interaction --no-progress --no-suggest

- name: Run integration tests with phpunit for push
if: github.event_name != 'pull_request'
env:
COMMERCETOOLS_CLIENT_ID: ${{ secrets.COMMERCETOOLS_CLIENT_ID }}
COMMERCETOOLS_CLIENT_SECRET: ${{ secrets.COMMERCETOOLS_CLIENT_SECRET }}
COMMERCETOOLS_PROJECT: ${{ secrets.COMMERCETOOLS_PROJECT }}
run: composer update --no-ansi --no-interaction --no-progress --no-suggest
run: vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Install highest dependencies with composer for PR
- name: Run integration tests with phpunit for PR
if: github.event_name == 'pull_request'
env:
COMMERCETOOLS_CLIENT_ID: ${{ secrets.PR_COMMERCETOOLS_CLIENT_ID }}
COMMERCETOOLS_CLIENT_SECRET: ${{ secrets.PR_COMMERCETOOLS_CLIENT_SECRET }}
COMMERCETOOLS_PROJECT: ${{ secrets.PR_COMMERCETOOLS_PROJECT }}
run: composer update --no-ansi --no-interaction --no-progress --no-suggest

- name: Run integration tests with phpunit
run: vendor/bin/phpunit --coverage-clover=coverage.xml

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

- name: Install dependencies with composer
env:
COMMERCETOOLS_CLIENT_ID: ${{ secrets.COMMERCETOOLS_CLIENT_ID }}
COMMERCETOOLS_CLIENT_SECRET: ${{ secrets.COMMERCETOOLS_CLIENT_SECRET }}
COMMERCETOOLS_PROJECT: ${{ secrets.COMMERCETOOLS_PROJECT }}
run: composer install --no-ansi --no-interaction --no-progress --no-suggest --no-dev

- name: Retrieve branch name
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# [2.17.0](https://github.com/commercetools/commercetools-php-sdk/compare/v2.16.0...v2.17.0) (2022-02-07)


### Features

* **Cart:** add key in Cart ([d3f24c4](https://github.com/commercetools/commercetools-php-sdk/commit/d3f24c4b419d363fbcea10cb7f44903025d1c5c9))
* **Cart:** add new field productkey ([ccd77b8](https://github.com/commercetools/commercetools-php-sdk/commit/ccd77b88d03f77e117521db6f9ce8ee78c740cfb))
* **Cart:** add test for replicate cart in store ([ec6390d](https://github.com/commercetools/commercetools-php-sdk/commit/ec6390d3235ebf8df9a7b57fd8e80638918e59c5))
* **Cart:** introduce more small features ([ba45fc5](https://github.com/commercetools/commercetools-php-sdk/commit/ba45fc54d3df1e5e39f296ff37866663d02442bc))
* **Cart:** support new update action setLineItemSupplyChannel ([87887cb](https://github.com/commercetools/commercetools-php-sdk/commit/87887cb1e05bdc769ae1a652f7d014ee479b98ea))
* **Customer:** add anonymousCart field ([4c45b41](https://github.com/commercetools/commercetools-php-sdk/commit/4c45b419573de216e34cb11b251364224b1d8f9c))
* **Delivery:** add field param ([c7ad278](https://github.com/commercetools/commercetools-php-sdk/commit/c7ad278fc2dba0ac513fdbcc3a6166ef86463c85))
* **Error:** add querytimeout error ([ec13853](https://github.com/commercetools/commercetools-php-sdk/commit/ec1385355be85bd9901215bd0515d9de04d70f87))
* **Error:** add querytimeout error ([153cc0b](https://github.com/commercetools/commercetools-php-sdk/commit/153cc0bdd3eee9d0adff330aeefb176f4a6c0e7d))
* **Head:** support Head method for products ([6a02a6b](https://github.com/commercetools/commercetools-php-sdk/commit/6a02a6be34237f46dd2424750f6e08941fd1e06e))
* **Message:** add field in InventoryEntryQuantitySetMessage ([7008f32](https://github.com/commercetools/commercetools-php-sdk/commit/7008f32ae9b83c8c50b2378a59a3d68ff3f9d873))
* **Message:** add new class as useProvidedIdentifiers for ContainerAndKey ([3d332fd](https://github.com/commercetools/commercetools-php-sdk/commit/3d332fd5dff35396920a67a7f6c3fb8ea5a76cb9))
* **Message:** add new message for products ([1e6e5ad](https://github.com/commercetools/commercetools-php-sdk/commit/1e6e5add27a4018b7469e586c518cba21f627680))
* **Message:** support oldState to OrderStateTransitionMessage and support store messages ([b56c7ed](https://github.com/commercetools/commercetools-php-sdk/commit/b56c7ed830661a7d6b81818f55926d8100576013))
* **Order:** support new update actions setReturnItemCustom as for order as for order edit ([d2e3879](https://github.com/commercetools/commercetools-php-sdk/commit/d2e38793890fc018908280c2d63537b50bfdbca9))
* **Order:** support setReturnInfoAction and related message ([b34aa6b](https://github.com/commercetools/commercetools-php-sdk/commit/b34aa6bfef43a311d64419b015b6d5ff54764941))
* **Order:** support update actions for Order and Order Edit to SetParcelCustom ([0124793](https://github.com/commercetools/commercetools-php-sdk/commit/0124793e950f793346bcdca7b238d2ca63c555c6))
* **Project:** add new actions and add customer message ([e97e521](https://github.com/commercetools/commercetools-php-sdk/commit/e97e521be1d8739f0291f5246441f02fe4f68fe4))
* **Project:** fix failed test ([b8357d0](https://github.com/commercetools/commercetools-php-sdk/commit/b8357d02643e980ddab735eb0bb2050b1117e408))
* **ShipingMethod:** add custom field and related action in shipping method ([5a9a3f9](https://github.com/commercetools/commercetools-php-sdk/commit/5a9a3f972781f25a744b599462834cc83ef603b8))
* **ShippingMethod:** support localizedName and related action ([50dbb24](https://github.com/commercetools/commercetools-php-sdk/commit/50dbb24e08d2553fbd09b73065e36c89b5c4ddd8))
* **UserAgent:** modify user agent ([aa7f055](https://github.com/commercetools/commercetools-php-sdk/commit/aa7f05537bfecd792d2feeb6cbb41d06991c010f))



# [2.16.0](https://github.com/commercetools/commercetools-php-sdk/compare/v2.15.0...v2.16.0) (2021-08-02)


Expand Down
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# <img src="build/theme/resources/CT_cube_200px.png" width="40" align="center"></img> commercetools PHP SDK

:warning: **This commercetools PHP SDK is in its Active Support mode currently, and is planned to be deprecated, please note the following dates.

| Active Support | Maintenance Support | End of Life |
| --------------------- | --------------------- | --------------------- |
| `28th February, 2022` | `31st August 2022.` | `1st September 2022.` |

We recommend to use our [PHP SDK V2](https://docs.commercetools.com/sdk/php-sdk#php-sdk-v2).

[![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)

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.
Expand Down Expand Up @@ -252,6 +260,64 @@ $middlewares = [
$config = Config::of()->setClientOptions(['middlewares' => $middlewares])
```

#### Timeouts

The clients are configured to timeout by default after 60 seconds. This can be changed by setting the client options in the Config instance

```php
$config = Config::of()->setClientOptions([
'defaults' => [
'timeout' => 10
]
])
```

Another option is to specify the timeout per request

```php
$request = ProductProjectionSearchRequest::of();
$response = $client->execute($request, null, ['timeout' => 10]);
```

#### Retrying

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

```php
$config = Config::of()->setClientOptions([
'defaults' => [
'timeout' => 10
]
])
$maxRetries = 3;
$clientOptions = [
'middlewares' => [
'retry' => Middleware::retry(
function ($retries, RequestInterface $request, ResponseInterface $response = null, $error = null) use ($maxRetries) {
if ($response instanceof ResponseInterface && $response->getStatusCode() < 500) {
return false;
}
if ($retries > $maxRetries) {
return false;
}
if ($error instanceof ServiceUnavailableException) {
return true;
}
if ($error instanceof ServerException && $error->getCode() == 503) {
return true;
}
if ($response instanceof ResponseInterface && $response->getStatusCode() == 503) {
return true;
}
return false;
},
[RetryMiddleware::class, 'exponentialDelay']
)
]
];
$config->setClientOptions($clientOptions);
```

### Using the phar distribution

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.
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "commercetools/php-sdk",
"license": "MIT",
"type": "project",
"description": "The commercetools PHP SDK \n The official PHP Interface to the commercetools eCommerce API",
"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.",
"homepage": "https://github.com/commercetools/commercetools-php-sdk",
"support": {
"email": "[email protected]",
Expand Down Expand Up @@ -31,24 +31,24 @@
},
"require": {
"php": ">=5.6",
"psr/log": "^1.0",
"psr/log": "^1.0 || ^2.0",
"guzzlehttp/guzzle": "^7.0 || ^6.0 || ^5.3.3 ",
"guzzlehttp/psr7": "^1.7 || ^2.0",
"psr/cache": "^1.0 || ^2.0",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/simple-cache": "^1.0",
"cache/apcu-adapter": "^1.0 || ^0.3 || ^0.2",
"paragonie/random_compat": "^2.0 || ^1.0 || ^9.99",
"ext-intl": "*"
},
"require-dev": {
"guzzlehttp/guzzle": "^7.0 || ^6.0",
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "9.5.10",
"phpspec/prophecy-phpunit": "^2.0",
"symplify/easy-coding-standard-prefixed": "8.3.48 || 9.2.23",
"symplify/easy-coding-standard": "10.0.2",
"doctrine/cache": "^1.6 || ^2.0",
"monolog/monolog": "^1.12 || ^2.0",
"symfony/yaml": "^4.0 || ^3.4.38",
"symfony/stopwatch": "^4.0 || ^3.4.38",
"symfony/yaml": "^4.0 || ^3.4.38 || ^5.0",
"symfony/stopwatch": "^4.0 || ^3.4.38 || ^5.0",
"cache/adapter-common": "^1.0",
"cache/apcu-adapter": "^1.0",
"cache/array-adapter": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "commercetools-php-sdk-changelog",
"version": "2.16.0",
"version": "2.17.0",
"description": "commercetools PHP SDK changelog generator package description",
"homepage": "https://github.com/commercetools/commercetools-php-sdk",
"bugs": "https://github.com/commercetools/commercetools-php-sdk/issues",
Expand Down
2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"labels": [
"Type: Maintenance"
],
"ignoreDeps": []
"ignoreDeps": ["symplify/easy-coding-standard-prefixed"]
}
2 changes: 1 addition & 1 deletion src/Core/AbstractHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
abstract class AbstractHttpClient
{
const VERSION = '2.16.0';
const VERSION = '2.17.0';

/**
* @var AdapterInterface
Expand Down
38 changes: 37 additions & 1 deletion src/Core/Builder/Request/CartRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

use Commercetools\Core\Request\Carts\CartByCustomerIdGetRequest;
use Commercetools\Core\Request\Carts\CartByIdGetRequest;
use Commercetools\Core\Request\Carts\CartByKeyGetRequest;
use Commercetools\Core\Request\Carts\CartCreateRequest;
use Commercetools\Core\Model\Cart\CartDraft;
use Commercetools\Core\Request\Carts\CartDeleteRequest;
use Commercetools\Core\Request\Carts\CartDeleteByKeyRequest;
use Commercetools\Core\Model\Cart\Cart;
use Commercetools\Core\Request\Carts\CartDeleteRequest;
use Commercetools\Core\Request\Carts\CartQueryRequest;
use Commercetools\Core\Request\Carts\CartReplicateRequest;
use Commercetools\Core\Request\Carts\CartUpdateByKeyRequest;
use Commercetools\Core\Request\Carts\CartUpdateRequest;

class CartRequestBuilder
Expand Down Expand Up @@ -37,6 +40,17 @@ public function getById($id)
return $request;
}

/**
* @link https://docs.commercetools.com/api/projects/carts#get-a-cart-by-key
* @param string $key
* @return CartByKeyGetRequest
*/
public function getByKey($key)
{
$request = CartByKeyGetRequest::ofKey($key);
return $request;
}

/**
* @link https://docs.commercetools.com/http-api-projects-carts.html#create-cart
* @param CartDraft $cartDraft
Expand All @@ -48,6 +62,17 @@ public function create(CartDraft $cartDraft)
return $request;
}

/**
* @link https://docs.commercetools.com/api/projects/carts#delete-a-cart-by-key
* @param Cart $cart
* @return CartDeleteByKeyRequest
*/
public function deleteByKey(Cart $cart)
{
$request = CartDeleteByKeyRequest::ofKeyAndVersion($cart->getKey(), $cart->getVersion());
return $request;
}

/**
* @link https://docs.commercetools.com/http-api-projects-carts.html#delete-cart
* @param Cart $cart
Expand Down Expand Up @@ -81,6 +106,17 @@ public function replicate($cartId)
return $request;
}

/**
* @link https://docs.commercetools.com/api/projects/carts#update-a-cart-by-key
* @param Cart $cart
* @return CartUpdateByKeyRequest
*/
public function updateByKey(Cart $cart)
{
$request = CartUpdateByKeyRequest::ofKeyAndVersion($cart->getKey(), $cart->getVersion());
return $request;
}

/**
* @link https://docs.commercetools.com/http-api-projects-carts.html#update-cart
* @param Cart $cart
Expand Down
7 changes: 4 additions & 3 deletions src/Core/Builder/Request/CustomerRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Commercetools\Core\Request\Customers\CustomerEmailConfirmRequest;
use Commercetools\Core\Request\Customers\CustomerEmailTokenRequest;
use Commercetools\Core\Request\Customers\CustomerLoginRequest;
use Commercetools\Core\Model\Cart\CartReference;
use Commercetools\Core\Request\Customers\CustomerPasswordChangeRequest;
use Commercetools\Core\Request\Customers\CustomerPasswordResetRequest;
use Commercetools\Core\Request\Customers\CustomerPasswordTokenRequest;
Expand Down Expand Up @@ -129,16 +130,16 @@ public function createEmailVerificationToken(Customer $customer, $ttlMinutes)
* @param string $email
* @param string $password
* @param bool $updateProductData
* @param string $anonymousCartId
* @param CartReference|string $anonymousCart
* @return CustomerLoginRequest
*/
public function login($email, $password, $updateProductData = false, $anonymousCartId = null)
public function login($email, $password, $updateProductData = false, $anonymousCart = null)
{
$request = CustomerLoginRequest::ofEmailPasswordAndUpdateProductData(
$email,
$password,
$updateProductData,
$anonymousCartId
$anonymousCart
);
return $request;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Core/Builder/Request/OrderRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Commercetools\Core\Request\Orders\OrderByOrderNumberGetRequest;
use Commercetools\Core\Request\Orders\OrderCreateFromCartRequest;
use Commercetools\Core\Model\Cart\Cart;
use Commercetools\Core\Model\Cart\CartReference;
use Commercetools\Core\Request\Orders\OrderDeleteByOrderNumberRequest;
use Commercetools\Core\Model\Order\Order;
use Commercetools\Core\Request\Orders\OrderDeleteRequest;
Expand Down Expand Up @@ -47,7 +48,7 @@ public function getByOrderNumber($orderNumber)
*/
public function createFromCart(Cart $cart)
{
$request = OrderCreateFromCartRequest::ofCartIdAndVersion($cart->getId(), $cart->getVersion());
$request = OrderCreateFromCartRequest::ofCartAndVersion(CartReference::ofId($cart->getId()), $cart->getVersion());
return $request;
}

Expand Down
Loading

0 comments on commit 0ee68c2

Please sign in to comment.