1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bookeo\Endpoints\Availability; |
4
|
|
|
|
5
|
|
|
use Bookeo\Endpoints\Availability; |
6
|
|
|
use Bookeo\Models\SlotList; |
7
|
|
|
|
8
|
|
|
class Slots extends Availability |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Navigate results of a matching slots search |
12
|
|
|
* |
13
|
|
|
* @param string $productId the product id (see /settings/products). If not provided, all products of type "fixed" or "fixedCourse" will be included in the result. If no |
14
|
|
|
* productId is provided, products that are not bookable by customers wil not be included in the result. If productId is provided, the product must |
15
|
|
|
* be of type "fixed" or "fixedCourse". For products of type "flexibleTime", use /availability/matchingslots instead. |
16
|
|
|
* @param string $startTime the start time to search from. Required unless pageNavigationToken is used. |
17
|
|
|
* @param string $endTime the end time to search to. Required unless pageNavigationToken is used. The maximum date range in a single call is 31 days. |
18
|
|
|
* @param string $pageNavigationToken |
19
|
|
|
* @param int $itemsPerPage maximum: 300 |
20
|
|
|
* @param int $pageNumber |
21
|
|
|
* |
22
|
|
|
* @return $this |
23
|
|
|
*/ |
24
|
|
|
public function __invoke( |
25
|
|
|
string $productId = null, |
26
|
|
|
string $startTime = null, |
27
|
|
|
string $endTime = null, |
28
|
|
|
int $itemsPerPage = 50, |
29
|
|
|
string $pageNavigationToken = null, |
30
|
|
|
int $pageNumber = 1 |
31
|
|
|
) { |
32
|
|
|
if (!empty($productId)) { |
33
|
|
|
$this->appendToQuery('productId', $productId); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
if (!empty($startTime) && empty($pageNavigationToken)) { |
37
|
|
|
$this->appendToQuery('startTime', $startTime); |
38
|
|
|
} elseif (empty($startTime) && !empty($pageNavigationToken)) { |
39
|
|
|
$this->appendToQuery('pageNavigationToken', $pageNavigationToken); |
40
|
|
|
} elseif (!empty($startTime) && !empty($pageNavigationToken)) { |
41
|
|
|
$this->appendToQuery('pageNavigationToken', $pageNavigationToken); |
42
|
|
|
} else { |
43
|
|
|
throw new \InvalidArgumentException('At least "startTime" or "pageNavigationToken" must be set'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if (!empty($endTime)) { |
47
|
|
|
$this->appendToQuery('endTime', $endTime); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if (!empty($itemsPerPage)) { |
51
|
|
|
$this->appendToQuery('itemsPerPage', $itemsPerPage); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
if (!empty($pageNavigationToken)) { |
55
|
|
|
$this->appendToQuery('pageNavigationToken', $pageNavigationToken); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if (!empty($pageNumber)) { |
59
|
|
|
$this->appendToQuery('pageNumber', $pageNumber); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
// Set HTTP params |
63
|
|
|
$this->type = 'get'; |
64
|
|
|
$this->endpoint = '/availability/slots' . '?' . $this->getQuery(); |
65
|
|
|
$this->response = SlotList::class; |
|
|
|
|
66
|
|
|
|
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.