1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace ApiClients\Client\AppVeyor; |
4
|
|
|
|
5
|
|
|
use ApiClients\Client\Github\Middleware\RateLimitStateMiddleware; |
6
|
|
|
use ApiClients\Foundation\Hydrator\Options as HydratorOptions; |
7
|
|
|
use ApiClients\Foundation\Options as FoundationOptions; |
8
|
|
|
use ApiClients\Foundation\Transport\Options as TransportOptions; |
9
|
|
|
use ApiClients\Middleware\BearerAuthorization\BearerAuthorizationHeaderMiddleware; |
10
|
|
|
use ApiClients\Middleware\BearerAuthorization\Options; |
11
|
|
|
use ApiClients\Middleware\HttpExceptions\HttpExceptionsMiddleware; |
12
|
|
|
use ApiClients\Middleware\Json\AcceptJsonMiddleware; |
13
|
|
|
use ApiClients\Middleware\Json\JsonDecodeMiddleware; |
14
|
|
|
use ApiClients\Middleware\Json\JsonEncodeMiddleware; |
15
|
|
|
use ApiClients\Middleware\UserAgent\Options as UserAgentMiddlewareOptions; |
16
|
|
|
use ApiClients\Middleware\UserAgent\UserAgentMiddleware; |
17
|
1 |
|
use ApiClients\Middleware\UserAgent\UserAgentStrategies; |
18
|
|
|
use function ApiClients\Foundation\options_merge; |
19
|
1 |
|
|
20
|
1 |
|
final class ApiSettings |
21
|
1 |
|
{ |
22
|
|
|
const NAMESPACE = 'ApiClients\\Client\\AppVeyor\\Resource'; |
23
|
|
|
|
24
|
|
|
const TRANSPORT_OPTIONS = [ |
25
|
|
|
FoundationOptions::HYDRATOR_OPTIONS => [ |
26
|
|
|
HydratorOptions::NAMESPACE => self::NAMESPACE, |
27
|
|
|
HydratorOptions::NAMESPACE_DIR => __DIR__ . DIRECTORY_SEPARATOR . 'Resource' . DIRECTORY_SEPARATOR, |
28
|
|
|
], |
29
|
|
|
FoundationOptions::TRANSPORT_OPTIONS => [ |
30
|
|
|
TransportOptions::HOST => 'ci.appveyor.com', |
31
|
|
|
TransportOptions::PATH => '/api/', |
32
|
|
|
TransportOptions::MIDDLEWARE => [ |
33
|
|
|
JsonDecodeMiddleware::class, |
34
|
|
|
JsonEncodeMiddleware::class, |
35
|
|
|
HttpExceptionsMiddleware::class, |
36
|
|
|
UserAgentMiddleware::class, |
37
|
|
|
BearerAuthorizationHeaderMiddleware::class, |
38
|
|
|
AcceptJsonMiddleware::class, |
39
|
|
|
], |
40
|
|
|
TransportOptions::DEFAULT_REQUEST_OPTIONS => [ |
41
|
|
|
UserAgentMiddleware::class => [ |
42
|
|
|
UserAgentMiddlewareOptions::STRATEGY => UserAgentStrategies::PACKAGE_VERSION, |
43
|
|
|
UserAgentMiddlewareOptions::PACKAGE => 'api-clients/appveyor', |
44
|
|
|
], |
45
|
|
|
], |
46
|
|
|
], |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
public static function getOptions( |
50
|
|
|
string $token, |
51
|
|
|
array $suppliedOptions, |
52
|
|
|
string $suffix |
53
|
|
|
): array { |
54
|
|
|
$options = options_merge(self::TRANSPORT_OPTIONS, $suppliedOptions); |
55
|
|
|
$options[FoundationOptions::HYDRATOR_OPTIONS][HydratorOptions::NAMESPACE_SUFFIX] = $suffix; |
56
|
|
|
$options[FoundationOptions::TRANSPORT_OPTIONS] |
57
|
|
|
[TransportOptions::DEFAULT_REQUEST_OPTIONS] |
58
|
|
|
[BearerAuthorizationHeaderMiddleware::class] = [ |
59
|
|
|
Options::TOKEN => $token, |
60
|
|
|
] |
61
|
|
|
; |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
return $options; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|