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

Commit 59b6106

Browse files
authored
Merge pull request #709 from commercetools/php-maintainance5
2 parents fe7c7b2 + d073700 commit 59b6106

File tree

12 files changed

+187
-131
lines changed

12 files changed

+187
-131
lines changed

src/Core/Builder/Update/ProductSelectionsActionBuilder.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Commercetools\Core\Request\ProductSelections\Command\ProductSelectionAddProductAction;
88
use Commercetools\Core\Request\ProductSelections\Command\ProductSelectionChangeNameAction;
99
use Commercetools\Core\Request\ProductSelections\Command\ProductSelectionRemoveProductAction;
10+
use Commercetools\Core\Request\ProductSelections\Command\ProductSelectionSetCustomFieldAction;
11+
use Commercetools\Core\Request\ProductSelections\Command\ProductSelectionSetCustomTypeAction;
1012
use Commercetools\Core\Request\ProductSelections\Command\ProductSelectionSetKeyAction;
1113

1214
class ProductSelectionsActionBuilder
@@ -46,6 +48,28 @@ public function removeProduct($action = null)
4648
return $this;
4749
}
4850

51+
/**
52+
* @link https://docs.commercetools.com/http-api-projects-productselections.html#set-customfield
53+
* @param ProductSelectionSetCustomFieldAction|callable $action
54+
* @return $this
55+
*/
56+
public function setCustomField($action = null)
57+
{
58+
$this->addAction($this->resolveAction(ProductSelectionSetCustomFieldAction::class, $action));
59+
return $this;
60+
}
61+
62+
/**
63+
* @link https://docs.commercetools.com/http-api-projects-productselections.html#set-custom-type
64+
* @param ProductSelectionSetCustomTypeAction|callable $action
65+
* @return $this
66+
*/
67+
public function setCustomType($action = null)
68+
{
69+
$this->addAction($this->resolveAction(ProductSelectionSetCustomTypeAction::class, $action));
70+
return $this;
71+
}
72+
4973
/**
5074
*
5175
* @param ProductSelectionSetKeyAction|callable $action

src/Core/Model/ApiClient/ApiClient.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
* @method ApiClient setSecret(string $secret = null)
2727
* @method DateTimeDecorator getDeleteAt()
2828
* @method ApiClient setDeleteAt(DateTime $deleteAt = null)
29+
* @method int getAccessTokenValiditySeconds()
30+
* @method ApiClient setAccessTokenValiditySeconds(int $accessTokenValiditySeconds = null)
31+
* @method int getRefreshTokenValiditySeconds()
32+
* @method ApiClient setRefreshTokenValiditySeconds(int $refreshTokenValiditySeconds = null)
2933
*/
3034
class ApiClient extends JsonObject
3135
{
@@ -51,6 +55,8 @@ public function fieldDefinitions()
5155
static::OPTIONAL => true,
5256
static::DECORATOR => DateTimeDecorator::class
5357
],
58+
'accessTokenValiditySeconds' => [static::TYPE => 'int', self::OPTIONAL => true],
59+
'refreshTokenValiditySeconds' => [static::TYPE => 'int', self::OPTIONAL => true],
5460
];
5561
}
5662
}

