1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jenschude <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Subscription; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Context; |
9
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
10
|
|
|
use Commercetools\Core\Model\Common\LocalizedString; |
11
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft; |
12
|
|
|
use Commercetools\Core\Model\Common\Address; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @package Commercetools\Core\Model\Subscription |
16
|
|
|
* @link https://docs.commercetools.com/http-api-projects-subscriptions.html#subscriptiondraft |
17
|
|
|
* @method string getKey() |
18
|
|
|
* @method SubscriptionDraft setKey(string $key = null) |
19
|
|
|
* @method Destination getDestination() |
20
|
|
|
* @method SubscriptionDraft setDestination(Destination $destination = null) |
21
|
|
|
* @method MessageSubscriptionCollection getMessages() |
22
|
|
|
* @method SubscriptionDraft setMessages(MessageSubscriptionCollection $messages = null) |
23
|
|
|
* @method ChangeSubscriptionCollection getChanges() |
24
|
|
|
* @method SubscriptionDraft setChanges(ChangeSubscriptionCollection $changes = null) |
25
|
|
|
*/ |
26
|
|
|
class SubscriptionDraft extends JsonObject |
27
|
|
|
{ |
28
|
2 |
|
public function fieldDefinitions() |
29
|
|
|
{ |
30
|
|
|
return [ |
31
|
2 |
|
'key' => [static::TYPE => 'string'], |
32
|
2 |
|
'destination' => [static::TYPE => Destination::class], |
33
|
2 |
|
'messages' => [static::TYPE => MessageSubscriptionCollection::class], |
34
|
2 |
|
'changes' => [static::TYPE => ChangeSubscriptionCollection::class], |
35
|
|
|
]; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param Destination $destination |
40
|
|
|
* @param MessageSubscriptionCollection $messages |
41
|
|
|
* @param Context|callable $context |
42
|
|
|
* @return SubscriptionDraft |
43
|
|
|
*/ |
44
|
|
|
public static function ofDestinationAndMessages( |
45
|
|
|
Destination $destination, |
46
|
|
|
MessageSubscriptionCollection $messages, |
47
|
|
|
$context = null |
48
|
|
|
) { |
49
|
|
|
return static::of($context)->setDestination($destination)->setMessages($messages); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param Destination $destination |
54
|
|
|
* @param ChangeSubscriptionCollection $changes |
55
|
|
|
* @param Context|callable $context |
56
|
|
|
* @return SubscriptionDraft |
57
|
|
|
*/ |
58
|
|
|
public static function ofDestinationAndChanges( |
59
|
|
|
Destination $destination, |
60
|
|
|
ChangeSubscriptionCollection $changes, |
61
|
|
|
$context = null |
62
|
|
|
) { |
63
|
|
|
return static::of($context)->setDestination($destination)->setChanges($changes); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param string $key |
68
|
|
|
* @param Destination $destination |
69
|
|
|
* @param MessageSubscriptionCollection $messages |
70
|
|
|
* @param Context|callable $context |
71
|
|
|
* @return SubscriptionDraft |
72
|
|
|
*/ |
73
|
|
|
public static function ofKeyDestinationAndMessages( |
74
|
|
|
$key, |
75
|
|
|
Destination $destination, |
76
|
|
|
MessageSubscriptionCollection $messages, |
77
|
|
|
$context = null |
78
|
|
|
) { |
79
|
|
|
return static::of($context)->setKey($key)->setDestination($destination)->setMessages($messages); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|