From 39f2f26d54454c63d6c7543d20d3d365226189f9 Mon Sep 17 00:00:00 2001 From: nkibardin Date: Fri, 12 Apr 2024 17:54:09 +0300 Subject: [PATCH] fix --- src/AmoCRM/Models/Chats/Templates/TemplateModel.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/AmoCRM/Models/Chats/Templates/TemplateModel.php b/src/AmoCRM/Models/Chats/Templates/TemplateModel.php index 5be5363..b1930ca 100644 --- a/src/AmoCRM/Models/Chats/Templates/TemplateModel.php +++ b/src/AmoCRM/Models/Chats/Templates/TemplateModel.php @@ -183,12 +183,16 @@ public static function fromArray(array $template): TemplateModel */ public function toArray(): array { + $buttons = $this->getButtons() !== null && !$this->getButtons()->isEmpty() + ? $this->getButtons()->toArray() + : null; + return [ 'id' => $this->getId(), 'account_id' => $this->getAccountId(), 'name' => $this->getName(), 'content' => $this->getContent(), - 'buttons' => $this->getButtons() ? $this->getButtons()->toArray() : null, + 'buttons' => $buttons, 'created_at' => $this->getCreatedAt(), 'updated_at' => $this->getUpdatedAt(), 'is_editable' => $this->getIsEditable(), @@ -213,11 +217,14 @@ public function toApi(?string $requestId = "0"): array if (is_null($this->getRequestId()) && !is_null($requestId)) { $this->setRequestId($requestId); } + $buttons = $this->getButtons() !== null && !$this->getButtons()->isEmpty() + ? $this->getButtons()->toArray() + : null; $result = [ 'name' => $this->getName(), 'content' => $this->getContent(), - 'buttons' => $this->getButtons() ? $this->getButtons()->toApi() : null, + 'buttons' => $buttons, 'is_editable' => $this->getIsEditable(), 'external_id' => $this->getExternalId(), 'request_id' => $this->getRequestId(),