diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7807f89 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# IDEs +/.idea +/.project +/nbproject +/.buildpath +/.settings +*.sublime-* +*.AppleDouble +*.AppleDB +*.AppleDesktop +phpstan.json \ No newline at end of file diff --git a/.license b/.license new file mode 100644 index 0000000..591bbb5 --- /dev/null +++ b/.license @@ -0,0 +1,4 @@ +/** + * MIT License + * For full license information, please view the LICENSE file that was distributed with this source code. + */ diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..e901230 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,18 @@ +build: + dependencies: + before: + - composer config repositories.spryker composer https://code.spryker.com/repo/private + environment: + php: + version: 7.1 + +checks: + php: + code_rating: true + +filter: + excluded_paths: + - config/* + - tests/* + - src/Generated/* + - src/Pyz/* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..14d5c59 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,47 @@ +language: php + +notifications: + email: false + +sudo: required + +matrix: + fast_finish: true + include: + - php: 7.1 + +services: + - postgresql + - redis + - rabbitmq + +addons: + postgresql: 9.4 + + apt: + packages: + - graphviz + + hosts: + - zed.de.spryker.test + - www.de.spryker.test + +env: + global: + - APPLICATION_ENV=devtest + - APPLICATION_STORE=DE + - MODULE_DIR=module + - SHOP_DIR=current + - MODULE_NAME=akeneo-pim + +cache: + directories: + - $SHOP_DIR/current/vendor + - $HOME/.composer/cache + +before_install: + - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + +script: + - git clone -b master https://github.com/spryker-eco/eco-ci.git ecoci + - ./ecoci/build/travis.sh \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f0d3aa6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 SPRYKER SYSTEMS GMBH + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 0000000..20dbc5d --- /dev/null +++ b/codeception.yml @@ -0,0 +1,24 @@ +namespace: AkeneoPim + +include: + - tests/SprykerEcoTest/Service/AkeneoPim + +paths: + tests: tests + support: . + log: tests/_output + data: tests/_data + envs: tests/_envs + +settings: + bootstrap: _bootstrap.php + suite_class: \PHPUnit_Framework_TestSuite + colors: true + memory_limit: 1024M + log: true + +coverage: + enabled: true + whitelist: + include: + - 'src/*' \ No newline at end of file diff --git a/composer.json b/composer.json index af7a155..509c89c 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,10 @@ "name": "spryker-eco/akeneo-pim", "description": "Akeneo PIM Integration Module", "require": { - "akeneo/api-php-client": "^1.0@beta" + "php": ">=7.1", + "spryker/kernel": "^3.0.0", + "akeneo/api-php-client": "^1.0.0", + "php-http/guzzle6-adapter": "^1.0.0" }, "autoload": { "psr-0": { @@ -10,6 +13,7 @@ "Function": "tests/" } }, + "minimum-stability": "dev", "autoload-dev": { "psr-0": { "Functional": "tests/", diff --git a/config/Shared/config.dist.php b/config/Shared/config.dist.php deleted file mode 100644 index 6ddf19d..0000000 --- a/config/Shared/config.dist.php +++ /dev/null @@ -1,14 +0,0 @@ - 'akeneo-import', - 'command' => '$PHP_BIN vendor/bin/console akeneo:import', - 'schedule' => '0 * * * *', - 'enable' => true, - 'run_on_non_production' => false, - 'stores' => ['DE'], -]; \ No newline at end of file diff --git a/src/SprykerEco/Zed/AkeneoPim/AkeneoPimConfig.php b/src/SprykerEco/Service/AkeneoPim/AkeneoPimConfig.php similarity index 61% rename from src/SprykerEco/Zed/AkeneoPim/AkeneoPimConfig.php rename to src/SprykerEco/Service/AkeneoPim/AkeneoPimConfig.php index fe8c712..ef69f5c 100644 --- a/src/SprykerEco/Zed/AkeneoPim/AkeneoPimConfig.php +++ b/src/SprykerEco/Service/AkeneoPim/AkeneoPimConfig.php @@ -2,25 +2,20 @@ /** * MIT License - * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. + * For full license information, please view the LICENSE file that was distributed with this source code. */ -namespace SprykerEco\Zed\AkeneoPim; +namespace SprykerEco\Service\AkeneoPim; -use Spryker\Zed\Kernel\AbstractBundleConfig; +use Spryker\Service\Kernel\AbstractBundleConfig; use SprykerEco\Shared\AkeneoPim\AkeneoPimConstants; -/** - * Class AkeneoPimConfig - * @package SprykerEco\Zed\AkeneoPim - */ class AkeneoPimConfig extends AbstractBundleConfig { - /** * @return string */ - public function getHost() + public function getHost(): string { return $this->get(AkeneoPimConstants::HOST); } @@ -28,7 +23,7 @@ public function getHost() /** * @return string */ - public function getUsername() + public function getUsername(): string { return $this->get(AkeneoPimConstants::USERNAME); } @@ -36,7 +31,7 @@ public function getUsername() /** * @return string */ - public function getPassword() + public function getPassword(): string { return $this->get(AkeneoPimConstants::PASSWORD); } @@ -44,7 +39,7 @@ public function getPassword() /** * @return string */ - public function getClientId() + public function getClientId(): string { return $this->get(AkeneoPimConstants::CLIENT_ID); } @@ -52,9 +47,8 @@ public function getClientId() /** * @return string */ - public function getClientSecret() + public function getClientSecret(): string { return $this->get(AkeneoPimConstants::CLIENT_SECRET); } - } diff --git a/src/SprykerEco/Service/AkeneoPim/AkeneoPimService.php b/src/SprykerEco/Service/AkeneoPim/AkeneoPimService.php new file mode 100644 index 0000000..eed3367 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/AkeneoPimService.php @@ -0,0 +1,744 @@ +getFactory() + ->createAkeneoPimAdapterFactory() + ->createProductApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllCategories($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createCategoryApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllAttributes($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $attributeCode Code of the attribute + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllAttributeOptions($attributeCode, $pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeOptionApiAdapter() + ->all($attributeCode, $pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllAttributeGroups($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeGroupApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllChannels($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createChannelApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllCurrencies($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createCurrencyApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllLocales($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createLocaleApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllFamilies($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createFamilyApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $familyCode Family code from which you want to get a list of family variants. + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllFamilyVariants($familyCode, $pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createFamilyVariantApiAdapter() + ->all($familyCode, $pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllMeasureFamilies($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createMeasureFamilyApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllAssociationTypes($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAssociationTypeApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllProductMediaFiles($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createProductMediaFileApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $pageSize The size of the page returned by the server. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function getAllProductModels($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createProductModelApiAdapter() + ->all($pageSize, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the attribute + * + * @return array + */ + public function getAttribute($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the attribute group + * + * @return array + */ + public function getAttributeGroup($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeGroupApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $attributeCode Code of the attribute + * @param string $code Code of the attribute option + * + * @return array + */ + public function getAttributeOption($attributeCode, $code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeOptionApiAdapter() + ->get($attributeCode, $code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the category + * + * @return array + */ + public function getCategory($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createCategoryApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the channel + * + * @return array + */ + public function getChannel($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createChannelApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the currency + * + * @return array + */ + public function getCurrency($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createCurrencyApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the locale + * + * @return array + */ + public function getLocale($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createLocaleApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the family + * + * @return array + */ + public function getFamily($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createFamilyApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $familyCode Code of the family + * @param string $code Code of the family variant + * + * @return array + */ + public function getFamilyVariant($familyCode, $code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createFamilyVariantApiAdapter() + ->get($familyCode, $code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the measure family + * + * @return array + */ + public function getMeasureFamily($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createMeasureFamilyApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the product + * + * @return array + */ + public function getProduct($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createProductApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the product media file + * + * @return array + */ + public function getProductMediaFile($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createProductMediaFileApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $code Code of the product model + * + * @return array + */ + public function getProductModel($code): array + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createProductModelApiAdapter() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of attributes to return. + * @param bool $withCount Set to true to return the total count of attributes. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getAttributesListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of attribute groups to return. + * @param bool $withCount Set to true to return the total count of attribute groups. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getAttributeGroupsListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeGroupApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $attributeCode Code of the attribute + * @param int $limit The maximum number of resources to return. + * @param bool $withCount Set to true to return the total count of resources. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getAttributeOptionsListPerPage($attributeCode, $limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeOptionApiAdapter() + ->listPerPage($attributeCode, $limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of categories to return. + * @param bool $withCount Set to true to return the total count of categories. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getCategoriesListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createCategoryApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of channels to return. + * @param bool $withCount Set to true to return the total count of channels. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getChannelsListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createChannelApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of currencies to return. + * @param bool $withCount Set to true to return the total count of currencies. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getCurrenciesListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createCurrencyApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of locales to return. + * @param bool $withCount Set to true to return the total count of locales. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getLocalesListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createAttributeGroupApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of families to return. + * @param bool $withCount Set to true to return the total count of families. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getFamiliesListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createFamilyApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param string $familyCode Family code from which you want to get a list of family variants. + * @param int $limit The maximum number of family variants to return. + * @param bool $withCount Set to true to return the total count of family variants. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getFamilyVariantsListPerPage($familyCode, $limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createFamilyVariantApiAdapter() + ->listPerPage($familyCode, $limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of measure families to return. + * @param bool $withCount Set to true to return the total count of measure families. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getMeasureFamilyListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createMeasureFamilyApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of products to return. + * @param bool $withCount Set to true to return the total count of products. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getProductsListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createProductApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of product media files to return. + * @param bool $withCount Set to true to return the total count of product media files. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getProductMediaFilesListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createProductMediaFileApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } + + /** + * {@inheritdoc} + * + * @api + * + * @param int $limit The maximum number of product models to return. + * @param bool $withCount Set to true to return the total count of product models. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getProductModelsListPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + return $this->getFactory() + ->createAkeneoPimAdapterFactory() + ->createProductModelApiAdapter() + ->listPerPage($limit, $withCount, $queryParameters); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/AkeneoPimServiceFactory.php b/src/SprykerEco/Service/AkeneoPim/AkeneoPimServiceFactory.php new file mode 100644 index 0000000..15226de --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/AkeneoPimServiceFactory.php @@ -0,0 +1,36 @@ +getConfig(), $this->createWrapperFactory()); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\WrapperFactoryInterface + */ + public function createWrapperFactory(): WrapperFactoryInterface + { + return new WrapperFactory(); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/AkeneoPimServiceInterface.php b/src/SprykerEco/Service/AkeneoPim/AkeneoPimServiceInterface.php new file mode 100644 index 0000000..c004656 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/AkeneoPimServiceInterface.php @@ -0,0 +1,540 @@ +akeneoPimClient = $akeneoPimClient; + } + + /** + * {@inheritdoc} + */ + abstract public function get($code): array; + + /** + * {@inheritdoc} + */ + abstract public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface; + + /** + * {@inheritdoc} + */ + abstract public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface; +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/AdapterFactory.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/AdapterFactory.php new file mode 100644 index 0000000..b371ee4 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/AdapterFactory.php @@ -0,0 +1,214 @@ +config = $config; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createProductApiAdapter(): ApiAdapterInterface + { + return new ProductApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createCategoryApiAdapter(): ApiAdapterInterface + { + return new CategoryApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createAttributeApiAdapter(): ApiAdapterInterface + { + return new AttributeApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createAttributeGroupApiAdapter(): ApiAdapterInterface + { + return new AttributeGroupApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\Attributes\AttributeOptionApiAdapterInterface + */ + public function createAttributeOptionApiAdapter(): AttributeOptionApiAdapterInterface + { + return new AttributeOptionApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createAssociationTypeApiAdapter(): ApiAdapterInterface + { + return new AssociationTypeApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createChannelApiAdapter(): ApiAdapterInterface + { + return new ChannelApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createCurrencyApiAdapter(): ApiAdapterInterface + { + return new CurrencyApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createFamilyApiAdapter(): ApiAdapterInterface + { + return new FamilyApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\Family\FamilyVariantApiAdapterInterface + */ + public function createFamilyVariantApiAdapter(): FamilyVariantApiAdapterInterface + { + return new FamilyVariantApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createLocaleApiAdapter(): ApiAdapterInterface + { + return new LocaleApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createMeasureFamilyApiAdapter(): ApiAdapterInterface + { + return new MeasureFamilyApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createProductMediaFileApiAdapter(): ApiAdapterInterface + { + return new ProductMediaFileApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + public function createProductModelApiAdapter(): ApiAdapterInterface + { + return new ProductModelApiAdapter( + $this->createAkeneoPimSdkFactory()->createAkeneoPimClient($this->config), + $this->wrapperFactory + ); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\Sdk\AkeneoPimSdkFactoryInterface + */ + public function createAkeneoPimSdkFactory(): AkeneoPimSdkFactoryInterface + { + return new AkeneoPimSdkFactory(); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/AdapterFactoryInterface.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/AdapterFactoryInterface.php new file mode 100644 index 0000000..11d92f3 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/AdapterFactoryInterface.php @@ -0,0 +1,84 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getAttributeApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getAttributeApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getAttributeApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Attributes/AttributeGroupApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Attributes/AttributeGroupApiAdapter.php new file mode 100644 index 0000000..2c0363c --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Attributes/AttributeGroupApiAdapter.php @@ -0,0 +1,91 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getAttributeGroupApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getAttributeGroupApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getAttributeGroupApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Attributes/AttributeOptionApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Attributes/AttributeOptionApiAdapter.php new file mode 100644 index 0000000..78ba11b --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Attributes/AttributeOptionApiAdapter.php @@ -0,0 +1,89 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($attributeCode, $code): array + { + return $this->akeneoPimClient + ->getAttributeOptionApi() + ->get($attributeCode, $code); + } + + /** + * {@inheritdoc} + * + * @param string $attributeCode + * @param int $limit + * @param bool $withCount + * @param array $queryParameters + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($attributeCode, $limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getAttributeOptionApi() + ->listPerPage($attributeCode, $limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param string $attributeCode + * @param int $pageSize + * @param array $queryParameters + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($attributeCode, $pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getAttributeOptionApi() + ->all($attributeCode, $pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Attributes/AttributeOptionApiAdapterInterface.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Attributes/AttributeOptionApiAdapterInterface.php new file mode 100644 index 0000000..b75f426 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Attributes/AttributeOptionApiAdapterInterface.php @@ -0,0 +1,51 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getCategoryApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getCategoryApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getCategoryApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Category/ChannelApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Category/ChannelApiAdapter.php new file mode 100644 index 0000000..815c599 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Category/ChannelApiAdapter.php @@ -0,0 +1,91 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getChannelApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getChannelApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getChannelApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Category/CurrencyApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Category/CurrencyApiAdapter.php new file mode 100644 index 0000000..c306cb2 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Category/CurrencyApiAdapter.php @@ -0,0 +1,91 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getCurrencyApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getCurrencyApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getCurrencyApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Category/LocaleApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Category/LocaleApiAdapter.php new file mode 100644 index 0000000..43c47a5 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Category/LocaleApiAdapter.php @@ -0,0 +1,91 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getLocaleApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getLocaleApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getLocaleApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Family/FamilyApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Family/FamilyApiAdapter.php new file mode 100644 index 0000000..5c10582 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Family/FamilyApiAdapter.php @@ -0,0 +1,91 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getFamilyApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getFamilyApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getFamilyApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Family/FamilyVariantApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Family/FamilyVariantApiAdapter.php new file mode 100644 index 0000000..44fecd8 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Family/FamilyVariantApiAdapter.php @@ -0,0 +1,90 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $familyCode Code of the parent family + * @param string $familyVariantCode Code of the family variant + * + * @return array + */ + public function get($familyCode, $familyVariantCode): array + { + return $this->akeneoPimClient + ->getFamilyVariantApi() + ->get($familyCode, $familyVariantCode); + } + + /** + * {@inheritdoc} + * + * @param string $familyCode + * @param int $limit + * @param bool $withCount + * @param array $queryParameters + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($familyCode, $limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getFamilyVariantApi() + ->listPerPage($familyCode, $limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param string $familyCode + * @param int $pageSize + * @param array $queryParameters + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($familyCode, $pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getFamilyVariantApi() + ->all($familyCode, $pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Family/FamilyVariantApiAdapterInterface.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Family/FamilyVariantApiAdapterInterface.php new file mode 100644 index 0000000..d1aabe7 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Family/FamilyVariantApiAdapterInterface.php @@ -0,0 +1,51 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getMeasureFamilyApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getMeasureFamilyApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getMeasureFamilyApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/AssociationTypeApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/AssociationTypeApiAdapter.php new file mode 100644 index 0000000..72cbfa1 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/AssociationTypeApiAdapter.php @@ -0,0 +1,91 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getAssociationTypeApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getAssociationTypeApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getAssociationTypeApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/ProductApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/ProductApiAdapter.php new file mode 100644 index 0000000..42510c4 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/ProductApiAdapter.php @@ -0,0 +1,91 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getProductApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getProductApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getProductApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/ProductMediaFileApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/ProductMediaFileApiAdapter.php new file mode 100644 index 0000000..75df85a --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/ProductMediaFileApiAdapter.php @@ -0,0 +1,91 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getProductMediaFileApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getProductMediaFileApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getProductMediaFileApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/ProductModelApiAdapter.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/ProductModelApiAdapter.php new file mode 100644 index 0000000..785de79 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Product/ProductModelApiAdapter.php @@ -0,0 +1,91 @@ +akeneoPimClient = $akeneoPimClient; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * {@inheritdoc} + * + * @param string $code Code of the resource + * + * @return array + */ + public function get($code): array + { + return $this->akeneoPimClient + ->getProductModelApi() + ->get($code); + } + + /** + * {@inheritdoc} + * + * @param int $limit The maximum number of resources to return. + * Do note that the server has a maximum limit allowed. + * @param bool $withCount Set to true to return the total count of resources. + * This parameter could decrease drastically the performance when set to true. + * @param array $queryParameters Additional query parameters to pass in the request. + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function listPerPage($limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface + { + $page = $this->akeneoPimClient + ->getProductModelApi() + ->listPerPage($limit, $withCount, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoPage($page); + } + + /** + * {@inheritdoc} + * + * @param int $pageSize The size of the page returned by the server. + * Do note that the server has a maximum limit allowed. + * @param array $queryParameters Additional query parameters to pass in the request + * + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + public function all($pageSize = 10, array $queryParameters = []): AkeneoResourceCursorInterface + { + $resourceCursor = $this->akeneoPimClient + ->getProductModelApi() + ->all($pageSize, $queryParameters); + + return $this->wrapperFactory + ->createAkeneoResourceCursor($resourceCursor); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Sdk/AkeneoPimSdkFactory.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Sdk/AkeneoPimSdkFactory.php new file mode 100644 index 0000000..bd31fc4 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Sdk/AkeneoPimSdkFactory.php @@ -0,0 +1,49 @@ +getHost() + ); + $clientBuilder->setHttpClient( + $this->createHttpClient() + ); + + return $clientBuilder->buildAuthenticatedByPassword( + $config->getClientId(), + $config->getClientSecret(), + $config->getUsername(), + $config->getPassword() + ); + } + + /** + * @SuppressWarnings(FactoryMethodReturnInterfaceRule) + * + * @return \Http\Client\HttpClient + */ + protected function createHttpClient(): HttpClient + { + return new Client(); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Sdk/AkeneoPimSdkFactoryInterface.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Sdk/AkeneoPimSdkFactoryInterface.php new file mode 100644 index 0000000..0bbfd3c --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/Sdk/AkeneoPimSdkFactoryInterface.php @@ -0,0 +1,21 @@ +resourceCursor = $resourceCursor; + } + + /** + * {@inheritdoc} + * + * @return int + */ + public function getPageSize(): int + { + return $this->resourceCursor + ->getPageSize(); + } + + /** + * {@inheritdoc} + * + * @return mixed + */ + public function current() + { + return $this->resourceCursor + ->current(); + } + + /** + * {@inheritdoc} + * + * @return void + */ + public function next(): void + { + $this->resourceCursor + ->next(); + } + + /** + * {@inheritdoc} + * + * @return mixed + */ + public function key() + { + return $this->resourceCursor + ->key(); + } + + /** + * {@inheritdoc} + * + * @return bool + */ + public function valid(): bool + { + return $this->resourceCursor + ->valid(); + } + + /** + * {@inheritdoc} + * + * @return void + */ + public function rewind(): void + { + $this->resourceCursor + ->rewind(); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Wrapper/AkeneoResourceCursorInterface.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Wrapper/AkeneoResourceCursorInterface.php new file mode 100644 index 0000000..d25b736 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Wrapper/AkeneoResourceCursorInterface.php @@ -0,0 +1,18 @@ +page = $page; + $this->wrapperFactory = $wrapperFactory; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface + */ + public function getFirstPage(): AkeneoResourcePageInterface + { + $firstPage = $this->page + ->getFirstPage(); + + return $this->wrapperFactory + ->createAkeneoPage($firstPage); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface|null + */ + public function getPreviousPage(): ?AkeneoResourcePageInterface + { + $previousPage = $this->page + ->getPreviousPage(); + if (!$previousPage) { + return null; + } + + return $this->wrapperFactory + ->createAkeneoPage($previousPage); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourcePageInterface|null + */ + public function getNextPage(): ?AkeneoResourcePageInterface + { + $nextPage = $this->page + ->getNextPage(); + if (!$nextPage) { + return null; + } + + return $this->wrapperFactory + ->createAkeneoPage($nextPage); + } + + /** + * @return int|null + */ + public function getCount(): ?int + { + return $this->page + ->getCount(); + } + + /** + * @return array + */ + public function getItems(): array + { + return $this->page + ->getItems(); + } + + /** + * @return bool + */ + public function hasNextPage(): bool + { + return $this->page + ->hasNextPage(); + } + + /** + * @return bool + */ + public function hasPreviousPage(): bool + { + return $this->page + ->hasPreviousPage(); + } + + /** + * @return string|null + */ + public function getNextLink(): ?string + { + return $this->page + ->getNextLink(); + } + + /** + * @return string|null + */ + public function getPreviousLink(): ?string + { + return $this->page + ->getNextLink(); + } +} diff --git a/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Wrapper/AkeneoResourcePageInterface.php b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Wrapper/AkeneoResourcePageInterface.php new file mode 100644 index 0000000..d5a0211 --- /dev/null +++ b/src/SprykerEco/Service/AkeneoPim/Dependencies/External/Api/Wrapper/AkeneoResourcePageInterface.php @@ -0,0 +1,56 @@ +addImporter($this->createCategoryImporter()); - - return $importerCollection; - } - - /** - * @return \SprykerEco\Zed\AkeneoPim\Business\Api\AkeneoPimClientAdapter - */ - public function createAkeneoPimClientAdapter() - { - return new AkeneoPimClientAdapter( - $this->createAkeneoPimClient(), - $this->createAkeneoSearchBuilder() - ); - } - - /** - * @return \Akeneo\Pim\AkeneoPimClientInterface - */ - protected function createAkeneoPimClient() - { - $akeneoPimClientBuilder = $this->createAkeneoPimClientBuilder(); - return $akeneoPimClientBuilder - ->buildAuthenticatedByPassword( - $this->getConfig()->getClientId(), - $this->getConfig()->getClientSecret(), - $this->getConfig()->getUsername(), - $this->getConfig()->getPassword() - ); - } - - /** - * @return \SprykerEco\Zed\AkeneoPim\Business\Api\AkeneoPimSearchBuilderInterface - */ - protected function createAkeneoSearchBuilder() - { - return new AkeneoPimSearchBuilder(); - } - - /** - * @return \Akeneo\Pim\AkeneoPimClientBuilder - */ - protected function createAkeneoPimClientBuilder() - { - return new AkeneoPimClientBuilder( - $this->getConfig()->getHost() - ); - } - - /** - * @return \SprykerEco\Zed\AkeneoPim\Business\Model\Category\Importer - */ - protected function createCategoryImporter() - { - return new CategoryImporter(); - } - -} diff --git a/src/SprykerEco/Zed/AkeneoPim/Business/AkeneoPimFacade.php b/src/SprykerEco/Zed/AkeneoPim/Business/AkeneoPimFacade.php deleted file mode 100644 index 2be934e..0000000 --- a/src/SprykerEco/Zed/AkeneoPim/Business/AkeneoPimFacade.php +++ /dev/null @@ -1,35 +0,0 @@ -getFactory()->createImporter()->import( - $this->getFactory()->createAkeneoPimClientAdapter(), - $akeneoPimImportTransfer - ); - } - -} diff --git a/src/SprykerEco/Zed/AkeneoPim/Business/AkeneoPimFacadeInterface.php b/src/SprykerEco/Zed/AkeneoPim/Business/AkeneoPimFacadeInterface.php deleted file mode 100644 index 3f22395..0000000 --- a/src/SprykerEco/Zed/AkeneoPim/Business/AkeneoPimFacadeInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -akeneoPimClient = $akeneoPimClient; - $this->akeneoPimSearchBuilder = $akeneoPimSearchBuilder; - } - - /** - * @return \SprykerEco\Zed\AkeneoPim\Business\Api\AkeneoPimSearchBuilderInterface - */ - public function getSearchBuilder() - { - return $this->akeneoPimSearchBuilder; - } - - /** - * @param int $pageSize - * - * @return \Akeneo\Pim\Pagination\ResourceCursorInterface - */ - public function getCategories($pageSize) - { - return $this->akeneoPimClient->getCategoryApi()->all($pageSize); - } - - /** - * @param int $pageSize - * - * @return \Akeneo\Pim\Pagination\ResourceCursorInterface - */ - public function getAttributes($pageSize) - { - return $this->akeneoPimClient->getAttributeApi()->all($pageSize); - } - - /** - * @param int $pageSize - * @param array $queryParameters - * - * @return \Akeneo\Pim\Pagination\ResourceCursorInterface - */ - public function getProducts($pageSize, array $queryParameters = []) - { - return $this->akeneoPimClient->getProductApi()->all($pageSize, $queryParameters); - } - -} diff --git a/src/SprykerEco/Zed/AkeneoPim/Business/Api/AkeneoPimClientAdapterInterface.php b/src/SprykerEco/Zed/AkeneoPim/Business/Api/AkeneoPimClientAdapterInterface.php deleted file mode 100644 index 74e0bf9..0000000 --- a/src/SprykerEco/Zed/AkeneoPim/Business/Api/AkeneoPimClientAdapterInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - $operator]; - if ($value) { - $filter['value'] = $value; - } - $this->filters[$property][] = $filter + $options; - - return $this; - } - - /** - * @return array - */ - public function getFilters() - { - $filters = $this->filters; - $this->filters = []; - - return $filters; - } - -} diff --git a/src/SprykerEco/Zed/AkeneoPim/Business/Api/AkeneoPimSearchBuilderInterface.php b/src/SprykerEco/Zed/AkeneoPim/Business/Api/AkeneoPimSearchBuilderInterface.php deleted file mode 100644 index 0ffcb47..0000000 --- a/src/SprykerEco/Zed/AkeneoPim/Business/Api/AkeneoPimSearchBuilderInterface.php +++ /dev/null @@ -1,32 +0,0 @@ -getCategories(50); - $counter = 0; - foreach ($categories as $category) { - ++$counter; - } - $akeneoPimImportTransfer->getReport()->setResult('Categories Imported: ' . $counter); - - return $akeneoPimImportTransfer->getReport(); - } - -} diff --git a/src/SprykerEco/Zed/AkeneoPim/Business/Model/ImporterCollection.php b/src/SprykerEco/Zed/AkeneoPim/Business/Model/ImporterCollection.php deleted file mode 100644 index 6cf4aa8..0000000 --- a/src/SprykerEco/Zed/AkeneoPim/Business/Model/ImporterCollection.php +++ /dev/null @@ -1,50 +0,0 @@ -importers[] = $importer; - - return $this; - } - - /** - * @param \SprykerEco\Zed\AkeneoPim\Business\Api\AkeneoPimClientAdapterInterface $client - * @param \Generated\Shared\Transfer\AkeneoPimImportTransfer $akeneoPimImportTransfer - * - * @return \Generated\Shared\Transfer\AkeneoPimImportReportTransfer - */ - public function import( - AkeneoPimClientAdapterInterface $client, - AkeneoPimImportTransfer $akeneoPimImportTransfer - ) { - foreach ($this->importers as $importer) { - $importer->import($client, $akeneoPimImportTransfer); - } - - return $akeneoPimImportTransfer->getReport(); - } - -} diff --git a/src/SprykerEco/Zed/AkeneoPim/Business/Model/ImporterCollectionInterface.php b/src/SprykerEco/Zed/AkeneoPim/Business/Model/ImporterCollectionInterface.php deleted file mode 100644 index 7618a01..0000000 --- a/src/SprykerEco/Zed/AkeneoPim/Business/Model/ImporterCollectionInterface.php +++ /dev/null @@ -1,24 +0,0 @@ -setName('akeneo:import') - ->setDescription('This command executes Akeneo Pim importers'); - } - - /** - * @param \Symfony\Component\Console\Input\InputInterface $input - * @param \Symfony\Component\Console\Output\OutputInterface $output - * - * @return void - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $akeneoPimImportTransfer = $this->getAkeneoPimImportTransfer($input); - $akeneoPimImportReportTransfer = $this->getFacade()->import($akeneoPimImportTransfer); - - $this->output->writeln($akeneoPimImportReportTransfer->getResult()); - } - - /** - * @param \Symfony\Component\Console\Input\InputInterface $input - * - * @return \Generated\Shared\Transfer\AkeneoPimImportTransfer - */ - private function getAkeneoPimImportTransfer(InputInterface $input) - { - $akeneoPimImportTransfer = new AkeneoPimImportTransfer(); - $akeneoPimImportTransfer->setConfig($this->getAkeneoPimImportConfigTransfer()); - $akeneoPimImportTransfer->setOptions($this->getAkeneoOptionsTransfer($input)); - $akeneoPimImportTransfer->setReport(new AkeneoPimImportReportTransfer()); - - return $akeneoPimImportTransfer; - } - - /** - * @return \Generated\Shared\Transfer\AkeneoPimImportConfigTransfer - */ - private function getAkeneoPimImportConfigTransfer() - { - // TODO Get options from input - $akeneoPimImportConfigTransfer = new AkeneoPimImportConfigTransfer(); - $akeneoPimImportConfigTransfer->setType('import'); - - return $akeneoPimImportConfigTransfer; - } - - /** - * @param \Symfony\Component\Console\Input\InputInterface $input - * - * @return \Generated\Shared\Transfer\AkeneoPimImportOptionsTransfer - */ - private function getAkeneoOptionsTransfer(InputInterface $input) - { - // TODO Get options from input - $akeneoPimImportOptionsTransfer = new AkeneoPimImportOptionsTransfer(); - $akeneoPimImportOptionsTransfer->setChannel('commerce'); - $akeneoPimImportOptionsTransfer->setLocale('en_EN'); - - return $akeneoPimImportOptionsTransfer; - } - -} diff --git a/tests/SprykerEcoTest/Service/AkeneoPim/AkeneoPimServiceTest.php b/tests/SprykerEcoTest/Service/AkeneoPim/AkeneoPimServiceTest.php new file mode 100644 index 0000000..9a4eb5e --- /dev/null +++ b/tests/SprykerEcoTest/Service/AkeneoPim/AkeneoPimServiceTest.php @@ -0,0 +1,297 @@ +prepareService(); + + $this->assertTrue($service->getAllProducts() instanceof AkeneoResourceCursorInterface); + } + + /** + * @return void + */ + public function testGetAllCategories(): void + { + $service = $this->prepareService(); + + $this->assertTrue($service->getAllCategories() instanceof AkeneoResourceCursorInterface); + } + + /** + * @return void + */ + public function testGetAllAttributes(): void + { + $service = $this->prepareService(); + + $this->assertTrue($service->getAllAttributes() instanceof AkeneoResourceCursorInterface); + } + + /** + * @return void + */ + public function testGetAllFamilies(): void + { + $service = $this->prepareService(); + + $this->assertTrue($service->getAllFamilies() instanceof AkeneoResourceCursorInterface); + } + + /** + * @return void + */ + public function testGetFamilyVariants(): void + { + $service = $this->prepareService(); + + $this->assertTrue($service->getAllFamilyVariants('code') instanceof AkeneoResourceCursorInterface); + } + + /** + * @return void + */ + public function testGetAllAttributeOptions(): void + { + $service = $this->prepareService(); + + $this->assertTrue($service->getAllAttributeOptions('code') instanceof AkeneoResourceCursorInterface); + } + + /** + * @return void + */ + public function testGetAllProductModels(): void + { + $service = $this->prepareService(); + + $this->assertTrue($service->getAllProductModels() instanceof AkeneoResourceCursorInterface); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\AkeneoPimServiceInterface + */ + protected function prepareService(): AkeneoPimServiceInterface + { + $serviceFactory = $this->createAkeneoPimServiceFactoryMock(); + + $service = $this->getAkeneoPimService(); + $service->setFactory($serviceFactory); + + return $service; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\AkeneoPimServiceInterface + */ + protected function getAkeneoPimService(): AkeneoPimServiceInterface + { + return new AkeneoPimService(); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\AkeneoPimServiceFactory + */ + protected function createAkeneoPimServiceFactoryMock(): AkeneoPimServiceFactory + { + $factory = $this->getMockBuilder(AkeneoPimServiceFactory::class) + ->setMethods(['createAkeneoPimAdapterFactory']) + ->getMock(); + + $factory->expects($this->once())->method('createAkeneoPimAdapterFactory')->willReturn($this->createAdapterFactoryMock()); + $factory->setConfig($this->getAkeneoPimConfig()); + + return $factory; + } + + /** + * @return \Spryker\Service\Kernel\AbstractBundleConfig + */ + protected function getAkeneoPimConfig(): AbstractBundleConfig + { + return new AkeneoPimConfig(); + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\AdapterFactoryInterface + */ + protected function createAdapterFactoryMock(): AdapterFactoryInterface + { + $factory = $this->getMockBuilder(AdapterFactory::class) + ->setMethods([ + 'createProductApiAdapter', + 'createCategoryApiAdapter', + 'createAttributeApiAdapter', + 'createFamilyApiAdapter', + 'createFamilyVariantApiAdapter', + 'createAttributeOptionApiAdapter', + 'createProductModelApiAdapter', + ]) + ->disableOriginalConstructor() + ->getMock(); + + $factory->method('createCategoryApiAdapter')->willReturn($this->createCategoryApiAdapterMock()); + $factory->method('createProductApiAdapter')->willReturn($this->createProductApiAdapterMock()); + $factory->method('createAttributeApiAdapter')->willReturn($this->createAttributeApiAdapterMock()); + $factory->method('createFamilyApiAdapter')->willReturn($this->createFamilyApiAdapterMock()); + $factory->method('createFamilyVariantApiAdapter')->willReturn($this->createFamilyVariantApiAdapterMock()); + $factory->method('createAttributeOptionApiAdapter')->willReturn($this->createAttributeOptionApiAdapterMock()); + $factory->method('createProductModelApiAdapter')->willReturn($this->createProductModelApiAdapterMock()); + + return $factory; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + protected function createCategoryApiAdapterMock(): ApiAdapterInterface + { + $adapter = $this->getMockBuilder(CategoryApiAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['all']) + ->getMock(); + + $adapter->method('all')->willReturn($this->createAkeneoResourceMock()); + + return $adapter; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + protected function createProductApiAdapterMock(): ApiAdapterInterface + { + $adapter = $this->getMockBuilder(ProductApiAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['all']) + ->getMock(); + + $adapter->method('all')->willReturn($this->createAkeneoResourceMock()); + + return $adapter; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + protected function createAttributeApiAdapterMock(): ApiAdapterInterface + { + $adapter = $this->getMockBuilder(AttributeApiAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['all']) + ->getMock(); + + $adapter->method('all')->willReturn($this->createAkeneoResourceMock()); + + return $adapter; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + protected function createFamilyApiAdapterMock(): ApiAdapterInterface + { + $adapter = $this->getMockBuilder(FamilyApiAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['all']) + ->getMock(); + + $adapter->method('all')->willReturn($this->createAkeneoResourceMock()); + + return $adapter; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\Family\FamilyVariantApiAdapterInterface + */ + protected function createFamilyVariantApiAdapterMock(): FamilyVariantApiAdapterInterface + { + $adapter = $this->getMockBuilder(FamilyVariantApiAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['all']) + ->getMock(); + + $adapter->method('all')->willReturn($this->createAkeneoResourceMock()); + + return $adapter; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\Attributes\AttributeOptionApiAdapterInterface + */ + protected function createAttributeOptionApiAdapterMock(): AttributeOptionApiAdapterInterface + { + $adapter = $this->getMockBuilder(AttributeOptionApiAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['all']) + ->getMock(); + + $adapter->method('all')->willReturn($this->createAkeneoResourceMock()); + + return $adapter; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\ApiAdapterInterface + */ + protected function createProductModelApiAdapterMock(): ApiAdapterInterface + { + $adapter = $this->getMockBuilder(ProductModelApiAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['all']) + ->getMock(); + + $adapter->method('all')->willReturn($this->createAkeneoResourceMock()); + + return $adapter; + } + + /** + * @return \SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Wrapper\AkeneoResourceCursorInterface + */ + protected function createAkeneoResourceMock(): AkeneoResourceCursorInterface + { + $mock = $this->getMockBuilder(AkeneoResourceCursorInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + return $mock; + } +} diff --git a/tests/SprykerEcoTest/Service/AkeneoPim/codeception.yml b/tests/SprykerEcoTest/Service/AkeneoPim/codeception.yml new file mode 100644 index 0000000..7888fa3 --- /dev/null +++ b/tests/SprykerEcoTest/Service/AkeneoPim/codeception.yml @@ -0,0 +1,22 @@ +namespace: SprykerEcoTest\Service\AkeneoPim + +paths: + tests: . + data: ../../../_data + support: _support + log: ../../../_output + output: ../../../_output + +coverage: + enabled: true + remote: false + whitelist: { include: ['../../../../src/*'] } + +suites: + Service: + path: . + class_name: AkeneoPimServiceTester + modules: + enabled: + - Asserts + - \PyzTest\Shared\Testify\Helper\Environment \ No newline at end of file