1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace UON\Endpoint; |
4
|
|
|
|
5
|
|
|
use UON\Client; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Collection of methods for work with leads created by users |
9
|
|
|
* @package UON |
10
|
|
|
*/ |
11
|
|
|
class Leads extends Client |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Create new lead |
15
|
|
|
* |
16
|
|
|
* @link https://api.u-on.ru/{key}/lead/create.{_format} |
17
|
|
|
* @param array $parameters - List of parameters [r_id_internal, r_dat, status_id, sources etc.] |
18
|
|
|
* @return array|false |
19
|
|
|
*/ |
20
|
|
|
public function create(array $parameters) |
21
|
|
|
{ |
22
|
|
|
$endpoint = '/lead/create'; |
23
|
|
|
return $this->doRequest('post', $endpoint, $parameters); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Get leads data by client ID |
28
|
|
|
* |
29
|
|
|
* @link https://api.u-on.ru/{key}/lead-by-client/{id}.{_format} |
30
|
|
|
* @param int $id - Unique lead ID |
31
|
|
|
* @param int $page - Number of page, 1 by default |
32
|
|
|
* @return array|false |
33
|
|
|
*/ |
34
|
|
|
public function getByClient($id, $page = 1) |
35
|
|
|
{ |
36
|
|
|
$endpoint = '/lead-by-client/' . $id . '/' . $page; |
37
|
|
|
return $this->doRequest('get', $endpoint); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get lead by ID |
42
|
|
|
* |
43
|
|
|
* @link https://api.u-on.ru/{key}/lead/{id}.{_format} |
44
|
|
|
* @param int $id - Unique lead ID |
45
|
|
|
* @return array|false |
46
|
|
|
*/ |
47
|
|
|
public function get($id) |
48
|
|
|
{ |
49
|
|
|
$endpoint = '/lead/' . $id; |
50
|
|
|
return $this->doRequest('get', $endpoint); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get all leads into dates range (and by sources if needed) |
55
|
|
|
* |
56
|
|
|
* @link https://api.u-on.ru/{key}/lead/{date_from}/{date_to}.{_format} |
57
|
|
|
* @param string $date_from - Start of dates range |
58
|
|
|
* @param string $date_to - End of dates range |
59
|
|
|
* @param int $page - Number of page, 1 by default |
60
|
|
|
* @param int|null $source_id - Source ID, eg ID of SMS or JivoSite |
61
|
|
|
* @return array|false |
62
|
|
|
*/ |
63
|
|
|
public function getDate($date_from, $date_to, $page = 1, $source_id = null) |
64
|
|
|
{ |
65
|
|
|
$endpoint = '/lead/' . $date_from . '/' . $date_to; |
66
|
|
|
if (null !== $source_id) { |
67
|
|
|
$endpoint .= '/' . $source_id; |
68
|
|
|
} |
69
|
|
|
$endpoint .= '/' . $page; |
70
|
|
|
return $this->doRequest('get', $endpoint); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Get lead data by filters |
75
|
|
|
* |
76
|
|
|
* @link https://api.u-on.ru/{key}/lead/search.{_format} |
77
|
|
|
* @since 1.8.2 |
78
|
|
|
* @param array $parameters - List of parameters |
79
|
|
|
* @return array|false |
80
|
|
|
*/ |
81
|
|
|
public function search(array $parameters = []) |
82
|
|
|
{ |
83
|
|
|
$endpoint = '/lead/search'; |
84
|
|
|
return $this->doRequest('post', $endpoint, $parameters); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
} |
88
|
|
|
|