ClassPasses   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 32
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A retrieve() 0 8 1
A list() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace InShore\Bookwhen\Resources;
6
7
use InShore\Bookwhen\Contracts\Resources\ClassPassesContract;
8
use InShore\Bookwhen\Responses\ClassPasses\ListResponse;
9
use InShore\Bookwhen\Responses\ClassPasses\RetrieveResponse;
10
use InShore\Bookwhen\ValueObjects\Transporter\Payload;
11
12
final class ClassPasses implements ClassPassesContract
13
{
14
    use Concerns\Transportable;
15
16
    /**
17
     * Returns a list of class passes that belong to the user's organization.
18
     *
19
     * @see https://api.bookwhen.com/v2#tag/ClassPass/paths/~1class_passes/get
20
     */
21 1
    public function list(array $parameters): ListResponse
22
    {
23 1
        $payload = Payload::list('class_passes', $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 class pass.
33
     *
34
     * @see https://api.bookwhen.com/v2#tag/ClassPass/paths/~1class_passes~1%7Bclass_pass_id%7D/get
35
     */
36 1
    public function retrieve(string $classPassId): RetrieveResponse
37
    {
38 1
        $payload = Payload::retrieve('class_passes', $classPassId, []);
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