Add send configuration method
This commit is contained in:
parent
5f80630806
commit
4e244d9791
@ -322,6 +322,49 @@ class RCrmActions
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function sendConfiguration($api, $api_version, $active = true)
|
||||
{
|
||||
$scheme = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
|
||||
$baseUrl = $scheme . $_SERVER['HTTP_HOST'];
|
||||
$integrationCode = 'bitrix';
|
||||
$logo = 'https://s3.eu-central-1.amazonaws.com/retailcrm-billing/images/5af47fe682bf2-1c-bitrix-logo.svg';
|
||||
$accountUrl = $baseUrl . '/bitrix/admin';
|
||||
|
||||
$clientId = COption::GetOptionString(self::$MODULE_ID, 'client_id', 0);
|
||||
|
||||
if (!$clientId) {
|
||||
$clientId = uniqid();
|
||||
COption::SetOptionString(self::$MODULE_ID, 'client_id', $clientId);
|
||||
}
|
||||
|
||||
$code = $integrationCode . '-' . $clientId;
|
||||
|
||||
if ($api_version == 'v4') {
|
||||
$configuration = array(
|
||||
'name' => GetMessage('API_MODULE_NAME'),
|
||||
'code' => $code,
|
||||
'logo' => $logo,
|
||||
'configurationUrl' => $accountUrl,
|
||||
'active' => $active
|
||||
);
|
||||
|
||||
self::apiMethod($api, 'marketplaceSettingsEdit', __METHOD__, $configuration);
|
||||
} else {
|
||||
$configuration = array(
|
||||
'clientId' => $clientId,
|
||||
'code' => $code,
|
||||
'integrationCode' => $integrationCode,
|
||||
'active' => $active,
|
||||
'name' => GetMessage('API_MODULE_NAME'),
|
||||
'logo' => $logo,
|
||||
'baseUrl' => $baseUrl,
|
||||
'accountUrl' => $accountUrl
|
||||
);
|
||||
|
||||
self::apiMethod($api, 'integrationModulesEdit', __METHOD__, $configuration);
|
||||
}
|
||||
}
|
||||
|
||||
public static function apiMethod($api, $methodApi, $method, $params, $site = null)
|
||||
{
|
||||
switch ($methodApi) {
|
||||
|
@ -1046,46 +1046,8 @@ class intaro_retailcrm extends CModule
|
||||
$api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
|
||||
$api_version = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, 0);
|
||||
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key);
|
||||
$scheme = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
|
||||
$baseUrl = $scheme . $_SERVER['HTTP_HOST'];
|
||||
$code = 'bitrix';
|
||||
$logo = 'https://s3.eu-central-1.amazonaws.com/retailcrm-billing/images/5af47fe682bf2-1c-bitrix-logo.svg';
|
||||
$accountUrl = $baseUrl . '/bitrix/admin/settings.php?mid=intaro.retailcrm';
|
||||
|
||||
try {
|
||||
if ($api_version == 'v4') {
|
||||
$configuration = array(
|
||||
'name' => GetMessage('API_MODULE_NAME'),
|
||||
'code' => $code,
|
||||
'logo' => $logo,
|
||||
'configurationUrl' => $accountUrl,
|
||||
'active' => true
|
||||
);
|
||||
|
||||
$this->RETAIL_CRM_API->marketplaceSettingsEdit($configuration);
|
||||
} else {
|
||||
$clientId = hash('md5', date('Y-m-d H:i:s'));
|
||||
|
||||
$configuration = array(
|
||||
'clientId' => $clientId,
|
||||
'code' => $code,
|
||||
'integrationCode' => $code,
|
||||
'active' => true,
|
||||
'name' => GetMessage('API_MODULE_NAME'),
|
||||
'logo' => $logo,
|
||||
'baseUrl' => $baseUrl,
|
||||
'accountUrl' => $accountUrl
|
||||
);
|
||||
|
||||
$this->RETAIL_CRM_API->integrationModulesEdit($configuration);
|
||||
COption::SetOptionString($this->MODULE_ID, $this->CLIENT_ID, $clientId);
|
||||
}
|
||||
} catch (\RetailCrm\Exception\CurlException $e) {
|
||||
RCrmActions::eventLog(
|
||||
'intaro.retailcrm/install/index.php', 'RetailCrm\ApiClient::statisticUpdate::CurlException',
|
||||
$e->getCode() . ': ' . $e->getMessage()
|
||||
);
|
||||
}
|
||||
RCrmActions::sendConfiguration($this->RETAIL_CRM_API, $api_version);
|
||||
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step6.php'
|
||||
@ -1100,7 +1062,6 @@ class intaro_retailcrm extends CModule
|
||||
$api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0);
|
||||
$api_version = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, 0);
|
||||
$clientId = COption::GetOptionString($this->MODULE_ID, $this->CLIENT_ID, 0);
|
||||
|
||||
include($this->INSTALL_PATH . '/../classes/general/Http/Client.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/Response/ApiResponse.php');
|
||||
@ -1119,13 +1080,6 @@ class intaro_retailcrm extends CModule
|
||||
|
||||
$retail_crm_api = new \RetailCrm\ApiClient($api_host, $api_key);
|
||||
|
||||
$configuration = array(
|
||||
'clientId' => $clientId,
|
||||
'code' => 'bitrix',
|
||||
'integrationCode' => 'bitrix',
|
||||
'active' => false,
|
||||
);
|
||||
|
||||
CAgent::RemoveAgent("RCrmActions::orderAgent();", $this->MODULE_ID);
|
||||
CAgent::RemoveAgent("RetailCrmInventories::inventoriesUpload();", $this->MODULE_ID);
|
||||
CAgent::RemoveAgent("RetailCrmPrices::pricesUpload();", $this->MODULE_ID);
|
||||
@ -1196,13 +1150,7 @@ class intaro_retailcrm extends CModule
|
||||
}
|
||||
}
|
||||
|
||||
if ($api_version == 'v4') {
|
||||
unset($configuration['integrationCode']);
|
||||
unset($configuration['clientId']);
|
||||
$retail_crm_api->marketplaceSettingsEdit($configuration);
|
||||
} else {
|
||||
$retail_crm_api->integrationModulesEdit($configuration);
|
||||
}
|
||||
RCrmActions::sendConfiguration($retail_crm_api, $api_version, false);
|
||||
|
||||
$this->DeleteFiles();
|
||||
|
||||
|
2
intaro.retailcrm/lang/ru/classes/general/RCrmActions.php
Normal file
2
intaro.retailcrm/lang/ru/classes/general/RCrmActions.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$MESS ['API_MODULE_NAME'] = '1С-Битрикс';
|
@ -13,7 +13,6 @@ $MESS ['RETAILCRM_CURL_ERR'] = 'Для работы модуля интегра
|
||||
$MESS ['ERR_ARTICLE_IBLOCK'] = 'Не установлены артикулы';
|
||||
$MESS ['DATE_TIMEZONE_ERR'] = 'Не указана временная зона в настройках php.';
|
||||
$MESS ['SALE_VERSION_ERR'] = 'Версия модуля \'Интернет-магазин\' должна быть выше 16.';
|
||||
$MESS ['API_MODULE_NAME'] = '1С-Битрикс';
|
||||
/*
|
||||
$MESS ['ORDER_PROPS'] = 'Настройки соответствия полей заказа retailCRM свойствам заказа 1С-Битрикс';
|
||||
$MESS ['FIO'] = 'Ф.И.О.';
|
||||
|
Loading…
Reference in New Issue
Block a user