Passed
Pull Request — develop (#83)
by
unknown
12:02
created

ClassPasses::retrieve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
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;
0 ignored issues
show
Bug introduced by
The type InShore\Bookwhen\Respons...lassPasses\ListResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use InShore\Bookwhen\Responses\ClassPasses\RetrieveResponse;
0 ignored issues
show
Bug introduced by
The type InShore\Bookwhen\Respons...Passes\RetrieveResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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 files that belong to the user's organization.
18
     *
19
     * @see https://beta.openai.com/docs/api-reference/files/list
20
     */
21
    public function list(): ListResponse
22
    {
23
        $payload = Payload::list('classPasses');
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
        $result = $this->transporter->requestObject($payload);
27
28
        return ListResponse::from($result);
29
    }
30
31
    /**
32
     * Returns information about a specific file.
33
     *
34
     * @see https://beta.openai.com/docs/api-reference/files/retrieve
35
     */
36
    public function retrieve(string $classPassId): RetrieveResponse
37
    {
38
        $payload = Payload::retrieve('classPasses', $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
        $result = $this->transporter->requestObject($payload)['data'];
42
43
        return RetrieveResponse::from($result);
44
    }
45
}
46