Webhooks   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 75
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 7 1
A update() 0 8 1
A delete() 0 7 1
A create() 0 8 1
1
<?php
2
3
namespace Uon\Endpoints;
4
5
use Uon\Client;
6
7
class Webhooks extends Client
8
{
9
    /**
10
     * Create a new webhook
11
     *
12
     * @link https://api.u-on.ru/{key}/webhook/create.{_format}
13
     *
14
     * @param array $parameters List of parameters
15
     *
16
     * @return null|object|\Uon\Interfaces\ClientInterface
17
     */
18
    public function create(array $parameters)
19
    {
20
        // Set HTTP params
21
        $this->type     = 'post';
22
        $this->endpoint = 'webhook/create';
23
        $this->params   = $parameters;
24
25
        return $this->done();
26
    }
27
28
    /**
29
     * Get a list of webhooks (divided by pages, 100 hotels per page)
30
     *
31
     * @link https://api.u-on.ru/{key}/webhook/{page}.{_format}
32
     *
33
     * @param int $page Number of page, 1 by default
34
     *
35
     * @return null|object|\Uon\Interfaces\ClientInterface
36
     */
37
    public function all(int $page = 1)
38
    {
39
        // Set HTTP params
40
        $this->type     = 'get';
41
        $this->endpoint = 'webhook/' . $page;
42
43
        return $this->done();
44
    }
45
46
    /**
47
     * Update information about webhook
48
     *
49
     * @link https://api.u-on.ru/{key}/webhook/update/{id}.{_format}
50
     *
51
     * @param int   $id         Unique webhook ID
52
     * @param array $parameters List of parameters
53
     *
54
     * @return null|object|\Uon\Interfaces\ClientInterface
55
     */
56
    public function update(int $id, array $parameters)
57
    {
58
        // Set HTTP params
59
        $this->type     = 'post';
60
        $this->endpoint = 'webhook/update/' . $id;
61
        $this->params   = $parameters;
62
63
        return $this->done();
64
    }
65
66
    /**
67
     * Delete selected webhook from database
68
     *
69
     * @link https://api.u-on.ru/{key}/webhook/delete/{id}.{_format}
70
     *
71
     * @param int $id Unique webhook ID
72
     *
73
     * @return null|object|\Uon\Interfaces\ClientInterface
74
     */
75
    public function delete(int $id)
76
    {
77
        // Set HTTP params
78
        $this->type     = 'post';
79
        $this->endpoint = 'webhook/delete/' . $id;
80
81
        return $this->done();
82
    }
83
}
84