1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
ApiClient.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\MessageService
;
4
5
use
Bitrix\Main\Config\Option
;
6
use
Bitrix\Main\Result
;
7
use
Bitrix\Main\Service\MicroService\BaseSender
;
8
9
class
ApiClient
extends
BaseSender
10
{
11
protected
const
SERVICE_ENDPOINT_OPTION
=
'service_endpoint'
;
12
protected
const
DEFAULT_ENDPOINT
=
'https://unc.bitrix24.tech'
;
13
protected
const
ENDPOINTS
= [
14
'ru'
=>
'https://unc.bitrix24.tech'
,
15
'en'
=>
'https://unc-eu.bitrix.info'
,
16
];
17
protected
const
RU_REGIONS
= [
'ru'
,
'by'
,
'kz'
,
'uz'
];
18
19
protected
$customEndpoint
;
20
21
public
function
__construct
(
string
$endpoint =
null
)
22
{
23
parent::__construct();
24
25
if
($endpoint)
26
{
27
$this->customEndpoint = $endpoint;
28
}
29
}
30
36
protected
function
getServiceUrl
(): string
37
{
38
return
$this->customEndpoint ?? $this::getDefaultEndpoint();
39
}
40
41
protected
static
function
getDefaultEndpoint
(): string
42
{
43
if
(defined(
'NOTIFICATIONS_ENDPOINT'
))
44
{
45
return \NOTIFICATIONS_ENDPOINT;
46
}
47
48
return
Option::get(
'notifications'
, static::SERVICE_ENDPOINT_OPTION, self::getCurrentEndpoint());
49
}
50
51
protected
static
function
getCurrentEndpoint
(): string
52
{
53
$region
=
\Bitrix\Main\Application::getInstance
()->getLicense()->getRegion() ??
'en'
;
54
55
if
(in_array(
$region
, static::RU_REGIONS))
56
{
57
return
self::ENDPOINTS[
'ru'
];
58
}
59
60
return
self::ENDPOINTS[
$region
] ?? self::ENDPOINTS[
'en'
];
61
}
62
63
public
function
listAutoTemplates
(
string
$langId =
''
):
Result
64
{
65
return
$this->
performRequest
(
66
"notificationservice.Template.listAuto"
,
67
[
68
'languageId'
=> $langId
69
]
70
);
71
}
72
}
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
Bitrix\Main\Config\Option
Определения
option.php:15
Bitrix\Main\ORM\Data\Result
Определения
result.php:16
Bitrix\Main\Service\MicroService\BaseSender
Определения
basesender.php:15
Bitrix\Main\Service\MicroService\BaseSender\performRequest
performRequest($action, array $parameters=[])
Определения
basesender.php:25
Bitrix\MessageService\ApiClient
Определения
ApiClient.php:10
Bitrix\MessageService\ApiClient\getServiceUrl
getServiceUrl()
Определения
ApiClient.php:36
Bitrix\MessageService\ApiClient\SERVICE_ENDPOINT_OPTION
const SERVICE_ENDPOINT_OPTION
Определения
ApiClient.php:11
Bitrix\MessageService\ApiClient\$customEndpoint
$customEndpoint
Определения
ApiClient.php:19
Bitrix\MessageService\ApiClient\__construct
__construct(string $endpoint=null)
Определения
ApiClient.php:21
Bitrix\MessageService\ApiClient\listAutoTemplates
listAutoTemplates(string $langId='')
Определения
ApiClient.php:63
Bitrix\MessageService\ApiClient\getCurrentEndpoint
static getCurrentEndpoint()
Определения
ApiClient.php:51
Bitrix\MessageService\ApiClient\DEFAULT_ENDPOINT
const DEFAULT_ENDPOINT
Определения
ApiClient.php:12
Bitrix\MessageService\ApiClient\ENDPOINTS
const ENDPOINTS
Определения
ApiClient.php:13
Bitrix\MessageService\ApiClient\RU_REGIONS
const RU_REGIONS
Определения
ApiClient.php:17
Bitrix\MessageService\ApiClient\getDefaultEndpoint
static getDefaultEndpoint()
Определения
ApiClient.php:41
$region
$region
Определения
.description.php:13
Bitrix\Bizproc\Result
Определения
DeviceResultHandler.php:3
Bitrix\MessageService
Определения
ApiClient.php:3
bitrix
modules
messageservice
lib
ApiClient.php
Создано системой
1.14.0