floweye/client

Floweye PHP API client

v0.4.1 2024-10-25 07:36 UTC

This package is auto-updated.

Last update: 2024-11-25 08:04:00 UTC


README

PHP API client for Floweye - REST API - Docs

Versions

Instalation

Install package using Composer.

composer require floweye/client

How to use

High level

Simply inject desired services which allow you to work directly with processed data.

$userService = $context->getService(Floweye\Client\Service\UserService::class);
$user = $userService->getById(1, []);

PSR-7 level

In case you need to access PSR-7 response. You can work with our client layer.

$userClient = $context->getService(Floweye\Client\Client\UserClient::class);

/** @var Psr\Http\Message\ResponseInterface $response */
$response = $userClient->getById(1, []);

Low level

This example showcases the manual service instantiation.

$guzzleFactory = $context->getService(Floweye\Client\Http\Guzzle\GuzzleFactory::class);
$httpClient = $guzzleFactory->create([
    'base_uri' => 'https://floweye.tld/api/v1/',
    'http_errors' => false,
    'headers' => [
        'X-Api-Token' => 'floweye-api-key',
    ]
]);

// You can now use $httpClient with our Clients, Services or on its own
$userClient = new Floweye\Client\Client\UserClient($httpClient);
$userService = new Floweye\Client\Service\UserService($userClient);

Nette bridge

extensions:
    # For Nette 3.0+
    floweye.api: Floweye\Client\DI\FloweyeExtension
    # For Nette 2.4
    floweye.api: Floweye\Client\DI\FloweyeExtension24

floweye.api:
    debug: %debugMode%
    http:
        base_uri: https://floweye.tld/api/v1/
        headers:
            X-Api-Token: floweye_api_key

Configure default http client Guzzle HTTP client under http option.

API endpoints overview

ApplicationService

UserService

UserGroupService