summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHannes Kindströmmer <hannes@kindstrommer.se>2017-03-13 11:14:36 +0100
committerHannes Kindströmmer <hannes@kindstrommer.se>2017-03-13 11:14:36 +0100
commit65dd84f61179605c5483e53554881a6434a79e65 (patch)
tree103236c0cc94fb836af02bb6ad2e4b52d496de2c /src
parent5ad6d887a2f6b23619264a02300065991f966c60 (diff)
downloadip1-php-sdk-65dd84f61179605c5483e53554881a6434a79e65.zip
ip1-php-sdk-65dd84f61179605c5483e53554881a6434a79e65.tar.gz
ip1-php-sdk-65dd84f61179605c5483e53554881a6434a79e65.tar.bz2
Add jsonSerialize to ProcessedGroup
Signed-off-by: Hannes Kindströmmer <hannes@kindstrommer.se>
Diffstat (limited to 'src')
-rw-r--r--src/Recipient/Group.php2
-rw-r--r--src/Recipient/ProcessedGroup.php15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/Recipient/Group.php b/src/Recipient/Group.php
index a1d2d91..3c4ddd1 100644
--- a/src/Recipient/Group.php
+++ b/src/Recipient/Group.php
@@ -94,7 +94,7 @@ class Group implements \JsonSerializable
{
$returnArray = [
'Name' => $this->name,
- 'Color' => $this->Color,
+ 'Color' => $this->color,
];
return $returnArray;
}
diff --git a/src/Recipient/ProcessedGroup.php b/src/Recipient/ProcessedGroup.php
index d4bff44..102cd21 100644
--- a/src/Recipient/ProcessedGroup.php
+++ b/src/Recipient/ProcessedGroup.php
@@ -184,4 +184,19 @@ class ProcessedGroup extends Group implements UpdatableComponent, MembershipRela
}
return $this->updated ?? null;
}
+ /**
+ * Serializes the object to a value that can be serialized natively by json_encode().
+ * @return array Associative.
+ * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
+ */
+ public function jsonSerialize(): array
+ {
+ $parentArray = parent::jsonSerialize();
+ $parentArray['Created'] = isset($this->created) ? $this->updated->format("Y-m-d\TH:i:s.").
+ substr($this->updated->format('u'), 0, 3) : null;
+ $parentArray['Updated'] = isset($this->created) ? $this->updated->format("Y-m-d\TH:i:s.").
+ substr($this->updated->format('u'), 0, 3) : null;
+ $parentArray['ID'] = $this->groupID;
+ return $parentArray;
+ }
}