cleared api version detecting (#198)

* cleared api version detecting
* phpcs stage
This commit is contained in:
Akolzin Dmitry 2020-09-25 10:39:00 +03:00 committed by GitHub
parent 769f35f379
commit 579150ea08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 44 additions and 64 deletions

View File

@ -19,6 +19,7 @@ env:
stages:
- test
- phpcs
- deploy
before_install:
@ -119,6 +120,10 @@ jobs:
env: TEST_SUITE=3.0 OPENCART=3.0.3.1
- php: 7.3
env: TEST_SUITE=3.0 OPENCART=3.0.3.2
- stage: phpcs
before_script: composer install
script: make phpcomp
after_success: skip
- stage: deploy
before_script: skip
script: make build_archive

View File

@ -45,3 +45,9 @@ run_test: run
test: robo_deploy
composer test
phpcs-config:
bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility
phpcomp: phpcs-config
@bin/phpcs -s -p ./src --standard=PHPCompatibility --runtime-set testVersion 5.4-7.3

View File

@ -1 +1 @@
4.1.2
4.1.3

View File

@ -32,7 +32,6 @@
},
"require-dev": {
"consolidation/robo": "~1.0",
"beyondit/opencart-test-suite": "~3.0",
"opencart/opencart": "3.0.2.0"
"phpcompatibility/php-compatibility": "^9.3"
}
}

View File

@ -278,7 +278,6 @@ class ControllerExtensionModuleRetailcrm extends Controller
'button_cancel',
'text_notice',
'retailcrm_title',
'retailcrm_apiversion',
'retailcrm_url',
'retailcrm_apikey',
'retailcrm_base_settings',
@ -358,9 +357,6 @@ class ControllerExtensionModuleRetailcrm extends Controller
$key = isset($_data['saved_settings'][$this->moduleTitle . '_apikey'])
? $_data['saved_settings'][$this->moduleTitle . '_apikey']
: null;
$apiVersion = isset($_data['saved_settings'][$this->moduleTitle . '_apiversion'])
? $_data['saved_settings'][$this->moduleTitle . '_apiversion']
: null;
if (!empty($url) && !empty($key)) {
@ -370,11 +366,8 @@ class ControllerExtensionModuleRetailcrm extends Controller
->getOrderStatuses();
$_data['payments'] = $this->model_extension_retailcrm_references
->getPaymentTypes();
if ($apiVersion == 'v5') {
$_data['customFields'] = $this->model_extension_retailcrm_references
->getCustomFields();
}
$_data['lenghts'] = $this->model_localisation_length_class->getLengthClasses();
$_data['priceTypes'] = $this->model_extension_retailcrm_references

View File

@ -20,7 +20,6 @@ $_['collector_tab_text'] = 'Daemon Collector';
$_['logs_tab_text'] = 'Logs';
$_['collector_custom_text'] = 'Configuration of form fields';
$_['custom_fields_tab_text'] = 'Custom fields';
$_['retailcrm_apiversion'] = 'API Version';
$_['retailcrm_url'] = 'URL of retailCRM';
$_['retailcrm_apikey'] = 'API key of retailCRM';
$_['corporate_enabled_label'] = 'Corporate customers support';

View File

@ -20,7 +20,6 @@ $_['collector_tab_text'] = 'Daemon Collector';
$_['logs_tab_text'] = 'Registro';
$_['collector_custom_text'] = 'Configurar campos de formulario';
$_['custom_fields_tab_text'] = 'Campos personalizados';
$_['retailcrm_apiversion'] = 'Versión de la API';
$_['retailcrm_url'] = 'Dirección del retailCRM';
$_['retailcrm_apikey'] = 'Clave de la API del retailCRM';
$_['corporate_enabled_label'] = 'Corporate customers support';

View File

@ -20,7 +20,6 @@ $_['consultant_tab_text'] = 'Online Consultant';
$_['logs_tab_text'] = 'Логи';
$_['collector_custom_text'] = 'Настройка полей формы';
$_['custom_fields_tab_text'] = 'Пользовательские поля';
$_['retailcrm_apiversion'] = 'Версия API';
$_['retailcrm_url'] = 'Адрес RetailCRM';
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
$_['corporate_enabled_label'] = 'Поддержка корпоративных клиентов';

View File

@ -60,10 +60,6 @@ class ModelExtensionRetailcrmPrices extends Model
$prices = array();
$site = $this->getSite($retailcrmApiClient);
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v3') {
return false;
}
foreach ($products as $product) {
$specials = $this->model_catalog_product->getProductSpecials($product['product_id']);

View File

@ -68,7 +68,7 @@ class ModelExtensionRetailcrmOrder extends Model {
$response = $retailcrmApiClient->ordersEdit($order);
}
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v5' && $response->isSuccessful()) {
if ($response->isSuccessful()) {
$this->updatePayment($order_payment, $order['externalId'], $retailcrmApiClient);
}
}
@ -169,17 +169,9 @@ class ModelExtensionRetailcrmOrder extends Model {
}
$order['createdAt'] = $order_data['date_added'];
if ($this->settings[$this->moduleTitle . '_apiversion'] != 'v5') {
$order['paymentType'] = $payment_code;
if ($couponTotal > 0) {
$order['discount'] = $couponTotal;
}
} else {
if ($couponTotal > 0) {
$order['discountManualAmount'] = $couponTotal;
}
}
$country = isset($order_data['shipping_country']) ? $order_data['shipping_country'] : '' ;
@ -245,7 +237,6 @@ class ModelExtensionRetailcrmOrder extends Model {
$offerId = implode('_', $offerId);
}
if ($this->settings[$this->moduleTitle . '_apiversion'] != 'v3') {
$item = array(
'offer' => array(
'externalId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
@ -270,14 +261,6 @@ class ModelExtensionRetailcrmOrder extends Model {
}
}
}
} else {
$item = array(
'productName' => $product['name'],
'initialPrice' => $product['price'],
'quantity' => $product['quantity'],
'productId' => !empty($offerId) ? $product['product_id'].'#'.$offerId : $product['product_id']
);
}
if (isset($properties)) $item['properties'] = $properties;

