1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Uon\Endpoints; |
4
|
|
|
|
5
|
|
|
use Uon\Client; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Users |
9
|
|
|
* |
10
|
|
|
* @package Uon\Endpoint |
11
|
|
|
*/ |
12
|
|
|
class Users extends Client |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Get all users from database |
16
|
|
|
* |
17
|
|
|
* @link https://api.u-on.ru/{key}/user.{_format} |
18
|
|
|
* |
19
|
|
|
* @param int $page Number of page, 1 by default |
20
|
|
|
* |
21
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
22
|
|
|
*/ |
23
|
|
|
public function all(int $page = 1) |
24
|
|
|
{ |
25
|
|
|
// Set HTTP params |
26
|
|
|
$this->type = 'get'; |
27
|
|
|
$this->endpoint = 'users/' . $page; |
28
|
|
|
|
29
|
|
|
return $this->done(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Get single user by ID |
34
|
|
|
* |
35
|
|
|
* @link https://api.u-on.ru/{key}/user/{id}.{_format} |
36
|
|
|
* |
37
|
|
|
* @param int $id |
38
|
|
|
* |
39
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
40
|
|
|
*/ |
41
|
|
|
public function get(int $id) |
42
|
|
|
{ |
43
|
|
|
// Set HTTP params |
44
|
|
|
$this->type = 'get'; |
45
|
|
|
$this->endpoint = 'user/' . $id; |
46
|
|
|
|
47
|
|
|
return $this->done(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get users by filters |
52
|
|
|
* |
53
|
|
|
* @link https://api.u-on.ru/{key}/user/search.{_format} |
54
|
|
|
* |
55
|
|
|
* @param array $parameters Some parameters for search [telegram, whatsapp, viber, instagram] |
56
|
|
|
* |
57
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
58
|
|
|
*/ |
59
|
|
|
public function search(array $parameters = []) |
60
|
|
|
{ |
61
|
|
|
// Set HTTP params |
62
|
|
|
$this->type = 'post'; |
63
|
|
|
$this->endpoint = 'user/search'; |
64
|
|
|
$this->params = $parameters; |
65
|
|
|
|
66
|
|
|
return $this->done(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get list of user's labels |
71
|
|
|
* |
72
|
|
|
* @link https://api.u-on.ru/{key}/user-label.{_format} |
73
|
|
|
* |
74
|
|
|
* @param array $parameters List of parameters |
75
|
|
|
* |
76
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
77
|
|
|
*/ |
78
|
|
|
public function getLabel(array $parameters = []) |
79
|
|
|
{ |
80
|
|
|
// Set HTTP params |
81
|
|
|
$this->type = 'get'; |
82
|
|
|
$this->endpoint = 'user-label'; |
83
|
|
|
$this->params = $parameters; |
84
|
|
|
|
85
|
|
|
return $this->done(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Get single user by phone number |
90
|
|
|
* |
91
|
|
|
* @link https://api.u-on.ru/{key}/user/phone/{phone}.{_format} |
92
|
|
|
* |
93
|
|
|
* @param string $phone Number of client phone |
94
|
|
|
* |
95
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
96
|
|
|
*/ |
97
|
|
|
public function getPhone(string $phone) |
98
|
|
|
{ |
99
|
|
|
// Set HTTP params |
100
|
|
|
$this->type = 'get'; |
101
|
|
|
$this->endpoint = 'user/phone/' . $phone; |
102
|
|
|
|
103
|
|
|
return $this->done(); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @link https://api.u-on.ru/{key}/user/email.{_format} |
108
|
|
|
* |
109
|
|
|
* @param string $email Email of client |
110
|
|
|
* |
111
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
112
|
|
|
*/ |
113
|
|
|
public function getEmail(string $email) |
114
|
|
|
{ |
115
|
|
|
// Set HTTP params |
116
|
|
|
$this->type = 'post'; |
117
|
|
|
$this->endpoint = 'user/email'; |
118
|
|
|
$this->params = ['email' => $email]; |
119
|
|
|
|
120
|
|
|
return $this->done(); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Get all users. profiles which were updated in the specified date range |
125
|
|
|
* |
126
|
|
|
* @link https://api.u-on.ru/{key}/user/updated/{date_from}/{date_to}.{_format} |
127
|
|
|
* |
128
|
|
|
* @param string $dateFrom Start of dates range |
129
|
|
|
* @param string $dateTo End of dates range |
130
|
|
|
* @param int $page Number of page, 1 by default |
131
|
|
|
* |
132
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
133
|
|
|
*/ |
134
|
|
|
public function getUpdated(string $dateFrom, string $dateTo, int $page = 1) |
135
|
|
|
{ |
136
|
|
|
// Set HTTP params |
137
|
|
|
$this->type = 'get'; |
138
|
|
|
$this->endpoint = 'user/updated/' . $dateFrom . '/' . $dateTo . '/' . $page; |
139
|
|
|
|
140
|
|
|
return $this->done(); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Create new user in database |
145
|
|
|
* |
146
|
|
|
* @link https://api.u-on.ru/{key}/user/create.{_format} |
147
|
|
|
* |
148
|
|
|
* @param array $parameters |
149
|
|
|
* |
150
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
151
|
|
|
*/ |
152
|
|
|
public function create(array $parameters) |
153
|
|
|
{ |
154
|
|
|
// Set HTTP params |
155
|
|
|
$this->type = 'post'; |
156
|
|
|
$this->endpoint = 'user/create'; |
157
|
|
|
$this->params = $parameters; |
158
|
|
|
|
159
|
|
|
return $this->done(); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Add file into tourists files |
164
|
|
|
* |
165
|
|
|
* @link https://api.u-on.ru/{key}/user-file/create.{_format} |
166
|
|
|
* |
167
|
|
|
* @param array $parameters |
168
|
|
|
* |
169
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
170
|
|
|
*/ |
171
|
|
|
public function createFile(array $parameters) |
172
|
|
|
{ |
173
|
|
|
// Set HTTP params |
174
|
|
|
$this->type = 'post'; |
175
|
|
|
$this->endpoint = 'user-file/create'; |
176
|
|
|
$this->params = $parameters; |
177
|
|
|
|
178
|
|
|
return $this->done(); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Update existing user by ID |
183
|
|
|
* |
184
|
|
|
* @link https://api.u-on.ru/{key}/user/update/{id}.{_format} |
185
|
|
|
* |
186
|
|
|
* @param int $id ID of client |
187
|
|
|
* @param array $parameters List of parameters |
188
|
|
|
* |
189
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
190
|
|
|
*/ |
191
|
|
|
public function update(int $id, array $parameters) |
192
|
|
|
{ |
193
|
|
|
// Set HTTP params |
194
|
|
|
$this->type = 'post'; |
195
|
|
|
$this->endpoint = 'user/update/' . $id; |
196
|
|
|
$this->params = $parameters; |
197
|
|
|
|
198
|
|
|
return $this->done(); |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|