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