1
0
mirror of synced 2024-11-25 06:46:07 +03:00
api-client-php/lib/RetailCrm/Methods/V5/Customers.php

151 lines
3.9 KiB
PHP
Raw Normal View History

<?php
/**
* PHP version 5.4
*
2017-06-22 16:42:42 +03:00
* Customers
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
namespace RetailCrm\Methods\V5;
use RetailCrm\Methods\V4\Customers as Previous;
/**
* PHP version 5.4
*
2017-06-22 16:42:42 +03:00
* Customers class
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
trait Customers
{
use Previous;
/**
* Combine customers
*
* @param array $customers
* @param array $resultCustomer
*
* @return \RetailCrm\Response\ApiResponse
*/
public function customersCombine(array $customers, $resultCustomer)
{
if (!count($customers) || !count($resultCustomer)) {
throw new \InvalidArgumentException(
'Parameters `customers` & `resultCustomer` must contains a data'
);
}
/* @noinspection PhpUndefinedMethodInspection */
return $this->client->makeRequest(
'/customers/combine',
"POST",
[
'customers' => json_encode($customers),
'resultCustomer' => json_encode($resultCustomer)
]
);
}
/**
* Returns filtered customers notes list
*
* @param array $filter (default: array())
* @param int $page (default: null)
* @param int $limit (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return \RetailCrm\Response\ApiResponse
*/
public function customersNotesList(array $filter = [], $page = null, $limit = null)
{
$parameters = [];
if (count($filter)) {
$parameters['filter'] = $filter;
}
if (null !== $page) {
$parameters['page'] = (int) $page;
}
if (null !== $limit) {
$parameters['limit'] = (int) $limit;
}
/* @noinspection PhpUndefinedMethodInspection */
return $this->client->makeRequest(
'/customers/notes',
"GET",
$parameters
);
}
/**
* Create customer note
*
* @param array $note (default: array())
* @param string $site (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return \RetailCrm\Response\ApiResponse
*/
public function customersNotesCreate($note, $site = null)
{
if (empty($note['customer']['id']) && empty($note['customer']['externalId'])) {
throw new \InvalidArgumentException(
'Customer identifier must be set'
);
}
/* @noinspection PhpUndefinedMethodInspection */
return $this->client->makeRequest(
'/customers/notes/create',
"POST",
2017-06-22 16:42:42 +03:00
$this->fillSite($site, ['note' => json_encode($note)])
);
}
/**
2017-06-22 16:42:42 +03:00
* Delete customer note
*
* @param integer $id
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return \RetailCrm\Response\ApiResponse
*/
public function customersNotesDelete($id)
{
if (empty($id)) {
throw new \InvalidArgumentException(
'Note id must be set'
);
}
/* @noinspection PhpUndefinedMethodInspection */
return $this->client->makeRequest(
"/customers/notes/$id/delete",
"POST"
);
}
}