\Iqrf\Repository\Utils ApiClient

HTTP(S) client for API

Summary

Methods
Properties
Constants
sendApiRequest
__construct
sendRequest
No public properties found
No public constants found
No protected methods found
configuration
httpClient
No protected constants found
No private methods found
No private properties found
No private constants found

Properties

$configuration

$configuration : \Iqrf\Repository\Configuration

Type

Configuration

$httpClient

$httpClient : \GuzzleHttp\Client

Type

Client

Methods

sendApiRequest()

sendApiRequest(string  $path, array|null  $query = null, bool  $useCredentials = false) : array

Sends JSON API request

Parameters

string $path

API path

array|null $query

Optional API query

bool $useCredentials

Throws

\Iqrf\Repository\Exceptions\CorruptedData

Corrupted data in the API response

\Iqrf\Repository\Exceptions\DataNotFound

Requested data not found

\Iqrf\Repository\Exceptions\ServiceUnavailable

IQRF Repository API is unavailable

Returns

array —

JSON API response

__construct()

__construct(\Iqrf\Repository\Configuration  $configuration, \GuzzleHttp\Client  $httpClient) : mixed

Constructor

Parameters

\Iqrf\Repository\Configuration $configuration

Configuration

\GuzzleHttp\Client $httpClient

HTTP(S) client

Returns

mixed —

sendRequest()

sendRequest(string  $url, array|null  $query = null, bool  $useCredentials = false) : string

Sends HTTP request

Parameters

string $url

URL

array|null $query

Optional query parameters

bool $useCredentials

Throws

\Iqrf\Repository\Exceptions\DataNotFound

Requested data not found

\Iqrf\Repository\Exceptions\ServiceUnavailable

IQRF Repository API is unavailable

Returns

string —

HTTP response