src/Core/Model/ApiClient/ApiClientDraft.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* @method ApiClientDraft setScope(string $scope = null)
1717
* @method int getDeleteDaysAfterCreation()
1818
* @method ApiClientDraft setDeleteDaysAfterCreation(int $deleteDaysAfterCreation = null)
19+
* @method int getAccessTokenValiditySeconds()
20+
* @method ApiClientDraft setAccessTokenValiditySeconds(int $accessTokenValiditySeconds = null)
21+
* @method int getRefreshTokenValiditySeconds()
22+
* @method ApiClientDraft setRefreshTokenValiditySeconds(int $refreshTokenValiditySeconds = null)
1923
*/
2024
class ApiClientDraft extends JsonObject
2125
{
@@ -25,6 +29,8 @@ public function fieldDefinitions()
2529
'name' => [static::TYPE => 'string'],
2630
'scope' => [static::TYPE => 'string'],
2731
'deleteDaysAfterCreation' => [static::TYPE => 'int', self::OPTIONAL => true],
32+
'accessTokenValiditySeconds' => [static::TYPE => 'int', self::OPTIONAL => true],
33+
'refreshTokenValiditySeconds' => [static::TYPE => 'int', self::OPTIONAL => true],
2834
];
2935
}
3036

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Commercetools\Core\Model\Message;
4+
5+
use Commercetools\Core\Model\Common\DateTimeDecorator;
6+
use Commercetools\Core\Model\Common\Reference;
7+
use Commercetools\Core\Model\Payment\PaymentReference;
8+
use DateTime;
9+
10+
/**
11+
* @package Commercetools\Core\Model\Message
12+
* @link https://docs.commercetools.com/http-api-projects-messages.html#orderpaymentstatechanged-message
13+
* @method string getId()
14+
* @method OrderPaymentAddedMessage setId(string $id = null)
15+
* @method DateTimeDecorator getCreatedAt()
16+
* @method OrderPaymentAddedMessage setCreatedAt(DateTime $createdAt = null)
17+
* @method int getSequenceNumber()
18+
* @method OrderPaymentAddedMessage setSequenceNumber(int $sequenceNumber = null)
19+
* @method Reference getResource()
20+
* @method OrderPaymentAddedMessage setResource(Reference $resource = null)
21+
* @method int getResourceVersion()
22+
* @method OrderPaymentAddedMessage setResourceVersion(int $resourceVersion = null)
23+
* @method string getType()
24+
* @method OrderPaymentAddedMessage setType(string $type = null)
25+
* @method int getVersion()
26+
* @method OrderPaymentAddedMessage setVersion(int $version = null)
27+
* @method DateTimeDecorator getLastModifiedAt()
28+
* @method OrderPaymentAddedMessage setLastModifiedAt(DateTime $lastModifiedAt = null)
29+
* @method PaymentReference getPaymentState()
30+
* @method OrderPaymentAddedMessage setPayment(PaymentReference $payment = null)
31+
* @method UserProvidedIdentifiers getResourceUserProvidedIdentifiers()
32+
* phpcs:disable
33+
* @method OrderPaymentAddedMessage setResourceUserProvidedIdentifiers(UserProvidedIdentifiers $resourceUserProvidedIdentifiers = null)
34+
* phpcs:enable
35+
* @method PaymentReference getPayment()
36+
*/
37+
class OrderPaymentAddedMessage extends Message
38+
{
39+
const MESSAGE_TYPE = 'OrderPaymentAdded';
40+
41+
public function fieldDefinitions()
42+
{
43+
$definitions = parent::fieldDefinitions();
44+
$definitions['payment'] = [static::TYPE => PaymentReference::class];
45+
46+
return $definitions;
47+
}
48+
}

src/Core/Model/ProductSelection/ProductSelection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Commercetools\Core\Model\Common\LastModifiedBy;
88
use Commercetools\Core\Model\Common\LocalizedString;
99
use Commercetools\Core\Model\Common\Resource;
10+
use Commercetools\Core\Model\CustomField\CustomFieldObject;
1011
use DateTime;
1112

1213
/**
@@ -32,6 +33,8 @@
3233
* @method ProductSelection setProductCount(int $productCount = null)
3334
* @method ProductSelectionType getType()
3435
* @method ProductSelection setType(ProductSelectionType $type = null)
36+
* @method CustomFieldObject getCustom()
37+
* @method ProductSelection setCustom(CustomFieldObject $custom = null)
3538
* @method ProductSelectionReference getReference()
3639
*/
3740
class ProductSelection extends Resource
@@ -54,7 +57,8 @@ public function fieldDefinitions()
5457
'createdBy' => [static::TYPE => CreatedBy::class, static::OPTIONAL => true],
5558
'name' => [static::TYPE => LocalizedString::class],
5659
'productCount' => [static::TYPE => 'int'],
57-
'type' => [static::TYPE => ProductSelectionType::class]
60+
'type' => [static::TYPE => ProductSelectionType::class],
61+
'custom' => [static::TYPE => CustomFieldObject::class, static::OPTIONAL => true],
5862
];
5963
}
6064
}

src/Core/Model/ProductSelection/ProductSelectionDraft.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Commercetools\Core\Model\Common\Context;
66
use Commercetools\Core\Model\Common\JsonObject;
77
use Commercetools\Core\Model\Common\LocalizedString;
8+
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
89

