1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
request.php
См. документацию.
1<?
2
3namespace Bitrix\Seo\Retargeting;
4
5use Bitrix\Main\Error;
6use Bitrix\Main\SystemException;
7use Bitrix\Seo\Retargeting\Internals\ServiceLogTable;
8
13abstract class Request
14{
15 const TYPE_CODE = '';
16
18 protected $adapter;
19
21 protected $client;
22
24 protected $response;
25
27 protected $type;
28
30 protected $endpoint;
31
33 protected $useDirectQuery = false;
34
38 public function __construct()
39 {
40 $this->type = static::TYPE_CODE;
41
43 'socketTimeout' => 5
44 );
45 $this->client = new AdsHttpClient($options);
46 }
47
52 public function setUseDirectQuery($mode)
53 {
54 $this->useDirectQuery = $mode;
55 }
56
62 public function getAuthAdapter()
63 {
64 return $this->adapter;
65 }
66
74 {
75 $this->adapter = $adapter;
76 return $this;
77 }
78
84 public function getResponse()
85 {
86 return $this->response;
87 }
88
94 public function getClient()
95 {
96 return $this->client;
97 }
98
106 {
107 $this->client = $client;
108 return $this;
109 }
110
116 public function getEndpoint()
117 {
118 return $this->endpoint;
119 }
120
127 public static function create($type)
128 {
129 return Factory::create(get_called_class(), $type);
130 }
131
139 public function send(array $params = array())
140 {
141 if (!$this->adapter)
142 {
143 throw new SystemException('AuthAdapter not applied.');
144 }
145 $this->client = $this->client ?? new AdsHttpClient(['socketTimeout' => 5]);
146 $this->client->clearHeaders();
147
148 $response = Response::create($this->type);
149 $response->setRequest($this);
150 try
151 {
152 $data = $this->query($params);
153 $response->setResponseText($data);
154 $response->parse($data);
155 }
156 catch (\Exception $exception)
157 {
158 $response->addError(new Error($exception->getMessage(), $exception->getCode()));
159 }
160
161 if ($response->getErrorCollection()->count() > 0)
162 {
163 $errors = $response->getErrors();
164 foreach ($errors as $error)
165 {
166 if (!$error->getMessage())
167 {
168 continue;
169 }
170
171 ServiceLogTable::add(array(
172 'GROUP_ID' => 'retargeting',
173 'TYPE' => static::TYPE_CODE,
174 'CODE' => $error->getCode(),
175 'MESSAGE' => $error->getMessage()
176 ));
177 }
178 }
179
180
181 return $response;
182 }
183
184 public function getProxyUrl(): string
185 {
186 return '';
187 }
188
195 abstract public function query(array $params = array());
196
197 protected function directQuery(array $params = array())
198 {
199 return [];
200 }
201}
Определения error.php:15
Определения request.php:10
static create($object, $type, $parameters=null)
Определения factory.php:9
const TYPE_CODE
Определения request.php:15
static create($type)
Определения request.php:127
setUseDirectQuery($mode)
Определения request.php:52
send(array $params=array())
Определения request.php:139
directQuery(array $params=array())
Определения request.php:197
setAuthAdapter(AuthAdapter $adapter)
Определения request.php:73
setClient(AdsHttpClient $client)
Определения request.php:105
query(array $params=array())
static create($type)
Определения response.php:108
$options
Определения commerceml2.php:49
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$errors
Определения iblock_catalog_edit.php:74
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$response
Определения result.php:21
$error
Определения subscription_card_product.php:20