1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace InShore\Bookwhen\Resources; |
6
|
|
|
|
7
|
|
|
use InShore\Bookwhen\Contracts\Resources\LocationsContract; |
8
|
|
|
use InShore\Bookwhen\Responses\Locations\ListResponse; |
9
|
|
|
use InShore\Bookwhen\Responses\Locations\RetrieveResponse; |
10
|
|
|
use InShore\Bookwhen\ValueObjects\Transporter\Payload; |
11
|
|
|
|
12
|
|
|
final class Locations implements LocationsContract |
13
|
|
|
{ |
14
|
|
|
use Concerns\Transportable; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Returns a list of locations that belong to the user's organization. |
18
|
|
|
* |
19
|
|
|
* @see https://api.bookwhen.com/v2#tag/Location/paths/~1locations/get |
20
|
|
|
*/ |
21
|
1 |
|
public function list(array $parameters): ListResponse |
22
|
|
|
{ |
23
|
1 |
|
$payload = Payload::list('locations', $parameters); |
24
|
|
|
|
25
|
|
|
/** @var array{object: string, data: array<int, array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}>} $result */ |
26
|
1 |
|
$result = $this->transporter->requestObject($payload); |
27
|
|
|
|
28
|
1 |
|
return ListResponse::from($result); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Returns information about a specific location. |
33
|
|
|
* |
34
|
|
|
* @see https://api.bookwhen.com/v2#tag/Location/paths/~1locations~1%7Blocation_id%7D/get |
35
|
|
|
*/ |
36
|
1 |
|
public function retrieve(string $eventId): RetrieveResponse |
37
|
|
|
{ |
38
|
1 |
|
$payload = Payload::retrieve('locations', $eventId); |
39
|
|
|
|
40
|
|
|
/** @var array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null} $result */ |
41
|
1 |
|
$result = $this->transporter->requestObject($payload)['data']; |
42
|
|
|
|
43
|
1 |
|
return RetrieveResponse::from($result); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|