From b7045f703677bb558192ed366145653471fb9900 Mon Sep 17 00:00:00 2001 From: Aydarkhan Tsyrenzhapov Date: Mon, 31 Aug 2020 14:34:37 +0300 Subject: [PATCH 1/2] catalogs filter by type --- examples/catalogs_actions.php | 11 +++++++ examples/testCatalogs.php | 0 src/AmoCRM/Filters/CatalogsFilter.php | 46 +++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 examples/testCatalogs.php create mode 100644 src/AmoCRM/Filters/CatalogsFilter.php diff --git a/examples/catalogs_actions.php b/examples/catalogs_actions.php index 7dccd988..ae71292a 100644 --- a/examples/catalogs_actions.php +++ b/examples/catalogs_actions.php @@ -1,5 +1,6 @@ setType(EntityTypesInterface::INVOICES_CATALOG_TYPE_STRING); + $catalogsCollection = $apiClient->catalogs()->get($catalogsFilter); +} catch (AmoCRMApiException $e) { + printError($e); + die; +} + //Получим все каталоги try { $catalogsCollection = $apiClient->catalogs()->get(); diff --git a/examples/testCatalogs.php b/examples/testCatalogs.php new file mode 100644 index 00000000..e69de29b diff --git a/src/AmoCRM/Filters/CatalogsFilter.php b/src/AmoCRM/Filters/CatalogsFilter.php new file mode 100644 index 00000000..434eb739 --- /dev/null +++ b/src/AmoCRM/Filters/CatalogsFilter.php @@ -0,0 +1,46 @@ +type = $type; + + return $this; + } + + /** + * @return null|string + */ + public function getType(): ?string + { + return $this->type; + } + + public function buildFilter(): array + { + $filter = []; + + if (!is_null($this->getType())) { + $filter['type'] = $this->getType(); + } + + return $filter; + } +} From b4fb444be63a3202fd91847d5c85707e658f6b51 Mon Sep 17 00:00:00 2001 From: Aydarkhan Tsyrenzhapov Date: Mon, 31 Aug 2020 14:36:51 +0300 Subject: [PATCH 2/2] delete example --- examples/testCatalogs.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/testCatalogs.php diff --git a/examples/testCatalogs.php b/examples/testCatalogs.php deleted file mode 100644 index e69de29b..00000000