Catalog::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Uon\Endpoints;
4
5
use Uon\Client;
6
7
/**
8
 * Class for management services of "I'am operator"
9
 *
10
 * @package Uon\Endpoint
11
 */
12
class Catalog extends Client
13
{
14
    /**
15
     * Get services of "I'm operator" by page number (first page by default)
16
     *
17
     * @link https://api.u-on.ru/{key}/bcard-bonus-by-card/{id}.{_format}
18
     *
19
     * @param int $page Number of page, 1 by default
20
     *
21
     * @return null|object|\Uon\Interfaces\ClientInterface
22
     */
23
    public function get(int $page = 1)
24
    {
25
        // Set HTTP params
26
        $this->type     = 'get';
27
        $this->endpoint = 'catalog-service/' . $page;
28
29
        return $this->done();
30
    }
31
32
    /**
33
     * Create services of "I'm operator"
34
     *
35
     * @link https://api.u-on.ru/{key}/bcard-activate/create.{_format}
36
     *
37
     * @param array $parameters List of parameters [s_id ...]
38
     *
39
     * @return null|object|\Uon\Interfaces\ClientInterface
40
     */
41
    public function create(array $parameters)
42
    {
43
        // Set HTTP params
44
        $this->type     = 'post';
45
        $this->endpoint = 'catalog-service/create';
46
        $this->params   = $parameters;
47
48
        return $this->done();
49
    }
50
51
    /**
52
     * Update services of "I'm operator"
53
     *
54
     * @link https://api.u-on.ru/{key}/catalog-service/update/{id}.{_format}
55
     *
56
     * @param int   $id         Unique ID of element
57
     * @param array $parameters List of parameters [s_id ...]
58
     *
59
     * @return null|object|\Uon\Interfaces\ClientInterface
60
     */
61
    public function update(int $id, array $parameters)
62
    {
63
        // Set HTTP params
64
        $this->type     = 'post';
65
        $this->endpoint = 'catalog-service/update/' . $id;
66
        $this->params   = $parameters;
67
68
        return $this->done();
69
    }
70
}
71