View File

@ -8,7 +8,7 @@
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
class CurlException extends RuntimeException
{

View File

@ -8,7 +8,7 @@
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
class InvalidJsonException extends DomainException
{

View File

@ -8,7 +8,7 @@
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
class RetailcrmApiResponse implements ArrayAccess
{

View File

@ -8,7 +8,7 @@
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
class RetailcrmHttpClient
{

View File

@ -229,7 +229,7 @@ class Order {
$product_id = $item['offer']['externalId'];
$options = array();
if (mb_strpos($item['offer']['externalId'], '#') > 1) {
if (mb_strpos($item['offer']['externalId'], '#', 0, mb_internal_encoding()) > 1) {
$offer = explode('#', $item['offer']['externalId']);
$product_id = $offer[0];
$options_from_crm = explode('_', $offer[1]);

View File

@ -18,8 +18,10 @@ class SettingsManager extends \retailcrm\Base {
}
public function getSetting($key) {
if (!empty($this->getSettings()[$this->retailcrm->getModuleTitle() . '_' . $key])) {
return $this->getSettings()[$this->retailcrm->getModuleTitle() . '_' . $key];
$settings = $this->getSettings();
if (!empty($settings[$this->retailcrm->getModuleTitle() . '_' . $key])) {
return $settings[$this->retailcrm->getModuleTitle() . '_' . $key];
}
return null;

View File

@ -52,11 +52,10 @@ class Retailcrm {
*
* @param string $apiUrl (default = null)
* @param string $apiKey (default = null)
* @param string $apiVersion (default = null)
*
* @return mixed object | boolean
*/
public function getApiClient($apiUrl = null, $apiKey = null, $apiVersion = null) {
public function getApiClient($apiUrl = null, $apiKey = null) {
if (!$this->registry->has('RetailcrmProxy')) {
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());