16 return $this->getFieldsInfoItem() + $this->getCustomProductFieldsInfo();
21 return $this->getFieldsInfoItem() + $this->getFieldsInfoCatalogProduct();
24 private function getFieldsInfoItem()
28 'TYPE'=>self::TYPE_STRING,
30 Attributes::Immutable,
35 'TYPE'=>self::TYPE_STRING,
36 'ATTRIBUTES'=>[Attributes::ReadOnly]
39 'TYPE'=>self::TYPE_INT,
40 'ATTRIBUTES'=>[Attributes::ReadOnly]
43 'TYPE'=>self::TYPE_STRING,
44 'ATTRIBUTES'=>[Attributes::ReadOnly]
47 'TYPE'=>self::TYPE_INT
50 'TYPE'=>self::TYPE_INT,
52 Attributes::Immutable,
57 'TYPE'=>self::TYPE_FLOAT
60 'TYPE'=>self::TYPE_CHAR,
61 'ATTRIBUTES'=>[Attributes::ReadOnly]
64 'TYPE'=>self::TYPE_STRING,
71 'TYPE'=>self::TYPE_FLOAT,
72 'ATTRIBUTES'=>[Attributes::Required]
75 'TYPE'=>self::TYPE_CHAR
78 'TYPE'=>self::TYPE_STRING
81 'TYPE'=>self::TYPE_STRING
84 'TYPE'=>self::TYPE_DATETIME,
85 'ATTRIBUTES'=>[Attributes::ReadOnly]
88 'TYPE'=>self::TYPE_DATETIME,
89 'ATTRIBUTES'=>[Attributes::ReadOnly]
92 'TYPE'=>self::TYPE_DATETIME,
93 'ATTRIBUTES'=>[Attributes::ReadOnly],
96 'TYPE'=>self::TYPE_LIST,
97 'ATTRIBUTES'=>[Attributes::Hidden]
102 private function getFieldsInfoCatalogProduct()
106 'TYPE'=>self::TYPE_STRING,
107 'ATTRIBUTES'=>[Attributes::ReadOnly]
109 'PRODUCT_PRICE_ID'=>[
110 'TYPE'=>self::TYPE_INT,
111 'ATTRIBUTES'=>[Attributes::ReadOnly]
114 'TYPE'=>self::TYPE_INT,
115 'ATTRIBUTES'=>[Attributes::ReadOnly]
118 'TYPE'=>self::TYPE_STRING,
119 'ATTRIBUTES'=>[Attributes::ReadOnly]
122 'TYPE'=>self::TYPE_FLOAT,
123 'ATTRIBUTES'=>[Attributes::ReadOnly]
126 'TYPE'=>self::TYPE_FLOAT,
127 'ATTRIBUTES'=>[Attributes::ReadOnly]
130 'TYPE'=>self::TYPE_FLOAT,
131 'ATTRIBUTES'=>[Attributes::ReadOnly]
134 'TYPE'=>self::TYPE_STRING,
135 'ATTRIBUTES'=>[Attributes::ReadOnly]
138 'TYPE'=>self::TYPE_STRING,
139 'ATTRIBUTES'=>[Attributes::ReadOnly]
142 'TYPE'=>self::TYPE_STRING,
143 'ATTRIBUTES'=>[Attributes::ReadOnly]
146 'TYPE'=>self::TYPE_CHAR,
147 'ATTRIBUTES'=>[Attributes::ReadOnly]
150 'TYPE'=>self::TYPE_STRING,
151 'ATTRIBUTES'=>[Attributes::ReadOnly]
154 'TYPE'=>self::TYPE_FLOAT,
155 'ATTRIBUTES'=>[Attributes::ReadOnly]
158 'TYPE'=>self::TYPE_CHAR,
159 'ATTRIBUTES'=>[Attributes::ReadOnly]
162 'TYPE'=>self::TYPE_CHAR,
163 'ATTRIBUTES'=>[Attributes::ReadOnly]
166 'TYPE'=>self::TYPE_STRING,
167 'ATTRIBUTES'=>[Attributes::ReadOnly]
170 'TYPE'=>self::TYPE_STRING,
171 'ATTRIBUTES'=>[Attributes::ReadOnly]
174 'TYPE'=>self::TYPE_STRING,
175 'ATTRIBUTES'=>[Attributes::ReadOnly]
178 'TYPE'=>self::TYPE_STRING,
179 'ATTRIBUTES'=>[Attributes::ReadOnly]
182 'TYPE'=>self::TYPE_STRING,
183 'ATTRIBUTES'=>[Attributes::ReadOnly]
186 'TYPE'=>self::TYPE_STRING,
187 'ATTRIBUTES'=>[Attributes::ReadOnly]
190 'TYPE'=>self::TYPE_STRING,
191 'ATTRIBUTES'=>[Attributes::ReadOnly]
193 'PRODUCT_PROVIDER_CLASS'=>[
194 'TYPE'=>self::TYPE_STRING,
195 'ATTRIBUTES'=>[Attributes::ReadOnly]
198 'TYPE'=>self::TYPE_STRING,
199 'ATTRIBUTES'=>[Attributes::ReadOnly]
204 private function getCustomProductFieldsInfo()
208 'TYPE'=>self::TYPE_STRING
210 'PRODUCT_PRICE_ID'=>[
211 'TYPE'=>self::TYPE_INT
214 'TYPE'=>self::TYPE_INT
217 'TYPE'=>self::TYPE_STRING
220 'TYPE'=>self::TYPE_FLOAT
223 'TYPE'=>self::TYPE_FLOAT
226 'TYPE'=>self::TYPE_FLOAT
229 'TYPE'=>self::TYPE_STRING
232 'TYPE'=>self::TYPE_STRING
235 'TYPE'=>self::TYPE_STRING
238 'TYPE'=>self::TYPE_CHAR
241 'TYPE'=>self::TYPE_STRING
244 'TYPE'=>self::TYPE_FLOAT
247 'TYPE'=>self::TYPE_CHAR
250 'TYPE'=>self::TYPE_CHAR
253 'TYPE'=>self::TYPE_STRING
256 'TYPE'=>self::TYPE_STRING
259 'TYPE'=>self::TYPE_STRING
262 'TYPE'=>self::TYPE_STRING
265 'TYPE'=>self::TYPE_STRING
268 'TYPE'=>self::TYPE_STRING,
269 'ATTRIBUTES'=>[Attributes::Immutable]
272 'TYPE'=>self::TYPE_STRING,
273 'ATTRIBUTES'=>[Attributes::Immutable]
275 'PRODUCT_PROVIDER_CLASS'=>[
276 'TYPE'=>self::TYPE_STRING,
277 'ATTRIBUTES'=>[Attributes::Immutable]
280 'TYPE'=>self::TYPE_STRING,
281 'ATTRIBUTES'=>[Attributes::Immutable]
288 if($name ==
'getfieldscatalogproduct'){}
289 elseif ($name ==
'addcatalogproduct'
290 || $name ==
'updatecatalogproduct'
291 || $name ==
'modifycatalogproduct')
293 if(isset($arguments[
'fields']))
295 $fields = $arguments[
'fields'];
302 $arguments = parent::convertKeysToSnakeCaseArguments($name, $arguments);
312 if($name ==
'getfieldscatalogproduct'){}
313 elseif($name ==
'addcatalogproduct')
315 $fields = $arguments[
'fields'];
321 if(!$required->isSuccess())
322 $r->addError(
new Error(
'Required fields: '.implode(
', ', $required->getErrorMessages())));
325 elseif($name ==
'updatecatalogproduct')
327 $fields = $arguments[
'fields'];
333 if(!$required->isSuccess())
334 $r->addError(
new Error(
'Required fields: '.implode(
', ', $required->getErrorMessages())));
339 $r = parent::checkArguments($name, $arguments);
348 || $name ==
'getbaseprice'
349 || $name ==
'getbasepricewithvat'
350 || $name ==
'getcurrency'
351 || $name ==
'getdefaultprice'
352 || $name ==
'getdiscountprice'
353 || $name ==
'getfinalprice'
354 || $name ==
'getinitialprice'
355 || $name ==
'getprice'
356 || $name ==
'getpricewithvat'
357 || $name ==
'getproductid'
358 || $name ==
'getquantity'
359 || $name ==
'getreservedquantity'
361 || $name ==
'getvatrate'
362 || $name ==
'getweight'
363 || $name ==
'isbarcodemulti'
364 || $name ==
'iscustommulti'
365 || $name ==
'iscustomprice'
366 || $name ==
'isdelay'
367 || $name ==
'isvatinprice'
368 || $name ==
'getfieldscatalogproduct'
370 elseif($name ==
'addcatalogproduct')
372 $fields = $arguments[
'fields'];
380 elseif($name ==
'updatecatalogproduct')
382 $fields = $arguments[
'fields'];
390 elseif($name ==
'modifycatalogproduct'){}
393 parent::internalizeArguments($name, $arguments);
401 if($name ==
'getfieldscatalogproduct'){}
402 elseif($name ==
'addcatalogproduct'
403 || $name ==
'updatecatalogproduct')
409 parent::externalizeResult($name, $fields);
417 if(isset($fields[
'ID']) ===
false)
423 return BasketBuilderRest::isBasketItemNew($fields[
'ID']);
432 $fieldsInfo = empty($fieldsInfo)? $this->
getFields():$fieldsInfo;
433 $listFieldsInfoAdd = $this->
getListFieldInfo($fieldsInfo, [
'filter'=>[
'ignoredAttributes'=>[Attributes::Hidden, Attributes::ReadOnly],
'ignoredFields'=>[
'ORDER_ID']]]);
434 $listFieldsInfoUpdate = $this->
getListFieldInfo($fieldsInfo, [
'filter'=>[
'ignoredAttributes'=>[Attributes::Hidden, Attributes::ReadOnly, Attributes::Immutable],
'skipFields'=>[
'ID']]]);
436 if(isset($fields[
'ORDER'][
'ID']))
437 $result[
'ORDER'][
'ID'] = (int)$fields[
'ORDER'][
'ID'];
439 if(isset($fields[
'ORDER'][
'BASKET_ITEMS']))
441 foreach ($fields[
'ORDER'][
'BASKET_ITEMS'] as $k=>$item)
444 $this->
isNewItem($item)? $listFieldsInfoAdd:$listFieldsInfoUpdate
448 if($this->
isNewItem($item) && isset($item[
'ID']))
449 $result[
'ORDER'][
'BASKET_ITEMS'][$k][
'ID'] = $item[
'ID'];
451 if(isset($item[
'PROPERTIES']))
453 $result[
'ORDER'][
'BASKET_ITEMS'][$k][
'PROPERTIES'] = $basketProperties->internalizeFieldsModify([
'BASKET_ITEM'=>[
'PROPERTIES'=>$item[
'PROPERTIES']]])[
'BASKET_ITEM'][
'PROPERTIES'];
463 $basketProperties = new \Bitrix\Sale\Rest\Entity\BasketProperties();
465 $result = parent::externalizeFields($fields);
467 if(isset($fields[
'PROPERTIES']))
468 $result[
'PROPERTIES'] = $basketProperties->externalizeListFields($fields[
'PROPERTIES']);
483 if(!isset($fields[
'ORDER'][
'ID']))
485 $emptyFields[] =
'[order][id]';
487 if(!isset($fields[
'ORDER'][
'BASKET_ITEMS']) || !is_array($fields[
'ORDER'][
'BASKET_ITEMS']))
489 $emptyFields[] =
'[order][basketItems][]';
492 if(count($emptyFields)>0)
494 $r->addError(
new Error(
'Required fields: '.implode(
', ', $emptyFields)));
498 $r = parent::checkFieldsModify($fields);
510 $listFieldsInfoAdd = $this->
getListFieldInfo($this->
getFields(), [
'filter'=>[
'ignoredAttributes'=>[Attributes::Hidden, Attributes::ReadOnly],
'ignoredFields'=>[
'ORDER_ID']]]);
511 $listFieldsInfoUpdate = $this->
getListFieldInfo($this->
getFields(), [
'filter'=>[
'ignoredAttributes'=>[Attributes::Hidden, Attributes::ReadOnly, Attributes::Immutable]]]);
513 foreach ($fields[
'ORDER'][
'BASKET_ITEMS'] as $k=>$item)
516 $this->
isNewItem($item)? $listFieldsInfoAdd:$listFieldsInfoUpdate
518 if(!$required->isSuccess())
520 $r->addError(
new Error(
'[basketItems]['.$k.
'] - '.implode(
', ', $required->getErrorMessages()).
'.'));
523 if(isset($item[
'PROPERTIES']))
525 $requiredProperties = $basketProperties->checkRequiredFieldsModify([
'BASKET_ITEM'=>[
'PROPERTIES'=>$item[
'PROPERTIES']]]);
526 if(!$requiredProperties->isSuccess())
528 $requiredPropertiesFields = [];
529 foreach ($requiredProperties->getErrorMessages() as $errorMessage)
531 $requiredPropertiesFields[] =
'[basketItems]['.$k.
']'.$errorMessage;
533 $r->addError(
new Error(implode(
' ', $requiredPropertiesFields)));
externalizeListFields($list)
getListFieldInfo(array $fieldsInfo, $params=[])
internalizeFields($fields, array $fieldsInfo)
convertKeysToSnakeCaseFields($fields)
checkRequiredFields($fields, array $fieldsInfo, $params=[])
externalizeFields($fields)
getFieldsCatalogProduct()
internalizeArguments($name, $arguments)
checkFieldsModify($fields)
externalizeFieldsModify($fields)
convertKeysToSnakeCaseArguments($name, $arguments)
checkArguments($name, $arguments)
internalizeFieldsModify($fields, $fieldsInfo=[])
externalizeResult($name, $fields)
checkRequiredFieldsModify($fields)