|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace InShore\Bookwhen\Responses\Tickets; |
|
6
|
|
|
|
|
7
|
|
|
use InShore\Bookwhen\Contracts\ResponseContract; |
|
8
|
|
|
use InShore\Bookwhen\Responses\Concerns\ArrayAccessible; |
|
9
|
|
|
|
|
10
|
|
|
//use OpenAI\Testing\Responses\Concerns\Fakeable; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @implements ResponseContract<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}> |
|
14
|
|
|
*/ |
|
15
|
|
|
final class RetrieveResponse implements ResponseContract |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @use ArrayAccessible<array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null}> |
|
19
|
|
|
*/ |
|
20
|
|
|
use ArrayAccessible; |
|
21
|
|
|
|
|
22
|
|
|
//use Fakeable; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param array<array-key, mixed>|null $statusDetails |
|
|
|
|
|
|
26
|
|
|
, |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
'cost' => |
|
31
|
|
|
array ( |
|
32
|
|
|
'currency_code' => 'GBP', |
|
33
|
|
|
'net' => 3500, |
|
34
|
|
|
'tax' => 0, |
|
35
|
|
|
), |
|
36
|
|
|
*/ |
|
37
|
|
|
private function __construct( |
|
38
|
|
|
public readonly bool $available, |
|
39
|
|
|
public readonly null | string $availableFrom, |
|
40
|
|
|
public readonly null | string $availableTo, |
|
41
|
|
|
public readonly string $builtBasketUrl, |
|
42
|
|
|
public readonly string $builtBasketIframeUrl, |
|
43
|
|
|
public readonly bool $courseTicket, |
|
44
|
|
|
// cost |
|
45
|
|
|
public readonly string $details, |
|
46
|
|
|
public readonly bool $groupTicket, |
|
47
|
|
|
public readonly int $groupMin, |
|
48
|
|
|
public readonly int $groupMax, |
|
49
|
|
|
public readonly string $id, |
|
50
|
|
|
public readonly int | null $numberIssued, |
|
51
|
|
|
public readonly int $numberTaken, |
|
52
|
|
|
public readonly string $title |
|
53
|
|
|
) { |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Acts as static factory, and returns a new Response instance. |
|
58
|
|
|
* |
|
59
|
|
|
* @param array{id: string, object: string, created_at: int, bytes: int, filename: string, purpose: string, status: string, status_details: array<array-key, mixed>|string|null} $attributes |
|
|
|
|
|
|
60
|
|
|
*/ |
|
61
|
|
|
public static function from(array $attributes): self |
|
62
|
|
|
{ |
|
63
|
|
|
return new self( |
|
64
|
|
|
$attributes['attributes']['available'], |
|
65
|
|
|
$attributes['attributes']['available_from'], |
|
66
|
|
|
$attributes['attributes']['available_to'], |
|
67
|
|
|
$attributes['attributes']['built_basket_url'], |
|
68
|
|
|
$attributes['attributes']['built_basket_iframe_url'], |
|
69
|
|
|
$attributes['attributes']['course_ticket'], |
|
70
|
|
|
$attributes['attributes']['details'], |
|
71
|
|
|
$attributes['attributes']['group_ticket'], |
|
72
|
|
|
$attributes['attributes']['group_min'], |
|
73
|
|
|
$attributes['attributes']['group_max'], |
|
74
|
|
|
$attributes['id'], |
|
75
|
|
|
$attributes['attributes']['number_issued'], |
|
76
|
|
|
$attributes['attributes']['number_taken'], |
|
77
|
|
|
$attributes['attributes']['title'] |
|
78
|
|
|
); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritDoc} |
|
83
|
|
|
*/ |
|
84
|
|
|
public function toArray(): array |
|
85
|
|
|
{ |
|
86
|
|
|
return [ |
|
87
|
|
|
'id' => $this->id, |
|
88
|
|
|
'type' => $this->type, |
|
|
|
|
|
|
89
|
|
|
//'attributes' => $this->attributes, |
|
90
|
|
|
]; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|