1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Resova\Endpoints; |
4
|
|
|
|
5
|
|
|
use Resova\Client; |
6
|
|
|
use Resova\Endpoints\Baskets\Bookings; |
7
|
|
|
use Resova\Endpoints\Baskets\Promotions; |
8
|
|
|
use Resova\Endpoints\Baskets\Purchases; |
9
|
|
|
use Resova\Models\Basket; |
10
|
|
|
use Resova\Models\BasketDelete; |
11
|
|
|
use Resova\Models\BasketRequest; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @property Bookings $bookings Bookings management |
15
|
|
|
* @property Purchases $purchases Purchases management |
16
|
|
|
* @property Promotions $promotions Promotions management |
17
|
|
|
* |
18
|
|
|
* @method Bookings booking(int $booking_id) |
19
|
|
|
* @method Purchases purchase(int $purchase_id) |
20
|
|
|
* @method Promotions promotion(int $promotion_id) |
21
|
|
|
* |
22
|
|
|
* Class Baskets |
23
|
|
|
* |
24
|
|
|
* @package Resova\Endpoints |
25
|
|
|
*/ |
26
|
|
|
class Baskets extends Client |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
protected $namespace = __CLASS__; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Retrieve a basket |
35
|
|
|
* Retrieves the details of a basket. Provide the unique id for the basket. |
36
|
|
|
* |
37
|
|
|
* @param int $basket_id The basket id |
38
|
|
|
* |
39
|
|
|
* @return $this |
40
|
|
|
*/ |
41
|
1 |
|
public function __invoke(int $basket_id) |
42
|
|
|
{ |
43
|
1 |
|
$this->basket_id = $basket_id; |
|
|
|
|
44
|
|
|
|
45
|
|
|
// Set HTTP params |
46
|
1 |
|
$this->type = 'get'; |
47
|
1 |
|
$this->endpoint = '/baskets/' . $basket_id; |
48
|
1 |
|
$this->response = Basket::class; |
|
|
|
|
49
|
|
|
|
50
|
1 |
|
return $this; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Create a basket |
55
|
|
|
* Creates a new basket object. |
56
|
|
|
* |
57
|
|
|
* @param null|BasketRequest $basket |
58
|
|
|
* |
59
|
|
|
* @return $this |
60
|
|
|
*/ |
61
|
1 |
|
public function create(BasketRequest $basket = null): self |
62
|
|
|
{ |
63
|
|
|
// Set HTTP params |
64
|
1 |
|
$this->type = 'post'; |
65
|
1 |
|
$this->endpoint = '/baskets'; |
66
|
1 |
|
$this->params = $basket; |
67
|
1 |
|
$this->response = Basket::class; |
|
|
|
|
68
|
|
|
|
69
|
1 |
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Update a basket |
74
|
|
|
* Updates the specified basket by setting the values of the parameters passed. |
75
|
|
|
* Any parameters not provided will be left unchanged. |
76
|
|
|
* This request accepts mostly the same arguments as the basket creation call. |
77
|
|
|
* |
78
|
|
|
* @param null|BasketRequest $basket |
79
|
|
|
* |
80
|
|
|
* @return $this |
81
|
|
|
*/ |
82
|
|
|
public function update(BasketRequest $basket = null): self |
83
|
|
|
{ |
84
|
|
|
// Set HTTP params |
85
|
|
|
$this->type = 'put'; |
86
|
|
|
$this->endpoint = '/baskets/' . $this->basket_id; |
87
|
|
|
$this->params = $basket; |
88
|
|
|
$this->response = Basket::class; |
|
|
|
|
89
|
|
|
|
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Delete a basket |
95
|
|
|
* Permanently deletes a basket. This cannot be undone. |
96
|
|
|
* |
97
|
|
|
* @return $this |
98
|
|
|
*/ |
99
|
|
|
public function delete(): self |
100
|
|
|
{ |
101
|
|
|
// Set HTTP params |
102
|
|
|
$this->type = 'delete'; |
103
|
|
|
$this->endpoint = '/baskets/' . $this->basket_id; |
104
|
|
|
$this->response = BasketDelete::class; |
|
|
|
|
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
} |
110
|
|
|
|