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

Commit

Permalink
feat(Subscription): add payloadNotIncluded to message delivery
Browse files Browse the repository at this point in the history
Closes #413
  • Loading branch information
jenschude committed Jul 24, 2018
1 parent 602303a commit 60e207b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/Core/Model/Subscription/MessageDelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* @method MessageDelivery setCreatedAt(DateTime $createdAt = null)
* @method DateTimeDecorator getLastModifiedAt()
* @method MessageDelivery setLastModifiedAt(DateTime $lastModifiedAt = null)
* @method PayloadNotIncluded getPayloadNotIncluded()
* @method MessageDelivery setPayloadNotIncluded(PayloadNotIncluded $payloadNotIncluded = null)
*/
class MessageDelivery extends Delivery
{
Expand All @@ -51,13 +53,28 @@ public function fieldDefinitions()
static::TYPE => DateTime::class,
static::DECORATOR => DateTimeDecorator::class
],
'payloadNotIncluded' => [static::TYPE => PayloadNotIncluded::class],
]
);
return $definition;
}

/**
* @return Message
*/
public function getMessage()
{
return Message::fromArray($this->rawData);
}

/**
* @return string
*/
public function getMessageType()
{
if (is_null($this->getPayloadNotIncluded())) {
return $this->getMessage()->getType();
}
return $this->getPayloadNotIncluded()->getPayloadType();
}
}
2 changes: 1 addition & 1 deletion src/Core/Model/Subscription/MessageSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function fieldDefinitions()
{
return [
'resourceTypeId' => [static::TYPE => 'string'],
'types' => [static::TYPE => 'array']
'types' => [static::TYPE => 'array'],
];
}
}
26 changes: 26 additions & 0 deletions src/Core/Model/Subscription/PayloadNotIncluded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
*/

namespace Commercetools\Core\Model\Subscription;

use Commercetools\Core\Model\Common\JsonObject;

/**
* @package Commercetools\Core\Model\Subscription
*
* @method string getReason()
* @method PayloadNotIncluded setReason(string $reason = null)
* @method string getPayloadType()
* @method PayloadNotIncluded setPayloadType(string $payloadType = null)
*/
class PayloadNotIncluded extends JsonObject
{
public function fieldDefinitions()
{
return [
'reason' => [static::TYPE => 'string'],
'payloadType' => [static::TYPE => 'string'],
];
}
}

0 comments on commit 60e207b

Please # to comment.