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

Commit b0fbb04

Browse files
committed
feat(Subscription): add changeDestination update action
Closes #437
1 parent bffa245 commit b0fbb04

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/Core/Builder/Update/SubscriptionsActionBuilder.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Commercetools\Core\Error\InvalidArgumentException;
66
use Commercetools\Core\Request\AbstractAction;
7+
use Commercetools\Core\Request\Subscriptions\Command\SubscriptionChangeDestinationAction;
78
use Commercetools\Core\Request\Subscriptions\Command\SubscriptionSetChangesAction;
89
use Commercetools\Core\Request\Subscriptions\Command\SubscriptionSetKeyAction;
910
use Commercetools\Core\Request\Subscriptions\Command\SubscriptionSetMessagesAction;
@@ -12,6 +13,17 @@ class SubscriptionsActionBuilder
1213
{
1314
private $actions = [];
1415

16+
/**
17+
* @link https://docs.commercetools.com/http-api-projects-subscriptions.html#change-destination
18+
* @param SubscriptionChangeDestinationAction|callable $action
19+
* @return $this
20+
*/
21+
public function changeDestination($action = null)
22+
{
23+
$this->addAction($this->resolveAction(SubscriptionChangeDestinationAction::class, $action));
24+
return $this;
25+
}
26+
1527
/**
1628
* @link https://docs.commercetools.com/http-api-projects-subscriptions.html#set-changes
1729
* @param SubscriptionSetChangesAction|callable $action
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
*/
4+
5+
namespace Commercetools\Core\Request\Subscriptions\Command;
6+
7+
use Commercetools\Core\Model\Common\Context;
8+
use Commercetools\Core\Model\Extension\Destination;
9+
use Commercetools\Core\Request\AbstractAction;
10+
11+
/**
12+
* @package Commercetools\Core\Request\Subscriptions\Command
13+
* @link https://docs.commercetools.com/http-api-projects-subscriptions.html#change-destination
14+
* @method string getAction()
15+
* @method SubscriptionChangeDestinationAction setAction(string $action = null)
16+
* @method Destination getDestination()
17+
* @method SubscriptionChangeDestinationAction setDestination(Destination $destination = null)
18+
*/
19+
class SubscriptionChangeDestinationAction extends AbstractAction
20+
{
21+
public function fieldDefinitions()
22+
{
23+
return [
24+
'action' => [static::TYPE => 'string'],
25+
'destination' => [static::TYPE => Destination::class],
26+
];
27+
}
28+
29+
/**
30+
* @param array $data
31+
* @param Context|callable $context
32+
*/
33+
public function __construct(array $data = [], $context = null)
34+
{
35+
parent::__construct($data, $context);
36+
$this->setAction('changeDestination');
37+
}
38+
}

0 commit comments

Comments
 (0)