This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #455 from commercetools/order-setCustomerId-#435
feat(Order): support setCustomerId Closes #435
- Loading branch information
Showing
4 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
*/ | ||
|
||
namespace Commercetools\Core\Model\Message; | ||
|
||
use Commercetools\Core\Model\Customer\CustomerReference; | ||
use Commercetools\Core\Model\CustomerGroup\CustomerGroupReference; | ||
use Commercetools\Core\Model\Common\DateTimeDecorator; | ||
use DateTime; | ||
use Commercetools\Core\Model\Common\Reference; | ||
|
||
/** | ||
* @package Commercetools\Core\Model\Message | ||
* @link https://docs.commercetools.com/http-api-projects-messages.html#ordercustomerset-message | ||
* | ||
* @method string getId() | ||
* @method OrderCustomerSetMessage setId(string $id = null) | ||
* @method int getVersion() | ||
* @method OrderCustomerSetMessage setVersion(int $version = null) | ||
* @method DateTimeDecorator getCreatedAt() | ||
* @method OrderCustomerSetMessage setCreatedAt(DateTime $createdAt = null) | ||
* @method DateTimeDecorator getLastModifiedAt() | ||
* @method OrderCustomerSetMessage setLastModifiedAt(DateTime $lastModifiedAt = null) | ||
* @method int getSequenceNumber() | ||
* @method OrderCustomerSetMessage setSequenceNumber(int $sequenceNumber = null) | ||
* @method Reference getResource() | ||
* @method OrderCustomerSetMessage setResource(Reference $resource = null) | ||
* @method int getResourceVersion() | ||
* @method OrderCustomerSetMessage setResourceVersion(int $resourceVersion = null) | ||
* @method string getType() | ||
* @method OrderCustomerSetMessage setType(string $type = null) | ||
* @method CustomerReference getCustomer() | ||
* @method OrderCustomerSetMessage setCustomer(CustomerReference $customer = null) | ||
* @method CustomerGroupReference getCustomerGroup() | ||
* @method OrderCustomerSetMessage setCustomerGroup(CustomerGroupReference $customerGroup = null) | ||
* @method CustomerReference getOldCustomer() | ||
* @method OrderCustomerSetMessage setOldCustomer(CustomerReference $oldCustomer = null) | ||
* @method CustomerGroupReference getOldCustomerGroup() | ||
* @method OrderCustomerSetMessage setOldCustomerGroup(CustomerGroupReference $oldCustomerGroup = null) | ||
*/ | ||
class OrderCustomerSetMessage extends Message | ||
{ | ||
const MESSAGE_TYPE = 'OrderCustomerSet'; | ||
|
||
public function fieldDefinitions() | ||
{ | ||
$definitions = parent::fieldDefinitions(); | ||
$definitions['customer'] = [static::TYPE => CustomerReference::class]; | ||
$definitions['customerGroup'] = [static::TYPE => CustomerGroupReference::class]; | ||
$definitions['oldCustomer'] = [static::TYPE => CustomerReference::class]; | ||
$definitions['oldCustomerGroup'] = [static::TYPE => CustomerGroupReference::class]; | ||
|
||
return $definitions; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Core/Request/Orders/Command/OrderSetCustomerIdAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
*/ | ||
|
||
namespace Commercetools\Core\Request\Orders\Command; | ||
|
||
use Commercetools\Core\Model\Common\Context; | ||
use Commercetools\Core\Request\AbstractAction; | ||
|
||
/** | ||
* @package Commercetools\Core\Request\Orders\Command | ||
* | ||
* @link https://docs.commercetools.com/http-api-projects-orders.html#set-customer-id | ||
* @method string getAction() | ||
* @method OrderSetCustomerIdAction setAction(string $action = null) | ||
* @method string getCustomerId() | ||
* @method OrderSetCustomerIdAction setCustomerId(string $customerId = null) | ||
*/ | ||
class OrderSetCustomerIdAction extends AbstractAction | ||
{ | ||
public function fieldDefinitions() | ||
{ | ||
return [ | ||
'action' => [static::TYPE => 'string'], | ||
'customerId' => [static::TYPE => 'string'], | ||
]; | ||
} | ||
|
||
/** | ||
* @param array $data | ||
* @param Context|callable $context | ||
*/ | ||
public function __construct(array $data = [], $context = null) | ||
{ | ||
parent::__construct($data, $context); | ||
$this->setAction('setCustomerId'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters