Completed
Push — master ( 5c6f77...9539a1 )
by Mr
25s queued 11s
created

Cities::update()   A

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 2
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 Cities
9
 *
10
 * @package Uon\Endpoint
11
 */
12
class Cities extends Client
13
{
14
    /**
15
     * Create new city in country
16
     *
17
     * @link https://api.u-on.ru/{key}/city/create.{_format}
18
     *
19
     * @param array $parameters List of parameters
20
     *
21
     * @return null|object|\Uon\Interfaces\ClientInterface
22
     */
23
    public function create(array $parameters)
24
    {
25
        // Set HTTP params
26
        $this->type     = 'post';
27
        $this->endpoint = 'city/create';
28
        $this->params   = $parameters;
29
30
        return $this->done();
31
    }
32
33
    /**
34
     * Get all cities by country id
35
     *
36
     * @link https://api.u-on.ru/{key}/cities/{country_id}.{_format}
37
     *
38
     * @param int $countryId Unique ID of country
39
     * @param int $page      Number of page, 1 by default
40
     *
41
     * @return null|object|\Uon\Interfaces\ClientInterface
42
     */
43
    public function all(int $countryId, int $page = 1)
44
    {
45
        // Set HTTP params
46
        $this->type     = 'get';
47
        $this->endpoint = 'cities/' . $countryId . '/' . $page;
48
49
        return $this->done();
50
    }
51
52
    /**
53
     * Update some city by ID
54
     *
55
     * @link https://api.u-on.ru/{key}/city/update/{id}.{_format}
56
     *
57
     * @param int   $id         Unique city ID
58
     * @param array $parameters List of parameters
59
     *
60
     * @return null|object|\Uon\Interfaces\ClientInterface
61
     */
62
    public function update(int $id, array $parameters)
63
    {
64
        // Set HTTP params
65
        $this->type     = 'post';
66
        $this->endpoint = 'city/update/' . $id;
67
        $this->params   = $parameters;
68
69
        return $this->done();
70
    }
71
}
72