1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
request.php
См. документацию.
1<?php
2
3namespace Bitrix\Seo\Checkout;
4
5use Bitrix\Main\Error;
6use Bitrix\Main\SystemException;
7use Bitrix\Seo\Retargeting\Internals\ServiceLogTable;
8use Bitrix\Seo\Retargeting\AdsHttpClient;
9
14abstract class Request
15{
16 const TYPE_CODE = '';
17
19 protected $adapter;
20
22 protected $client;
23
25 protected $response;
26
28 protected $type;
29
33 public function __construct()
34 {
35 $this->type = static::TYPE_CODE;
36
38 'socketTimeout' => 5
39 );
40 $this->client = new AdsHttpClient($options);
41 }
42
48 public function getAuthAdapter()
49 {
50 return $this->adapter;
51 }
52
60 {
61 $this->adapter = $adapter;
62 return $this;
63 }
64
70 public function getResponse()
71 {
72 return $this->response;
73 }
74
80 public function getClient()
81 {
82 return $this->client;
83 }
84
92 {
93 $this->client = $client;
94 return $this;
95 }
96
104 public static function create($type)
105 {
106 return Factory::create(get_called_class(), $type);
107 }
108
116 public function send(array $params = array())
117 {
118 if (!$this->adapter)
119 {
120 throw new SystemException('AuthAdapter not applied.');
121 }
122
123 $options = [
124 'socketTimeout' => 5
125 ];
126 $this->client = new AdsHttpClient($options);
127
128 $data = $this->query($params);
129 $response = Response::create($this->type);
130 $response->setRequest($this);
131 $response->setResponseText($data);
132 try
133 {
134 $response->parse($data);
135 }
136 catch (\Exception $exception)
137 {
138 $response->addError(new Error($exception->getMessage(), $exception->getCode()));
139 }
140
141 if ($response->getErrorCollection()->count() > 0)
142 {
143 $errors = $response->getErrors();
144 foreach ($errors as $error)
145 {
146 if (!$error->getMessage())
147 {
148 continue;
149 }
150
151 ServiceLogTable::add(array(
152 'GROUP_ID' => 'checkout',
153 'TYPE' => static::TYPE_CODE,
154 'CODE' => $error->getCode(),
155 'MESSAGE' => $error->getMessage()
156 ));
157 }
158 }
159
160 return $response;
161 }
162
169 abstract public function query(array $params = array());
170}
Определения error.php:15
static create($object, $type, $parameters=null)
Определения factory.php:20
__construct()
Определения request.php:33
const TYPE_CODE
Определения request.php:16
static create($type)
Определения request.php:104
getClient()
Определения request.php:80
getResponse()
Определения request.php:70
getAuthAdapter()
Определения request.php:48
send(array $params=array())
Определения request.php:116
setAuthAdapter(AuthAdapter $adapter)
Определения request.php:59
setClient(AdsHttpClient $client)
Определения request.php:91
query(array $params=array())
static create($type)
Определения response.php:77
$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
$error
Определения subscription_card_product.php:20