diff --git a/src/Conversations/CustomField.php b/src/Conversations/CustomField.php index c14cf8a..81a08b3 100644 --- a/src/Conversations/CustomField.php +++ b/src/Conversations/CustomField.php @@ -25,6 +25,11 @@ class CustomField implements Extractable, Hydratable */ private $value; + /** + * @var string|null + */ + private $text; + public function hydrate(array $data, array $embedded = []) { if (isset($data['id'])) { @@ -33,6 +38,7 @@ public function hydrate(array $data, array $embedded = []) $this->setName($data['name'] ?? null); $this->setValue($data['value'] ?? null); + $this->setText($data['text'] ?? null); } /** @@ -44,6 +50,7 @@ public function extract(): array 'id' => $this->getId(), 'name' => $this->getName(), 'value' => $this->getValue(), + 'text' => $this->getText(), ]; if ($this->getValue() instanceof \DateTimeInterface) { @@ -96,4 +103,18 @@ public function setValue($value): self return $this; } + + public function getText(): ?string { + return $this->text; + } + + /** + * @param string|null $text + */ + public function setText($text): self + { + $this->text = $text; + + return $this; + } } diff --git a/tests/Conversations/ConversationTest.php b/tests/Conversations/ConversationTest.php index 0d55ff2..203a3ab 100644 --- a/tests/Conversations/ConversationTest.php +++ b/tests/Conversations/ConversationTest.php @@ -238,6 +238,7 @@ public function testExtract() $this->assertInstanceOf(CustomField::class, $customField->setId(936)); $this->assertInstanceOf(CustomField::class, $customField->setName('Account Type')); $customField->setValue('Administrator'); + $customField->setText('Administrator'); $conversation->setCustomFields(new Collection([ $customField, ])); @@ -349,6 +350,7 @@ public function testExtract() 'id' => 936, 'name' => 'Account Type', 'value' => 'Administrator', + 'text' => 'Administrator', ]], $extractedConversation['fields'] ); diff --git a/tests/Conversations/CustomFieldTest.php b/tests/Conversations/CustomFieldTest.php index fcc3c47..2950925 100644 --- a/tests/Conversations/CustomFieldTest.php +++ b/tests/Conversations/CustomFieldTest.php @@ -16,11 +16,13 @@ public function testHydrate() 'id' => 6688, 'name' => 'Account Type', 'value' => 'Premium', + 'text' => 'Premium', ]); $this->assertSame(6688, $customField->getId()); $this->assertSame('Account Type', $customField->getName()); $this->assertSame('Premium', $customField->getValue()); + $this->assertSame('Premium', $customField->getText()); } public function testExtract() @@ -29,11 +31,13 @@ public function testExtract() $this->assertInstanceOf(CustomField::class, $customField->setId(6688)); $this->assertInstanceOf(CustomField::class, $customField->setName('Account Type')); $this->assertInstanceOf(CustomField::class, $customField->setValue('Premium')); + $this->assertInstanceOf(CustomField::class, $customField->setText('Premium')); $this->assertSame([ 'id' => 6688, 'name' => 'Account Type', 'value' => 'Premium', + 'text' => 'Premium', ], $customField->extract()); } @@ -48,6 +52,7 @@ public function testExtractFormatsDateTime() 'id' => 6688, 'name' => 'Account Type', 'value' => '2017-01-02', + 'text' => null, ], $customField->extract()); } @@ -59,6 +64,7 @@ public function testExtractNewEntity() 'id' => null, 'name' => null, 'value' => null, + 'text' => null, ], $customField->extract()); } } diff --git a/tests/Conversations/CustomFieldsCollectionTest.php b/tests/Conversations/CustomFieldsCollectionTest.php index 30b84ca..4580e6a 100644 --- a/tests/Conversations/CustomFieldsCollectionTest.php +++ b/tests/Conversations/CustomFieldsCollectionTest.php @@ -18,6 +18,7 @@ public function testExtract() $customField->setId(936); $customField->setName('Account Type'); $customField->setValue('Administrator'); + $customField->setText('Administrator'); $customFieldsCollection->setCustomFields([ $customField, @@ -29,6 +30,7 @@ public function testExtract() 'id' => 936, 'name' => 'Account Type', 'value' => 'Administrator', + 'text' => 'Administrator', ], ], ], $customFieldsCollection->extract());