Passed
Push — master ( f86309...3fa716 )
by Mr
01:59 queued 22s
created

Users::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
     * @return  array|false
18
     */
19
    public function all()
20
    {
21
        $endpoint = '/user';
22
        return $this->doRequest('get', $endpoint);
23
    }
24
25
    /**
26
     * Get single user by ID
27
     *
28
     * @link    https://api.u-on.ru/{key}/user/{id}.{_format}
29
     * @param   int $id
30
     * @return  array|false
31
     */
32
    public function get($id)
33
    {
34
        $endpoint = '/user/' . $id;
35
        return $this->doRequest('get', $endpoint);
36
    }
37
38
    /**
39
     * Get users by filters
40
     *
41
     * @link    https://api.u-on.ru/{key}/user/search.{_format}
42
     * @param   array $parameters - Some parameters for search [telegram, whatsapp, viber, instagram]
43
     * @return  array|false
44
     */
45
    public function search(array $parameters = [])
46
    {
47
        $endpoint = '/user/search';
48
        return $this->doRequest('post', $endpoint, $parameters);
49
    }
50
51
    /**
52
     * Get list of user's labels
53
     *
54
     * @link    https://api.u-on.ru/{key}/user-label.{_format}
55
     * @param   array $parameters
56
     * @return  array|false
57
     */
58
    public function getLabel(array $parameters = [])
59
    {
60
        $endpoint = '/user-label';
61
        return $this->doRequest('get', $endpoint, $parameters);
62
    }
63
64
    /**
65
     * Get single user by phone number
66
     *
67
     * @link    https://api.u-on.ru/{key}/user/phone/{phone}.{_format}
68
     * @param   string $phone
69
     * @return  array|false
70
     */
71
    public function getPhone($phone)
72
    {
73
        $endpoint = '/user/phone/' . $phone;
74
        return $this->doRequest('get', $endpoint);
75
    }
76
77
    /**
78
     * @link    https://api.u-on.ru/{key}/user/email.{_format}
79
     * @param   string $email
80
     * @return  array|false
81
     */
82
    public function getEmail($email)
83
    {
84
        $endpoint = '/user/email';
85
        return $this->doRequest('post', $endpoint, ['email' => $email]);
86
    }
87
88
    /**
89
     * Get all users. profiles which were updated in the specified date range
90
     *
91
     * @link    https://api.u-on.ru/{key}/user/updated/{date_from}/{date_to}.{_format}
92
     * @param   string $date_from
93
     * @param   string $date_to
94
     * @return  array|false
95
     */
96
    public function getUpdated($date_from, $date_to)
97
    {
98
        $endpoint = '/user/updated/' . $date_from . '/' . $date_to;
99
        return $this->doRequest('get', $endpoint);
100
    }
101
102
    /**
103
     * The list of the tourists by page number
104
     *
105
     * @link    https://api.u-on.ru/{key}/users_by_page/{page}.{_format}
106
     * @param   int $page number of page
107
     * @return  array|false
108
     */
109
    public function getByPage($page)
110
    {
111
        $endpoint = '/users_by_page/' . $page;
112
        return $this->doRequest('get', $endpoint);
113
    }
114
115
    /**
116
     * Create new user in database
117
     *
118
     * @link    https://api.u-on.ru/{key}/user/create.{_format}
119
     * @param   array $parameters
120
     * @return  array|false
121
     */
122
    public function create(array $parameters)
123
    {
124
        $endpoint = '/user/create';
125
        return $this->doRequest('post', $endpoint, $parameters);
126
    }
127
128
    /**
129
     * Add file into tourists files
130
     *
131
     * @link    https://api.u-on.ru/{key}/user-file/create.{_format}
132
     * @param   array $parameters
133
     * @return  array|false
134
     */
135
    public function createFile(array $parameters)
136
    {
137
        $endpoint = '/user-file/create';
138
        return $this->doRequest('post', $endpoint, $parameters);
139
    }
140
141
    /**
142
     * Update existing user by their ID
143
     *
144
     * @link    https://api.u-on.ru/{key}/user/update/{id}.{_format}
145
     * @param   int $id
146
     * @param   array $parameters
147
     * @return  array|false
148
     */
149
    public function update($id, $parameters)
150
    {
151
        $endpoint = '/user/update/' . $id;
152
        return $this->doRequest('post', $endpoint, $parameters);
153
    }
154
155
}
156