1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace InShore\Bookwhen\Responses\Locations; |
6
|
|
|
|
7
|
|
|
use InShore\Bookwhen\Contracts\ResponseContract; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @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}> |
11
|
|
|
*/ |
12
|
|
|
final class RetrieveResponse implements ResponseContract |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @param array<array-key, mixed>|null $statusDetails |
|
|
|
|
16
|
|
|
*/ |
17
|
8 |
|
private function __construct( |
18
|
|
|
public readonly null | string $additionalInfo, |
19
|
|
|
public readonly null | string $addressText, |
20
|
|
|
public readonly string $id, |
21
|
|
|
public readonly float | null $latitude, |
22
|
|
|
public readonly float | null $longitude, |
23
|
|
|
public readonly null | string $mapUrl, |
24
|
|
|
public readonly int | null $zoom |
25
|
|
|
) { |
26
|
8 |
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Acts as static factory, and returns a new Response instance. |
30
|
|
|
* |
31
|
|
|
* @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 |
|
|
|
|
32
|
|
|
*/ |
33
|
8 |
|
public static function from(array $attributes): self |
34
|
|
|
{ |
35
|
8 |
|
return new self( |
36
|
8 |
|
$attributes['attributes']['additional_info'] ?? null, |
37
|
8 |
|
$attributes['attributes']['address_text'] ?? null, |
38
|
8 |
|
$attributes['id'], |
39
|
8 |
|
$attributes['attributes']['latitude'] ?? null, |
40
|
8 |
|
$attributes['attributes']['longitude'] ?? null, |
41
|
8 |
|
$attributes['attributes']['map_url'] ?? null, |
42
|
8 |
|
$attributes['attributes']['zoom'] ?? null |
43
|
8 |
|
); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|