910
/**
1011
* @package Commercetools\Core\Model\ProductSelection
@@ -13,6 +14,8 @@
1314
* @method ProductSelectionDraft setKey(string $key = null)
1415
* @method LocalizedString getName()
1516
* @method ProductSelectionDraft setName(LocalizedString $name = null)
17+
* @method CustomFieldObjectDraft getCustom()
18+
* @method ProductSelectionDraft setCustom(CustomFieldObjectDraft $custom = null)
1619
*/
1720
class ProductSelectionDraft extends JsonObject
1821
{
@@ -21,6 +24,7 @@ public function fieldDefinitions()
2124
return [
2225
'key' => [static::TYPE => 'string', static::OPTIONAL => true],
2326
'name' => [static::TYPE => LocalizedString::class],
27+
'custom' => [static::TYPE => CustomFieldObjectDraft::class, static::OPTIONAL => true],
2428
];
2529
}
2630

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Commercetools\Core\Request\ProductSelections\Command;
4+
5+
use Commercetools\Core\Request\CustomField\Command\SetCustomFieldAction;
6+
7+
/**
8+
* @package Commercetools\Core\Request\ProductSelections\Command
9+
* @link https://docs.commercetools.com/http-api-projects-productselections.html#set-customfield
10+
* @method string getAction()
11+
* @method ProductSelectionSetCustomFieldAction setAction(string $action = null)
12+
* @method string getName()
13+
* @method ProductSelectionSetCustomFieldAction setName(string $name = null)
14+
* @method mixed getValue()
15+
* @method ProductSelectionSetCustomFieldAction setValue($value = null)
16+
*/
17+
class ProductSelectionSetCustomFieldAction extends SetCustomFieldAction
18+
{
19+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Commercetools\Core\Request\ProductSelections\Command;
4+
5+
use Commercetools\Core\Model\Common\Context;
6+
use Commercetools\Core\Request\CustomField\Command\SetCustomTypeAction;
7+
use Commercetools\Core\Model\CustomField\FieldContainer;
8+
use Commercetools\Core\Model\Type\TypeReference;
9+
10+
/**
11+
* @package Commercetools\Core\Request\ProductSelections\Command
12+
* @link https://docs.commercetools.com/http-api-projects-productselections.html#set-custom-type
13+
* @method string getAction()
14+
* @method ProductSelectionSetCustomTypeAction setAction(string $action = null)
15+
* @method string getTypeId()
16+
* @method ProductSelectionSetCustomTypeAction setTypeId(string $typeId = null)
17+
* @method string getTypeKey()
18+
* @method ProductSelectionSetCustomTypeAction setTypeKey(string $typeKey = null)
19+
* @method FieldContainer getFields()
20+
* @method ProductSelectionSetCustomTypeAction setFields(FieldContainer $fields = null)
21+
* @method TypeReference getType()
22+
* @method ProductSelectionSetCustomTypeAction setType(TypeReference $type = null)
23+
*/
24+
class ProductSelectionSetCustomTypeAction extends SetCustomTypeAction
25+
{
26+
}

src/Core/Request/ShippingMethods/ShippingMethodByMatchingLocationGetRequest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Commercetools\Core\Model\ShippingMethod\ShippingMethodCollection;
1313
use Commercetools\Core\Request\AbstractApiRequest;
1414
use Commercetools\Core\Request\ExpandTrait;
15+
use Commercetools\Core\Request\SortTrait;
1516
use Commercetools\Core\Response\ApiResponseInterface;
1617
use Commercetools\Core\Response\PagedQueryResponse;
1718
use Psr\Http\Message\ResponseInterface;
@@ -25,6 +26,7 @@
2526
class ShippingMethodByMatchingLocationGetRequest extends AbstractApiRequest
2627
{
2728
use ExpandTrait;
29+
use SortTrait;
2830

2931
protected $resultClass = ShippingMethodCollection::class;
3032

tests/integration/Order/OrderQueryRequestTest.php

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,58 +24,6 @@
2424

2525
class OrderQueryRequestTest extends ApiTestCase
2626
{
27-
// todo cancel getCartDraft() and createOrder() after the OrderEdit migration
28-
/**
29-
* @return CartDraft
30-
*/
31-
protected function getCartDraft()
32-
{
33-
$draft = CartDraft::ofCurrency('EUR')->setCountry('DE');
34-
/**
35-
* @var Customer $customer
36-
*/
37-
$customer = $this->getCustomer();
38-
$draft->setCustomerId($customer->getId())
39-
->setShippingAddress($customer->getDefaultShippingAddress())
40-
->setBillingAddress($customer->getDefaultBillingAddress())
41-
->setCustomerEmail($customer->getEmail())
42-
->setLineItems(
43-
LineItemDraftCollection::of()
44-
->add(
45-
LineItemDraft::ofProductIdVariantIdAndQuantity($this->getProduct()->getId(), 1, 1)
46-
)
47-
)
48-
->setShippingMethod($this->getShippingMethod()->getReference());
49-
50-
return $draft;
51-
}
52-
53-
protected function createOrder(CartDraft $draft)
54-
{
55-
$request = CartCreateRequest::ofDraft($draft);
56-
$response = $request->executeWithClient($this->getClient());
57-
$cart = $request->mapResponse($response);
58-
59-
$orderRequest = OrderCreateFromCartRequest::ofCartAndVersion(CartReference::ofId($cart->getId()), $cart->getVersion());
60-
$response = $orderRequest->executeWithClient($this->getClient());
61-
$order = $orderRequest->mapResponse($response);
62-
$this->cleanupRequests[] = $this->deleteRequest = OrderDeleteRequest::ofIdAndVersion(
63-
$order->getId(),
64-
$order->getVersion()
65-
);
66-
67-
$cartRequest = CartByIdGetRequest::ofId($cart->getId());
68-
$response = $cartRequest->executeWithClient($this->getClient());
69-
$cart = $cartRequest->mapResponse($response);
70-
71-
$this->cleanupRequests[] = CartDeleteRequest::ofIdAndVersion(
72-
$cart->getId(),
73-
$cart->getVersion()
74-
);
75-
76-
return $order;
77-
}
78-
7927
public function testGetById()
8028
{
8129
$client = $this->getApiClient();

0 commit comments

Comments
 (0)