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

Leads::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 Leads
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
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
     * @return  array|false
32
     */
33
    public function getByClient($id)
34
    {
35
        $endpoint = '/lead-by-client/' . $id;
36
        return $this->doRequest('get', $endpoint);
37
    }
38
39
    /**
40
     * Get lead by ID
41
     *
42
     * @link    https://api.u-on.ru/{key}/lead/{id}.{_format}
43
     * @param   int $id - Unique lead ID
44
     * @return  array|false
45
     */
46
    public function get($id)
47
    {
48
        $endpoint = '/lead/' . $id;
49
        return $this->doRequest('get', $endpoint);
50
    }
51
52
    /**
53
     * Get all leads into dates range (and by sources if needed)
54
     *
55
     * @link    https://api.u-on.ru/{key}/lead/{date_from}/{date_to}.{_format}
56
     * @param   string $date_from
57
     * @param   string $date_to
58
     * @param   int|null $source_id - Source ID, eg ID of SMS or JivoSite
59
     * @return  array|false
60
     */
61
    public function getDate($date_from, $date_to, $source_id = null)
62
    {
63
        $endpoint = '/lead/' . $date_from . '/' . $date_to;
64
        if (!empty($source_id)) $endpoint .= '/' . $source_id;
65
        return $this->doRequest('get', $endpoint);
66
    }
67
68
}
69