1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Laravel WuBook. |
5
|
|
|
* |
6
|
|
|
* (c) Filippo Galante <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace IlGala\LaravelWubook\Api; |
13
|
|
|
|
14
|
|
|
use IlGala\LaravelWubook\Api\WuBookApi; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* This is the WuBook rooms api class. |
18
|
|
|
* |
19
|
|
|
* @author Filippo Galante <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class WuBookAvailability extends WuBookApi |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $token; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Create a new WuBookAvailability Instance. |
31
|
|
|
*/ |
32
|
|
|
public function __construct($config, $cache, $client, $token = null) |
33
|
|
|
{ |
34
|
|
|
parent::__construct($config, $cache, $client); |
35
|
|
|
|
36
|
|
|
$this->token = $token; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* http://tdocs.wubook.net/wired/avail.html#update_avail |
41
|
|
|
* http://tdocs.wubook.net/wired/avail.html#update_sparse_avail |
42
|
|
|
* |
43
|
|
|
* if dfrom param is not set the update_sparse_avail method will be called, update_avail method otherwise |
44
|
|
|
* |
45
|
|
|
* @param array $rooms |
46
|
|
|
* @param string $dfrom |
47
|
|
|
* @return mixed |
48
|
|
|
*/ |
49
|
|
|
public function update_avail($rooms, $dfrom = null) |
50
|
|
|
{ |
51
|
|
|
if (empty($dfrom)) { |
52
|
|
|
return $this->call_method($this->token, 'update_sparse_avail', [$rooms]); |
53
|
|
|
} else { |
54
|
|
|
return $this->call_method($this->token, 'update_avail', [$dfrom, $rooms]); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* http://tdocs.wubook.net/wired/avail.html#fetch_rooms_values |
60
|
|
|
* |
61
|
|
|
* if dfrom param is not set the update_sparse_avail method will be called, update_avail method otherwise |
62
|
|
|
* |
63
|
|
|
* @param array $rooms |
64
|
|
|
* @param string $dfrom |
65
|
|
|
* @return mixed |
66
|
|
|
*/ |
67
|
|
|
public function fetch_rooms_values($dfrom, $dto, $rooms = null) |
68
|
|
|
{ |
69
|
|
|
// Setup data |
70
|
|
|
$data = [ |
71
|
|
|
$dfrom, |
72
|
|
|
$dto |
73
|
|
|
]; |
74
|
|
|
|
75
|
|
|
if (!empty($rooms)) { |
76
|
|
|
array_push($data, $rooms); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return $this->call_method($this->token, 'fetch_rooms_values', $data); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|