Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
jwtsender.php
1
<?php
2
3
namespace
Bitrix\Main\Service\MicroService
;
4
5
use
Bitrix\Main\Result
;
6
use
Bitrix\Main\SystemException
;
7
use
Bitrix\Main\Web\HttpClient
;
8
9
abstract
class
JWTSender
extends
BaseSender
10
{
11
abstract
protected
function
obtainJWToken
();
12
13
protected
function
createHttpClient
()
14
{
15
$httpClient =
new
HttpClient
(
16
$this->
getHttpClientParameters
()
17
);
18
19
$token = $this->
obtainJWToken
();
20
21
if
(!$token)
22
{
23
throw
new
SystemException
(
'JWT Token must not be empty'
);
24
}
25
26
$httpClient->setHeader(
'Authorization'
,
'Bearer '
. $token);
27
return
$httpClient;
28
}
29
30
public
function
performRequest
($action, array $parameters = []):
Result
31
{
32
$url = $this->
getServiceUrl
() .
"/api/?action="
. $action;
33
$httpClient = $this->
createHttpClient
();
34
$result = $httpClient->query(
HttpClient::HTTP_POST
, $url, $parameters);
35
36
return
$this->createAnswer(
37
$result,
38
$httpClient->getResult(),
39
$httpClient->getError(),
40
$httpClient->getStatus()
41
);
42
}
43
}
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Main\Service\MicroService\BaseSender
Definition
basesender.php:15
Bitrix\Main\Service\MicroService\BaseSender\getServiceUrl
getServiceUrl()
Bitrix\Main\Service\MicroService\BaseSender\getHttpClientParameters
getHttpClientParameters()
Definition
basesender.php:116
Bitrix\Main\Service\MicroService\JWTSender
Definition
jwtsender.php:10
Bitrix\Main\Service\MicroService\JWTSender\createHttpClient
createHttpClient()
Definition
jwtsender.php:13
Bitrix\Main\Service\MicroService\JWTSender\performRequest
performRequest($action, array $parameters=[])
Definition
jwtsender.php:30
Bitrix\Main\Service\MicroService\JWTSender\obtainJWToken
obtainJWToken()
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Main\Web\HttpClient
Definition
httpclient.php:24
Bitrix\Main\Web\HttpClient\HTTP_POST
const HTTP_POST
Definition
httpclient.php:32
Bitrix\Main\Service\MicroService
Definition
basereceiver.php:3
modules
main
lib
service
microservice
jwtsender.php
Создано системой
1.10.0