1
0
Fork 0
mirror of synced 2025-04-20 01:21:01 +00:00

New module structure (refactoring)

* simple serializer and deserializer with models, new architecture
* move logic to strategies
* datetime strategy, some changes in order to make subtype parsing possible
* fallback to array casting for internal objects
* serializer now supports typed arrays and formatted DateTime
* models, prevent hangup from circular serialization of empty entities, improve compatibility with JMS Serializer (to simplify usage), (de)serialization callbacks
* fuser repository & correct annotations
* correct naming for proxy
* move several helper methods to the new structure
* customizable customer building
* more models, api corporate customer builder & bitrix customer builder
* AbstractApiModel shoudn't implement Traversable
* check if user exists in the order before building corporate customer
* don't check _rc cookie; it's untestable for now
* better structure + service locator, cookie extraction should be testable now
* enable forgotten domaincollector cookie extraction
* partial api client facade implementation (full implementation is not necessary for now)
* remove unimportant assert in tests, move utils to service
* move identifierspair to correct directory
* move CookieExtractor assert to a single test
* more models & ClientAdapter
* fix DateTimeConverter test compatibility with lower php versions
* update test date format
* finish customer-related methods in the client facade, fixes in models
* minor tweaks for (de)serializer, compatibility layer for models which implement types without full functionality
* make model's getters nullable
* better logic for AbstractSerializableModel
* different logic for AbstractSerializableModel
* ability to create filled AbstractSerializableModel by passing primary key value
* reuse logic from repositories for passing primary as constructor parameter for AbstractSerializableModel
This commit is contained in:
Pavel 2020-08-07 12:38:53 +03:00 committed by GitHub
parent 1451d0c230
commit 48c92c3e2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
156 changed files with 15548 additions and 783 deletions

View file

@ -32,17 +32,12 @@ script: make test
jobs:
include:
- php: 7.0
env: NOT_USE_VENDOR=1 BITRIX_EDITION=small_business_encode
after_success: bash <(curl -s https://codecov.io/bash)
- php: 7.1
env: BITRIX_EDITION=small_business_encode
- php: 7.2
env: BITRIX_EDITION=small_business_encode
- php: 7.3
env: BITRIX_EDITION=small_business_encode
- php: 7.0
env: NOT_USE_VENDOR=1 BITRIX_EDITION=business_encode
- php: 7.1
env: BITRIX_EDITION=business_encode
- php: 7.2

View file

@ -2,8 +2,7 @@
"name": "retailcrm/bitrix-module",
"scripts": {
"pre-module-install": "cp -R intaro.retailcrm $BITRIX_PATH/bitrix/modules",
"tests": "php vendor/bin/phpunit -c phpunit.xml.dist --whitelist=$BITRIX_PATH/bitrix/modules/intaro.retailcrm",
"tests7": "phpunit -c phpunit.xml.dist --whitelist=$BITRIX_PATH/bitrix/modules/intaro.retailcrm"
"tests": "php vendor/bin/phpunit -c phpunit.xml.dist --whitelist=$BITRIX_PATH/bitrix/modules/intaro.retailcrm"
},
"description": "Integration module for Bitrix & RetailCRM",
"type": "bitrix-module",
@ -15,7 +14,8 @@
],
"require": {
"ext-json": "*",
"ext-mbstring": "*"
"ext-mbstring": "*",
"ext-tokenizer": "*"
},
"require-dev": {
"phpunit/phpunit": "^7",

View file

@ -0,0 +1,307 @@
<?php
/**
* Class RetailcrmClasspathBuilder.
* Builds classpath for Bitrix autoloader. Contains some hardcoded things, which will go away when everything refactored.
*/
class RetailcrmClasspathBuilder
{
/**
* File extension as a string. Defaults to ".php".
* @var string
*/
protected $fileExt = 'php';
/**
* @var string $moduleId
*/
protected $moduleId = 'intaro.retailcrm';
/**
* The topmost directory where recursion should begin. Default: `classes/general`. Relative to the __DIR__.
* @var string
*/
protected $path = 'classes/general';
/**
* Do not include directory paths as namespaces.
* @var bool
*/
protected $disableNamespaces;
/**
* Bitrix document root
* @var string
*/
protected $documentRoot;
/**
* @var string
*/
protected $version;
/**
* @var array $result
*/
protected $result = [];
/**
* @var array $notIncluded
*/
protected $notIncluded = [];
/**
* These classes can be customized, in which case they would be replaced with files from
* directory <root>/bitrix/php_interface/retailcrm
*
* Array format:
* [
* 'class path with namespace' => 'file name'
* ]
*/
protected static $customizableClasses = [
'RestNormalizer' => 'RestNormalizer.php',
'Logger' => 'Logger.php',
'RetailCrm\ApiClient' => 'ApiClient_v5.php',
'RetailCrm\Http\Client' => 'Client.php',
'RCrmActions' => 'RCrmActions.php',
'RetailCrmUser' => 'RetailCrmUser.php',
'RetailCrmICML' => 'RetailCrmICML.php',
'RetailCrmInventories' => 'RetailCrmInventories.php',
'RetailCrmPrices' => 'RetailCrmPrices.php',
'RetailCrmCollector' => 'RetailCrmCollector.php',
'RetailCrmUa' => 'RetailCrmUa.php',
'RetailCrmEvent' => 'RetailCrmEvent.php',
'RetailCrmCorporateClient' => 'RetailCrmCorporateClient.php'
];
/**
* These classes can be customized, in which case they would be replaced with files from
* directory <root>/bitrix/php_interface/retailcrm
* Customized versions have fixed name, and original versions name depends on API version
*
* Array format:
* [
* 'class path with namespace' => ['customized file name', 'original file name with %s for API version']
* ]
*/
protected static $versionedClasses = [
'RetailCrm\ApiClient' => ['ApiClient.php', 'ApiClient_%s.php'],
'RetailCrmOrder' => ['RetailCrmOrder.php', 'RetailCrmOrder_%s.php'],
'RetailCrmHistory' => ['RetailCrmHistory.php', 'RetailCrmHistory_%s.php']
];
/**
* These classes will be ignored while loading from original files
*/
protected static $ignoredClasses = [
'ApiClient_v4.php',
'ApiClient_v5.php',
'RetailCrmOrder_v4.php',
'RetailCrmOrder_v5.php',
'RetailCrmHistory_v4.php',
'RetailCrmHistory_v5.php',
];
/**
* These namespaces are hardcoded.
*/
protected static $hardcodedNamespaces = [
'RetailCrm\Response\ApiResponse' => 'ApiResponse.php',
'RetailCrm\Exception\InvalidJsonException' => 'InvalidJsonException.php',
'RetailCrm\Exception\CurlException' => 'CurlException.php'
];
protected function buildCustomizableClasspath()
{
foreach (static::$customizableClasses as $className => $fileName) {
$customizedFile = $this->documentRoot . '/bitrix/php_interface/retailcrm/' . $fileName;
if (file_exists($customizedFile)) {
$this->result[$className] = $customizedFile;
} else {
$this->notIncluded[$className] = $fileName;
}
}
}
protected function buildVersionedClasspath()
{
foreach (static::$versionedClasses as $className => $fileNames) {
$customizedFile = $this->documentRoot . '/bitrix/php_interface/retailcrm/' . $fileNames[0];
if (file_exists($customizedFile)) {
$this->result[$className] = $customizedFile;
} else {
$this->notIncluded[$className] = sprintf($fileNames[1], $this->version);
}
}
}
/**
* Traverse through directories, build include paths
* @return $this
*/
public function build(): self
{
$directory = new RecursiveDirectoryIterator(
$this->getSearchPath(),
RecursiveDirectoryIterator::SKIP_DOTS
);
$fileIterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::LEAVES_ONLY);
$this->buildCustomizableClasspath();
$this->buildVersionedClasspath();
$notIncludedClasses = array_flip($this->notIncluded);
$hardcodedNamespaces = array_flip(static::$hardcodedNamespaces);
/** @var \SplFileObject $file */
foreach ($fileIterator as $file) {
$fileNameWithoutExt = str_ireplace('.' . $this->fileExt, '', $file->getFilename());
if ($file->getExtension() !== $this->fileExt) {
continue;
}
if (in_array($file->getFilename(), static::$customizableClasses)
|| in_array($file->getFilename(), static::$ignoredClasses)
) {
if (in_array($file->getFilename(), $this->notIncluded)) {
$this->result[$notIncludedClasses[$file->getFilename()]] = $this->getImportPath($file->getPathname());
}
continue;
}
if (in_array($file->getFilename(), static::$hardcodedNamespaces)) {
$this->result[$hardcodedNamespaces[$file->getFilename()]] = $this->getImportPath($file->getPathname());
} else {
$this->result[$this->getImportClass($fileNameWithoutExt, $file->getPath())] = $this->getImportPath($file->getPathname());
}
}
return $this;
}
/**
* Sets the $fileExt property
*
* @param string $fileExt The file extension used for class files. Default is "php".
*
* @return \RetailcrmClasspathBuilder
*/
public function setFileExt($fileExt)
{
$this->fileExt = $fileExt;
return $this;
}
/**
* @param string $documentRoot
*
* @return RetailcrmClasspathBuilder
*/
public function setDocumentRoot(string $documentRoot): RetailcrmClasspathBuilder
{
$this->documentRoot = $documentRoot;
return $this;
}
/**
* Sets the $path property
*
* @param string $path Top path to load files
*
* @return \RetailcrmClasspathBuilder
*/
public function setPath(string $path)
{
$this->path = $path;
return $this;
}
/**
* @param mixed $disableNamespaces
*
* @return RetailcrmClasspathBuilder
*/
public function setDisableNamespaces($disableNamespaces)
{
$this->disableNamespaces = $disableNamespaces;
return $this;
}
/**
* @param string $moduleId
*
* @return RetailcrmClasspathBuilder
*/
public function setModuleId(string $moduleId): RetailcrmClasspathBuilder
{
$this->moduleId = $moduleId;
return $this;
}
/**
* @param string $version
*
* @return RetailcrmClasspathBuilder
*/
public function setVersion(string $version): RetailcrmClasspathBuilder
{
$this->version = $version;
return $this;
}
/**
* @return array
*/
public function getResult(): array
{
return $this->result;
}
/**
* @return string
*/
protected function getSearchPath(): string
{
return __DIR__ . DIRECTORY_SEPARATOR . $this->path;
}
/**
* @param string $filePath
*
* @return string
*/
protected function getImportPath(string $filePath): string
{
return (string) str_ireplace(implode(DIRECTORY_SEPARATOR, [
$this->documentRoot,
'bitrix',
'modules',
$this->moduleId
]) . DIRECTORY_SEPARATOR, '', $filePath);
}
/**
* @param string $fileNameWithoutExt
* @param string $filePath
*
* @return string
*/
protected function getImportClass(string $fileNameWithoutExt, string $filePath): string
{
if ($this->disableNamespaces) {
return $fileNameWithoutExt;
}
$importClass = str_ireplace($this->getSearchPath(), '', $filePath). '\\' . $fileNameWithoutExt;
if (strlen($importClass) > 0 && $importClass[0] === '/') {
$importClass = '\\' . substr($importClass, 1);
}
return (string) str_replace(DIRECTORY_SEPARATOR, '\\', $importClass);
}
}

View file

