From 4056aeb25cbd64e5bc039cb9e999b37b448a5337 Mon Sep 17 00:00:00 2001 From: Nikita Date: Tue, 7 May 2024 16:42:06 +0500 Subject: [PATCH] small fixes --- composer.json | 2 +- src/AmoCRM/Client/AmoCRMApiRequest.php | 4 +-- src/AmoCRM/Contracts/Support/Arrayable.php | 2 ++ src/AmoCRM/Contracts/Support/Jsonable.php | 15 ++++++++ .../Models/CustomFields/ChainedList.php | 7 ++-- .../Models/CustomFields/ChainedLists.php | 34 +++++++++++++++---- src/AmoCRM/Models/NoteModel.php | 2 +- 7 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 src/AmoCRM/Contracts/Support/Jsonable.php diff --git a/composer.json b/composer.json index 3ff61e8f..1007f16d 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "ext-json": "*", "amocrm/oauth2-amocrm": "^2.0", "guzzlehttp/guzzle": "6.* || 7.*", - "symfony/dotenv": "3.* || 4.* || 5.* || 6.*", + "symfony/dotenv": "3.* || 4.* || 5.* || 6.* || 7.*", "fig/http-message-util": "1.*", "ramsey/uuid": "^3 || ^4", "lcobucci/jwt": "^3.4.6 || ^4.0.4", diff --git a/src/AmoCRM/Client/AmoCRMApiRequest.php b/src/AmoCRM/Client/AmoCRMApiRequest.php index 53e5adea..db296af4 100644 --- a/src/AmoCRM/Client/AmoCRMApiRequest.php +++ b/src/AmoCRM/Client/AmoCRMApiRequest.php @@ -36,7 +36,7 @@ class AmoCRMApiRequest public const CONNECT_TIMEOUT = 5; public const REQUEST_TIMEOUT = 20; //TODO Do not forget to change this on each release - public const LIBRARY_VERSION = '1.7.0'; + public const LIBRARY_VERSION = '1.8.0'; public const USER_AGENT = 'amoCRM-API-Library/' . self::LIBRARY_VERSION; public const SUCCESS_STATUSES = [ @@ -463,7 +463,7 @@ public function delete( return $this->delete($method, $body, $queryParams, $headers, true); } catch (AmoCRMApiNoContentException $e) { - return $response = ['result' => true]; + return ['result' => true]; } return $response; diff --git a/src/AmoCRM/Contracts/Support/Arrayable.php b/src/AmoCRM/Contracts/Support/Arrayable.php index 1bdf458a..c74c0cad 100644 --- a/src/AmoCRM/Contracts/Support/Arrayable.php +++ b/src/AmoCRM/Contracts/Support/Arrayable.php @@ -1,5 +1,7 @@ toArray(), $options); diff --git a/src/AmoCRM/Models/CustomFields/ChainedLists.php b/src/AmoCRM/Models/CustomFields/ChainedLists.php index fbb25603..4d7fe5f7 100644 --- a/src/AmoCRM/Models/CustomFields/ChainedLists.php +++ b/src/AmoCRM/Models/CustomFields/ChainedLists.php @@ -4,8 +4,6 @@ namespace AmoCRM\Models\CustomFields; -use Illuminate\Support\Collection; - use function array_filter; use function array_values; use function is_array; @@ -14,16 +12,25 @@ * Коллекция моделей вложенных списков * * @since Release Spring 2022 - * @template ChainedList */ -final class ChainedLists extends Collection +final class ChainedLists { + /** @var array */ + protected $items = []; + + public function addItem(int $catalogId, ChainedList $data): self + { + $this->items[$catalogId] = $data; + + return $this; + } + /** * @param array $items * - * @return ChainedLists + * @return ChainedLists */ - public static function fromArray(array $items): ChainedLists + public static function fromArray(array $items): self { $collection = new self(); @@ -41,9 +48,22 @@ public static function fromArray(array $items): ChainedLists $parentCatalogId = (int) ($item['parent_catalog_id'] ?? 0) ?: null; $title = (string) ($item['title'] ?? ''); - $collection->put($catalogId, new ChainedList($catalogId, $parentCatalogId, $title)); + $collection->addItem($catalogId, new ChainedList($catalogId, $parentCatalogId, $title)); } return $collection; } + + /** + * @return array + */ + public function toArray(): array + { + $result = []; + foreach ($this->items as $key => $item) { + $result[$key] = $item->toArray(); + } + + return $result; + } } diff --git a/src/AmoCRM/Models/NoteModel.php b/src/AmoCRM/Models/NoteModel.php index 9a5325e5..c2b2006b 100644 --- a/src/AmoCRM/Models/NoteModel.php +++ b/src/AmoCRM/Models/NoteModel.php @@ -24,7 +24,7 @@ class NoteModel extends BaseApiModel implements Arrayable, HasIdInterface protected $id; /** - * @var string + * @var int */ protected $entityId;