1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace InShore\Bookwhen\Resources; |
6
|
|
|
|
7
|
|
|
use InShore\Bookwhen\Contracts\Resources\TicketsContract; |
8
|
|
|
use InShore\Bookwhen\Responses\Tickets\ListResponse; |
9
|
|
|
use InShore\Bookwhen\Responses\Tickets\RetrieveResponse; |
10
|
|
|
use InShore\Bookwhen\ValueObjects\Transporter\Payload; |
11
|
|
|
|
12
|
|
|
final class Tickets implements TicketsContract |
13
|
|
|
{ |
14
|
|
|
use Concerns\Transportable; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Returns a list of tickets that belong to the user's organization's event. |
18
|
|
|
* |
19
|
|
|
* @see https://api.bookwhen.com/v2#tag/Ticket/paths/~1tickets/get |
20
|
|
|
*/ |
21
|
1 |
|
public function list(array $parameters): ListResponse // @todo change |
22
|
|
|
{ |
23
|
1 |
|
$payload = Payload::list('tickets', $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 |
|
if (!array_key_exists('included', $result)) { |
29
|
1 |
|
return ListResponse::from($result); |
30
|
|
|
} else { |
31
|
|
|
return ListResponse::from($result, $result['included']); |
|
|
|
|
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Returns information about a specific ticket. |
37
|
|
|
* |
38
|
|
|
* @see https://api.bookwhen.com/v2#tag/Ticket/paths/~1tickets~1%7Bticket_id%7D/get |
39
|
|
|
*/ |
40
|
1 |
|
public function retrieve(string $ticketId): RetrieveResponse |
41
|
|
|
{ |
42
|
1 |
|
$payload = Payload::retrieve('tickets', $ticketId); |
43
|
|
|
|
44
|
|
|
/** @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 */ |
45
|
1 |
|
$result = $this->transporter->requestObject($payload); |
46
|
|
|
|
47
|
1 |
|
if (!array_key_exists('included', $result)) { |
48
|
1 |
|
return RetrieveResponse::from($result['data']); |
49
|
|
|
} else { |
50
|
|
|
return RetrieveResponse::from($result['data'], $result['included']); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.