Completed
Push — develop ( 94ac5e...9b8817 )
by Jens
14:35
created

SubscriptionDraft::ofDestinationAndChanges()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
crap 2
1
<?php
2
/**
3
 * @author @jayS-de <[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://dev.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
    public function fieldDefinitions()
29
    {
30
        return [
31
            'key' => [static::TYPE => 'string'],
32
            'destination' => [static::TYPE => '\Commercetools\Core\Model\Subscription\Destination'],
33
            'messages' => [static::TYPE => '\Commercetools\Core\Model\Subscription\MessageSubscriptionCollection'],
34
            'changes' => [static::TYPE => '\Commercetools\Core\Model\Subscription\ChangeSubscriptionCollection'],
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