1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Uon\Endpoints; |
4
|
|
|
|
5
|
|
|
use Uon\Client; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Hotels |
9
|
|
|
* |
10
|
|
|
* @package Uon\Endpoint |
11
|
|
|
*/ |
12
|
|
|
class Hotels extends Client |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Create new hotel |
16
|
|
|
* |
17
|
|
|
* @link https://api.u-on.ru/{key}/hotel/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 = 'hotel/create'; |
28
|
|
|
$this->params = $parameters; |
29
|
|
|
|
30
|
|
|
return $this->done(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get a list of hotels (divided by pages, 100 hotels per page) |
35
|
|
|
* |
36
|
|
|
* @link https://api.u-on.ru/{key}/hotels/{page}.{_format} |
37
|
|
|
* |
38
|
|
|
* @param int $page Number of page, 1 by default |
39
|
|
|
* |
40
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
41
|
|
|
*/ |
42
|
|
|
public function all(int $page = 1) |
43
|
|
|
{ |
44
|
|
|
// Set HTTP params |
45
|
|
|
$this->type = 'get'; |
46
|
|
|
$this->endpoint = 'hotels/' . $page; |
47
|
|
|
|
48
|
|
|
return $this->done(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get information about hotel |
53
|
|
|
* |
54
|
|
|
* @link https://api.u-on.ru/{key}/hotel/{id}.{_format} |
55
|
|
|
* |
56
|
|
|
* @param int $id Unique hotel ID |
57
|
|
|
* |
58
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
59
|
|
|
*/ |
60
|
|
|
public function get(int $id) |
61
|
|
|
{ |
62
|
|
|
// Set HTTP params |
63
|
|
|
$this->type = 'get'; |
64
|
|
|
$this->endpoint = 'hotel/' . $id; |
65
|
|
|
|
66
|
|
|
return $this->done(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Update information about hotel |
71
|
|
|
* |
72
|
|
|
* @link https://api.u-on.ru/{key}/hotel/update/{id}.{_format} |
73
|
|
|
* |
74
|
|
|
* @param int $id Unique hotel ID |
75
|
|
|
* @param array $parameters List of parameters |
76
|
|
|
* |
77
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
78
|
|
|
*/ |
79
|
|
|
public function update(int $id, array $parameters) |
80
|
|
|
{ |
81
|
|
|
// Set HTTP params |
82
|
|
|
$this->type = 'post'; |
83
|
|
|
$this->endpoint = 'hotel/update/' . $id; |
84
|
|
|
$this->params = $parameters; |
85
|
|
|
|
86
|
|
|
return $this->done(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Delete selected hotel from database |
91
|
|
|
* |
92
|
|
|
* @link https://api.u-on.ru/{key}/hotel/delete/{id}.{_format} |
93
|
|
|
* |
94
|
|
|
* @param int $id Unique hotel ID |
95
|
|
|
* |
96
|
|
|
* @return null|object|\Uon\Interfaces\ClientInterface |
97
|
|
|
*/ |
98
|
|
|
public function delete(int $id) |
99
|
|
|
{ |
100
|
|
|
// Set HTTP params |
101
|
|
|
$this->type = 'post'; |
102
|
|
|
$this->endpoint = 'hotel/delete/' . $id; |
103
|
|
|
|
104
|
|
|
return $this->done(); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|