1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jenschude <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Subscription; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Reference; |
9
|
|
|
use Commercetools\Core\Model\Common\DateTimeDecorator; |
10
|
|
|
use Commercetools\Core\Model\Message\Message; |
11
|
|
|
use DateTime; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @package Commercetools\Core\Model\Subscription |
15
|
|
|
* @method string getProjectKey() |
16
|
|
|
* @method MessageDelivery setProjectKey(string $projectKey = null) |
17
|
|
|
* @method string getNotificationType() |
18
|
|
|
* @method MessageDelivery setNotificationType(string $notificationType = null) |
19
|
|
|
* @method Reference getResource() |
20
|
|
|
* @method MessageDelivery setResource(Reference $resource = null) |
21
|
|
|
* @method string getId() |
22
|
|
|
* @method MessageDelivery setId(string $id = null) |
23
|
|
|
* @method int getVersion() |
24
|
|
|
* @method MessageDelivery setVersion(int $version = null) |
25
|
|
|
* @method int getSequenceNumber() |
26
|
|
|
* @method MessageDelivery setSequenceNumber(int $sequenceNumber = null) |
27
|
|
|
* @method int getResourceVersion() |
28
|
|
|
* @method MessageDelivery setResourceVersion(int $resourceVersion = null) |
29
|
|
|
* @method DateTimeDecorator getCreatedAt() |
30
|
|
|
* @method MessageDelivery setCreatedAt(DateTime $createdAt = null) |
31
|
|
|
* @method DateTimeDecorator getLastModifiedAt() |
32
|
|
|
* @method MessageDelivery setLastModifiedAt(DateTime $lastModifiedAt = null) |
33
|
|
|
* @method PayloadNotIncluded getPayloadNotIncluded() |
34
|
|
|
* @method MessageDelivery setPayloadNotIncluded(PayloadNotIncluded $payloadNotIncluded = null) |
35
|
|
|
*/ |
36
|
|
|
class MessageDelivery extends Delivery |
37
|
|
|
{ |
38
|
1 |
|
public function fieldDefinitions() |
39
|
|
|
{ |
40
|
1 |
|
$definition = parent::fieldDefinitions(); |
41
|
1 |
|
$definition = array_merge( |
42
|
1 |
|
$definition, |
43
|
|
|
[ |
44
|
1 |
|
'id' => [static::TYPE => 'string'], |
45
|
1 |
|
'version' => [static::TYPE => 'int'], |
46
|
1 |
|
'sequenceNumber' => [static::TYPE => 'int'], |
47
|
1 |
|
'resourceVersion' => [static::TYPE => 'int'], |
48
|
|
|
'createdAt' => [ |
49
|
1 |
|
static::TYPE => DateTime::class, |
50
|
1 |
|
static::DECORATOR => DateTimeDecorator::class |
51
|
|
|
], |
52
|
|
|
'lastModifiedAt' => [ |
53
|
1 |
|
static::TYPE => DateTime::class, |
54
|
1 |
|
static::DECORATOR => DateTimeDecorator::class |
55
|
|
|
], |
56
|
1 |
|
'payloadNotIncluded' => [static::TYPE => PayloadNotIncluded::class], |
57
|
|
|
] |
58
|
|
|
); |
59
|
1 |
|
return $definition; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return Message |
64
|
|
|
*/ |
65
|
2 |
|
public function getMessage() |
66
|
|
|
{ |
67
|
2 |
|
return Message::fromArray($this->rawData); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getMessageType() |
74
|
|
|
{ |
75
|
|
|
if (is_null($this->getPayloadNotIncluded())) { |
76
|
|
|
return $this->getMessage()->getType(); |
77
|
|
|
} |
78
|
|
|
return $this->getPayloadNotIncluded()->getPayloadType(); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|