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

Commit

Permalink
feat(ShoppingList): support AnonymousId on ShoppingList owner
Browse files Browse the repository at this point in the history
  • Loading branch information
nikossvnk committed Jun 15, 2018
1 parent b53f991 commit efd2565
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/Core/Builder/Update/ShoppingListsActionBuilder.php
Expand Up @@ -14,6 +14,7 @@
use Commercetools\Core\Request\ShoppingLists\Command\ShoppingListChangeTextLineItemsOrderAction;
use Commercetools\Core\Request\ShoppingLists\Command\ShoppingListRemoveLineItemAction;
use Commercetools\Core\Request\ShoppingLists\Command\ShoppingListRemoveTextLineItemAction;
use Commercetools\Core\Request\ShoppingLists\Command\ShoppingListSetAnonymousIdAction;
use Commercetools\Core\Request\ShoppingLists\Command\ShoppingListSetCustomFieldAction;
use Commercetools\Core\Request\ShoppingLists\Command\ShoppingListSetCustomTypeAction;
use Commercetools\Core\Request\ShoppingLists\Command\ShoppingListSetCustomerAction;
Expand Down Expand Up @@ -141,6 +142,17 @@ public function removeTextLineItem($action = null)
return $this;
}

/**
*
* @param ShoppingListSetAnonymousIdAction|callable $action
* @return $this
*/
public function setAnonymousId($action = null)
{
$this->addAction($this->resolveAction(ShoppingListSetAnonymousIdAction::class, $action));
return $this;
}

/**
* @link https://docs.commercetools.com/http-api-projects-shoppingLists.html#set-customField
* @param ShoppingListSetCustomFieldAction|callable $action
Expand Down
5 changes: 4 additions & 1 deletion src/Core/Model/ShoppingList/ShoppingList.php
Expand Up @@ -41,6 +41,8 @@
* @method ShoppingList setCustom(CustomFieldObject $custom = null)
* @method int getDeleteDaysAfterLastModification()
* @method ShoppingList setDeleteDaysAfterLastModification(int $deleteDaysAfterLastModification = null)
* @method string getAnonymousId()
* @method ShoppingList setAnonymousId(string $anonymousId = null)
*/
class ShoppingList extends JsonObject
{
Expand All @@ -65,7 +67,8 @@ public function fieldDefinitions()
'lineItems' => [static::TYPE => LineItemCollection::class],
'textLineItems' => [static::TYPE => TextLineItemCollection::class],
'custom' => [static::TYPE => CustomFieldObject::class],
'deleteDaysAfterLastModification' => [static::TYPE => 'int']
'deleteDaysAfterLastModification' => [static::TYPE => 'int'],
'anonymousId' => [static::TYPE => 'string']
];
}
}
5 changes: 4 additions & 1 deletion src/Core/Model/ShoppingList/ShoppingListDraft.php
Expand Up @@ -32,6 +32,8 @@
* @method ShoppingListDraft setCustom(CustomFieldObjectDraft $custom = null)
* @method int getDeleteDaysAfterLastModification()
* @method ShoppingListDraft setDeleteDaysAfterLastModification(int $deleteDaysAfterLastModification = null)
* @method string getAnonymousId()
* @method ShoppingListDraft setAnonymousId(string $anonymousId = null)
*/
class ShoppingListDraft extends Resource
{
Expand All @@ -46,7 +48,8 @@ public function fieldDefinitions()
'lineItems' => [static::TYPE => LineItemDraftCollection::class],
'textLineItems' => [static::TYPE => TextLineItemDraftCollection::class],
'custom' => [static::TYPE => CustomFieldObjectDraft::class],
'deleteDaysAfterLastModification' => [static::TYPE => 'int']
'deleteDaysAfterLastModification' => [static::TYPE => 'int'],
'anonymousId' => [static::TYPE => 'string']
];
}

Expand Down
@@ -0,0 +1,37 @@
<?php
/**
*/

namespace Commercetools\Core\Request\ShoppingLists\Command;

use Commercetools\Core\Model\Common\Context;
use Commercetools\Core\Request\AbstractAction;

/**
* @package Commercetools\Core\Request\ShoppingLists\Command
*
* @method string getAction()
* @method ShoppingListSetAnonymousIdAction setAction(string $action = null)
* @method string getAnonymousId()
* @method ShoppingListSetAnonymousIdAction setAnonymousId(string $anonymousId = null)
*/
class ShoppingListSetAnonymousIdAction extends AbstractAction
{
public function fieldDefinitions()
{
return [
'action' => [static::TYPE => 'string'],
'anonymousId' => [static::TYPE => 'string'],
];
}

/**
* @param array $data
* @param Context|callable $context
*/
public function __construct(array $data = [], $context = null)
{
parent::__construct($data, $context);
$this->setAction('setAnonymousId');
}
}

0 comments on commit efd2565

Please sign in to comment.