1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace InShore\Bookwhen\Responses\ClassPasses; |
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
|
4 |
|
private function __construct( |
28
|
|
|
public readonly null | string $details, |
29
|
|
|
public readonly string $id, |
30
|
|
|
public readonly int | null $numberAvailable, |
31
|
|
|
public readonly null | string $title, |
32
|
|
|
public readonly int | null $usageAllowance, |
33
|
|
|
public readonly null | string $usageType, |
34
|
|
|
public readonly int | null $useRestrictedForDays, |
35
|
|
|
) { |
36
|
4 |
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Acts as static factory, and returns a new Response instance. |
40
|
|
|
* |
41
|
|
|
* @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 |
|
|
|
|
42
|
|
|
*/ |
43
|
4 |
|
public static function from(array $attributes): self |
44
|
|
|
{ |
45
|
|
|
|
46
|
4 |
|
return new self( |
47
|
4 |
|
$attributes['attributes']['details'], |
48
|
4 |
|
$attributes['id'], |
49
|
4 |
|
$attributes['attributes']['number_available'], |
50
|
4 |
|
$attributes['attributes']['title'], |
51
|
4 |
|
$attributes['attributes']['usage_allowance'], |
52
|
4 |
|
$attributes['attributes']['usage_type'], |
53
|
4 |
|
$attributes['attributes']['use_restricted_for_days'], |
54
|
4 |
|
); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|