| Total Complexity | 10 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 89.47% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class NavigaAdApi |
||
| 10 | { |
||
| 11 | protected PendingRequest $client; |
||
| 12 | |||
| 13 | 2 | public function __construct( |
|
| 14 | array $credentials, |
||
| 15 | string $baseUrl, |
||
| 16 | array $options = [], |
||
| 17 | ) { |
||
| 18 | 2 | $client = Http::baseUrl(rtrim($baseUrl, '/').'/'); |
|
| 19 | |||
| 20 | 2 | if (isset($credentials['username']) && isset($credentials['password'])) { |
|
| 21 | 2 | $client->withBasicAuth($credentials['username'], $credentials['password']); |
|
| 22 | } elseif (isset($credentials['bearer'])) { |
||
| 23 | $client->withToken($credentials['bearer']); |
||
| 24 | } |
||
| 25 | |||
| 26 | 2 | if (isset($options['guzzle'])) { |
|
| 27 | 2 | $client->withOptions($options['guzzle']); |
|
| 28 | } |
||
| 29 | |||
| 30 | 2 | if (isset($options['retry'])) { |
|
| 31 | 2 | $client->retry(...$options['retry']); |
|
|
|
|||
| 32 | } |
||
| 33 | |||
| 34 | 2 | if (isset($options['timeout'])) { |
|
| 35 | 2 | $client->timeout($options['timeout']); |
|
| 36 | } |
||
| 37 | |||
| 38 | 2 | if (isset($options['headers'])) { |
|
| 39 | 2 | $client->withHeaders($options['headers']); |
|
| 40 | } |
||
| 41 | |||
| 42 | 2 | $this->client = $client; |
|
| 43 | } |
||
| 44 | |||
| 45 | 2 | public function pendingRequest(): PendingRequest |
|
| 48 | } |
||
| 49 | |||
| 50 | 1 | public function paginatedRequest( |
|
| 56 | } |
||
| 57 | } |
||
| 58 |