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

Commit 1268a42

Browse files
author
Jens Schulze
committed
Merge branch 'release/v1.0.0-RC11'
2 parents 2d0c9cd + cfbf4da commit 1268a42

File tree

80 files changed

+2346
-309
lines changed

Some content is hidden

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

80 files changed

+2346
-309
lines changed

CHANGELOG.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,82 @@
1+
<a name="1.0.0-RC11"></a>
2+
# [1.0.0-RC11](https://github.com/sphereio/commercetools-php-sdk/compare/v1.0.0-RC10...v1.0.0-RC11) (2016-04-06)
3+
4+
5+
### Bug Fixes
6+
7+
* **Product:** change type of price collection ([8cc1262](https://github.com/sphereio/commercetools-php-sdk/commit/8cc1262))
8+
9+
### Code Refactoring
10+
11+
* **Customer:** adjust customer email verification request to API changes ([2e3dd32](https://github.com/sphereio/commercetools-php-sdk/commit/2e3dd32))
12+
* **Customer:** adjust customer password change request to API changes ([318e93f](https://github.com/sphereio/commercetools-php-sdk/commit/318e93f))
13+
14+
### Features
15+
16+
* **Client:** add support for oauth scopes ([5545dfd](https://github.com/sphereio/commercetools-php-sdk/commit/5545dfd))
17+
* **Client:** log response body and headers of api exceptions ([f371979](https://github.com/sphereio/commercetools-php-sdk/commit/f371979)), closes [#186](https://github.com/sphereio/commercetools-php-sdk/issues/186)
18+
* **Product:** add update action for stageable SKU ([870a1f8](https://github.com/sphereio/commercetools-php-sdk/commit/870a1f8))
19+
* **Response:** add getter for correlation id ([6029a02](https://github.com/sphereio/commercetools-php-sdk/commit/6029a02)), closes [#69](https://github.com/sphereio/commercetools-php-sdk/issues/69)
20+
21+
22+
### BREAKING CHANGES
23+
24+
* Product: renamed the ProductSetSKUAction to ProductSetSKUNotStageableAction
25+
26+
Before:
27+
28+
```
29+
ProductSetSKUAction::ofVariantId()
30+
```
31+
32+
After:
33+
34+
```
35+
ProductSetSKUNotStageableAction::ofVariantId() // old behavior action
36+
ProductSetSkuAction::ofVariantId() // stageable action
37+
```
38+
* Product: fix type of price collections
39+
40+
Before:
41+
42+
```
43+
ProductAddVariantAction::of()->setPrices(PriceCollection::of()->add(Price::of()))
44+
```
45+
46+
After:
47+
48+
```
49+
ProductAddVariantAction::of()->setPrices(PriceDraftCollection::of()->add(PriceDraft::of()))
50+
```
51+
* Customer: adjust customer email verification request to API changes
52+
53+
Before:
54+
55+
```
56+
CustomerEmailConfirmRequest::ofIdVersionAndToken($id, $version, $token)
57+
```
58+
59+
After:
60+
61+
```
62+
CustomerEmailConfirmRequest::ofToken($token)
63+
```
64+
* Customer: adjust customer password change request to API changes
65+
66+
Before:
67+
68+
```
69+
CustomerPasswordResetRequest::ofIdVersionTokenAndPassword($id, $version, $token, $newPassword)
70+
```
71+
72+
After:
73+
74+
```
75+
CustomerPasswordResetRequest::ofTokenAndPassword($token, $newPassword)
76+
```
77+
78+
79+
180
<a name="1.0.0-RC10"></a>
281
# [1.0.0-RC10](https://github.com/sphereio/commercetools-php-sdk/compare/v1.0.0-RC9...v1.0.0-RC10) (2016-03-22)
382

README.md

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

3-
> STATUS: Release Candidate 10. We ask you to really use this API thoroughly now, especially the API design and object structure. Thank you very much!
3+
> STATUS: Release Candidate 11. We ask you to really use this API thoroughly now, especially the API design and object structure. Thank you very much!
44
>
55
> See the [Milestone Plan](https://github.com/sphereio/commercetools-php-sdk/milestones?direction=desc&sort=completeness&state=open) for details of what's planned in detail. We love feedback and [Issue reports](https://github.com/sphereio/commercetools-php-sdk/issues?q=is%3Aopen+is%3Aissue+sort%3Acreated-asc)!
66
> Up-to-Date planning status can be found on this [Waffle Board](https://waffle.io/sphereio/commercetools-php-sdk)

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"require-dev": {
3636
"guzzlehttp/guzzle": "^6.0",
37-
"phpunit/phpunit": "^4.0",
37+
"phpunit/phpunit": "^5.0 || ^4.0",
3838
"phpmd/phpmd": "@stable",
3939
"squizlabs/php_codesniffer": "@stable",
4040
"sebastian/phpcpd": "@stable",
@@ -47,9 +47,7 @@
4747
"phpunit/phpcov": "*",
4848
"fabpot/php-cs-fixer": "@stable",
4949
"symfony/yaml": "*",
50-
"incenteev/composer-parameter-handler": "^2.0",
51-
"munkie/phpunit-teamcity-testlistener": "^1.2",
52-
"micheh/teamcity-clover": "^0.6.0"
50+
"incenteev/composer-parameter-handler": "^2.0"
5351
},
5452
"scripts": {
5553
"updateConfig": [
@@ -65,6 +63,8 @@
6563
"env-map": {
6664
"client_id": "COMMERCETOOLS_CLIENT_ID",
6765
"client_secret": "COMMERCETOOLS_CLIENT_SECRET",
66+
"view_products-client_id": "COMMERCETOOLS_CLIENT_ID_VIEW",
67+
"view_products-client_secret": "COMMERCETOOLS_CLIENT_SECRET_VIEW",
6868
"project": "COMMERCETOOLS_PROJECT",
6969
"oauth_url": "COMMERCETOOLS_OAUTH_URL",
7070
"api_url": "COMMERCETOOLS_API_URL"

docroot/myapp.yml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
parameters:
22
client_id: Your Commercetools client ID
33
client_secret: Your Commercetools client secret
4+
view_products-client_id: Your Commercetools client ID
5+
view_products-client_secret: Your Commercetools client secret
46
project: Your Commercetools project key
57
oauth_url: https://auth.sphere.io/oauth/token
68
api_url: https://api.sphere.io

features/bootstrap/ApiContext.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,9 @@ public function iWantToResetTheContextPasswordToNewPasswordWithToken($context, $
534534
$context = $this->getContext($context);
535535
$module = $this->getModuleName($context);
536536
$request = '\Commercetools\Core\Request\\' . $module . '\\' . $context . 'PasswordResetRequest';
537-
$requestContext = $context . 'Request';
538-
$id = $this->objects[$requestContext]['id'];
539-
$version = $this->objects[$requestContext]['version'];
540537
$this->request = call_user_func_array(
541-
$request. '::ofIdVersionTokenAndPassword',
542-
[$id, $version, $token, $newPassword]
538+
$request. '::ofTokenAndPassword',
539+
[$token, $newPassword]
543540
);
544541
}
545542

@@ -551,12 +548,9 @@ public function iWantToConfirmTheContextEmailWithToken($context, $token)
551548
$context = $this->getContext($context);
552549
$module = $this->getModuleName($context);
553550
$request = '\Commercetools\Core\Request\\' . $module . '\\' . $context . 'EmailConfirmRequest';
554-
$requestContext = $context . 'Request';
555-
$id = $this->objects[$requestContext]['id'];
556-
$version = $this->objects[$requestContext]['version'];
557551
$this->request = call_user_func_array(
558-
$request. '::ofIdVersionAndToken',
559-
[$id, $version, $token]
552+
$request. '::ofToken',
553+
[$token]
560554
);
561555
}
562556

features/request/Customer/CustomerEmailConfirmation.feature

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ Feature: I want to confirm a customer's email
1414
"""
1515

1616
Scenario: Confirm Token for email change
17-
Given a "customer" is identified by "id" and version 1
1817
Given i want to confirm the "Customer" email with token "token"
1918
Then the path should be "customers/email/confirm"
2019
And the method should be "POST"
2120
And the request should be
2221
"""
2322
{
24-
"id": "id",
25-
"version": 1,
2623
"tokenValue": "token"
2724
}
2825
"""

features/request/Customer/CustomerPasswordChange.feature

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ Feature: I want to change the customer's password
1818
And the method should be "GET"
1919

2020
Scenario: Reset customers password
21-
Given a "customer" is identified by "id" and version 1
22-
And i want to reset the "customer" password to "newPassword" with token "token"
21+
Given i want to reset the "customer" password to "newPassword" with token "token"
2322
Then the path should be "customers/password/reset"
2423
And the method should be "POST"
2524
And the request should be
2625
"""
2726
{
28-
"id": "id",
29-
"version": 1,
3027
"tokenValue": "token",
3128
"newPassword": "newPassword"
3229
}

features/request/Product/ProductUpdate.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ Feature: I want to send a Product Update Request
715715
Scenario:
716716
Given a "product" is identified by "id" and version 1
717717
And i want to update a "product"
718-
And add the "setSKU" action to "product" with values
718+
And add the "setSkuNotStageable" action to "product" with values
719719
"""
720720
{
721721
"action": "setSKU",

src/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 = '1.0.0-RC10';
17+
const VERSION = '1.0.0-RC11';
1818

1919
/**
2020
* @var AdapterInterface

src/Cache/NullCacheAdapter.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
*/
1212
class NullCacheAdapter extends AbstractCacheAdapter
1313
{
14+
protected $cache = [];
15+
1416
/**
1517
* @param $key
1618
* @param $options
1719
* @return bool
1820
*/
1921
public function has($key, $options = null)
2022
{
21-
return false;
23+
return isset($this->cache[$key]);
2224
}
2325

2426
/**
@@ -28,6 +30,9 @@ public function has($key, $options = null)
2830
*/
2931
public function fetch($key, $options = null)
3032
{
33+
if ($this->has($key)) {
34+
return $this->cache[$key];
35+
}
3136
return false;
3237
}
3338

@@ -40,6 +45,8 @@ public function fetch($key, $options = null)
4045
*/
4146
public function store($key, $data, $lifeTime = null, $options = null)
4247
{
48+
$this->cache[$key] = $data;
49+
4350
return true;
4451
}
4552

@@ -50,6 +57,7 @@ public function store($key, $data, $lifeTime = null, $options = null)
5057
*/
5158
public function remove($key, $options = null)
5259
{
60+
unset($this->cache[$key]);
5361
return true;
5462
}
5563
}

src/Client.php

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Commercetools\Core;
88

9+
use Commercetools\Core\Response\ErrorResponse;
910
use Psr\Http\Message\RequestInterface;
1011
use Psr\Http\Message\ResponseInterface;
1112
use Psr\Log\LoggerInterface;
@@ -231,7 +232,8 @@ public function execute(ClientRequestInterface $request)
231232
$httpRequest = $this->createHttpRequest($request);
232233

233234
try {
234-
$response = $this->getHttpClient()->execute($httpRequest);
235+
$httpResponse = $this->getHttpClient()->execute($httpRequest);
236+
$response = $request->buildResponse($httpResponse);
235237
} catch (ApiException $exception) {
236238
if ($exception instanceof InvalidTokenException && !$this->tokenRefreshed) {
237239
$this->tokenRefreshed = true;
@@ -241,11 +243,12 @@ public function execute(ClientRequestInterface $request)
241243
if ($this->getConfig()->getThrowExceptions() || !$exception->getResponse() instanceof ResponseInterface) {
242244
throw $exception;
243245
}
244-
$response = $exception->getResponse();
246+
$httpResponse = $exception->getResponse();
247+
$this->logException($exception);
248+
$response = new ErrorResponse($exception, $request, $httpResponse);
245249
}
246-
$this->logDeprecatedRequest($response, $httpRequest);
250+
$this->logDeprecatedRequest($httpResponse, $httpRequest);
247251

248-
$response = $request->buildResponse($response);
249252

250253
return $response;
251254
}
@@ -303,14 +306,22 @@ public function executeBatch()
303306
$request = $this->batchRequests[$key];
304307
$httpRequest = $requests[$key];
305308
if ($httpResponse instanceof ApiException) {
309+
$exception = $httpResponse;
306310
if ($this->getConfig()->getThrowExceptions() ||
307311
!$httpResponse->getResponse() instanceof ResponseInterface
308312
) {
309-
throw $httpResponse;
313+
throw $exception;
310314
}
311-
$httpResponse = $httpResponse->getResponse();
315+
$this->logException($httpResponse);
316+
$httpResponse = $exception->getResponse();
317+
$responses[$request->getIdentifier()] = new ErrorResponse(
318+
$exception,
319+
$request,
320+
$httpResponse
321+
);
322+
} else {
323+
$responses[$request->getIdentifier()] = $request->buildResponse($httpResponse);
312324
}
313-
$responses[$request->getIdentifier()] = $request->buildResponse($httpResponse);
314325
$this->logDeprecatedRequest($httpResponse, $httpRequest);
315326
}
316327
unset($this->batchRequests);
@@ -319,6 +330,30 @@ public function executeBatch()
319330
return $responses;
320331
}
321332

333+
/**
334+
* @param $exception
335+
* @return $this
336+
*/
337+
protected function logException(ApiException $exception)
338+
{
339+
if (is_null($this->logger)) {
340+
return $this;
341+
}
342+
$response = $exception->getResponse();
343+
344+
$context = [];
345+
if ($response instanceof ResponseInterface) {
346+
$context = [
347+
'responseStatusCode' => $response->getStatusCode(),
348+
'responseHeaders' => $response->getHeaders(),
349+
'responseBody' => (string)$response->getBody(),
350+
];
351+
}
352+
$this->logger->error($exception->getMessage(), $context);
353+
354+
return $this;
355+
}
356+
322357
/**
323358
* @param ResponseInterface $response
324359
* @param RequestInterface $request

0 commit comments

Comments
 (0)