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

Commit 60e207b

Browse files
committed
feat(Subscription): add payloadNotIncluded to message delivery
Closes #413
1 parent 602303a commit 60e207b

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

src/Core/Model/Subscription/MessageDelivery.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
* @method MessageDelivery setCreatedAt(DateTime $createdAt = null)
3131
* @method DateTimeDecorator getLastModifiedAt()
3232
* @method MessageDelivery setLastModifiedAt(DateTime $lastModifiedAt = null)
33+
* @method PayloadNotIncluded getPayloadNotIncluded()
34+
* @method MessageDelivery setPayloadNotIncluded(PayloadNotIncluded $payloadNotIncluded = null)
3335
*/
3436
class MessageDelivery extends Delivery
3537
{
@@ -51,13 +53,28 @@ public function fieldDefinitions()
5153
static::TYPE => DateTime::class,
5254
static::DECORATOR => DateTimeDecorator::class
5355
],
56+
'payloadNotIncluded' => [static::TYPE => PayloadNotIncluded::class],
5457
]
5558
);
5659
return $definition;
5760
}
5861

62+
/**
63+
* @return Message
64+
*/
5965
public function getMessage()
6066
{
6167
return Message::fromArray($this->rawData);
6268
}
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+
}
6380
}

src/Core/Model/Subscription/MessageSubscription.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function fieldDefinitions()
2121
{
2222
return [
2323
'resourceTypeId' => [static::TYPE => 'string'],
24-
'types' => [static::TYPE => 'array']
24+
'types' => [static::TYPE => 'array'],
2525
];
2626
}
2727
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
*/
4+
5+
namespace Commercetools\Core\Model\Subscription;
6+
7+
use Commercetools\Core\Model\Common\JsonObject;
8+
9+
/**
10+
* @package Commercetools\Core\Model\Subscription
11+
*
12+
* @method string getReason()
13+
* @method PayloadNotIncluded setReason(string $reason = null)
14+
* @method string getPayloadType()
15+
* @method PayloadNotIncluded setPayloadType(string $payloadType = null)
16+
*/
17+
class PayloadNotIncluded extends JsonObject
18+
{
19+
public function fieldDefinitions()
20+
{
21+
return [
22+
'reason' => [static::TYPE => 'string'],
23+
'payloadType' => [static::TYPE => 'string'],
24+
];
25+
}
26+
}

0 commit comments

Comments
 (0)