1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace UON\Endpoint; |
4
|
|
|
|
5
|
|
|
use UON\Client; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Users |
9
|
|
|
* @package UON |
10
|
|
|
*/ |
11
|
|
|
class Users extends Client |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Get all users from database |
15
|
|
|
* |
16
|
|
|
* @link api.u-on.ru/{key}/user.{_format} |
17
|
|
|
* @param int $page - Number of page, 1 by default |
18
|
|
|
* @return array|false |
19
|
|
|
*/ |
20
|
|
|
public function all($page = 1) |
21
|
|
|
{ |
22
|
|
|
$endpoint = '/users/' . $page; |
23
|
|
|
return $this->doRequest('get', $endpoint); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Get single user by ID |
28
|
|
|
* |
29
|
|
|
* @link https://api.u-on.ru/{key}/user/{id}.{_format} |
30
|
|
|
* @param int $id |
31
|
|
|
* @return array|false |
32
|
|
|
*/ |
33
|
|
|
public function get($id) |
34
|
|
|
{ |
35
|
|
|
$endpoint = '/user/' . $id; |
36
|
|
|
return $this->doRequest('get', $endpoint); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Get users by filters |
41
|
|
|
* |
42
|
|
|
* @link https://api.u-on.ru/{key}/user/search.{_format} |
43
|
|
|
* @param array $parameters - Some parameters for search [telegram, whatsapp, viber, instagram] |
44
|
|
|
* @return array|false |
45
|
|
|
*/ |
46
|
|
|
public function search(array $parameters = []) |
47
|
|
|
{ |
48
|
|
|
$endpoint = '/user/search'; |
49
|
|
|
return $this->doRequest('post', $endpoint, $parameters); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Get list of user's labels |
54
|
|
|
* |
55
|
|
|
* @link https://api.u-on.ru/{key}/user-label.{_format} |
56
|
|
|
* @param array $parameters |
57
|
|
|
* @return array|false |
58
|
|
|
*/ |
59
|
|
|
public function getLabel(array $parameters = []) |
60
|
|
|
{ |
61
|
|
|
$endpoint = '/user-label'; |
62
|
|
|
return $this->doRequest('get', $endpoint, $parameters); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get single user by phone number |
67
|
|
|
* |
68
|
|
|
* @link https://api.u-on.ru/{key}/user/phone/{phone}.{_format} |
69
|
|
|
* @param string $phone |
70
|
|
|
* @return array|false |
71
|
|
|
*/ |
72
|
|
|
public function getPhone($phone) |
73
|
|
|
{ |
74
|
|
|
$endpoint = '/user/phone/' . $phone; |
75
|
|
|
return $this->doRequest('get', $endpoint); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @link https://api.u-on.ru/{key}/user/email.{_format} |
80
|
|
|
* @param string $email |
81
|
|
|
* @return array|false |
82
|
|
|
*/ |
83
|
|
|
public function getEmail($email) |
84
|
|
|
{ |
85
|
|
|
$endpoint = '/user/email'; |
86
|
|
|
return $this->doRequest('post', $endpoint, ['email' => $email]); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get all users. profiles which were updated in the specified date range |
91
|
|
|
* |
92
|
|
|
* @link https://api.u-on.ru/{key}/user/updated/{date_from}/{date_to}.{_format} |
93
|
|
|
* @param string $date_from - Start of dates range |
94
|
|
|
* @param string $date_to - End of dates range |
95
|
|
|
* @param int $page - Number of page, 1 by default |
96
|
|
|
* @return array|false |
97
|
|
|
*/ |
98
|
|
|
public function getUpdated($date_from, $date_to, $page = 1) |
99
|
|
|
{ |
100
|
|
|
$endpoint = '/user/updated/' . $date_from . '/' . $date_to . '/' . $page; |
101
|
|
|
return $this->doRequest('get', $endpoint); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Create new user in database |
106
|
|
|
* |
107
|
|
|
* @link https://api.u-on.ru/{key}/user/create.{_format} |
108
|
|
|
* @param array $parameters |
109
|
|
|
* @return array|false |
110
|
|
|
*/ |
111
|
|
|
public function create(array $parameters) |
112
|
|
|
{ |
113
|
|
|
$endpoint = '/user/create'; |
114
|
|
|
return $this->doRequest('post', $endpoint, $parameters); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Add file into tourists files |
119
|
|
|
* |
120
|
|
|
* @link https://api.u-on.ru/{key}/user-file/create.{_format} |
121
|
|
|
* @param array $parameters |
122
|
|
|
* @return array|false |
123
|
|
|
*/ |
124
|
|
|
public function createFile(array $parameters) |
125
|
|
|
{ |
126
|
|
|
$endpoint = '/user-file/create'; |
127
|
|
|
return $this->doRequest('post', $endpoint, $parameters); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Update existing user by their ID |
132
|
|
|
* |
133
|
|
|
* @link https://api.u-on.ru/{key}/user/update/{id}.{_format} |
134
|
|
|
* @param int $id |
135
|
|
|
* @param array $parameters |
136
|
|
|
* @return array|false |
137
|
|
|
*/ |
138
|
|
|
public function update($id, $parameters) |
139
|
|
|
{ |
140
|
|
|
$endpoint = '/user/update/' . $id; |
141
|
|
|
return $this->doRequest('post', $endpoint, $parameters); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
} |
145
|
|
|
|