1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ApiClient.php
См. документацию.
1<?php
2
4
8
9class 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}
static getInstance()
Определения application.php:98
performRequest($action, array $parameters=[])
Определения basesender.php:25
const SERVICE_ENDPOINT_OPTION
Определения ApiClient.php:11
__construct(string $endpoint=null)
Определения ApiClient.php:21
listAutoTemplates(string $langId='')
Определения ApiClient.php:63
static getCurrentEndpoint()
Определения ApiClient.php:51
const DEFAULT_ENDPOINT
Определения ApiClient.php:12
const ENDPOINTS
Определения ApiClient.php:13
const RU_REGIONS
Определения ApiClient.php:17
static getDefaultEndpoint()
Определения ApiClient.php:41
$region
Определения .description.php:13