Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
jwtsender.php
1<?php
2
4
8
9abstract class JWTSender extends BaseSender
10{
11 abstract protected function obtainJWToken();
12
13 protected function createHttpClient()
14 {
15 $httpClient = new HttpClient(
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}
performRequest($action, array $parameters=[])
Definition jwtsender.php:30