@ -238,7 +238,7 @@ class ApiClient
*
* @return ApiResponse
*/
public function customersСorporateFixExternalIds(array $ids)
public function customersCorporateFixExternalIds(array $ids)
{
if (! count($ids)) {
throw new \InvalidArgumentException(
@ -249,11 +249,11 @@ class ApiClient
return $this->client->makeRequest(
'/customers-corporate/fix-external-ids',
Client::METHOD_POST,
array('customerCorporate' => json_encode($ids))
array('customersCorporate' => json_encode($ids))
);
}
/*
/**
* Upload array of the customers corporate
*
* @param array $customers array of customers
@ -293,7 +293,7 @@ class ApiClient
*
* @return ApiResponse
*/
public function customersСorporateGet($id, $by = 'externalId', $site = null)
public function customersCorporateGet($id, $by = 'externalId', $site = null)
{
$this->checkIdParameter($by);
@ -398,7 +398,7 @@ class ApiClient
* @return ApiResponse
*
*/
public function customersСorporateHistory(array $filter = array(), $page = null, $limit = null)
public function customersCorporateHistory(array $filter = array(), $page = null, $limit = null)
{
$parameters = array();

View file

@ -3,7 +3,7 @@
/**
* Class Logger
*
* @author pavel
* @author retailCRM
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
@ -44,7 +44,7 @@ class Logger
* @param string $logPath
* @param int $files
*/
private function __construct($logPath = '/bitrix/modules/intaro.retailcrm/log', $files = 3)
public function __construct($logPath = '/bitrix/modules/intaro.retailcrm/log', $files = 3)
{
$this->logPath = $logPath;
$this->files = $files;

View file

@ -226,19 +226,9 @@ class RCrmActions
*/
public static function clearArr($arr)
{
if (is_array($arr) === false) {
return $arr;
}
$result = array();
foreach ($arr as $index => $node ) {
$result[ $index ] = is_array($node) === true ? self::clearArr($node) : trim($node);
if ($result[ $index ] == '' || $result[ $index ] === null || count($result[ $index ]) < 1) {
unset($result[ $index ]);
}
}
return $result;
/** @var \Intaro\RetailCrm\Service\Utils $utils */
$utils = \Intaro\RetailCrm\Component\ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
return $utils->clearArray($arr);
}
/**
@ -246,13 +236,12 @@ class RCrmActions
* @param array|bool|\SplFixedArray|string $str in SITE_CHARSET
*
* @return array|bool|\SplFixedArray|string $str in utf-8
* @global $APPLICATION
*/
public static function toJSON($str)
{
global $APPLICATION;
return $APPLICATION->ConvertCharset($str, SITE_CHARSET, 'utf-8');
/** @var \Intaro\RetailCrm\Service\Utils $utils */
$utils = \Intaro\RetailCrm\Component\ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
return $utils->toUTF8($str);
}
/**
@ -260,13 +249,12 @@ class RCrmActions
* @param string|array|\SplFixedArray $str in utf-8
*
* @return array|bool|\SplFixedArray|string $str in SITE_CHARSET
* @global $APPLICATION
*/
public static function fromJSON($str)
{
global $APPLICATION;
return $APPLICATION->ConvertCharset($str, 'utf-8', SITE_CHARSET);
/** @var \Intaro\RetailCrm\Service\Utils $utils */
$utils = \Intaro\RetailCrm\Component\ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
return $utils->fromUTF8($str);
}
/**

View file

@ -177,4 +177,12 @@ class ApiResponse implements \ArrayAccess
return $this->response[$offset];
}
/**
* @return array
*/
public function getResponseBody()
{
return $this->response;
}
}

View file

@ -25,583 +25,6 @@ IncludeModuleLangFile(__FILE__);
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
*/
class RetailcrmConfigProvider
class RetailcrmConfigProvider extends \Intaro\RetailCrm\Component\ConfigProvider
{
/** @var bool|null|string */
private static $apiUrl;
/** @var bool|null|string */
private static $apiKey;
/** @var bool|null|string */
private static $catalogBasePrice;
/** @var bool|null|string */
private static $currency;
/** @var bool|null|string */
private static $orderDimensions;
/** @var bool|null|string */
private static $corporateClientName;
/** @var bool|null|string */
private static $corporateClientAddress;
/** @var bool|null|string */
private static $corporateClient;
/** @var bool|null|string $shipmentDeducted */
private static $shipmentDeducted;
/** @var array $sitesList */
private static $sitesList;
/** @var array $sitesListCorporate */
private static $sitesListCorporate;
/** @var bool|null|string $orderNumbers */
private static $orderNumbers;
/** @var array $orderTypes */
private static $orderTypes;
/** @var array $deliveryTypes */
private static $deliveryTypes;
/** @var array $paymentTypes */
private static $paymentTypes;
/** @var array $paymentStatuses */
private static $paymentStatuses;
/** @var array $payment */
private static $payment;
/** @var array $orderProps */
private static $orderProps;
/** @var array $legalDetails */
private static $legalDetails;
/** @var array $contragentTypes */
private static $contragentTypes;
/** @var array $cancellableOrderPaymentStatuses */
private static $cancellableOrderPaymentStatuses;
/** @var array $customFields */
private static $customFields;
/** @var array $infoblocksInventories */
private static $infoblocksInventories;
/** @var array $stores */
private static $stores;
/** @var array $shops */
private static $shops;
/**
* @return bool|string|null
*/
public static function getApiUrl()
{
if (self::isEmptyNotZero(static::$apiUrl)) {
static::$apiUrl = static::getOption(RetailcrmConstants::CRM_API_HOST_OPTION);
}
return static::$apiUrl;
}
/**
* @return bool|string|null
*/
public static function getApiKey()
{
if (self::isEmptyNotZero(static::$apiKey)) {
static::$apiKey = static::getOption(RetailcrmConstants::CRM_API_KEY_OPTION);
}
return static::$apiKey;
}
/**
* getCorporateClientName
*
* @return bool|string|null
*/
public static function getCorporateClientName()
{
if (self::isEmptyNotZero(static::$corporateClientName)) {
static::$corporateClientName = static::getUnserializedOption(RetailcrmConstants::CRM_CORP_NAME);
}
return static::$corporateClientName;
}
/**
* getCorporateClientAddress
*
* @return bool|string|null
*/
public static function getCorporateClientAddress()
{
if (self::isEmptyNotZero(static::$corporateClientAddress)) {
static::$corporateClientAddress = static::getUnserializedOption(RetailcrmConstants::CRM_CORP_ADDRESS);
}
return static::$corporateClientAddress;
}
/**
* getCorporateClient
*
* @return bool|string|null
*/
public static function getCorporateClientStatus()
{
if (self::isEmptyNotZero(static::$corporateClient)) {
static::$corporateClient = static::getOption(RetailcrmConstants::CRM_CC);
}
return static::$corporateClient;
}
/**
* getSitesList
*
* @return array
*/
public static function getSitesList()
{
if (self::isEmptyNotZero(static::$sitesList)) {
static::$sitesList = static::getUnserializedOption(RetailcrmConstants::CRM_SITES_LIST);
}
return static::$sitesList;
}
/**
* getSitesListCorporate
*
* @return array
*/
public static function getSitesListCorporate()
{
if (self::isEmptyNotZero(static::$sitesListCorporate)) {
static::$sitesListCorporate = static::getUnserializedOption(
RetailcrmConstants::CRM_SITES_LIST_CORPORATE
);
}
return static::$sitesListCorporate;
}
/**
* getOrderTypes
*
* @return array
*/
public static function getOrderTypes()
{
if (self::isEmptyNotZero(static::$orderTypes)) {
static::$orderTypes = static::getUnserializedOption(RetailcrmConstants::CRM_ORDER_TYPES_ARR);
}
return static::$orderTypes;
}
/**
* getDeliveryTypes
*
* @return array
*/
public static function getDeliveryTypes()
{
if (self::isEmptyNotZero(static::$deliveryTypes)) {
static::$deliveryTypes = static::getUnserializedOption(RetailcrmConstants::CRM_DELIVERY_TYPES_ARR);
}
return static::$deliveryTypes;
}
/**
* getPaymentTypes
*
* @return array
*/
public static function getPaymentTypes()
{
if (self::isEmptyNotZero(static::$paymentTypes)) {
static::$paymentTypes = static::getUnserializedOption(RetailcrmConstants::CRM_PAYMENT_TYPES);
}
return static::$paymentTypes;
}
/**
* getPaymentStatuses
*
* @return array
*/
public static function getPaymentStatuses()
{
if (self::isEmptyNotZero(static::$paymentStatuses)) {
static::$paymentStatuses = static::getUnserializedOption(RetailcrmConstants::CRM_PAYMENT_STATUSES);
}
return static::$paymentStatuses;
}
/**
* getPayment
*
* @return array
*/
public static function getPayment()
{
if (self::isEmptyNotZero(static::$payment)) {
static::$payment = static::getUnserializedOption(RetailcrmConstants::CRM_PAYMENT);
}
return static::$payment;
}
/**
* getOrderProps
*
* @return array
*/
public static function getOrderProps()
{
if (self::isEmptyNotZero(static::$orderProps)) {
static::$orderProps = static::getUnserializedOption(RetailcrmConstants::CRM_ORDER_PROPS);
}
return static::$orderProps;
}
/**
* getLegalDetails
*
* @return array
*/
public static function getLegalDetails()
{
if (self::isEmptyNotZero(static::$legalDetails)) {
static::$legalDetails = static::getUnserializedOption(RetailcrmConstants::CRM_LEGAL_DETAILS);
}
return static::$legalDetails;
}
/**
* getContragentTypes
*
* @return array
*/
public static function getContragentTypes()
{
if (self::isEmptyNotZero(static::$contragentTypes)) {
static::$contragentTypes = static::getUnserializedOption(RetailcrmConstants::CRM_CONTRAGENT_TYPE);
}
return static::$contragentTypes;
}
/**
* getCustomFields
*
* @return array
*/
public static function getCustomFields()
{
if (self::isEmptyNotZero(static::$customFields)) {
static::$customFields = static::getUnserializedOption(RetailcrmConstants::CRM_CUSTOM_FIELDS);
}
return static::$customFields;
}
/**
* getCancellableOrderPaymentStatuses
*
* @return array
*/
public static function getCancellableOrderPaymentStatuses()
{
if (self::isEmptyNotZero(static::$cancellableOrderPaymentStatuses)) {
static::$cancellableOrderPaymentStatuses = static::getUnserializedOption(
RetailcrmConstants::CRM_CANCEL_ORDER
);
}
return static::$cancellableOrderPaymentStatuses;
}
/**
* getLastOrderId
*
* @return bool|string|null
*/
public static function getLastOrderId()
{
return static::getOption(RetailcrmConstants::CRM_ORDER_LAST_ID);
}
/**
* setLastOrderId
*
* @param $id
*/
public static function setLastOrderId($id)
{
static::setOption(RetailcrmConstants::CRM_ORDER_LAST_ID, $id);
}
/**
* getFailedOrdersIds
*
* @return array
*/
public static function getFailedOrdersIds()
{
return static::getUnserializedOption(RetailcrmConstants::CRM_ORDER_FAILED_IDS);
}
/**
* setFailedOrdersIds
*
* @param $ids
*/
public static function setFailedOrdersIds($ids)
{
static::setOption(RetailcrmConstants::CRM_ORDER_FAILED_IDS, serialize($ids));
}
/**
* getOrderNumbers
*
* @return bool|string|null
*/
public static function getOrderNumbers()
{
if (self::isEmptyNotZero(self::$orderNumbers)) {
self::$orderNumbers = static::getOption(RetailcrmConstants::CRM_ORDER_NUMBERS);
}
return self::$orderNumbers;
}
/**
* getOrderHistoryDate
*
* @return bool|string|null
*/
public static function getOrderHistoryDate()
{
return static::getOption(RetailcrmConstants::CRM_ORDER_HISTORY_DATE);
}
/**
* Returns customers history since ID
*
* @return int
*/
public static function getCustomersHistorySinceId()
{
return (int) static::getOption(RetailcrmConstants::CRM_CUSTOMERS_HISTORY_SINCE_ID);
}
/**
* Sets new customers history since ID
*
* @param int $sinceId
*/
public static function setCustomersHistorySinceId($sinceId)
{
static::setOption(RetailcrmConstants::CRM_CUSTOMERS_HISTORY_SINCE_ID, $sinceId);
}
/**
* getCatalogBasePrice
*
* @return bool|string|null
*/
public static function getCatalogBasePrice()
{
if (self::isEmptyNotZero(static::$catalogBasePrice)) {
static::$catalogBasePrice = static::getOption(RetailcrmConstants::CRM_CATALOG_BASE_PRICE);
}
return static::$catalogBasePrice;
}
/**
* getOrderDimensions
*
* @return bool|string|null
*/
public static function getOrderDimensions()
{
if (self::isEmptyNotZero(static::$orderDimensions)) {
static::$orderDimensions = static::getOption(RetailcrmConstants::CRM_ORDER_DIMENSIONS, 'N');
}
return static::$orderDimensions;
}
/**
* getCurrency
*
* @return bool|string|null
*/
public static function getCurrency()
{
if (self::isEmptyNotZero(static::$currency)) {
static::$currency = static::getOption(RetailcrmConstants::CRM_CURRENCY);
}
return static::$currency;
}
/**
* Returns currency from settings. If it's not set - returns Bitrix base currency.
*
* @return bool|string|null
*/
public static function getCurrencyOrDefault()
{
return self::getCurrency() ? self::getCurrency() : \Bitrix\Currency\CurrencyManager::getBaseCurrency();
}
/**
* getInfoblocksInventories
*
* @return array
*/
public static function getInfoblocksInventories()
{
if (self::isEmptyNotZero(static::$infoblocksInventories)) {
static::$infoblocksInventories = static::getUnserializedOption(
RetailcrmConstants::CRM_IBLOCKS_INVENTORIES
);
}
return static::$infoblocksInventories;
}
/**
* getStores
*
* @return array
*/
public static function getStores()
{
if (self::isEmptyNotZero(static::$stores)) {
static::$stores = static::getUnserializedOption(RetailcrmConstants::CRM_STORES);
}
return static::$stores;
}
/**
* getShops
*
* @return array
*/
public static function getShops()
{
if (self::isEmptyNotZero(static::$shops)) {
static::$shops = static::getUnserializedOption(RetailcrmConstants::CRM_SHOPS);
}
return static::$shops;
}
/**
* getShipmentDeducted
*
* @return bool|string|null
*/
public static function getShipmentDeducted()
{
if (self::isEmptyNotZero(static::$shipmentDeducted)) {
static::$shipmentDeducted = static::getOption(RetailcrmConstants::CRM_SHIPMENT_DEDUCTED);
}
return static::$shipmentDeducted;
}
/**
* isPhoneRequired
*
* @return bool|string|null
*/
public static function isPhoneRequired()
{
return COption::GetOptionString("main", "new_user_phone_required") === 'Y';
}
/**
* Wraps Bitrix COption::GetOptionString(...)
*
* @param string $option
* @param int|string $def
*
* @return bool|string|null
*/
private static function getOption($option, $def = 0)
{
return COption::GetOptionString(
RetailcrmConstants::MODULE_ID,
$option,
$def
);
}
/**
* setOption
*
* @param $name
* @param string $value
* @param bool $desc
* @param string $site
*/
private static function setOption($name, $value = "", $desc = false, $site = "")
{
COption::SetOptionString(
RetailcrmConstants::MODULE_ID,
$name,
$value,
$desc,
$site
);
}
/**
* Wraps Bitrix unserialize(COption::GetOptionString(...))
*
* @param string $option
* @param int|string $def
*
* @return mixed
*/
private static function getUnserializedOption($option, $def = 0)
{
return unserialize(static::getOption($option, $def));
}
/**
* Returns true if value is empty and not zero (0 - digit)
*
* @param mixed $value
*
* @return bool
*/
private static function isEmptyNotZero($value)
{
return empty($value) && $value !== 0;
}
}

View file

@ -25,56 +25,6 @@ IncludeModuleLangFile(__FILE__);
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
*/
class RetailcrmConstants
class RetailcrmConstants extends \Intaro\RetailCrm\Component\Constants
{
const MODULE_ID = 'intaro.retailcrm';
const CRM_API_HOST_OPTION = 'api_host';
const CRM_API_KEY_OPTION = 'api_key';
const CRM_ORDER_TYPES_ARR = 'order_types_arr';
const CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr';
const CRM_DELIVERY_SERVICES_ARR = 'deliv_services_arr';
const CRM_PAYMENT_TYPES = 'pay_types_arr';
const CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
const CRM_PAYMENT = 'payment_arr'; //order payment Y/N
const CRM_ORDER_LAST_ID = 'order_last_id';
const CRM_ORDER_SITES = 'sites_ids';
const CRM_ORDER_DISCHARGE = 'order_discharge';
const CRM_SITES_LIST = 'sites_list';
const CRM_ORDER_PROPS = 'order_props';
const CRM_LEGAL_DETAILS = 'legal_details';
const CRM_CUSTOM_FIELDS = 'custom_fields';
const CRM_CONTRAGENT_TYPE = 'contragent_type';
const CRM_SITES_LIST_CORPORATE = 'shops-corporate';
const CRM_ORDER_NUMBERS = 'order_numbers';
const CRM_CANCEL_ORDER = 'cansel_order';
const CRM_INVENTORIES_UPLOAD = 'inventories_upload';
const CRM_STORES = 'stores';
const CRM_SHOPS = 'shops';
const CRM_IBLOCKS_INVENTORIES = 'iblocks_inventories';
const CRM_PRICES_UPLOAD = 'prices_upload';
const CRM_PRICES = 'prices';
const CRM_PRICE_SHOPS = 'price_shops';
const CRM_IBLOCKS_PRICES = 'iblock_prices';
const CRM_COLLECTOR = 'collector';
const CRM_COLL_KEY = 'coll_key';
const CRM_UA = 'ua';
const CRM_UA_KEYS = 'ua_keys';
const CRM_DISCOUNT_ROUND = 'discount_round';
const CRM_CC = 'cc';
const CRM_CORP_SHOPS = 'shops-corporate';
const CRM_CORP_NAME = 'nickName-corporate';
const CRM_CORP_ADDRESS = 'adres-corporate';
const CRM_API_VERSION = 'api_version';
const CRM_CURRENCY = 'currency';
const CRM_ADDRESS_OPTIONS = 'address_options';
const CRM_DIMENSIONS = 'order_dimensions';
const PROTOCOL = 'protocol';
const CRM_ORDER_FAILED_IDS = 'order_failed_ids';
const CRM_CUSTOMERS_HISTORY_SINCE_ID = 'customer_history';
const CRM_ORDER_HISTORY_DATE = 'order_history_date';
const CRM_CATALOG_BASE_PRICE = 'catalog_base_price';
const CRM_ORDER_DIMENSIONS = 'order_dimensions';
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
const CRM_INTEGRATION_DELIVERY = 'integration_delivery';
const CRM_SHIPMENT_DEDUCTED = 'shipment_deducted';
}

View file

@ -25,80 +25,6 @@ IncludeModuleLangFile(__FILE__);
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
*/
class RetailcrmDependencyLoader
class RetailcrmDependencyLoader extends \Intaro\RetailCrm\Component\DependencyLoader
{
/** @var int */
const LEGACY_LOADER = 0;
/** @var int */
const D7_LOADER = 1;
/** @var int $loader */
private static $loader = self::D7_LOADER;
/**
* Loads dependencies
*
* @return bool
*/
public static function loadDependencies()
{
foreach (self::getDependencies() as $dependency) {
if (self::LEGACY_LOADER == self::$loader) {
if (!CModule::IncludeModule($dependency)) {
RCrmActions::eventLog(
__CLASS__ . '::' . __METHOD__,
$dependency,
'module not found'
);
return false;
}
} else {
try {
if (!\Bitrix\Main\Loader::includeModule($dependency)) {
RCrmActions::eventLog(
__CLASS__ . '::' . __METHOD__,
$dependency,
'module not found'
);
return false;
}
} catch (\Bitrix\Main\LoaderException $exception) {
RCrmActions::eventLog(
__CLASS__ . '::' . __METHOD__,
$dependency,
sprintf('error while trying to load module: %s', $exception->getMessage())
);
return false;
}
}
}
return true;
}
/**
* Set loader mode. Use RetailcrmDependencyLoader::LEGACY_LOADER or RetailcrmDependencyLoader::D7_LOADER
*
* @param $loader
*/
public static function setLoader($loader)
{
if (in_array($loader, array(self::LEGACY_LOADER, self::D7_LOADER))) {
self::$loader = $loader;
}
}
/**
* Returns array of required modules names
*
* @return array<string>
*/
public static function getDependencies()
{
return array("iblock", "sale", "catalog");
}
}

View file

@ -3,7 +3,7 @@ class RetailCrmService
{
public static function unsetIntegrationDeliveryFields($order)
{
$integrationDelivery = unserialize(COption::GetOptionString(RetailcrmConstants::MODULE_ID, RetailcrmConstants::CRM_INTEGRATION_DELIVERY, 0));
$integrationDelivery = RetailcrmConfigProvider::getIntegrationDeliveriesMapping();
$deliveryCode = $order['delivery']['code'];
if ($deliveryCode) {
switch ($integrationDelivery[$deliveryCode]) {

View file

@ -78,7 +78,7 @@ class RetailCrmUser
return $customer;
}
public static function customerEdit($arFields, $api, $optionsSitesList = array()){
public static function customerEdit($arFields, $api, $optionsSitesList = array()) {
if (empty($arFields)) {
RCrmActions::eventLog('RetailCrmUser::customerEdit', 'empty($arFields)', 'incorrect customer');
return false;

View file

@ -1,43 +1,31 @@
<?php
use Intaro\RetailCrm\Component\ServiceLocator;
use Intaro\RetailCrm\Service\CollectorCookieExtractor;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\AnnotationReader;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\AnnotationRegistry;
require_once __DIR__ . '/RetailcrmClasspathBuilder.php';
$retailcrmModuleId = 'intaro.retailcrm';
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
$version = COption::GetOptionString('intaro.retailcrm', 'api_version');
CModule::AddAutoloadClasses(
'intaro.retailcrm', // module name
array (
'RetailcrmDependencyLoader' => 'classes/general/RetailcrmDependencyLoader.php',
'RestNormalizer' => file_exists($server . '/bitrix/php_interface/retailcrm/RestNormalizer.php') ? '../../php_interface/retailcrm/RestNormalizer.php' : 'classes/general/RestNormalizer.php',
'Logger' => file_exists($server . '/bitrix/php_interface/retailcrm/Logger.php') ? '../../php_interface/retailcrm/Logger.php' : 'classes/general/Logger.php',
'RetailCrm\ApiClient' => file_exists($server . '/bitrix/php_interface/retailcrm/ApiClient.php') ? '../../php_interface/retailcrm/ApiClient.php' : 'classes/general/ApiClient_' . $version . '.php',
'RetailCrm\Http\Client' => file_exists($server . '/bitrix/php_interface/retailcrm/Client.php') ? '../../php_interface/retailcrm/Client.php' : 'classes/general/Http/Client.php',
'RCrmActions' => file_exists($server . '/bitrix/php_interface/retailcrm/RCrmActions.php') ? '../../php_interface/retailcrm/RCrmActions.php' : 'classes/general/RCrmActions.php',
'RetailCrmUser' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmUser.php') ? '../../php_interface/retailcrm/RetailCrmUser.php' : 'classes/general/user/RetailCrmUser.php',
'RetailCrmOrder' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmOrder.php') ? '../../php_interface/retailcrm/RetailCrmOrder.php' : 'classes/general/order/RetailCrmOrder_' . $version . '.php',
'RetailCrmHistory' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmHistory.php') ? '../../php_interface/retailcrm/RetailCrmHistory.php' : 'classes/general/history/RetailCrmHistory_' . $version . '.php',
'RetailCrmICML' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmICML.php') ? '../../php_interface/retailcrm/RetailCrmICML.php' : 'classes/general/icml/RetailCrmICML.php',
'RetailCrmInventories' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmInventories.php') ? '../../php_interface/retailcrm/RetailCrmInventories.php' : 'classes/general/inventories/RetailCrmInventories.php',
'RetailCrmPrices' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmPrices.php') ? '../../php_interface/retailcrm/RetailCrmPrices.php' : 'classes/general/prices/RetailCrmPrices.php',
'RetailCrmCollector' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmCollector.php') ? '../../php_interface/retailcrm/RetailCrmCollector.php' : 'classes/general/collector/RetailCrmCollector.php',
'RetailCrmUa' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmUa.php') ? '../../php_interface/retailcrm/RetailCrmUa.php' : 'classes/general/ua/RetailCrmUa.php',
'RetailCrmEvent' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmEvent.php') ? '../../php_interface/retailcrm/RetailCrmEvent.php' : 'classes/general/events/RetailCrmEvent.php',
'RetailCrm\Response\ApiResponse' => 'classes/general/Response/ApiResponse.php',
'RetailCrm\Exception\InvalidJsonException' => 'classes/general/Exception/InvalidJsonException.php',
'RetailCrm\Exception\CurlException' => 'classes/general/Exception/CurlException.php',
'RetailCrmCorporateClient' => file_exists($server . '/bitrix/php_interface/retailcrm/RetailCrmCorporateClient.php') ? '../../php_interface/retailcrm/RetailCrmCorporateClient.php' : 'classes/general/user/RetailCrmCorporateClient.php',
'RetailcrmConfigProvider' => 'classes/general/RetailcrmConfigProvider.php',
'RetailcrmConstants' => 'classes/general/RetailcrmConstants.php',
'RetailcrmBuilderInterface' => 'classes/general/RetailcrmBuilderInterface.php',
'CustomerBuilder' => 'classes/general/CustomerBuilder.php',
'CorporateCustomerBuilder' => 'classes/general/CorporateCustomerBuilder.php',
'Customer' => 'classes/general/Model/Customer.php',
'CustomerAddress' => 'classes/general/Model/CustomerAddress.php',
'CustomerContragent' => 'classes/general/Model/CustomerContragent.php',
'BuyerProfile' => 'classes/general/Model/BuyerProfile.php',
'AdressBuilder' => 'classes/general/AdressBuilder.php',
'BuilderBase' => 'classes/general/BuilderBase.php',
'AddressBuilder' => 'classes/general/AddressBuilder.php',
'AbstractBuilder' => 'classes/general/AbstractBuilder.php',
'BaseModel' => 'classes/general/Model/BaseModel.php',
'RetailCrmService' => 'classes/general/services/RetailCrmService.php',
)
);
$builder = new RetailcrmClasspathBuilder();
$builder->setDisableNamespaces(true)
->setDocumentRoot($server)
->setModuleId($retailcrmModuleId)
->setPath('classes')
->setVersion($version)
->build();
\Bitrix\Main\Loader::switchAutoLoad(true);
\Bitrix\Main\Loader::registerAutoLoadClasses('intaro.retailcrm', $builder->getResult());
AnnotationRegistry::registerLoader('class_exists');
ServiceLocator::registerServices([
\Intaro\RetailCrm\Service\Utils::class,
Logger::class,
AnnotationReader::class,
CollectorCookieExtractor::class
]);

View file

@ -0,0 +1,128 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\ApiClient
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\ApiClient;
use Intaro\RetailCrm\Component\ApiClient\Traits\CustomersCorporateTrait;
use Intaro\RetailCrm\Component\ApiClient\Traits\CustomersTrait;
use RetailCrm\Response\ApiResponse;
/**
* Class ClientAdapter. It's sole purpose is to allow models usage via old API client.
* Currently, it only implements customers and corporate customers methods (except combine method).
* Better solution can be found later. For now, this will work just fine.
*
* @package Intaro\RetailCrm\Component\ApiClient
*
* @method ApiResponse usersList(array $filter = array(), $page = null, $limit = null)
* @method ApiResponse usersGroups($page = null, $limit = null)
* @method ApiResponse usersStatus($id, $status)
* @method ApiResponse usersGet($id)
* @method ApiResponse ordersList(array $filter = array(), $page = null, $limit = null)
* @method ApiResponse customersCorporateNotesDelete($id)
* @method ApiResponse ordersCreate(array $order, $site = null)
* @method ApiResponse ordersFixExternalIds(array $ids)
* @method ApiResponse ordersStatuses(array $ids = array(), array $externalIds = array())
* @method ApiResponse ordersUpload(array $orders, $site = null)
* @method ApiResponse ordersGet($id, $by = 'externalId', $site = null)
* @method ApiResponse ordersEdit(array $order, $by = 'externalId', $site = null)
* @method ApiResponse ordersHistory(array $filter = array(), $page = null, $limit = null)
* @method ApiResponse ordersCombine($order, $resultOrder, $technique = 'ours')
* @method ApiResponse ordersPaymentCreate(array $payment, $site = null)
* @method ApiResponse ordersPaymentEdit(array $payment, $by = 'id', $site = null)
* @method ApiResponse ordersPaymentDelete($id)
* @method ApiResponse customersCombine(array $customers, $resultCustomer)
* @method ApiResponse customersNotesDelete($id)
* @method ApiResponse customFieldsList(array $filter = array(), $limit = null, $page = null)
* @method ApiResponse customFieldsCreate($entity, $customField)
* @method ApiResponse customFieldsEdit($entity, $customField)
* @method ApiResponse customFieldsGet($entity, $code)
* @method ApiResponse customDictionariesList(array $filter = array(), $limit = null, $page = null)
* @method ApiResponse customDictionariesCreate($customDictionary)
* @method ApiResponse customDictionariesEdit($customDictionary)
* @method ApiResponse customDictionariesGet($code)
* @method ApiResponse tasksList(array $filter = array(), $limit = null, $page = null)
* @method ApiResponse tasksCreate($task, $site = null)
* @method ApiResponse tasksEdit($task, $site = null)
* @method ApiResponse tasksGet($id)
* @method ApiResponse ordersPacksList(array $filter = array(), $page = null, $limit = null)
* @method ApiResponse ordersPacksCreate(array $pack, $site = null)
* @method ApiResponse ordersPacksHistory(array $filter = array(), $page = null, $limit = null)
* @method ApiResponse ordersPacksGet($id)
* @method ApiResponse ordersPacksDelete($id)
* @method ApiResponse ordersPacksEdit(array $pack, $site = null)
* @method ApiResponse storeInventories(array $filter = array(), $page = null, $limit = null)
* @method ApiResponse storeInventoriesUpload(array $offers, $site = null)
* @method ApiResponse storePricesUpload(array $prices, $site = null)
* @method ApiResponse storeProducts(array $filter = array(), $page = null, $limit = null)
* @method ApiResponse integrationModulesGet($code)
* @method ApiResponse integrationModulesEdit(array $configuration)
* @method ApiResponse deliveryTracking($code, array $statusUpdate)
* @method ApiResponse countriesList()
* @method ApiResponse deliveryServicesList()
* @method ApiResponse deliveryServicesEdit(array $data)
* @method ApiResponse deliveryTypesList()
* @method ApiResponse deliveryTypesEdit(array $data)
* @method ApiResponse orderMethodsList()
* @method ApiResponse orderMethodsEdit(array $data)
* @method ApiResponse orderTypesList()
* @method ApiResponse orderTypesEdit(array $data)
* @method ApiResponse paymentStatusesList()
* @method ApiResponse paymentStatusesEdit(array $data)
* @method ApiResponse paymentTypesList()
* @method ApiResponse paymentTypesEdit(array $data)
* @method ApiResponse productStatusesList()
* @method ApiResponse productStatusesEdit(array $data)
* @method ApiResponse storeProductsGroups(array $filter = array(), $page = null, $limit = null)
* @method ApiResponse sitesList()
* @method ApiResponse sitesEdit(array $data)
* @method ApiResponse statusGroupsList()
* @method ApiResponse statusesList()
* @method ApiResponse statusesEdit(array $data)
* @method ApiResponse storesList()
* @method ApiResponse storesEdit(array $data)
* @method ApiResponse pricesTypes()
* @method ApiResponse pricesEdit(array $data)
* @method ApiResponse telephonyCallsUpload(array $calls)
* @method ApiResponse telephonyCallManager($phone, $details)
* @method ApiResponse segmentsList(array $filter = array(), $limit = null, $page = null)
* @method ApiResponse statisticUpdate()
* @method ApiResponse getSite()
* @method ApiResponse setSite($site)
*/
class ClientAdapter
{
use CustomersTrait;
use CustomersCorporateTrait;
/** @var string */
public const ID = 'id';
/** @var string */
public const EXTERNAL_ID = 'externalId';
/**
* Proxy call for all methods we don't care about... or didn't implemented yet.
*
* @param string $name
* @param array $arguments
*
* @return mixed
*/
public function __call($name, $arguments)
{
if (method_exists($this->client, $name)) {
return \call_user_func_array([$this->client, $name], $arguments);
}
throw new \RuntimeException(sprintf("Method '%s' doesn't exist.", $name));
}
}

View file

@ -0,0 +1,37 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\ApiClient
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\ApiClient\Traits;
use RetailCrm\ApiClient;
/**
* Trait BaseClientTrait
*
* @package Intaro\RetailCrm\Component\ApiClient\Traits
*/
trait BaseClientTrait
{
/** @var \RetailCrm\ApiClient */
private $client;
/**
* ClientFacade constructor.
*
* @param string $url
* @param string $apiKey
* @param string|null $site
*/
public function __construct(string $url, string $apiKey, $site = null)
{
$this->client = new ApiClient($url, $apiKey, $site);
}
}

View file

@ -0,0 +1,391 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\ApiClient
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\ApiClient\Traits;
use Intaro\RetailCrm\Component\Json\Deserializer;
use Intaro\RetailCrm\Component\Json\Serializer;
use Intaro\RetailCrm\Model\Api\Request\Customers as Request;
use Intaro\RetailCrm\Model\Api\Response\CompaniesResponse;
use Intaro\RetailCrm\Model\Api\Response\CreateResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomerChangeResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomerCorporateResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomersCorporateAddressesResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomersCorporateContactsResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomersCorporateResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomersNotesResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomersUploadResponse;
use Intaro\RetailCrm\Model\Api\Response\HistoryResponse;
use Intaro\RetailCrm\Model\Api\Response\OperationResponse;
/**
* Trait CustomersCorporateTrait
*
* @package Intaro\RetailCrm\Component\ApiClient\Traits
*/
trait CustomersCorporateTrait
{
use BaseClientTrait;
/**
* Create customers corporate
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateCreateRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomerChangeResponse|null
*/
public function customersCorporateCreate(Request\CustomersCorporateCreateRequest $request): ?CustomerChangeResponse
{
$response = $this->client->customersCorporateCreate(
Serializer::serializeArray($request->customerCorporate),
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CustomerChangeResponse::class);
}
/**
* Save corporate customer IDs' (id and externalId) association in the CRM
*
* @param Request\CustomersCorporateFixExternalIdsRequest $ids ids mapping
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return OperationResponse|null
*/
public function customersCorporateFixExternalIds(
Request\CustomersCorporateFixExternalIdsRequest $ids
): ?OperationResponse {
$request = $this->client->customersCorporateFixExternalIds(
Serializer::serializeArray($ids)['customersCorporate']
);
return Deserializer::deserializeArray($request->getResponseBody(), OperationResponse::class);
}
/**
* Upload array of the customers corporate
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateUploadRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomersUploadResponse|null
*/
public function customersCorporateUpload(Request\CustomersCorporateUploadRequest $request): ?CustomersUploadResponse
{
$serialized = Serializer::serializeArray($request);
$response = $this->client->customersCorporateUpload($serialized['customersCorporate'], $request->site);
return Deserializer::deserializeArray($response->getResponseBody(), CustomersUploadResponse::class);
}
/**
* Get customer corporate by id or externalId
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersGetRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomerCorporateResponse|null
*/
public function customersCorporateGet(Request\CustomersGetRequest $request): ?CustomerCorporateResponse
{
$response = $this->client->customersCorporateGet((string) $request->id, $request->by, $request->site);
return Deserializer::deserializeArray($response->getResponseBody(), CustomerCorporateResponse::class);
}
/**
* Edit a customer corporate
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersEditRequest $request
*
* @return CustomerChangeResponse|null
*/
public function customersCorporateEdit(Request\CustomersEditRequest $request): ?CustomerChangeResponse {
$response = $this->client->customersCorporateEdit(
Serializer::serializeArray($request->customer),
$request->by,
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CustomerChangeResponse::class);
}
/**
* Get customers corporate history
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersHistoryRequest $request
*
* @return HistoryResponse|null
*/
public function customersCorporateHistory(Request\CustomersHistoryRequest $request): ?HistoryResponse
{
$response = $this->client->customersCorporateHistory(
Serializer::serializeArray($request->filter),
$request->page,
$request->limit
);
return Deserializer::deserializeArray($response->getResponseBody(), HistoryResponse::class);
}
/**
* Returns filtered corporate customers list
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateListRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomersCorporateResponse|null
*/
public function customersCorporateList(Request\CustomersCorporateListRequest $request): ?CustomersCorporateResponse
{
$response = $this->client->customersCorporateList(
Serializer::serializeArray($request->filter),
$request->page,
$request->limit
);
return Deserializer::deserializeArray($response->getResponseBody(), CustomersCorporateResponse::class);
}
/**
* Returns filtered corporate customers notes list
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersNotesRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomersNotesResponse|null
*/
public function customersCorporateNotesList(Request\CustomersNotesRequest $request): ?CustomersNotesResponse
{
$response = $this->client->customersCorporateNotesList(
Serializer::serializeArray($request->filter),
$request->page,
$request->limit
);
return Deserializer::deserializeArray($response->getResponseBody(), CustomersNotesResponse::class);
}
/**
* Create corporate customer note
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersNotesCreateRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CreateResponse|null
*/
public function customersCorporateNotesCreate(Request\CustomersNotesCreateRequest $request): ?CreateResponse
{
$response = $this->client->customersCorporateNotesCreate(
Serializer::serializeArray($request->note),
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CreateResponse::class);
}
/**
* Get corporate customer addresses
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateAddressesRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomersCorporateAddressesResponse|null
*/
public function customersCorporateAddresses(
Request\CustomersCorporateAddressesRequest $request
): ?CustomersCorporateAddressesResponse {
$response = $this->client->customersCorporateAddresses(
$request->externalId,
Serializer::serializeArray($request->filter),
$request->page,
$request->limit,
$request->by,
$request->site
);
return Deserializer::deserializeArray(
$response->getResponseBody(),
CustomersCorporateAddressesResponse::class
);
}
/**
* Create corporate customer note
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateAddressesCreateRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CreateResponse|null
*/
public function customersCorporateAddressesCreate(
Request\CustomersCorporateAddressesCreateRequest $request
): ?CreateResponse {
$response = $this->client->customersCorporateAddressesCreate(
$request->externalId,
Serializer::serializeArray($request->address),
$request->externalId,
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CreateResponse::class);
}
/**
* Edit corporate customer note
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateAddressesEditRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CreateResponse|null
*/
public function customersCorporateAddressesEdit(
Request\CustomersCorporateAddressesEditRequest $request
): ?OperationResponse {
$response = $this->client->customersCorporateAddressesEdit(
$request->externalId,
$request->entityBy === self::EXTERNAL_ID ? $request->address->externalId : $request->address->id,
Serializer::serializeArray($request->address),
$request->by,
$request->entityBy,
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), OperationResponse::class);
}
/**
* Get corporate customer companies by id or externalId
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateCompaniesRequest $request
*
* @return CompaniesResponse|null
*/
public function customersCorporateCompanies(
Request\CustomersCorporateCompaniesRequest $request
): ?CompaniesResponse {
$response = $this->client->customersCorporateCompanies(
$request->idOrExternalId,
Serializer::serializeArray($request->filter),
$request->page,
$request->limit,
$request->by,
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CompaniesResponse::class);
}
/**
* Create corporate customer companies
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateCompaniesCreateRequest $request
*
* @return CompaniesResponse|null
*/
public function customersCorporateCompaniesCreate(
Request\CustomersCorporateCompaniesCreateRequest $request
): ?CreateResponse {
$response = $this->client->customersCorporateCompaniesCreate(
$request->externalId,
Serializer::serializeArray($request->company),
$request->by,
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CreateResponse::class);
}
/**
* Edit corporate customer companies by id or externalId
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateCompaniesEditRequest $request
*
* @return CompaniesResponse|null
*/
public function customersCorporateCompaniesEdit(
Request\CustomersCorporateCompaniesEditRequest $request
): ?OperationResponse {
$response = $this->client->customersCorporateAddressesEdit(
$request->externalId,
$request->entityBy === self::EXTERNAL_ID ? $request->company->externalId : $request->company->id,
Serializer::serializeArray($request->company),
$request->by,
$request->entityBy,
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CreateResponse::class);
}
/**
* Get corporate customer contacts by id or externalId
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateContactsRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomersCorporateContactsResponse|null
*/
public function customersCorporateContacts(
Request\CustomersCorporateContactsRequest $request
): ?CustomersCorporateContactsResponse {
$response = $this->client->customersCorporateContacts(
$request->externalId,
Serializer::serializeArray($request->filter),
$request->page,
$request->limit,
$request->by,
$request->site
);
return Deserializer::deserializeArray(
$response->getResponseBody(),
CustomersCorporateContactsResponse::class
);
}
/**
* Create corporate customer contact
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateContactsCreateRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CreateResponse|null
*/
public function customersCorporateContactsCreate(
Request\CustomersCorporateContactsCreateRequest $request
): ?CreateResponse {
$response = $this->client->customersCorporateContactsCreate(
$request->idOrExternalId,
Serializer::serializeArray($request->contact),
$request->by,
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CreateResponse::class);
}
/**
* Edit corporate customer contacts by id or externalId
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCorporateContactsEditRequest $request
*
* @return CompaniesResponse|null
*/
public function customersCorporateContactsEdit(
Request\CustomersCorporateContactsEditRequest $request
): ?OperationResponse {
$response = $this->client->customersCorporateContactsEdit(
$request->idOrExternalId,
$request->entityBy === self::EXTERNAL_ID ? $request->contact->externalId : $request->contact->id,
Serializer::serializeArray($request->contact),
$request->by,
$request->entityBy,
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CreateResponse::class);
}
}

View file

@ -0,0 +1,183 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\ApiClient
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\ApiClient\Traits;
use Intaro\RetailCrm\Component\Json\Deserializer;
use Intaro\RetailCrm\Component\Json\Serializer;
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCreateRequest;
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersEditRequest;
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersFixExternalIdsRequest;
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersGetRequest;
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersHistoryRequest;
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersListRequest;
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersNotesCreateRequest;
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersNotesRequest;
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersUploadRequest;
use Intaro\RetailCrm\Model\Api\Response\CreateResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomerChangeResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomerResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomersNotesResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomersResponse;
use Intaro\RetailCrm\Model\Api\Response\CustomersUploadResponse;
use Intaro\RetailCrm\Model\Api\Response\HistoryResponse;
use Intaro\RetailCrm\Model\Api\Response\OperationResponse;
trait CustomersTrait
{
/**
* Returns filtered customers list
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersListRequest $request
*
* @return CustomersResponse|null
*/
public function customersList(CustomersListRequest $request): ?CustomersResponse
{
$serialized = Serializer::serializeArray($request);
$response = $this->client->customersList(
Serializer::serializeArray($serialized['filter'] ?? []),
$request->page,
$request->limit
);
return Deserializer::deserializeArray($response->getResponseBody(), CustomersResponse::class);
}
/**
* Returns filtered corporate customers notes list
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersNotesRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomersNotesResponse|null
*/
public function customersNotesList(CustomersNotesRequest $request): ?CustomersNotesResponse
{
$response = $this->client->customersNotesList(
Serializer::serializeArray($request->filter),
$request->page,
$request->limit
);
return Deserializer::deserializeArray($response->getResponseBody(), CustomersNotesResponse::class);
}
/**
* Create customer note
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersNotesCreateRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CreateResponse|null
*/
public function customersNotesCreate(CustomersNotesCreateRequest $request): ?CreateResponse
{
$response = $this->client->customersNotesCreate(
Serializer::serializeArray($request->note),
$request->site
);
return Deserializer::deserializeArray($response->getResponseBody(), CreateResponse::class);
}
/**
* Create customer
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCreateRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomerChangeResponse|null
*/
public function customersCreate(CustomersCreateRequest $request): ?CustomerChangeResponse
{
$serialized = Serializer::serializeArray($request);
$response = $this->client->customersCreate($serialized['customer'] ?? [], $request->site);
return Deserializer::deserializeArray($response->getResponseBody(), CustomerChangeResponse::class);
}
/**
* Save customer IDs' (id and externalId) association in the CRM
*
* @param CustomersFixExternalIdsRequest $ids ids mapping
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return OperationResponse|null
*/
public function customersFixExternalIds(CustomersFixExternalIdsRequest $ids): ?OperationResponse
{
$request = $this->client->customersFixExternalIds(Serializer::serializeArray($ids)['customers']);
return Deserializer::deserializeArray($request->getResponseBody(), OperationResponse::class);
}
/**
* Upload array of the customers
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersUploadRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomersUploadResponse|null
*/
public function customersUpload(CustomersUploadRequest $request): ?CustomersUploadResponse
{
$serialized = Serializer::serializeArray($request);
$response = $this->client->customersUpload($serialized['customers'] ?? [], $request->site);
return Deserializer::deserializeArray($response->getResponseBody(), CustomersUploadResponse::class);
}
/**
* Get customer by id or externalId
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersGetRequest $request
*
* @return \Intaro\RetailCrm\Model\Api\Response\CustomerResponse|null
*/
public function customersGet(CustomersGetRequest $request): ?CustomerResponse
{
$response = $this->client->customersGet((string) $request->id, $request->by, $request->site);
return Deserializer::deserializeArray($response->getResponseBody(), CustomerResponse::class);
}
/**
* Edit customer
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersEditRequest $request
*
* @return CustomerChangeResponse|null
*/
public function customersEdit(CustomersEditRequest $request): ?CustomerChangeResponse {
$serialized = Serializer::serializeArray($request);
$response = $this->client->customersEdit($serialized['customer'], $request->by, $request->site);
return Deserializer::deserializeArray($response->getResponseBody(), CustomerChangeResponse::class);
}
/**
* Get customers history
*
* @param \Intaro\RetailCrm\Model\Api\Request\Customers\CustomersHistoryRequest $request
*
* @return HistoryResponse|null
*/
public function customersHistory(CustomersHistoryRequest $request): ?HistoryResponse
{
$response = $this->client->customersHistory(
Serializer::serializeArray($request->filter),
$request->page,
$request->limit
);
return Deserializer::deserializeArray($response->getResponseBody(), HistoryResponse::class);
}
}

View file

@ -0,0 +1,348 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Builder\API
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Builder\Api;
use Bitrix\Main\Type\DateTime;
use Bitrix\Sale\Order;
use Intaro\RetailCrm\Component\Builder\BuilderInterface;
use Intaro\RetailCrm\Component\Builder\Exception\BuilderException;
use Intaro\RetailCrm\Service\CollectorCookieExtractor;
use Intaro\RetailCrm\Component\ConfigProvider;
use Intaro\RetailCrm\Component\Converter\DateTimeConverter;
use Intaro\RetailCrm\Component\Events;
use Intaro\RetailCrm\Component\ServiceLocator;
use Intaro\RetailCrm\Model\Api\Address;
use Intaro\RetailCrm\Model\Api\Company;
use Intaro\RetailCrm\Model\Api\Contragent;
use Intaro\RetailCrm\Model\Api\Customer;
use Intaro\RetailCrm\Model\Api\CustomerContact;
use Intaro\RetailCrm\Model\Bitrix\User;
use Intaro\RetailCrm\Repository\UserRepository;
/**
* Class CorporateCustomerBuilder
*
*TODO
* Support for building corporate customers is partial for now. Full support should be implemented, which would be
* possible with a full refactoring. For current purposes this will work.
*
* @package Intaro\RetailCrm\Component\Builder\Api
*/
class CorporateCustomerBuilder implements BuilderInterface
{
/** @var \Intaro\RetailCrm\Model\Bitrix\User $user */
private $user;
/** @var \Intaro\RetailCrm\Model\Api\Customer $customer */
private $customer;
/** @var \Bitrix\Sale\Order $order */
private $order;
/** @var CollectorCookieExtractor */
private $cookieExtractor;
/** @var array */
private $sites;
/** @var array */
private $legalDetails;
/** @var array */
private $contragentTypes;
/** @var string */
private $foundAddress;
/** @var bool */
private $buildChildEntities = false;
/** @var bool */
private $mainCompany = false;
/** @var bool */
private $mainContact = false;
/** @var bool */
private $mainAddress = false;
/** @var bool */
private $attachDaemonCollectorId = false;
/**
* CorporateCustomerBuilder constructor.
*/
public function __construct()
{
$this->cookieExtractor = ServiceLocator::get(CollectorCookieExtractor::class);
$this->sites = ConfigProvider::getSitesList();
$this->legalDetails = ConfigProvider::getLegalDetails();
$this->contragentTypes = ConfigProvider::getContragentTypes();
}
/**
* @return $this|\Intaro\RetailCrm\Component\Builder\BuilderInterface
* @throws \Bitrix\Main\ArgumentException
* @throws \Bitrix\Main\NotImplementedException
* @throws \Bitrix\Main\ObjectPropertyException
* @throws \Bitrix\Main\SystemException
* @throws \Intaro\RetailCrm\Component\Builder\Exception\BuilderException
*/
public function build(): BuilderInterface
{
if (!($this->order instanceof Order)) {
throw new BuilderException('Order should be provided for building corporate customer!');
}
$contragentType = ConfigProvider::getContragentTypeForPersonType($this->order->getPersonTypeId());
if (null === $contragentType) {
throw new BuilderException(sprintf(
'Cannot find corresponding contragent type for PERSON_TYPE_ID `%s`',
$this->order->getPersonTypeId()
));
}
$this->customer = new Customer();
$dateCreated = $this->order->getDateInsert();
if ($dateCreated instanceof DateTime) {
$this->customer->createdAt = DateTimeConverter::bitrixToPhp($dateCreated);
}
$this->buildLegalDetails();
if ($this->buildChildEntities) {
$this->buildCustomerContact();
$this->buildCustomerCompany();
$this->buildCustomerAddresses();
}
if ($this->attachDaemonCollectorId) {
$this->buildDaemonCollectorId();
}
return $this;
}
/**
* @param bool $buildChildEntities
*
* @return CorporateCustomerBuilder
*/
public function setBuildChildEntities(bool $buildChildEntities): CorporateCustomerBuilder
{
$this->buildChildEntities = $buildChildEntities;
return $this;
}
/**
* @param bool $mainCompany
*
* @return CorporateCustomerBuilder
*/
public function setMainCompany(bool $mainCompany): CorporateCustomerBuilder
{
$this->mainCompany = $mainCompany;
return $this;
}
/**
* @param bool $mainContact
*
* @return CorporateCustomerBuilder
*/
public function setMainContact(bool $mainContact): CorporateCustomerBuilder
{
$this->mainContact = $mainContact;
return $this;
}
/**
* @inheritDoc
*/
public function reset(): BuilderInterface
{
$this->user = null;
$this->customer = null;
$this->order = null;
$this->foundAddress = null;
$this->buildChildEntities = false;
$this->mainAddress = false;
$this->mainCompany = false;
$this->mainContact = false;
$this->attachDaemonCollectorId = false;
return $this;
}
/**
* @inheritDoc
*/
public function getResult()
{
Events::push(Events::API_CORPORATE_CUSTOMER_BUILDER_GET_RESULT, ['customer' => $this->customer]);
return $this->customer;
}
/**
* @param \Intaro\RetailCrm\Model\Bitrix\User $user
*
* @return CorporateCustomerBuilder
*/
public function setUser(User $user): CorporateCustomerBuilder
{
$this->user = $user;
return $this;
}
/**
* @param \Bitrix\Sale\Order $order
*
* @return CorporateCustomerBuilder
* @throws \Bitrix\Main\ArgumentException
* @throws \Bitrix\Main\ObjectPropertyException
* @throws \Bitrix\Main\SystemException
* @throws \Intaro\RetailCrm\Component\Builder\Exception\BuilderException
*/
public function setOrder(Order $order): CorporateCustomerBuilder
{
$this->order = $order;
$userId = $order->getUserId();
if (null === $userId || !is_int($userId)) {
throw new BuilderException('Either user in order is not set or user id is not valid.');
}
$this->user = UserRepository::getById($userId);
return $this;
}
/**
* @param bool $attachDaemonCollectorId
*
* @return CorporateCustomerBuilder
*/
public function setAttachDaemonCollectorId(bool $attachDaemonCollectorId): CorporateCustomerBuilder
{
$this->attachDaemonCollectorId = $attachDaemonCollectorId;
return $this;
}
/**
* @throws \Bitrix\Main\ArgumentException
* @throws \Bitrix\Main\NotImplementedException
* @throws \Bitrix\Main\ObjectPropertyException
* @throws \Bitrix\Main\SystemException
*/
protected function buildLegalDetails(): void
{
$this->customer->contragent = new Contragent();
/** @var \Bitrix\Sale\PropertyValue $property */
foreach ($this->order->getPropertyCollection() as $property) {
if (ConfigProvider::getCorporateClientName() === $property->getField('CODE')) {
$this->customer->nickName = $property->getValue();
}
if (ConfigProvider::getCorporateClientAddress() === $property->getField('CODE')) {
$this->foundAddress = $property->getValue();
}
if (!empty($this->legalDetails)) {
$contragentProperty = array_search(
$property->getField('CODE'),
$this->legalDetails[$this->order->getPersonTypeId()],
false
);
if (property_exists(Contragent::class, $contragentProperty)) {
$this->customer->contragent->$contragentProperty = $property->getValue();
}
}
}
if (array_key_exists($this->order->getPersonTypeId(), $this->contragentTypes)) {
$this->customer->contragent->contragentType = $this->contragentTypes[$this->order->getPersonTypeId()];
}
if (empty($this->customer->nickName)) {
$this->customer->nickName = $this->user->getWorkCompany();
}
}
/**
* @throws \Intaro\RetailCrm\Component\Builder\Exception\BuilderException
*/
protected function buildCustomerContact(): void
{
$site = null;
$shop = $this->order->getField('LID');
if (array_key_exists($shop, $this->sites) && !empty($this->sites[$shop])) {
$site = $this->sites[$shop];
}
if (null === $site) {
throw new BuilderException(sprintf(
'Site `%s` is not connected to any sites in the retailCRM',
$shop
));
}
$contact = new CustomerContact();
$contact->isMain = $this->mainContact;
$contact->customer = new Customer();
$contact->customer->externalId = $this->user->getId();
$contact->customer->site = $site;
$this->customer->customerContacts = [$contact];
}
/**
* Builds customer company
*/
protected function buildCustomerCompany(): void
{
$company = new Company();
$company->name = $this->customer->nickName;
$company->isMain = $this->mainCompany;
$this->customer->companies = [$company];
}
/**
* Builds customer addresses
*/
protected function buildCustomerAddresses(): void
{
if (!empty($this->foundAddress)) {
$address = new Address();
$address->name = $this->customer->nickName;
$address->text = $this->foundAddress;
$address->isMain = $this->mainAddress;
$this->customer->addresses = [$address];
}
}
/**
* Integrated Daemon Collector cookie (if it's present).
*/
protected function buildDaemonCollectorId(): void
{
if ($this->cookieExtractor->extractCookie()) {
$this->customer->browserId = $this->cookieExtractor->extractCookie();
}
}
}

View file

@ -0,0 +1,222 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Builder\API
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Builder\Api;
use Intaro\RetailCrm\Component\Builder\Exception\BuilderException;
use Intaro\RetailCrm\Service\CollectorCookieExtractor;
use Intaro\RetailCrm\Component\ConfigProvider;
use Intaro\RetailCrm\Component\Converter\DateTimeConverter;
use Intaro\RetailCrm\Component\Events;
use Intaro\RetailCrm\Component\ServiceLocator;
use Intaro\RetailCrm\Model\Api\Address;
use Intaro\RetailCrm\Model\Api\Contragent;
use Intaro\RetailCrm\Model\Api\Customer;
use Intaro\RetailCrm\Model\Api\Phone;
use Intaro\RetailCrm\Model\Bitrix\User;
use Intaro\RetailCrm\Component\Builder\BuilderInterface;
/**
* Class CustomerBuilder
*
* @package Intaro\RetailCrm\Component\Builder\Api
*/
class CustomerBuilder implements BuilderInterface
{
/** @var \Intaro\RetailCrm\Model\Bitrix\User $user */
private $user;
/** @var \Intaro\RetailCrm\Model\Api\Customer $customer */
private $customer;
/** @var CollectorCookieExtractor */
private $cookieExtractor;
/** @var string $personTypeId */
private $personTypeId;
/** @var bool */
private $attachDaemonCollectorId = false;
/**
* CustomerBuilder constructor.
*/
public function __construct()
{
$this->cookieExtractor = ServiceLocator::get(CollectorCookieExtractor::class);
}
/**
* @inheritDoc
*/
public function build(): BuilderInterface
{
$contragentType = ConfigProvider::getContragentTypeForPersonType($this->personTypeId);
if (null === $contragentType) {
throw new BuilderException(sprintf(
'Cannot find corresponding contragent type for PERSON_TYPE_ID `%s`',
$this->personTypeId
));
}
$this->buildBase($contragentType);
$this->buildNames();
$this->buildPhones();
$this->buildAddress();
if ($this->attachDaemonCollectorId) {
$this->buildDaemonCollectorId();
}
return $this;
}
/**
* @inheritDoc
*/
public function reset(): BuilderInterface
{
$this->user = null;
$this->customer = null;
$this->personTypeId = null;
return $this;
}
/**
* @inheritDoc
*/
public function getResult()
{
Events::push(Events::API_CUSTOMER_BUILDER_GET_RESULT, ['customer' => $this->customer]);
return $this->customer;
}
/**
* @param \Intaro\RetailCrm\Model\Bitrix\User $user
*
* @return CustomerBuilder
*/
public function setUser(User $user): CustomerBuilder
{
$this->user = $user;
return $this;
}
/**
* @param string $personTypeId
*
* @return CustomerBuilder
*/
public function setPersonTypeId(string $personTypeId): CustomerBuilder
{
$this->personTypeId = $personTypeId;
return $this;
}
/**
* @param bool $attachDaemonCollectorId
*
* @return CustomerBuilder
*/
public function setAttachDaemonCollectorId(bool $attachDaemonCollectorId): CustomerBuilder
{
$this->attachDaemonCollectorId = $attachDaemonCollectorId;
return $this;
}
/**
* Create base customer with initial data.
*
* @param string $contragentType
*/
protected function buildBase(string $contragentType): void
{
$this->customer = new Customer();
$this->customer->contragent = new Contragent();
$this->customer->contragent->contragentType = $contragentType;
$this->customer->externalId = $this->user->getId();
$this->customer->email = $this->user->getEmail();
$this->customer->createdAt = $this->user->getDateRegister();
$this->customer->subscribed = false;
}
/**
* Build names.
*/
protected function buildNames(): void
{
$this->customer->firstName = $this->user->getName();
$this->customer->lastName = $this->user->getLastName();
$this->customer->patronymic = $this->user->getSecondName();
}
/**
* Build phones.
*/
protected function buildPhones(): void
{
$this->customer->phones = [];
if (!empty($this->user->getPersonalPhone())) {
$this->addPhone($this->user->getPersonalPhone());
}
if (!empty($this->user->getWorkPhone())) {
$this->addPhone($this->user->getWorkPhone());
}
}
/**
* Build address.
*/
protected function buildAddress(): void
{
$address = new Address();
if (!empty($this->user->getPersonalCity())) {
$address->city = $this->user->getPersonalCity();
}
if (!empty($this->user->getPersonalStreet())) {
$address->text = $this->user->getPersonalStreet();
}
if (!empty($this->user->getPersonalZip())) {
$address->index = $this->user->getPersonalZip();
}
$this->customer->address = $address;
}
/**
* Integrated Daemon Collector cookie (if it's present).
*/
protected function buildDaemonCollectorId(): void
{
if ($this->cookieExtractor->extractCookie()) {
$this->customer->browserId = $this->cookieExtractor->extractCookie();
}
}
/**
* @param string $number
*/
protected function addPhone(string $number): void
{
$phone = new Phone();
$phone->number = $number;
$this->customer->phones[] = $phone;
}
}

View file

@ -0,0 +1,236 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Builder\Bitrix
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Builder\Bitrix;
use Intaro\RetailCrm\Component\Builder\BuilderInterface;
use Intaro\RetailCrm\Component\Converter\DateTimeConverter;
use Intaro\RetailCrm\Component\Events;
use Intaro\RetailCrm\Component\ServiceLocator;
use Intaro\RetailCrm\Service\Utils;
use Intaro\RetailCrm\Model\Api\Customer;
use Intaro\RetailCrm\Model\Bitrix\User;
/**
* Class CustomerBuilder
*
* @package Intaro\RetailCrm\Component\Builder\Bitrix
*/
class CustomerBuilder implements BuilderInterface
{
/** @var \Intaro\RetailCrm\Model\Bitrix\User */
protected $user;
/** @var \Intaro\RetailCrm\Model\Api\Customer */
protected $customer;
/** @var Utils */
protected $utils;
/**
* CustomerBuilder constructor.
*/
public function __construct()
{
$this->utils = ServiceLocator::get(Utils::class);
}
/**
* @param \Intaro\RetailCrm\Model\Bitrix\User $user
*
* @return $this
*/
public function setUser($user): self
{
$this->user = $user;
return $this;
}
/**
* @return \Intaro\RetailCrm\Model\Bitrix\User
*/
public function getUser(): User
{
return $this->user;
}
/**
* @param \Intaro\RetailCrm\Model\Api\Customer $customer
*
* @return CustomerBuilder
*/
public function setCustomer(Customer $customer): CustomerBuilder
{
$this->customer = $customer;
return $this;
}
public function build(): BuilderInterface
{
if (null === $this->user) {
$this->user = new User();
}
$this->buildNames();
$this->buildPhones();
$this->buildAddress();
$this->buildBirthdaySexAndEmail();
$this->fillFieldsForHistoryClient();
return $this;
}
/**
* @param string $login
* @return $this
*/
public function setLogin($login): self
{
$this->user->setLogin($login);
return $this;
}
/**
* @param string $email
* @return $this
*/
public function setEmail($email): self
{
$this->user->setEmail($email);
return $this;
}
/**
* @inheritDoc
*/
public function reset(): BuilderInterface
{
$this->customer = null;
$this->user = null;
return $this;
}
/**
* @inheritDoc
*/
public function getResult()
{
Events::push(Events::BITRIX_CUSTOMER_BUILDER_GET_RESULT, ['customer' => $this->user]);
return $this->user;
}
/**
* Fill first name, last name and second name in the user
*/
protected function buildNames(): void
{
if (!empty($this->customer->firstName)) {
$this->user->setName($this->utils->fromUTF8($this->customer->firstName));
}
if (!empty($this->customer->lastName)) {
$this->user->setLastName($this->utils->fromUTF8($this->customer->lastName));
}
if (!empty($this->customer->patronymic)) {
$this->user->setSecondName($this->utils->fromUTF8($this->customer->patronymic));
}
}
/**
* Fill phone numbers in the user
*/
protected function buildPhones(): void
{
if (!empty($this->customer->phones)) {
foreach ($this->customer->phones as $phone) {
if (!empty($phone->oldNumber)) {
if ($this->user->getPersonalPhone() == $phone->oldNumber) {
$this->user->setPersonalPhone($phone->number);
}
if ($this->user->getWorkPhone() == $phone->oldNumber) {
$this->user->setWorkPhone($phone->number);
}
}
if (isset($phone->number)) {
if (strlen($this->user->getPersonalPhone()) == 0
&& $this->user->getPersonalPhone() != $phone->number
) {
$this->user->setPersonalPhone($phone->number);
continue;
}
if (strlen($this->user->getPersonalMobile()) == 0
&& $this->user->getPersonalMobile() != $phone->number
) {
$this->user->setPersonalMobile($phone->number);
continue;
}
}
}
}
}
/**
* Fill zip code and city in the user
*/
protected function buildAddress(): void
{
if (!empty($this->customer->address)) {
if (!empty($this->customer->address->index)) {
$this->user->setPersonalZip($this->utils->fromUTF8($this->customer->address->index));
}
if (!empty($this->customer->address->city)) {
$this->user->setPersonalCity($this->utils->fromUTF8($this->customer->address->city));
}
}
}
/**
* Fill birthday, email and gender in the user
*/
protected function buildBirthdaySexAndEmail(): void
{
if (!empty($this->customer->birthday)) {
$this->user->setPersonalBirthday(DateTimeConverter::phpToBitrix($this->customer->birthday));
}
if (!empty($this->customer->email)) {
$this->user->setEmail($this->utils->fromUTF8($this->customer->email));
}
if (!empty($this->customer->sex)) {
$this->user->setPersonalGender($this->utils->fromUTF8($this->customer->sex));
}
}
/**
* Fill fields with placeholders in the user (only for new users from history, when some data is not provided).
*/
protected function fillFieldsForHistoryClient(): void
{
if (empty($this->customer->externalId)) {
$this->user->setPassword($this->utils->createPlaceholderPassword());
}
if (empty($this->customer->email) && empty($this->customer->externalId)) {
$login = $this->utils->createPlaceholderEmail();
$this->user->setLogin($login);
$this->user->setEmail($login);
}
}
}

View file

@ -0,0 +1,42 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Builder
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Builder;
/**
* Interface BuilderInterface
*
* @package Intaro\RetailCrm\Component\Builder
*/
interface BuilderInterface
{
/**
* Builds result
*
* @return \Intaro\RetailCrm\Component\Builder\BuilderInterface
* @throws \Intaro\RetailCrm\Component\Builder\Exception\BuilderException
*/
public function build(): BuilderInterface;
/**
* Resets builder
*
* @return \Intaro\RetailCrm\Component\Builder\BuilderInterface
*/
public function reset(): BuilderInterface;
/**
* Returns builder result
*
* @return mixed
*/
public function getResult();
}

View file

@ -0,0 +1,21 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Builder\Exception
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Builder\Exception;
/**
* Class BuilderException
*
* @package Intaro\RetailCrm\Component\Builder\Exception
*/
class BuilderException extends \Exception
{
}

View file

@ -0,0 +1,663 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component;
use Bitrix\Main\ArgumentNullException;
use Bitrix\Main\ArgumentOutOfRangeException;
use Bitrix\Main\Config\Option;
/**
* Class ConfigProvider
*
* @package Intaro\RetailCrm\Component
*/
class ConfigProvider
{
/** @var bool|null|string */
protected static $apiUrl;
/** @var bool|null|string */
protected static $apiKey;
/** @var bool|null|string */
protected static $catalogBasePrice;
/** @var bool|null|string */
protected static $currency;
/** @var bool|null|string */
protected static $orderDimensions;
/** @var bool|null|string */
protected static $corporateClientName;
/** @var bool|null|string */
protected static $corporateClientAddress;
/** @var bool|null|string */
protected static $corporateClient;
/** @var bool|null|string $shipmentDeducted */
protected static $shipmentDeducted;
/** @var array $sitesList */
protected static $sitesList;
/** @var array $sitesListCorporate */
protected static $sitesListCorporate;
/** @var bool|null|string $orderNumbers */
protected static $orderNumbers;
/** @var array $orderTypes */
protected static $orderTypes;
/** @var array $deliveryTypes */
protected static $deliveryTypes;
/** @var array $paymentTypes */
protected static $paymentTypes;
/** @var array $paymentStatuses */
protected static $paymentStatuses;
/** @var array $payment */
protected static $payment;
/** @var array $orderProps */
protected static $orderProps;
/** @var array $legalDetails */
protected static $legalDetails;
/** @var array $contragentTypes */
protected static $contragentTypes;
/** @var array $cancellableOrderPaymentStatuses */
protected static $cancellableOrderPaymentStatuses;
/** @var array $customFields */
protected static $customFields;
/** @var array $infoblocksInventories */
protected static $infoblocksInventories;
/** @var array $stores */
protected static $stores;
/** @var array $shops */
protected static $shops;
/** @var array $integrationDeliveriesMapping */
protected static $integrationDeliveriesMapping;
/**
* @return bool|string|null
*/
public static function getApiUrl()
{
if (self::isEmptyNotZero(static::$apiUrl)) {
static::$apiUrl = static::getOption(Constants::CRM_API_HOST_OPTION);
}
return static::$apiUrl;
}
/**
* @return bool|string|null
*/
public static function getApiKey()
{
if (self::isEmptyNotZero(static::$apiKey)) {
static::$apiKey = static::getOption(Constants::CRM_API_KEY_OPTION);
}
return static::$apiKey;
}
/**
* getCorporateClientName
*
* @return bool|string|null
*/
public static function getCorporateClientName()
{
if (self::isEmptyNotZero(static::$corporateClientName)) {
static::$corporateClientName = static::getUnserializedOption(Constants::CRM_CORP_NAME);
}
return static::$corporateClientName;
}
/**
* getCorporateClientAddress
*
* @return bool|string|null
*/
public static function getCorporateClientAddress()
{
if (self::isEmptyNotZero(static::$corporateClientAddress)) {
static::$corporateClientAddress = static::getUnserializedOption(Constants::CRM_CORP_ADDRESS);
}
return static::$corporateClientAddress;
}
/**
* getCorporateClient
*
* @return bool|string|null
*/
public static function getCorporateClientStatus()
{
if (self::isEmptyNotZero(static::$corporateClient)) {
static::$corporateClient = static::getOption(Constants::CRM_CC);
}
return static::$corporateClient;
}
/**
* Returns true if corporate clients are enabled
*
* @return bool
*/
public static function isCorporateClientEnabled(): bool
{
return self::getCorporateClientStatus() === 'Y';
}
/**
* getSitesList
*
* @return array
*/
public static function getSitesList()
{
if (self::isEmptyNotZero(static::$sitesList)) {
static::$sitesList = static::getUnserializedOption(Constants::CRM_SITES_LIST);
}
return static::$sitesList;
}
/**
* getSitesListCorporate
*
* @return array
*/
public static function getSitesListCorporate()
{
if (self::isEmptyNotZero(static::$sitesListCorporate)) {
static::$sitesListCorporate = static::getUnserializedOption(
Constants::CRM_SITES_LIST_CORPORATE
);
}
return static::$sitesListCorporate;
}
/**
* getOrderTypes
*
* @return array
*/
public static function getOrderTypes()
{
if (self::isEmptyNotZero(static::$orderTypes)) {
static::$orderTypes = static::getUnserializedOption(Constants::CRM_ORDER_TYPES_ARR);
}
return static::$orderTypes;
}
/**
* getDeliveryTypes
*
* @return array
*/
public static function getDeliveryTypes()
{
if (self::isEmptyNotZero(static::$deliveryTypes)) {
static::$deliveryTypes = static::getUnserializedOption(Constants::CRM_DELIVERY_TYPES_ARR);
}
return static::$deliveryTypes;
}
/**
* getPaymentTypes
*
* @return array
*/
public static function getPaymentTypes()
{
if (self::isEmptyNotZero(static::$paymentTypes)) {
static::$paymentTypes = static::getUnserializedOption(Constants::CRM_PAYMENT_TYPES);
}
return static::$paymentTypes;
}
/**
* getPaymentStatuses
*
* @return array
*/
public static function getPaymentStatuses()
{
if (self::isEmptyNotZero(static::$paymentStatuses)) {
static::$paymentStatuses = static::getUnserializedOption(Constants::CRM_PAYMENT_STATUSES);
}
return static::$paymentStatuses;
}
/**
* getPayment
*
* @return array
*/
public static function getPayment()
{
if (self::isEmptyNotZero(static::$payment)) {
static::$payment = static::getUnserializedOption(Constants::CRM_PAYMENT);
}
return static::$payment;
}
/**
* getOrderProps
*
* @return array
*/
public static function getOrderProps()
{
if (self::isEmptyNotZero(static::$orderProps)) {
static::$orderProps = static::getUnserializedOption(Constants::CRM_ORDER_PROPS);
}
return static::$orderProps;
}
/**
* getLegalDetails
*
* @return array
*/
public static function getLegalDetails()
{
if (self::isEmptyNotZero(static::$legalDetails)) {
static::$legalDetails = static::getUnserializedOption(Constants::CRM_LEGAL_DETAILS);
}
return static::$legalDetails;
}
/**
* getContragentTypes
*
* @return array
*/
public static function getContragentTypes()
{
if (self::isEmptyNotZero(static::$contragentTypes)) {
static::$contragentTypes = static::getUnserializedOption(Constants::CRM_CONTRAGENT_TYPE);
}
return static::$contragentTypes;
}
/**
* Returns contragent type for provided person type (PERSON_TYPE_ID in the Bitrix order).
* Returns null if nothing was found.
*
* @param string $personTypeId
*
* @return string|null
*/
public static function getContragentTypeForPersonType(string $personTypeId): ?string
{
$personTypes = static::getContragentTypes();
if (!empty($personTypes[$personTypeId])) {
return $personTypes[$personTypeId];
}
return null;
}
/**
* getCustomFields
*
* @return array
*/
public static function getCustomFields()
{
if (self::isEmptyNotZero(static::$customFields)) {
static::$customFields = static::getUnserializedOption(Constants::CRM_CUSTOM_FIELDS);
}
return static::$customFields;
}
/**
* getCancellableOrderPaymentStatuses
*
* @return array
*/
public static function getCancellableOrderPaymentStatuses()
{
if (self::isEmptyNotZero(static::$cancellableOrderPaymentStatuses)) {
static::$cancellableOrderPaymentStatuses = static::getUnserializedOption(
Constants::CRM_CANCEL_ORDER
);
}
return static::$cancellableOrderPaymentStatuses;
}
/**
* getLastOrderId
*
* @return bool|string|null
*/
public static function getLastOrderId()
{
return static::getOption(Constants::CRM_ORDER_LAST_ID);
}
/**
* setLastOrderId
*
* @param $id
*/
public static function setLastOrderId($id): void
{
static::setOption(Constants::CRM_ORDER_LAST_ID, $id);
}
/**
* getFailedOrdersIds
*
* @return array
*/
public static function getFailedOrdersIds()
{
return static::getUnserializedOption(Constants::CRM_ORDER_FAILED_IDS);
}
/**
* setFailedOrdersIds
*
* @param $ids
*/
public static function setFailedOrdersIds($ids): void
{
static::setOption(Constants::CRM_ORDER_FAILED_IDS, serialize($ids));
}
/**
* getOrderNumbers
*
* @return bool|string|null
*/
public static function getOrderNumbers()
{
if (self::isEmptyNotZero(self::$orderNumbers)) {
self::$orderNumbers = static::getOption(Constants::CRM_ORDER_NUMBERS);
}
return self::$orderNumbers;
}
/**
* getOrderHistoryDate
*
* @return bool|string|null
*/
public static function getOrderHistoryDate()
{
return static::getOption(Constants::CRM_ORDER_HISTORY_DATE);
}
/**
* Returns customers history since ID
*
* @return int
*/
public static function getCustomersHistorySinceId(): int
{
return (int) static::getOption(Constants::CRM_CUSTOMERS_HISTORY_SINCE_ID);
}
/**
* Sets new customers history since ID
*
* @param int $sinceId
*/
public static function setCustomersHistorySinceId($sinceId): void
{
static::setOption(Constants::CRM_CUSTOMERS_HISTORY_SINCE_ID, $sinceId);
}
/**
* getCatalogBasePrice
*
* @return bool|string|null
*/
public static function getCatalogBasePrice()
{
if (self::isEmptyNotZero(static::$catalogBasePrice)) {
static::$catalogBasePrice = static::getOption(Constants::CRM_CATALOG_BASE_PRICE);
}
return static::$catalogBasePrice;
}
/**
* getOrderDimensions
*
* @return bool|string|null
*/
public static function getOrderDimensions()
{
if (self::isEmptyNotZero(static::$orderDimensions)) {
static::$orderDimensions = static::getOption(Constants::CRM_ORDER_DIMENSIONS, 'N');
}
return static::$orderDimensions;
}
/**
* getCurrency
*
* @return bool|string|null
*/
public static function getCurrency()
{
if (self::isEmptyNotZero(static::$currency)) {
static::$currency = static::getOption(Constants::CRM_CURRENCY);
}
return static::$currency;
}
/**
* Returns currency from settings. If it's not set - returns Bitrix base currency.
*
* @return bool|string|null
*/
public static function getCurrencyOrDefault()
{
return self::getCurrency() ? self::getCurrency() : \Bitrix\Currency\CurrencyManager::getBaseCurrency();
}
/**
* getInfoblocksInventories
*
* @return array
*/
public static function getInfoblocksInventories()
{
if (self::isEmptyNotZero(static::$infoblocksInventories)) {
static::$infoblocksInventories = static::getUnserializedOption(
Constants::CRM_IBLOCKS_INVENTORIES
);
}
return static::$infoblocksInventories;
}
/**
* getStores
*
* @return array
*/
public static function getStores()
{
if (self::isEmptyNotZero(static::$stores)) {
static::$stores = static::getUnserializedOption(Constants::CRM_STORES);
}
return static::$stores;
}
/**
* getShops
*
* @return array
*/
public static function getShops()
{
if (self::isEmptyNotZero(static::$shops)) {
static::$shops = static::getUnserializedOption(Constants::CRM_SHOPS);
}
return static::$shops;
}
/**
* getShipmentDeducted
*
* @return bool|string|null
*/
public static function getShipmentDeducted()
{
if (self::isEmptyNotZero(static::$shipmentDeducted)) {
static::$shipmentDeducted = static::getOption(Constants::CRM_SHIPMENT_DEDUCTED);
}
return static::$shipmentDeducted;
}
/**
* isPhoneRequired
*
* @return bool|string|null
*/
public static function isPhoneRequired()
{
return static::getExternalOption("main", "new_user_phone_required") === 'Y';
}
/**
* Returns integration delivery mapping
*
* @return array
*/
public static function getIntegrationDeliveriesMapping(): array
{
if (empty(self::$integrationDeliveriesMapping)) {
self::$integrationDeliveriesMapping =
(array) static::getUnserializedOption(Constants::CRM_INTEGRATION_DELIVERY);
}
return self::$integrationDeliveriesMapping;
}
/**
* Wraps Bitrix \COption::GetOptionString(...)
*
* @param string $option
* @param int|string $def
*
* @return string|null
*/
protected static function getOption($option, $def = 0): ?string
{
return static::getExternalOption(Constants::MODULE_ID, $option, $def);
}
/**
* Returns option from provided module
*
* @param string $moduleId
* @param string $option
* @param int $def
*
* @return string|null
*/
protected static function getExternalOption(string $moduleId, string $option, $def = 0): ?string
{
try {
return Option::get($moduleId, $option, $def);
} catch (ArgumentNullException | ArgumentOutOfRangeException $e) {
return null;
}
}
/**
* setOption
*
* @param $name
* @param string $value
* @param string $site
*
* @throws \Bitrix\Main\ArgumentOutOfRangeException
*/
protected static function setOption($name, $value = "", $site = ""): void
{
Option::set(
Constants::MODULE_ID,
$name,
$value,
$site
);
}
/**
* Wraps Bitrix unserialize(\COption::GetOptionString(...))
*
* @param string $option
* @param int|string $def
*
* @return mixed
*/
protected static function getUnserializedOption($option, $def = 0)
{
return unserialize(static::getOption($option, $def), null);
}
/**
* Returns true if value is empty and not zero (0 - digit)
*
* @param mixed $value
*
* @return bool
*/
protected static function isEmptyNotZero($value): bool
{
return empty($value) && $value !== 0;
}
}

View file

@ -0,0 +1,72 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component;
/**
* Class Constants
*
* @package Intaro\RetailCrm\Component
*/
class Constants
{
public const MODULE_ID = 'intaro.retailcrm';
public const CRM_API_HOST_OPTION = 'api_host';
public const CRM_API_KEY_OPTION = 'api_key';
public const CRM_ORDER_TYPES_ARR = 'order_types_arr';
public const CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr';
public const CRM_DELIVERY_SERVICES_ARR = 'deliv_services_arr';
public const CRM_PAYMENT_TYPES = 'pay_types_arr';
public const CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
public const CRM_PAYMENT = 'payment_arr'; //order payment Y/N
public const CRM_ORDER_LAST_ID = 'order_last_id';
public const CRM_ORDER_SITES = 'sites_ids';
public const CRM_ORDER_DISCHARGE = 'order_discharge';
public const CRM_SITES_LIST = 'sites_list';
public const CRM_ORDER_PROPS = 'order_props';
public const CRM_LEGAL_DETAILS = 'legal_details';
public const CRM_CUSTOM_FIELDS = 'custom_fields';
public const CRM_CONTRAGENT_TYPE = 'contragent_type';
public const CRM_SITES_LIST_CORPORATE = 'shops-corporate';
public const CRM_ORDER_NUMBERS = 'order_numbers';
public const CRM_CANCEL_ORDER = 'cansel_order';
public const CRM_INVENTORIES_UPLOAD = 'inventories_upload';
public const CRM_STORES = 'stores';
public const CRM_SHOPS = 'shops';
public const CRM_IBLOCKS_INVENTORIES = 'iblocks_inventories';
public const CRM_PRICES_UPLOAD = 'prices_upload';
public const CRM_PRICES = 'prices';
public const CRM_PRICE_SHOPS = 'price_shops';
public const CRM_IBLOCKS_PRICES = 'iblock_prices';
public const CRM_COLLECTOR = 'collector';
public const CRM_COLL_KEY = 'coll_key';
public const CRM_UA = 'ua';
public const CRM_UA_KEYS = 'ua_keys';
public const CRM_DISCOUNT_ROUND = 'discount_round';
public const CRM_CC = 'cc';
public const CRM_CORP_SHOPS = 'shops-corporate';
public const CRM_CORP_NAME = 'nickName-corporate';
public const CRM_CORP_ADDRESS = 'adres-corporate';
public const CRM_API_VERSION = 'api_version';
public const CRM_CURRENCY = 'currency';
public const CRM_ADDRESS_OPTIONS = 'address_options';
public const CRM_DIMENSIONS = 'order_dimensions';
public const PROTOCOL = 'protocol';
public const CRM_ORDER_FAILED_IDS = 'order_failed_ids';
public const CRM_CUSTOMERS_HISTORY_SINCE_ID = 'customer_history';
public const CRM_ORDER_HISTORY_DATE = 'order_history_date';
public const CRM_CATALOG_BASE_PRICE = 'catalog_base_price';
public const CRM_ORDER_DIMENSIONS = 'order_dimensions';
public const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
public const CRM_INTEGRATION_DELIVERY = 'integration_delivery';
public const CRM_SHIPMENT_DEDUCTED = 'shipment_deducted';
public const CORPORATE_CONTRAGENT_TYPE = 'legal-entity';
}

View file

@ -0,0 +1,54 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Converter
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Converter;
use Bitrix\Main\Type\DateTime as BitrixDateTime;
/**
* Class DateTimeConverter
*
* @package Intaro\RetailCrm\Component\Converter
*/
class DateTimeConverter
{
/**
* Intermediate format for converting Bitrix DateTime to PHP DateTime
*/
const INTERMEDIATE_FORMAT = 'U';
/**
* Converts Bitrix DateTime to php version
*
* @param \Bitrix\Main\Type\DateTime $dateTime
*
* @return \DateTime
*/
public static function bitrixToPhp(BitrixDateTime $dateTime): \DateTime
{
return \DateTime::createFromFormat(
static::INTERMEDIATE_FORMAT,
$dateTime->format(static::INTERMEDIATE_FORMAT)
);
}
/**
* Converts PHP DateTime to Bitrix version
*
* @param \DateTime $dateTime
*
* @return \Bitrix\Main\Type\DateTime
*/
public static function phpToBitrix(\DateTime $dateTime): BitrixDateTime
{
return BitrixDateTime::createFromPhp($dateTime);
}
}

View file

@ -0,0 +1,95 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component;
/**
* Class DependencyLoader
*
* @package Intaro\RetailCrm\Component
*/
class DependencyLoader
{
/** @var int */
const LEGACY_LOADER = 0;
/** @var int */
const D7_LOADER = 1;
/** @var int $loader */
private static $loader = self::D7_LOADER;
/**
* Loads dependencies
*
* @return bool
*/
public static function loadDependencies()
{
foreach (self::getDependencies() as $dependency) {
if (self::LEGACY_LOADER == self::$loader) {
if (!CModule::IncludeModule($dependency)) {
RCrmActions::eventLog(
__CLASS__ . '::' . __METHOD__,
$dependency,
'module not found'
);
return false;
}
} else {
try {
if (!\Bitrix\Main\Loader::includeModule($dependency)) {
RCrmActions::eventLog(
__CLASS__ . '::' . __METHOD__,
$dependency,
'module not found'
);
return false;
}
} catch (\Bitrix\Main\LoaderException $exception) {
RCrmActions::eventLog(
__CLASS__ . '::' . __METHOD__,
$dependency,
sprintf('error while trying to load module: %s', $exception->getMessage())
);
return false;
}
}
}
return true;
}
/**
* Set loader mode. Use RetailcrmDependencyLoader::LEGACY_LOADER or RetailcrmDependencyLoader::D7_LOADER
*
* @param $loader
*/
public static function setLoader($loader)
{
if (in_array($loader, array(self::LEGACY_LOADER, self::D7_LOADER))) {
self::$loader = $loader;
}
}
/**
* Returns array of required modules names
*
* @return array<string>
*/
public static function getDependencies()
{
return array("iblock", "sale", "catalog");
}
}

View file

@ -0,0 +1,49 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component;
use Bitrix\Main\Event;
/**
* Class Events
*
* @package Intaro\RetailCrm\Component
*/
class Events
{
/**
* Fired before returning result from retailCRM customer builder (customer for retailCRM API)
*/
public const API_CUSTOMER_BUILDER_GET_RESULT = 'OnRetailcrmApiCustomerBuilderGetResult';
/**
* Fired before returning result from retailCRM corporate customer builder (customer for retailCRM API)
*/
public const API_CORPORATE_CUSTOMER_BUILDER_GET_RESULT = 'OnRetailcrmApiCorporateCustomerBuilderGetResult';
/**
* Fired before returning result from retailCRM customer builder (builds user data for Bitrix)
*/
public const BITRIX_CUSTOMER_BUILDER_GET_RESULT = 'OnRetailcrmBitrixCustomerBuilderGetResult';
/**
* Push event
*
* @param string $eventType
* @param array $eventParams
*/
public static function push(string $eventType, array $eventParams): void
{
$event = new Event(Constants::MODULE_ID, $eventType, $eventParams);
$event->send();
}
}

View file

@ -0,0 +1,88 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json;
use Intaro\RetailCrm\Component\Json\Mapping\PostDeserialize;
use Intaro\RetailCrm\Component\Json\Strategy\AnnotationReaderTrait;
use Intaro\RetailCrm\Component\Json\Strategy\StrategyFactory;
use RetailCrm\Exception\InvalidJsonException;
/**
* Class Deserializer
*
* @package Intaro\RetailCrm\Component\Json
*/
class Deserializer
{
use AnnotationReaderTrait;
/**
* @param string $type
* @param string $json
*
* @return mixed
*/
public static function deserialize(string $json, string $type)
{
$result = json_decode($json, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new InvalidJsonException(json_last_error_msg(), json_last_error());
}
return static::deserializeArray($result, $type);
}
/**
* @param string $type
* @param array $value
*
* @return mixed
*/
public static function deserializeArray(array $value, string $type)
{
$result = StrategyFactory::deserializeStrategyByType($type)->deserialize($type, $value);
static::processPostDeserialize($result);
return $result;
}
/**
* Process post deserialize callback
*
* @param object $object
*/
private static function processPostDeserialize($object): void
{
$class = get_class($object);
if ($object) {
try {
$reflection = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
return;
}
foreach ($reflection->getMethods() as $method) {
$postDeserialize = static::annotationReader()
->getMethodAnnotation($method, PostDeserialize::class);
if ($postDeserialize instanceof PostDeserialize) {
$method->invoke($object);
break;
}
}
}
}
}

View file

@ -0,0 +1,21 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Exception
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Exception;
/**
* Class InvalidAnnotationException
*
* @package Intaro\RetailCrm\Component\Json\Exception
*/
class InvalidAnnotationException extends \Exception
{
}

View file

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Mapping
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Target;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Attribute;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Attributes;
/**
* Class Accessor
*
* @package Intaro\RetailCrm\Component\Json\Mapping
* @Annotation
* @Attributes(
* @Attribute("getter", required=false, type="string"),
* @Attribute("setter", required=false, type="string")
* )
* @Target({"PROPERTY","ANNOTATION"})
*/
final class Accessor
{
/**
* Property getter
*
* @var string
*/
public $getter;
/**
* Property setter
*
* @var string
*/
public $setter;
}

View file

@ -0,0 +1,26 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Mapping
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Target;
/**
* Class NoTransform
*
* @package Intaro\RetailCrm\Component\Json\Mapping
* @Annotation
* @Target({"PROPERTY","ANNOTATION"})
*/
final class NoTransform
{
}

View file

@ -0,0 +1,26 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Mapping
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Target;
/**
* Class PostDeserialize
*
* @package Intaro\RetailCrm\Component\Json\Mapping
* @Annotation
* @Target({"METHOD"})
*/
final class PostDeserialize
{
}

View file

@ -0,0 +1,26 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Mapping
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Target;
/**
* Class PostDeserialize
*
* @package Intaro\RetailCrm\Component\Json\Mapping
* @Annotation
* @Target({"METHOD"})
*/
final class PostSerialize
{
}

View file

@ -0,0 +1,37 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Mapping
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Target;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Attribute;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Attributes;
/**
* Class SerializedName
*
* @package Intaro\RetailCrm\Component\Json\Mapping
* @Annotation
* @Attributes(
* @Attribute("name", required=true, type="string")
* )
* @Target({"PROPERTY","ANNOTATION"})
*/
final class SerializedName
{
/**
* Property name in result JSON
*
* @var string
*/
public $name;
}

View file

@ -0,0 +1,37 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Mapping
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Target;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Attribute;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\Annotation\Attributes;
/**
* Class Type
*
* @package Intaro\RetailCrm\Component\Json\Mapping
* @Annotation
* @Attributes(
* @Attribute("type", required=false, type="string")
* )
* @Target({"PROPERTY","ANNOTATION"})
*/
final class Type
{
/**
* Property type
*
* @var string
*/
public $type;
}

View file

@ -0,0 +1,90 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json;
use Intaro\RetailCrm\Component\Json\Mapping\PostSerialize;
use Intaro\RetailCrm\Component\Json\Strategy\AnnotationReaderTrait;
use Intaro\RetailCrm\Component\Json\Strategy\StrategyFactory;
use RetailCrm\Exception\InvalidJsonException;
/**
* Class Serializer
*
* @package Intaro\RetailCrm\Component\Json
*/
class Serializer
{
use AnnotationReaderTrait;
/**
* @param mixed $object
* @param string $type
*
* @return string
*/
public static function serialize($object, string $type = ''): string
{
$result = json_encode(static::serializeArray($object, $type));
if (json_last_error() !== JSON_ERROR_NONE) {
throw new InvalidJsonException(json_last_error_msg(), json_last_error());
}
return (string) $result;
}
/**
* @param mixed $object
* @param string $type
*
* @return array
*/
public static function serializeArray($object, string $type = ''): array
{
$type = empty($type) ? gettype($object) : $type;
$result = (array) StrategyFactory::serializeStrategyByType($type)->serialize($object);
return static::processPostSerialize($object, $result);
}
/**
* Process post deserialize callback
*
* @param object $object
* @param array $result
*
* @return array
*/
private static function processPostSerialize($object, array $result): array
{
$class = get_class($object);
if ($object) {
try {
$reflection = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
return $result;
}
foreach ($reflection->getMethods() as $method) {
$postDeserialize = static::annotationReader()
->getMethodAnnotation($method, PostSerialize::class);
if ($postDeserialize instanceof PostSerialize) {
return $method->invokeArgs($object, [$result]);
}
}
}
return $result;
}
}

View file

@ -0,0 +1,31 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy;
use Intaro\RetailCrm\Component\ServiceLocator;
use Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\AnnotationReader;
/**
* Trait AnnotationReaderTrait
*
* @package Intaro\RetailCrm\Component\Json
*/
trait AnnotationReaderTrait
{
/**
* @return \Intaro\RetailCrm\Vendor\Doctrine\Common\Annotations\AnnotationReader
*/
private static function annotationReader()
{
return ServiceLocator::get(AnnotationReader::class);
}
}

View file

@ -0,0 +1,40 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Deserialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Deserialize;
/**
* Class DateTimeStrategy
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Deserialize
*/
class DateTimeStrategy implements DeserializeStrategyInterface
{
use InnerTypeTrait;
/**
* @inheritDoc
*/
public function deserialize(string $type, $value)
{
if (!empty($value)) {
$result = \DateTime::createFromFormat($this->innerType, $value);
if (!$result) {
return null;
}
return $result;
}
return null;
}
}

View file

@ -0,0 +1,39 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Deserialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Deserialize;
/**
* Interface DeserializeStrategyInterface
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
*/
interface DeserializeStrategyInterface
{
/**
* Deserialize value
*
* @param string $type
* @param mixed $value
*
* @return mixed
*/
public function deserialize(string $type, $value);
/**
* Sets inner type for types like array<key, value> and \DateTime<format>
*
* @param string $type
*
* @return \Intaro\RetailCrm\Component\Json\Strategy\Deserialize\DeserializeStrategyInterface
*/
public function setInnerType(string $type): DeserializeStrategyInterface;
}

View file

@ -0,0 +1,99 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Deserialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Deserialize;
use Intaro\RetailCrm\Component\Json\Mapping\Accessor;
use Intaro\RetailCrm\Component\Json\Mapping\SerializedName;
use Intaro\RetailCrm\Component\Json\Mapping\Type;
use Intaro\RetailCrm\Component\Json\Strategy\AnnotationReaderTrait;
use Intaro\RetailCrm\Component\Json\Strategy\IsNoTransformTrait;
use Intaro\RetailCrm\Component\Json\Strategy\StrategyFactory;
/**
* Class EntityStrategy
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
*/
class EntityStrategy implements DeserializeStrategyInterface
{
use InnerTypeTrait;
use IsNoTransformTrait;
/**
* @param string $type
* @param mixed $value
*
* @return mixed
* @throws \ReflectionException
*/
public function deserialize(string $type, $value)
{
if (empty($value)) {
return null;
}
$reflection = new \ReflectionClass($type);
$instance = new $type();
if (!$reflection->isUserDefined()) {
if (is_iterable($value)) {
foreach ($value as $field => $content) {
$instance->$field = $content;
}
}
return $instance;
}
foreach ($reflection->getProperties() as $property) {
static::deserializeProperty($instance, $property, $value);
}
return $instance;
}
/**
* @param object $object
* @param \ReflectionProperty $property
* @param array $data
*/
protected static function deserializeProperty($object, \ReflectionProperty $property, array $data): void
{
$nameData = static::annotationReader()->getPropertyAnnotation($property, SerializedName::class);
if (!($nameData instanceof SerializedName)) {
return;
}
$accessorData = static::annotationReader()->getPropertyAnnotation($property, Accessor::class);
$typeData = static::annotationReader()->getPropertyAnnotation($property, Type::class);
if ($typeData instanceof Type) {
$type = $typeData->type;
} else {
$type = gettype($data[$nameData->name]);
}
if (static::isNoTransform($property)) {
$value = $data[$nameData->name];
} else {
$value = StrategyFactory::deserializeStrategyByType($type)->deserialize($type, $data[$nameData->name]);
}
if ($accessorData instanceof Accessor && !empty($accessorData->setter)) {
$object->{$accessorData->setter}($value);
} else {
$property->setAccessible(true);
$property->setValue($object, $value);
}
}
}

View file

@ -0,0 +1,36 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Deserialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Deserialize;
/**
* Trait InnerTypeTrait
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Deserialize
*/
trait InnerTypeTrait
{
/** @var string $innerType */
private $innerType;
/**
* Sets inner type for types like array<key, value> and \DateTime<format>
*
* @param string $type
*
* @return \Intaro\RetailCrm\Component\Json\Strategy\Serialize\DeserializeStrategyInterface
*/
public function setInnerType(string $type): DeserializeStrategyInterface
{
$this->innerType = $type;
return $this;
}
}

View file

@ -0,0 +1,49 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Deserialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Deserialize;
/**
* Class SimpleTypeStrategy
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
*/
class SimpleTypeStrategy implements DeserializeStrategyInterface
{
use InnerTypeTrait;
/**
* @inheritDoc
*/
public function deserialize(string $type, $value)
{
switch ($type) {
case 'bool':
case 'boolean':
return (bool) $value;
case 'int':
case 'integer':
return (int) $value;
case 'float':
return (float) $value;
case 'double':
return (double) $value;
case 'string':
return (string) $value;
default:
if (is_iterable($value)) {
return (array) $value;
}
return null;
}
}
}

View file

@ -0,0 +1,62 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Deserialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Deserialize;
use Intaro\RetailCrm\Component\Json\Exception\InvalidAnnotationException;
use Intaro\RetailCrm\Component\Json\Strategy\StrategyFactory;
use Intaro\RetailCrm\Component\Json\Strategy\TypedArrayTrait;
/**
* Class TypedArrayStrategy
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Deserialize
*/
class TypedArrayStrategy implements DeserializeStrategyInterface
{
use InnerTypeTrait;
use TypedArrayTrait;
/**
* @inheritDoc
*/
public function deserialize(string $type, $value)
{
$keyType = '';
$valueType = '';
$result = [];
if (strpos($this->innerType, ',') !== false) {
[$keyType, $valueType] = static::getInnerTypes($this->innerType);
if ('' === $keyType && '' === $valueType) {
$valueType = $this->innerType;
}
} else {
$valueType = $this->innerType;
}
$simpleStrategy = new SimpleTypeStrategy();
foreach (array_keys($value) as $key) {
$deserializedKey = $key;
if ('' !== $keyType) {
$deserializedKey = $simpleStrategy->deserialize($keyType, $key);
}
$result[$deserializedKey]
= StrategyFactory::deserializeStrategyByType($valueType)->deserialize($valueType, $value[$key]);
}
return $result;
}
}

View file

@ -0,0 +1,38 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy;
use Intaro\RetailCrm\Component\Json\Mapping\NoTransform;
/**
* Class IsNoTransformTrait
*
* @package Intaro\RetailCrm\Component\Json\Strategy
*/
trait IsNoTransformTrait
{
use AnnotationReaderTrait;
/**
* Returns true if NoTransform annotation was used
*
* @param \ReflectionProperty $property
*
* @return bool
*/
protected static function isNoTransform(\ReflectionProperty $property): bool
{
$isNoTransform = static::annotationReader()->getPropertyAnnotation($property, NoTransform::class);
return $isNoTransform instanceof NoTransform;
}
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Serialize;
/**
* Class DateTimeStrategy
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
*/
class DateTimeStrategy implements SerializeStrategyInterface
{
use InnerTypeTrait;
/**
* @inheritDoc
*/
public function serialize($value)
{
if ($value instanceof \DateTime) {
return $value->format($this->innerType);
}
return null;
}
}

View file

@ -0,0 +1,88 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Serialize;
use Intaro\RetailCrm\Component\Json\Strategy\IsNoTransformTrait;
use Intaro\RetailCrm\Component\Json\Mapping\Accessor;
use Intaro\RetailCrm\Component\Json\Mapping\SerializedName;
use Intaro\RetailCrm\Component\Json\Mapping\Type;
use Intaro\RetailCrm\Component\Json\Strategy\StrategyFactory;
/**
* Class EntityStrategy
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
*/
class EntityStrategy implements SerializeStrategyInterface
{
use InnerTypeTrait;
use IsNoTransformTrait;
/**
* @inheritDoc
* @throws \ReflectionException
*/
public function serialize($value)
{
if (empty($value)) {
return null;
}
$result = [];
$reflection = new \ReflectionClass(get_class($value));
if (!$reflection->isUserDefined()) {
return (array) $value;
}
foreach ($reflection->getProperties() as $property) {
static::serializeProperty($value, $property, $result);
}
return $result;
}
/**
* @param object $object
* @param \ReflectionProperty $property
* @param array $result
*/
protected static function serializeProperty($object, \ReflectionProperty $property, array &$result): void
{
$nameData = static::annotationReader()->getPropertyAnnotation($property, SerializedName::class);
if (!($nameData instanceof SerializedName)) {
return;
}
$accessorData = static::annotationReader()->getPropertyAnnotation($property, Accessor::class);
if ($accessorData instanceof Accessor && !empty($accessorData->getter)) {
$value = $object->{$accessorData->getter}();
} else {
$property->setAccessible(true);
$value = $property->getValue($object);
}
if (static::isNoTransform($property)) {
$result[$nameData->name] = $value;
} else {
$typeData = static::annotationReader()->getPropertyAnnotation($property, Type::class);
if ($typeData instanceof Type) {
$result[$nameData->name] = StrategyFactory::serializeStrategyByType($typeData->type)->serialize($value);
} else {
$result[$nameData->name] = StrategyFactory::serializeStrategyByType(gettype($value))->serialize($value);
}
}
}
}

View file

@ -0,0 +1,36 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Serialize;
/**
* Trait InnerTypeTrait
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
*/
trait InnerTypeTrait
{
/** @var string $innerType */
private $innerType;
/**
* Sets inner type for types like array<key, value> and \DateTime<format>
*
* @param string $type
*
* @return \Intaro\RetailCrm\Component\Json\Strategy\Serialize\SerializeStrategyInterface
*/
public function setInnerType(string $type): SerializeStrategyInterface
{
$this->innerType = $type;
return $this;
}
}

View file

@ -0,0 +1,38 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Serialize;
/**
* Interface SerializeStrategyInterface
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
*/
interface SerializeStrategyInterface
{
/**
* Serialize value
*
* @param mixed $value
*
* @return mixed
*/
public function serialize($value);
/**
* Sets inner type for types like array<key, value> and \DateTime<format>
*
* @param string $type
*
* @return \Intaro\RetailCrm\Component\Json\Strategy\Serialize\SerializeStrategyInterface
*/
public function setInnerType(string $type): SerializeStrategyInterface;
}

View file

@ -0,0 +1,57 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Serialize;
use Intaro\RetailCrm\Component\Json\Strategy\StrategyFactory;
/**
* Class SimpleTypeStrategy
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
*/
class SimpleTypeStrategy implements SerializeStrategyInterface
{
use InnerTypeTrait;
/**
* @inheritDoc
*/
public function serialize($value)
{
switch (gettype($value)) {
case 'bool':
case 'boolean':
return (bool) $value;
case 'int':
case 'integer':
return (int) $value;
case 'float':
return (float) $value;
case 'double':
return (double) $value;
case 'string':
return (string) $value;
default:
if (is_iterable($value)) {
$result = [];
foreach ($value as $key => $item) {
$result[$key] = StrategyFactory::serializeStrategyByType(gettype($item))->serialize($item);
}
return $result;
}
return null;
}
}
}

View file

@ -0,0 +1,55 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy\Serialize;
use Intaro\RetailCrm\Component\Json\Exception\InvalidAnnotationException;
use Intaro\RetailCrm\Component\Json\Strategy\StrategyFactory;
use Intaro\RetailCrm\Component\Json\Strategy\TypedArrayTrait;
/**
* Class TypedArrayStrategy
*
* @package Intaro\RetailCrm\Component\Json\Strategy\Serialize
*/
class TypedArrayStrategy implements SerializeStrategyInterface
{
use InnerTypeTrait;
use TypedArrayTrait;
/**
* @inheritDoc
*/
public function serialize($value)
{
$valueType = '';
$result = [];
if (strpos($this->innerType, ',') !== false) {
[$keyType, $valueType] = static::getInnerTypes($this->innerType);
if ('' === $keyType && '' === $valueType) {
$valueType = $this->innerType;
}
} else {
$valueType = $this->innerType;
}
$simpleStrategy = new SimpleTypeStrategy();
foreach (array_keys($value) as $key) {
$result[$simpleStrategy->serialize($key)]
= StrategyFactory::serializeStrategyByType($valueType)->serialize($value[$key]);
}
return $result;
}
}

View file

@ -0,0 +1,174 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy;
use Intaro\RetailCrm\Component\Json\Strategy\Deserialize\DeserializeStrategyInterface;
use Intaro\RetailCrm\Component\Json\Strategy\Serialize;
use Intaro\RetailCrm\Component\Json\Strategy\Serialize\SerializeStrategyInterface;
/**
* Class StrategyFactory
*
* @package Intaro\RetailCrm\Component\Json\Strategy
*/
class StrategyFactory
{
/** @var string */
private const TYPED_MATCHER = '/^\\\\?([a-zA-Z0-9_]+)\s*\<(.+)\>$/m';
/** @var string[] $simpleTypes */
private static $simpleTypes = [
'bool',
'boolean',
'int',
'integer',
'float',
'double',
'string',
'array'
];
/**
* @param string $dataType
*
* @return \Intaro\RetailCrm\Component\Json\Strategy\Serialize\SerializeStrategyInterface
*/
public static function serializeStrategyByType(string $dataType): SerializeStrategyInterface
{
if (in_array($dataType, static::$simpleTypes)) {
return new Serialize\SimpleTypeStrategy();
}
if (static::isDateTime($dataType)) {
return (new Serialize\DateTimeStrategy())->setInnerType(\DateTime::RFC3339);
}
$arrSubType = static::getArrayInnerTypes($dataType);
if (!empty($arrSubType)) {
return (new Serialize\TypedArrayStrategy())->setInnerType($arrSubType);
}
$dateTimeFormat = static::getDateTimeFormat($dataType);
if (!empty($dateTimeFormat)) {
return (new Serialize\DateTimeStrategy())->setInnerType($dateTimeFormat);
}
return new Serialize\EntityStrategy();
}
/**
* @param string $dataType
*
* @return \Intaro\RetailCrm\Component\Json\Strategy\Deserialize\DeserializeStrategyInterface
*/
public static function deserializeStrategyByType(string $dataType): DeserializeStrategyInterface
{
if (in_array($dataType, static::$simpleTypes)) {
return new Deserialize\SimpleTypeStrategy();
}
if (static::isDateTime($dataType)) {
return (new Deserialize\DateTimeStrategy())->setInnerType(\DateTime::RFC3339);
}
$arrSubType = static::getArrayInnerTypes($dataType);
if (!empty($arrSubType)) {
return (new Deserialize\TypedArrayStrategy())->setInnerType($arrSubType);
}
$dateTimeFormat = static::getDateTimeFormat($dataType);
if (!empty($dateTimeFormat)) {
return (new Deserialize\DateTimeStrategy())->setInnerType($dateTimeFormat);
}
return new Deserialize\EntityStrategy();
}
/**
* Returns array inner type for arrays like array<int, \DateTime<Y-m-d\TH:i:sP>>
* For this example, "int, \DateTime<Y-m-d\TH:i:sP>" will be returned.
*
* Also works for arrays like int[].
*
* @param string $dataType
*
* @return string
*/
private static function getArrayInnerTypes(string $dataType): string
{
$matches = [];
preg_match_all(static::TYPED_MATCHER, $dataType, $matches, PREG_SET_ORDER, 0);
if (empty($matches)) {
if (strlen($dataType) > 2 && substr($dataType, -2) === '[]') {
return substr($dataType, 0, -2);
}
return '';
}
if ($matches[0][1] === 'array') {
return $matches[0][2];
}
return '';
}
/**
* Returns DateTime format. Example: \DateTime<Y-m-d\TH:i:sP>>
*
* @param string $dataType
*
* @return string
*/
private static function getDateTimeFormat(string $dataType): string
{
$matches = [];
preg_match_all(static::TYPED_MATCHER, $dataType, $matches, PREG_SET_ORDER, 0);
if (empty($matches)) {
return '';
}
if ($matches[0][1] === 'DateTime') {
$format = $matches[0][2];
if (strlen($format) > 2 && $format[0] === "'" && substr($format, -1) === "'") {
return substr($format, 1, -1);
}
return $format;
}
return '';
}
/**
* Returns true if provided type is DateTime
*
* @param string $dataType
*
* @return bool
*/
private static function isDateTime(string $dataType): bool
{
return strlen($dataType) > 1
&& (\DateTime::class === $dataType
|| ('\\' === $dataType[0] && \DateTime::class === substr($dataType, 1)));
}
}

View file

@ -0,0 +1,44 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component\Json\Strategy
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component\Json\Strategy;
/**
* Class TypedArrayTrait
*
* @package Intaro\RetailCrm\Component\Json\Strategy
*/
trait TypedArrayTrait
{
private static $innerTypesMatcher = '/^([a-z]+)\s*\,?\s*(.+?\>)/m';
/**
* Returns inner types for array with typed key (example: array<string, DateTime<Y m d H i s>>).
*
* @param string $innerType
*
* @return string[]
*/
private static function getInnerTypes(string $innerType)
{
$matches = [];
preg_match_all(static::$innerTypesMatcher, $innerType, $matches, PREG_SET_ORDER, 0);
if (empty($matches)) {
return ['', ''];
}
$matches = $matches[0];
return [trim($matches[1]), trim($matches[2])];
}
}

View file

@ -0,0 +1,99 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component;
/**
* Class ServiceLocator
*
* @package Intaro\RetailCrm\Component
*/
class ServiceLocator
{
/**
* @var array<string, object>
*/
private static $services = [];
/**
* Register passed services
*
* @param array $services
*/
public static function registerServices(array $services = []): void
{
foreach ($services as $name => $service) {
static::registerService($name, $service);
}
}
/**
* Register passed service
*
* @param string $name
* @param mixed $service
*/
public static function registerService(string $name, $service): void
{
if (is_string($service)) {
if (class_exists($service)) {
if (is_numeric($name)) {
$name = $service;
}
static::set($name, new $service());
} else {
throw new \RuntimeException(
sprintf('Cannot find class "%s" for service "%s"', $service, $name)
);
}
} elseif (is_object($service)) {
static::set($name, $service);
} elseif (is_callable($service)) {
$instance = $service();
if (empty($instance)) {
throw new \RuntimeException(
sprintf('Cannot register service "%s": callable didn\'t return anything.', $name)
);
}
static::set($name, $instance);
} else {
throw new \RuntimeException(
sprintf('Cannot register service "%s": use class FQN, instance, or factory method.', $name)
);
}
}
/**
* Get service (returns null if service doesn't registered)
*
* @param string $name
*
* @return mixed
*/
public static function get(string $name)
{
return static::$services[$name] ?? null;
}
/**
* Sets service into ServiceContainer.
*
* @param string $name
* @param mixed $instance
*/
public static function set(string $name, $instance): void
{
static::$services[$name] = $instance;
}
}

View file

@ -0,0 +1,70 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping\PostDeserialize;
use Intaro\RetailCrm\Component\Json\Mapping\PostSerialize;
use Intaro\RetailCrm\Component\ServiceLocator;
use Intaro\RetailCrm\Service\Utils;
/**
* Class AbstractApiModel
*
* @package Intaro\RetailCrm\Model\Api
*/
class AbstractApiModel implements ApiModelInterface
{
/** @var Utils */
private $utils;
/**
* AbstractApiModel constructor.
*/
public function __construct()
{
$this->utils = ServiceLocator::get(Utils::class);
}
/**
* @PostDeserialize()
*/
public function postDeserialize(): void
{
foreach ($this as $field => $value) {
if (null === $value) {
unset($this->{$field});
}
if (is_string($value)) {
$this->{$field} = null !== json_decode($value, true) ?
json_decode($value, true, 512, JSON_BIGINT_AS_STRING) :
('null' !== $value ?
$value :
null
);
}
}
}
/**
* Removes empty fields from serialized data
*
* @PostSerialize()
* @param array $fields
*
* @return array
*/
public function postSerialize(array $fields): array
{
return $this->utils->clearArray($fields);
}
}

View file

@ -0,0 +1,208 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class Address
*
* @package Intaro\RetailCrm\Model\Api
*/
class Address extends AbstractApiModel
{
/**
* ID адреса клиента
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Внешний ID
*
* @var string $externalId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
/**
* Наименование адреса
*
* @var string $name
*
* @Mapping\Type("string")
* @Mapping\SerializedName("name")
*/
public $name;
/**
* Адрес клиента является основным
*
* @var boolean $isMain
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("isMain")
*/
public $isMain;
/**
* Индекс
*
* @var string $index
*
* @Mapping\Type("string")
* @Mapping\SerializedName("index")
*/
public $index;
/**
* Город
*
* @var string $city
*
* @Mapping\Type("string")
* @Mapping\SerializedName("city")
*/
public $city;
/**
* Регион
*
* @var string $region
*
* @Mapping\Type("string")
* @Mapping\SerializedName("region")
*/
public $region;
/**
* Улица
*
* @var string $street
*
* @Mapping\Type("string")
* @Mapping\SerializedName("street")
*/
public $street;
/**
* Дом
*
* @var string $building
*
* @Mapping\Type("string")
* @Mapping\SerializedName("building")
*/
public $building;
/**
* Номер квартиры/офиса
*
* @var string $flat
*
* @Mapping\Type("string")
* @Mapping\SerializedName("flat")
*/
public $flat;
/**
* Этаж
*
* @var string $floor
*
* @Mapping\Type("string")
* @Mapping\SerializedName("floor")
*/
public $floor;
/**
* Подъезд
*
* @var string $block
*
* @Mapping\Type("string")
* @Mapping\SerializedName("block")
*/
public $block;
/**
* Строение
*
* @var string $house
*
* @Mapping\Type("string")
* @Mapping\SerializedName("house")
*/
public $house;
/**
* Корпус
*
* @var string $housing
*
* @Mapping\Type("string")
* @Mapping\SerializedName("housing")
*/
public $housing;
/**
* Метро
*
* @var string $metro
*
* @Mapping\Type("string")
* @Mapping\SerializedName("metro")
*/
public $metro;
/**
* Заметка
*
* @var string $notes
*
* @Mapping\Type("string")
* @Mapping\SerializedName("notes")
*/
public $notes;
/**
* Адрес в текстовом виде
*
* @var string $text
*
* @Mapping\Type("string")
* @Mapping\SerializedName("text")
*/
public $text;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("country")
*/
public $country;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("intercomCode")
*/
public $intercomCode;
}

View file

@ -0,0 +1,24 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
/**
* Interface ApiModelInterface
*
* @package Intaro\RetailCrm\Model\Api
*/
interface ApiModelInterface
{
public function postDeserialize(): void;
public function postSerialize(array $fields): array;
}

View file

@ -0,0 +1,38 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class CodeValueModel
*
* @package Intaro\RetailCrm\Model\Api
*/
class CodeValueModel extends AbstractApiModel
{
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("code")
*/
public $code;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("value")
*/
public $value;
}

View file

@ -0,0 +1,142 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class Company
*
* @package Intaro\RetailCrm\Model\Api
*/
class Company extends AbstractApiModel
{
/**
* ID компании
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Внешний идентификатор компании в складской системе
*
* @var string $uuid
*
* @Mapping\Type("string")
* @Mapping\SerializedName("uuid")
*/
public $uuid;
/**
* Главная компания
*
* @var boolean $isMain
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("isMain")
*/
public $isMain;
/**
* Магазин
*
* @var string $site
*
* @Mapping\Type("string")
* @Mapping\SerializedName("site")
*/
public $site;
/**
* Внешний ID компании
*
* @var string $externalId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
/**
* Активность
*
* @var string $active
*
* @Mapping\Type("string")
* @Mapping\SerializedName("active")
*/
public $active;
/**
* Наименование
*
* @var string $name
*
* @Mapping\Type("string")
* @Mapping\SerializedName("name")
*/
public $name;
/**
* Бренд
*
* @var string $brand
*
* @Mapping\Type("string")
* @Mapping\SerializedName("brand")
*/
public $brand;
/**
* Дата создания
*
* @var \DateTime $createdAt
*
* @Mapping\Type("DateTime<'Y-m-d H:i:s'>")
* @Mapping\SerializedName("createdAt")
*/
public $createdAt;
/**
* Реквизиты
*
* @var Contragent $contragent
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Contragent")
* @Mapping\SerializedName("contragent")
*/
public $contragent;
/**
* Адрес
*
* @var Address $address
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Address")
* @Mapping\SerializedName("address")
*/
public $address;
/**
* Ассоциативный массив пользовательских полей
*
* @var array $customFields
*
* @Mapping\Type("array")
* @Mapping\SerializedName("customFields")
*/
public $customFields;
}

View file

@ -0,0 +1,173 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class Contragent
*
* @package Intaro\RetailCrm\Model\Api
*/
class Contragent extends AbstractApiModel
{
/**
* Тип контрагента
*
* @var string $contragentType
*
* @Mapping\Type("string")
* @Mapping\SerializedName("contragentType")
*/
public $contragentType;
/**
* Полное наименование
*
* @var string $legalName
*
* @Mapping\Type("string")
* @Mapping\SerializedName("legalName")
*/
public $legalName;
/**
* Адрес регистрации
*
* @var string $legalAddress
*
* @Mapping\Type("string")
* @Mapping\SerializedName("legalAddress")
*/
public $legalAddress;
/**
* ИНН
*
* @var string $inn
*
* @Mapping\Type("string")
* @Mapping\SerializedName("INN")
*/
public $inn;
/**
* КПП
*
* @var string $kpp
*
* @Mapping\Type("string")
* @Mapping\SerializedName("KPP")
*/
public $kpp;
/**
* ОКПО
*
* @var string $okpo
*
* @Mapping\Type("string")
* @Mapping\SerializedName("OKPO")
*/
public $okpo;
/**
* ОГРН
*
* @var string $ogrn
*
* @Mapping\Type("string")
* @Mapping\SerializedName("OGRN")
*/
public $ogrn;
/**
* ОГРНИП
*
* @var string $ogrnip
*
* @Mapping\Type("string")
* @Mapping\SerializedName("OGRNIP")
*/
public $ogrnip;
/**
* Номер свидетельства
*
* @var string $certificateNumber
*
* @Mapping\Type("string")
* @Mapping\SerializedName("certificateNumber")
*/
public $certificateNumber;
/**
* Дата свидетельства
*
* @var \DateTime $certificateDate
*
* @Mapping\Type("DateTime<'Y-m-d'>")
* @Mapping\SerializedName("certificateDate")
*/
public $certificateDate;
/**
* БИК
*
* @var string $bik
*
* @Mapping\Type("string")
* @Mapping\SerializedName("BIK")
*/
public $bik;
/**
* Банк
*
* @var string $bank
*
* @Mapping\Type("string")
* @Mapping\SerializedName("bank")
*/
public $bank;
/**
* Адрес банка
*
* @var string $bankAddress
*
* @Mapping\Type("string")
* @Mapping\SerializedName("bankAddress")
*/
public $bankAddress;
/**
* Корр. счёт
*
* @var string $corrAccount
*
* @Mapping\Type("string")
* @Mapping\SerializedName("corrAccount")
*/
public $corrAccount;
/**
* Расчётный счёт
*
* @var string $bankAccount
*
* @Mapping\Type("string")
* @Mapping\SerializedName("bankAccount")
*/
public $bankAccount;
}

View file

@ -0,0 +1,302 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class Customer
*
* @package Intaro\RetailCrm\Model\Api
*/
class Customer extends AbstractApiModel
{
/**
* ID [обычного|корпоративного] клиента
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Внешний ID [обычного|корпоративного] клиента
*
* @var string $externalId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
/**
* Внешний идентификатор [обычного|корпоративного] клиента в складской системе
*
* @var string $uuid
*
* @Mapping\Type("string")
* @Mapping\SerializedName("uuid")
*/
public $uuid;
/**
* Тип клиента (корпоративный или обычный)
*
* @var string $type
*
* @Mapping\Type("string")
* @Mapping\SerializedName("type")
*/
public $type;
/**
* Контактное лицо корпоративного клиента является основным
*
* @var bool $isMain
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("isMain")
*/
public $isMain;
/**
* Индикатор подписки на рассылку
*
* @var bool $subscribed
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("subscribed")
*/
public $subscribed;
/**
* Кука Daemon Collector
*
* @var bool $browserId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("browserId")
*/
public $browserId;
/**
* Является ли клиент контактным лицом корпоративного клиента
*
* @var boolean $isContact
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("isContact")
*/
public $isContact;
/**
* Дата создания в системе
*
* @var \DateTime $createdAt
*
* @Mapping\Type("DateTime<'Y-m-d H:i:s'>")
* @Mapping\SerializedName("createdAt")
*/
public $createdAt;
/**
* Имя
*
* @var string $firstName
*
* @Mapping\Type("string")
* @Mapping\SerializedName("firstName")
*/
public $firstName;
/**
* Фамилия
*
* @var string $lastName
*
* @Mapping\Type("string")
* @Mapping\SerializedName("lastName")
*/
public $lastName;
/**
* Отчество
*
* @var string $patronymic
*
* @Mapping\Type("string")
* @Mapping\SerializedName("patronymic")
*/
public $patronymic;
/**
* Адрес электронной почты
*
* @var string $email
*
* @Mapping\Type("string")
* @Mapping\SerializedName("email")
*/
public $email;
/**
* Телефоны
*
* @var \Intaro\RetailCrm\Model\Api\Phone[] $phones
*
* @Mapping\Type("array<Intaro\RetailCrm\Model\Api\Phone>")
* @Mapping\SerializedName("phones")
*/
public $phones;
/**
* Дата рождения
*
* @var \DateTime
*
* @Mapping\Type("DateTime<'Y-m-d'>")
* @Mapping\SerializedName("birthday")
*/
public $birthday;
/**
* Пол
*
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("sex")
*/
public $sex;
/**
* ID менеджера, к которому привязан клиент
*
* @var integer $managerId
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("managerId")
*/
public $managerId;
/**
* Реквизиты
*
* @var Contragent $contragent
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Contragent")
* @Mapping\SerializedName("contragent")
*/
public $contragent;
/**
* Список пользовательских полей
*
* @var array $customFields
*
* @Mapping\Type("array")
* @Mapping\SerializedName("customFields")
*/
public $customFields;
/**
* Магазин, с которого пришел клиент
*
* @var string $site
*
* @Mapping\Type("string")
* @Mapping\SerializedName("site")
*/
public $site;
/**
* Наименование
*
* @var string $nickName
*
* @Mapping\Type("string")
* @Mapping\SerializedName("nickName")
*/
public $nickName;
/**
* Адрес
*
* @var Address $address
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Address")
* @Mapping\SerializedName("address")
*/
public $address;
/**
* Адреса
*
* @var array $addresses
*
* @Mapping\Type("array<Intaro\RetailCrm\Model\Api\Address>")
* @Mapping\SerializedName("addresses")
*/
public $addresses;
/**
* Основной адрес
*
* @var Address $mainAddress
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Address")
* @Mapping\SerializedName("mainAddress")
*/
public $mainAddress;
/**
* Компании
*
* @var array $companies
*
* @Mapping\Type("array<Intaro\RetailCrm\Model\Api\Company>")
* @Mapping\SerializedName("companies")
*/
public $companies;
/**
* Основная компания
*
* @var Company $mainCompany
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Company")
* @Mapping\SerializedName("mainCompany")
*/
public $mainCompany;
/**
* Контактные лица
*
* @var array $customerContacts
*
* @Mapping\Type("array<Intaro\RetailCrm\Model\Api\CustomerContact>")
* @Mapping\SerializedName("customerContacts")
*/
public $customerContacts;
/**
* Основное контактное лицо
*
* @var CustomerContact $mainCustomerContact
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\CustomerContact")
* @Mapping\SerializedName("mainCustomerContact")
*/
public $mainCustomerContact;
}

View file

@ -0,0 +1,72 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class CustomerContact
*
* @package Intaro\RetailCrm\Model\Api
*/
class CustomerContact extends AbstractApiModel
{
/**
* ID контакта
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Внешний ID контакта
*
* @var string $externalId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
/**
* Главный контакт
*
* @var boolean $isMain
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("isMain")
*/
public $isMain;
/**
* Клиент
*
* @var Customer $customer
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Customer")
* @Mapping\SerializedName("customer")
*/
public $customer;
/**
* Компании контактного лица
*
* @var array $companies
*
* @Mapping\Type("array<Intaro\RetailCrm\Model\Api\Company>")
* @Mapping\SerializedName("companies")
*/
public $companies;
}

View file

@ -0,0 +1,66 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class CustomerNote
*
* @package Intaro\RetailCrm\Model\Api
*/
class CustomerNote extends AbstractApiModel
{
/**
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* @var string $externalId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("text")
*/
public $text;
/**
* Дата создания в системе
*
* @var \DateTime $createdAt
*
* @Mapping\Type("DateTime<'Y-m-d H:i:s'>")
* @Mapping\SerializedName("createdAt")
*/
public $createdAt;
/**
* ID менеджера, к которому привязан клиент
*
* @var integer $managerId
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("managerId")
*/
public $managerId;
/**
* @var \Intaro\RetailCrm\Model\Api\Customer
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Customer")
* @Mapping\SerializedName("customer")
*/
public $customer;
}

View file

@ -0,0 +1,203 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class History
*
* @package Intaro\RetailCrm\Model\Api
*/
class History extends AbstractApiModel
{
/**
* Внутренний идентификатор записи в истории
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Дата внесения изменения
*
* @var \DateTime $createdAt
*
* @Mapping\Type("DateTime<'Y-m-d H:i:s'>")
* @Mapping\SerializedName("createdAt")
*/
public $createdAt;
/**
* Признак создания сущности
*
* @var string $created
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("created")
*/
public $created;
/**
* Признак удаления сущности
*
* @var string $deleted
*
* @Mapping\Type("boolean")
* @Mapping\SerializedName("deleted")
*/
public $deleted;
/**
* Источник изменения
*
* @var string $source
*
* @Mapping\Type("string")
* @Mapping\SerializedName("source")
*/
public $source;
/**
* Пользователь
*
* @var \Intaro\RetailCrm\Model\Api\User $user
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\User")
* @Mapping\SerializedName("user")
*/
public $user;
/**
* Имя изменившегося поля
*
* @var string $field
*
* @Mapping\Type("string")
* @Mapping\SerializedName("field")
*/
public $field;
/**
* Информация о ключе api, использовавшемся для этого изменения
*
* @var array $apiKey
*
* @Mapping\Type("array")
* @Mapping\SerializedName("apiKey")
*/
public $apiKey;
/**
* Старое значение свойства
*
* @var string $oldValue
*
* @Mapping\Type("string")
* @Mapping\SerializedName("oldValue")
*/
public $oldValue;
/**
* Новое значение свойства
*
* @var string $newValue
*
* @Mapping\Type("string")
* @Mapping\SerializedName("newValue")
*/
public $newValue;
/**
* Клиент
*
* @var \Intaro\RetailCrm\Model\Api\Customer $customer
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Customer")
* @Mapping\SerializedName("customer")
*/
public $customer;
/**
* Заказ
*
* @var \Intaro\RetailCrm\Model\Api\Order $order
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Order")
* @Mapping\SerializedName("order")
*/
public $order;
/**
* Позиция в заказе
*
* @var \Intaro\RetailCrm\Model\Api\Item $item
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Item")
* @Mapping\SerializedName("item")
*/
public $item;
/**
* Платёж
*
* @var \Intaro\RetailCrm\Model\Api\Payment $payment
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Payment")
* @Mapping\SerializedName("payment")
*/
public $payment;
/**
* Адрес клиента
*
* @var \Intaro\RetailCrm\Model\Api\Address $address
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Address")
* @Mapping\SerializedName("address")
*/
public $address;
/**
* Информация о [заказе|клиенте], который получился после объединения с текущим клиентом
*
* @var array $combinedTo
*
* @Mapping\Type("array")
* @Mapping\SerializedName("combinedTo")
*/
public $combinedTo;
/**
* Информация о клиенте, который получился после объединения с текущим клиентом
*
* @var \Intaro\RetailCrm\Model\Api\CustomerContact $customerContact
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\CustomerContact")
* @Mapping\SerializedName("customerContact")
*/
public $customerContact;
/**
* Информация о компании
*
* @var \Intaro\RetailCrm\Model\Api\Company $company
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Company")
* @Mapping\SerializedName("company")
*/
public $company;
}

View file

@ -0,0 +1,38 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class IdentifiersPair
*
* @package Intaro\RetailCrm\Model\Api
*/
class IdentifiersPair extends AbstractApiModel
{
/**
* @var int
*
* @Mapping\Type("int")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
}

View file

@ -0,0 +1,63 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class Item
*
* @package Intaro\RetailCrm\Model\Api
*/
class Item extends AbstractApiModel
{
/**
* ID позиции в заказе
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Внешние идентификаторы позиции в заказе
*
* @var array $externalIds
*
* @Mapping\Type("array")
* @Mapping\SerializedName("externalIds")
*/
public $externalIds;
/**
* Торговое предложение
*
* @var array $offer
*
* @Mapping\Type("array")
* @Mapping\SerializedName("offer")
*/
public $offer;
/**
* [массив] Дополнительные свойства позиции в заказе
*
* @var array $properties
*
* @Mapping\Type("array")
* @Mapping\SerializedName("properties")
*/
public $properties;
}

View file

@ -0,0 +1,123 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Order
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Order;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class Order
*
* @package Intaro\RetailCrm\Model\Api\Order
*/
class Order extends AbstractApiModel
{
/**
* ID заказа
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Номер заказа
*
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("number")
*/
public $number;
/**
* Внешний ID корпоративного клиента
*
* @var string $externalId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
/**
* Менеджер, прикрепленный к заказу
*
* @var string $managerId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("managerId")
*/
public $managerId;
/**
* Магазин
*
* @var string $site
*
* @Mapping\Type("string")
* @Mapping\SerializedName("site")
*/
public $site;
/**
* Статус заказа
*
* @var string $status
*
* @Mapping\Type("string")
* @Mapping\SerializedName("status")
*/
public $status;
/**
* @var \Intaro\RetailCrm\Model\Api\Order\SerializedOrderDelivery
*
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Order\SerializedOrderDelivery")
* @Mapping\SerializedName("delivery")
*/
public $delivery;
/**
* @var double
*
* @Mapping\Type("double")
* @Mapping\SerializedName("weight")
*/
public $weight;
/**
* @var int
*
* @Mapping\Type("int")
* @Mapping\SerializedName("length")
*/
public $length;
/**
* @var int
*
* @Mapping\Type("int")
* @Mapping\SerializedName("width")
*/
public $width;
/**
* @var int
*
* @Mapping\Type("int")
* @Mapping\SerializedName("height")
*/
public $height;
}

View file

@ -0,0 +1,70 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Order
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Order;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class OrderDeliveryData
*
* @package Intaro\RetailCrm\Model\Api\Order
*/
class OrderDeliveryData extends AbstractApiModel
{
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("trackNumber")
*/
public $trackNumber;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("tariff")
*/
public $tariff;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("pickuppointId")
*/
public $pickuppointId;
/**
* @var array
*
* @Mapping\Type("array")
* @Mapping\SerializedName("extraData")
*/
public $extraData;
/**
* @var \Intaro\RetailCrm\Model\Api\Order\Package[]
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Order\Package[]")
* @Mapping\SerializedName("packages")
*/
public $packages;
}

View file

@ -0,0 +1,70 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Order
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Order;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class Package
*
* @package Intaro\RetailCrm\Model\Api\Order
*/
class Package extends AbstractApiModel
{
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("packageId")
*/
public $packageId;
/**
* @var double
*
* @Mapping\Type("double")
* @Mapping\SerializedName("weight")
*/
public $weight;
/**
* @var int
*
* @Mapping\Type("int")
* @Mapping\SerializedName("length")
*/
public $length;
/**
* @var int
*
* @Mapping\Type("int")
* @Mapping\SerializedName("width")
*/
public $width;
/**
* @var int
*
* @Mapping\Type("int")
* @Mapping\SerializedName("height")
*/
public $height;
/**
* @var \Intaro\RetailCrm\Model\Api\Order\PackageItem[]
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Order\PackageItem[]")
* @Mapping\SerializedName("items")
*/
public $items;
}

View file

@ -0,0 +1,38 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Order
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Order;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class PackageItem
*
* @package Intaro\RetailCrm\Model\Api\Order
*/
class PackageItem extends AbstractApiModel
{
/**
* @var \Intaro\RetailCrm\Model\Api\Order\PackageItemOrderProduct
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Order\PackageItemOrderProduct")
* @Mapping\SerializedName("orderProduct")
*/
public $orderProduct;
/**
* @var double
*
* @Mapping\Type("double")
* @Mapping\SerializedName("quantity")
*/
public $quantity;
}

View file

@ -0,0 +1,46 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Order
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Order;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class PackageItemOrderProduct
*
* @package Intaro\RetailCrm\Model\Api\Order
*/
class PackageItemOrderProduct extends AbstractApiModel
{
/**
* @var int
*
* @Mapping\Type("int")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
/**
* @var \Intaro\RetailCrm\Model\Api\CodeValueModel
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\CodeValueModel")
* @Mapping\SerializedName("externalIds")
*/
public $externalIds;
}

View file

@ -0,0 +1,54 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Order
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Order;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class SerializedDeliveryService
*
* @package Intaro\RetailCrm\Model\Api\Order
*/
class SerializedDeliveryService extends AbstractApiModel
{
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("name")
*/
public $name;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("code")
*/
public $code;
/**
* @var bool
*
* @Mapping\Type("bool")
* @Mapping\SerializedName("active")
*/
public $active;
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("deliveryType")
*/
public $deliveryType;
}

View file

@ -0,0 +1,81 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Order
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Order;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class SerializedOrderDelivery
*
* @package Intaro\RetailCrm\Model\Api\Order
*/
class SerializedOrderDelivery extends AbstractApiModel
{
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("code")
*/
public $code;
/**
* @var \Intaro\RetailCrm\Model\Api\Order\OrderDeliveryData
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Order\OrderDeliveryData")
* @Mapping\SerializedName("data")
*/
public $data;
/**
* @var \Intaro\RetailCrm\Model\Api\Order\SerializedDeliveryService
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Order\SerializedDeliveryService")
* @Mapping\SerializedName("service")
*/
public $service;
/**
* @var double
*
* @Mapping\Type("double")
* @Mapping\SerializedName("cost")
*/
public $cost;
/**
* @var double
*
* @Mapping\Type("double")
* @Mapping\SerializedName("netCost")
*/
public $netCost;
/**
* @var \DateTime
*
* @Mapping\Type("DateTime<'Y-m-d H:i:s'>")
* @Mapping\SerializedName("date")
*/
public $date;
/**
* @var \Intaro\RetailCrm\Model\Api\TimeInterval
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\TimeInterval")
* @Mapping\SerializedName("time")
*/
public $time;
//TODO:
// order[delivery][address] model
}

View file

@ -0,0 +1,52 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class Payment
*
* @package Intaro\RetailCrm\Model\Api
*/
class Payment extends AbstractApiModel
{
/**
* Внутренний ID
*
* @var integer $id
*
* @Mapping\Type("integer")
* @Mapping\SerializedName("id")
*/
public $id;
/**
* Тип оплаты
*
* @var string $type
*
* @Mapping\Type("string")
* @Mapping\SerializedName("type")
*/
public $type;
/**
* Внешний ID платежа
*
* @var string $externalId
*
* @Mapping\Type("string")
* @Mapping\SerializedName("externalId")
*/
public $externalId;
}

View file

@ -0,0 +1,39 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Class Phone
*
* @package Intaro\RetailCrm\Model\Api
*/
class Phone extends AbstractApiModel
{
/**
* Номер телефона
*
* @var string $number
*
* @Mapping\Type("string")
* @Mapping\SerializedName("number")
*/
public $number;
/**
* Старый номер телефона. Используется только в истории, игнорируется при сериализации.
*
* @var string $oldNumber
*/
public $oldNumber;
}

View file

@ -0,0 +1,30 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Trait ByTrait
*
* @package Intaro\RetailCrm\Model\Api\Request
*/
trait ByTrait
{
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("by")
*/
public $by;
}

View file

@ -0,0 +1,41 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateAddressesCreateRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateAddressesCreateRequest extends AbstractApiModel
{
use ByTrait;
use SiteScopedTrait;
/**
* @var string
*/
public $externalId;
/**
* @var \Intaro\RetailCrm\Model\Api\Address
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Address")
* @Mapping\SerializedName("address")
*/
public $address;
}

View file

@ -0,0 +1,43 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\Request\EntityByTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateAddressesEditRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateAddressesEditRequest extends AbstractApiModel
{
use ByTrait;
use EntityByTrait;
use SiteScopedTrait;
/**
* @var string
*/
public $externalId;
/**
* @var \Intaro\RetailCrm\Model\Api\Address
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Address")
* @Mapping\SerializedName("address")
*/
public $address;
}

View file

@ -0,0 +1,43 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\Request\PaginatedTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersNotesRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateAddressesRequest extends AbstractApiModel
{
use ByTrait;
use PaginatedTrait;
use SiteScopedTrait;
/**
* @var string
*/
public $externalId;
/**
* @var \Intaro\RetailCrm\Model\Api\Request\Filter\CustomersCorporateAddressesFilter
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Request\Filter\CustomersCorporateAddressesFilter")
* @Mapping\SerializedName("filter")
*/
public $filter;
}

View file

@ -0,0 +1,41 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateCompaniesCreateRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateCompaniesCreateRequest extends AbstractApiModel
{
use ByTrait;
use SiteScopedTrait;
/**
* @var string
*/
public $externalId;
/**
* @var \Intaro\RetailCrm\Model\Api\Company
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Company")
* @Mapping\SerializedName("company")
*/
public $company;
}

View file

@ -0,0 +1,43 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\Request\EntityByTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateCompaniesEditRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateCompaniesEditRequest extends AbstractApiModel
{
use ByTrait;
use EntityByTrait;
use SiteScopedTrait;
/**
* @var string
*/
public $externalId;
/**
* @var \Intaro\RetailCrm\Model\Api\Company
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Company")
* @Mapping\SerializedName("company")
*/
public $company;
}

View file

@ -0,0 +1,43 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\Request\PaginatedTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateCompaniesRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateCompaniesRequest extends AbstractApiModel
{
use ByTrait;
use PaginatedTrait;
use SiteScopedTrait;
/**
* @var string
*/
public $idOrExternalId;
/**
* @var \Intaro\RetailCrm\Model\Api\Request\Filter\CompanyFilter
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Request\Filter\CompanyFilter")
* @Mapping\SerializedName("filter")
*/
public $filter;
}

View file

@ -0,0 +1,41 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateCompaniesRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateContactsCreateRequest extends AbstractApiModel
{
use ByTrait;
use SiteScopedTrait;
/**
* @var string
*/
public $idOrExternalId;
/**
* @var \Intaro\RetailCrm\Model\Api\CustomerContact
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\CustomerContact")
* @Mapping\SerializedName("contact")
*/
public $contact;
}

View file

@ -0,0 +1,43 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\EntityByTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateContactsEditRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateContactsEditRequest extends AbstractApiModel
{
use ByTrait;
use EntityByTrait;
use SiteScopedTrait;
/**
* @var string
*/
public $idOrExternalId;
/**
* @var \Intaro\RetailCrm\Model\Api\CustomerContact
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\CustomerContact")
* @Mapping\SerializedName("contact")
*/
public $contact;
}

View file

@ -0,0 +1,43 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\Request\PaginatedTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateContactsRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateContactsRequest extends AbstractApiModel
{
use ByTrait;
use PaginatedTrait;
use SiteScopedTrait;
/**
* @var string
*/
public $externalId;
/**
* @var \Intaro\RetailCrm\Model\Api\Request\Filter\CustomerContactFilter
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Request\Filter\CustomerContactFilter")
* @Mapping\SerializedName("filter")
*/
public $filter;
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateCreateRequest
*
* @package Intaro\RetailCrm\Model\Api\Request
*/
class CustomersCorporateCreateRequest extends AbstractApiModel
{
use SiteScopedTrait;
/**
* @var \Intaro\RetailCrm\Model\Api\Customer
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Customer")
* @Mapping\SerializedName("customerCorporate")
*/
public $customerCorporate;
}

View file

@ -0,0 +1,31 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
/**
* Class CustomersCorporateFixExternalIdsRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateFixExternalIdsRequest extends AbstractApiModel
{
/**
* @var \Intaro\RetailCrm\Model\Api\IdentifiersPair[]
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\IdentifiersPair[]")
* @Mapping\SerializedName("customers")
*/
public $customers;
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\PaginatedTrait;
/**
* Class CustomersCorporateListRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateListRequest extends AbstractApiModel
{
use PaginatedTrait;
/**
* @var \Intaro\RetailCrm\Model\Api\Request\Filter\CustomersCorporateFilter
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Request\Filter\CustomersCorporateFilter")
* @Mapping\SerializedName("filter")
*/
public $filter;
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCorporateUploadRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersCorporateUploadRequest extends AbstractApiModel
{
use SiteScopedTrait;
/**
* @var \Intaro\RetailCrm\Model\Api\Customer[]
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Customer[]")
* @Mapping\SerializedName("customersCorporate")
*/
public $customersCorporate;
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersCreateRequest
*
* @package Intaro\RetailCrm\Model\Api\Request
*/
class CustomersCreateRequest extends AbstractApiModel
{
use SiteScopedTrait;
/**
* @var \Intaro\RetailCrm\Model\Api\Customer
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Customer")
* @Mapping\SerializedName("customer")
*/
public $customer;
}

View file

@ -0,0 +1,36 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersEditRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersEditRequest extends AbstractApiModel
{
use ByTrait;
use SiteScopedTrait;
/**
* @var \Intaro\RetailCrm\Model\Api\Customer
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Customer")
* @Mapping\SerializedName("customer")
*/
public $customer;
}

View file

@ -0,0 +1,31 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
/**
* Class CustomersFixExternalIdsRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersFixExternalIdsRequest extends AbstractApiModel
{
/**
* @var \Intaro\RetailCrm\Model\Api\IdentifiersPair[]
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\IdentifiersPair[]")
* @Mapping\SerializedName("customers")
*/
public $customers;
}

View file

@ -0,0 +1,36 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\ByTrait;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersGetRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersGetRequest extends AbstractApiModel
{
use ByTrait;
use SiteScopedTrait;
/**
* @var int
*
* @Mapping\Type("int")
* @Mapping\SerializedName("id")
*/
public $id;
}

View file

@ -0,0 +1,35 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\Filter\CustomerHistoryFilterV4Type;
use Intaro\RetailCrm\Model\Api\Request\PaginatedTrait;
/**
* Class CustomersHistoryRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersHistoryRequest extends AbstractApiModel
{
use PaginatedTrait;
/**
* @var CustomerHistoryFilterV4Type
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Request\Filter\CustomerHistoryFilterV4Type")
* @Mapping\SerializedName("filter")
*/
public $filter;
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\PaginatedTrait;
/**
* Class CustomersListRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersListRequest extends AbstractApiModel
{
use PaginatedTrait;
/**
* @var \Intaro\RetailCrm\Model\Api\Request\Filter\CustomerFilter
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Request\Filter\CustomerFilter")
* @Mapping\SerializedName("filter")
*/
public $filter;
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersNotesCreateRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersNotesCreateRequest extends AbstractApiModel
{
use SiteScopedTrait;
/**
* @var \Intaro\RetailCrm\Model\Api\CustomerNote
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\CustomerNote")
* @Mapping\SerializedName("note")
*/
public $note;
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\PaginatedTrait;
/**
* Class CustomersNotesRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersNotesRequest extends AbstractApiModel
{
use PaginatedTrait;
/**
* @var \Intaro\RetailCrm\Model\Api\Request\Filter\CustomersNotesFilter
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Request\Filter\CustomersNotesFilter")
* @Mapping\SerializedName("filter")
*/
public $filter;
}

View file

@ -0,0 +1,34 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Customers
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Customers;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
use Intaro\RetailCrm\Model\Api\Request\SiteScopedTrait;
/**
* Class CustomersUploadRequest
*
* @package Intaro\RetailCrm\Model\Api\Request\Customers
*/
class CustomersUploadRequest extends AbstractApiModel
{
use SiteScopedTrait;
/**
* @var \Intaro\RetailCrm\Model\Api\Customer[]
*
* @Mapping\Type("Intaro\RetailCrm\Model\Api\Customer[]")
* @Mapping\SerializedName("customers")
*/
public $customers;
}

View file

@ -0,0 +1,30 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request;
use Intaro\RetailCrm\Component\Json\Mapping;
/**
* Trait EntityByTrait
*
* @package Intaro\RetailCrm\Model\Api\Request
*/
trait EntityByTrait
{
/**
* @var string
*
* @Mapping\Type("string")
* @Mapping\SerializedName("entityBy")
*/
public $entityBy;
}

View file

@ -0,0 +1,39 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Filter
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Filter;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
/**
* Class CompanyFilter
*
* @package Intaro\RetailCrm\Model\Api\Request\Filter
*/
class CompanyFilter extends AbstractApiModel
{
/**
* @var int[]
*
* @Mapping\Type("int[]")
* @Mapping\SerializedName("ids")
*/
public $ids;
/**
* @var string[]
*
* @Mapping\Type("string[]")
* @Mapping\SerializedName("externalIds")
*/
public $externalIds;
}

View file

@ -0,0 +1,47 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Model\Api\Request\Filter
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Model\Api\Request\Filter;
use Intaro\RetailCrm\Component\Json\Mapping;
use Intaro\RetailCrm\Model\Api\AbstractApiModel;
/**
* Class CustomerContactFilter
*
* @package Intaro\RetailCrm\Model\Api\Filter
*/
class CustomerContactFilter extends AbstractApiModel
{
/**
* @var int[]
*
* @Mapping\Type("int[]")
* @Mapping\SerializedName("ids")
*/
public $ids;
/**
* @var int[]
*
* @Mapping\Type("int[]")
* @Mapping\SerializedName("contactIds")
*/
public $contactIds;
/**
* @var string[]
*
* @Mapping\Type("string[]")
* @Mapping\SerializedName("contactExternalIds")
*/
public $contactExternalIds;
}

Some files were not shown because too many files have changed in this diff Show more