Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nkibardin committed Apr 12, 2024
1 parent e6c81c3 commit 39f2f26
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/AmoCRM/Models/Chats/Templates/TemplateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down

0 comments on commit 39f2f26

Please sign in to comment.