Добавлена отправка запроса на активацию модуля в маркетплейсе при установке, и на деактивацию при удалении
This commit is contained in:
parent
69f9cd2219
commit
24ee93d335
@ -1483,6 +1483,7 @@ class ApiClient
|
||||
Client::METHOD_GET
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit module configuration
|
||||
*
|
||||
|
@ -69,6 +69,8 @@ class intaro_retailcrm extends CModule
|
||||
var $CRM_API_VERSION = 'api_version';
|
||||
var $HISTORY_TIME = 'history_time';
|
||||
|
||||
var $CLIENT_ID = 'client_id';
|
||||
|
||||
var $INSTALL_PATH;
|
||||
|
||||
function intaro_retailcrm()
|
||||
@ -1042,9 +1044,27 @@ 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);
|
||||
$this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key);
|
||||
$clientId = hash('md5', date('Y-m-d H:i:s'));
|
||||
|
||||
try {
|
||||
$this->RETAIL_CRM_API->statisticUpdate();
|
||||
$configuration = array(
|
||||
'clientId' => $clientId,
|
||||
'code' => 'bitrix',
|
||||
'integrationCode' => 'bitrix',
|
||||
'active' => true,
|
||||
'name' => GetMessage('API_MODULE_NAME'),
|
||||
'logo' => 'https://s3.eu-central-1.amazonaws.com/retailcrm-billing/images/5af47fe682bf2-1c-bitrix-logo.svg'
|
||||
);
|
||||
|
||||
if ($api_version == 'v4') {
|
||||
$this->RETAIL_CRM_API->marketplaceSettingsEdit($configuration);
|
||||
} else {
|
||||
$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',
|
||||
@ -1062,6 +1082,35 @@ class intaro_retailcrm extends CModule
|
||||
{
|
||||
global $APPLICATION;
|
||||
|
||||
$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');
|
||||
include($this->INSTALL_PATH . '/../classes/general/Exception/InvalidJsonException.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/Exception/CurlException.php');
|
||||
|
||||
if ($api_version == 'v4') {
|
||||
include($this->INSTALL_PATH . '/../classes/general/ApiClient_v4.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/order/RetailCrmOrder_v4.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/history/RetailCrmHistory_v4.php');
|
||||
} elseif ($api_version == 'v5') {
|
||||
include($this->INSTALL_PATH . '/../classes/general/ApiClient_v5.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/order/RetailCrmOrder_v5.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/history/RetailCrmHistory_v5.php');
|
||||
}
|
||||
|
||||
$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);
|
||||
@ -1108,6 +1157,7 @@ class intaro_retailcrm extends CModule
|
||||
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CRM_API_VERSION);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->HISTORY_TIME);
|
||||
COption::RemoveOption($this->MODULE_ID, $this->CLIENT_ID);
|
||||
|
||||
UnRegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "RetailCrmEvent", "onUpdateOrder");
|
||||
UnRegisterModuleDependences("main", "OnAfterUserUpdate", $this->MODULE_ID, "RetailCrmEvent", "OnAfterUserUpdate");
|
||||
@ -1131,12 +1181,18 @@ class intaro_retailcrm extends CModule
|
||||
}
|
||||
}
|
||||
|
||||
if ($api_version == 'v4') {
|
||||
$retail_crm_api->marketplaceSettingsEdit($configuration);
|
||||
} else {
|
||||
$retail_crm_api->integrationModulesEdit($configuration);
|
||||
}
|
||||
|
||||
$this->DeleteFiles();
|
||||
|
||||
UnRegisterModule($this->MODULE_ID);
|
||||
|
||||
$APPLICATION->IncludeAdminFile(
|
||||
GetMessage('MODULE_UNINSTALL_TITLE'), $this->INSTALL_PATH . '/unstep1.php'
|
||||
GetMessage('MODULE_UNINSTALL_TITLE'), $this->INSTALL_PATH . '/unstep1.php'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ $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