From 19697935e41109dda93799d78da03cf60b331b90 Mon Sep 17 00:00:00 2001 From: Benjamin Calef Date: Fri, 17 Nov 2023 18:55:38 +0100 Subject: [PATCH] [v1.1.3] fix xml config renaming --- Model/ConfigRequest.php | 28 ++++++++++++++-------------- Service/ApiProvider.php | 4 ++-- composer.json | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Model/ConfigRequest.php b/Model/ConfigRequest.php index 4c42924..760e857 100755 --- a/Model/ConfigRequest.php +++ b/Model/ConfigRequest.php @@ -20,22 +20,22 @@ class ConfigRequest { /** @var string */ - public const REST_API_SERVICE_BASE_URI = 'rest_api/%s/base_uri'; + public const XML_CONFIG_REST_API_SERVICE_BASE_URI = 'rest_api/%s/base_uri'; /** @var string */ - public const REST_API_SERVICE_TIMEOUT = 'rest_api/%s/timeout'; + public const XML_CONFIG_REST_API_SERVICE_TIMEOUT = 'rest_api/%s/timeout'; /** @var string */ - public const REST_API_SERVICE_IS_DEBUG = 'rest_api/%s/is_debug'; + public const XML_CONFIG_REST_API_SERVICE_IS_DEBUG = 'rest_api/%s/is_debug'; /** @var string */ - public const REST_API_SERVICE_CACHE_TTL = 'rest_api/%s/cache_ttl'; + public const XML_CONFIG_REST_API_SERVICE_CACHE_TTL = 'rest_api/%s/cache_ttl'; /** @var string */ - public const REST_API_DEFAULT_IS_FORCE_DEBUG = 'rest_api/default/is_force_debug'; + public const XML_CONFIG_REST_API_GENERAL_IS_FORCE_DEBUG = 'rest_api/general/is_force_debug'; /** @var string */ - public const REST_API_CONFIG_DEFAULT = 'general'; + public const XML_CONFIG_REST_API_GROUP_GENERAL = 'general'; public function __construct( private ScopeConfigInterface $scopeConfig, @@ -48,7 +48,7 @@ public function __construct( public function getBaseUri(): string { return $this->scopeConfig->getValue( - sprintf(self::REST_API_SERVICE_BASE_URI, $this->configName) + sprintf(self::XML_CONFIG_REST_API_SERVICE_BASE_URI, $this->configName) ); } @@ -58,11 +58,11 @@ public function getBaseUri(): string public function getTimeout(): int { $timeout = $this->scopeConfig->getValue( - sprintf(self::REST_API_SERVICE_TIMEOUT, $this->configName) + sprintf(self::XML_CONFIG_REST_API_SERVICE_TIMEOUT, $this->configName) ); if ($timeout === null) { $timeout = $this->scopeConfig->getValue( - sprintf(self::REST_API_SERVICE_TIMEOUT, self::REST_API_CONFIG_DEFAULT) + sprintf(self::XML_CONFIG_REST_API_SERVICE_TIMEOUT, self::XML_CONFIG_REST_API_GROUP_GENERAL) ); } @@ -75,11 +75,11 @@ public function getTimeout(): int public function getCacheLifetime(): int { $cacheLifetime = $this->scopeConfig->getValue( - sprintf(self::REST_API_SERVICE_CACHE_TTL, $this->configName) + sprintf(self::XML_CONFIG_REST_API_SERVICE_CACHE_TTL, $this->configName) ); if ($cacheLifetime === null) { $cacheLifetime = $this->scopeConfig->getValue( - sprintf(self::REST_API_SERVICE_CACHE_TTL, self::REST_API_CONFIG_DEFAULT) + sprintf(self::XML_CONFIG_REST_API_SERVICE_CACHE_TTL, self::XML_CONFIG_REST_API_GROUP_GENERAL) ); } @@ -91,16 +91,16 @@ public function getCacheLifetime(): int */ public function isDebugEnabled(): bool { - if ($this->scopeConfig->isSetFlag(self::REST_API_DEFAULT_IS_FORCE_DEBUG)) { + if ($this->scopeConfig->isSetFlag(self::XML_CONFIG_REST_API_GENERAL_IS_FORCE_DEBUG)) { return true; } $debugEnabled = $this->scopeConfig->getValue( - sprintf(self::REST_API_SERVICE_IS_DEBUG, $this->configName) + sprintf(self::XML_CONFIG_REST_API_SERVICE_IS_DEBUG, $this->configName) ); if ($debugEnabled === null) { $debugEnabled = $this->scopeConfig->getValue( - sprintf(self::REST_API_SERVICE_IS_DEBUG, self::REST_API_CONFIG_DEFAULT) + sprintf(self::XML_CONFIG_REST_API_SERVICE_IS_DEBUG, self::XML_CONFIG_REST_API_GROUP_GENERAL) ); } diff --git a/Service/ApiProvider.php b/Service/ApiProvider.php index 3154d9a..ab26607 100644 --- a/Service/ApiProvider.php +++ b/Service/ApiProvider.php @@ -37,7 +37,7 @@ public function __construct( private ConfigRequestFactory $configRequestFactory, private SerializerInterface $serializer, private RequestAdapter $requestAdapter, - private string $configName = ConfigRequest::REST_API_CONFIG_DEFAULT, + private string $configName = ConfigRequest::XML_CONFIG_REST_API_GROUP_GENERAL, private string $method = Request::METHOD_GET, private bool $isVerify = true, private bool $isJsonRequest = true, @@ -100,7 +100,7 @@ protected function buildParameters(string $serviceName): ParametersInterface */ protected function buildConfigRequest(): ConfigRequest { - if ($this->getConfigName() === ConfigRequest::REST_API_CONFIG_DEFAULT) { + if ($this->getConfigName() === ConfigRequest::XML_CONFIG_REST_API_GROUP_GENERAL) { throw new LogicException(__('ConfigName parameter is missing and must be injected')); } diff --git a/composer.json b/composer.json index 50f403c..bbcbc93 100755 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { "name": "zepgram/module-rest", - "description": "Technical module to industrialize API REST call with dependency injection pattern using Guzzle library in Magento 2", + "description": "Technical module to industrialize API REST call with dependency injection pattern using Guzzle library", "type": "magento2-module", - "version": "1.1.2", + "version": "1.1.3", "authors": [ { "name": "Benjamin Calef",