floweye/client

Floweye PHP API client

v0.3 2024-01-30 12:21 UTC

This package is auto-updated.

Last update: 2024-04-09 07:50:54 UTC


README

PHP API client for Floweye - REST API - Docs

68747470733a2f2f62616467656e2e6e65742f6769746875622f7374617475732f666c6f77736f757263652f666c6f776579652d636c69656e742f 68747470733a2f2f62616467656e2e6e65742f636f766572616c6c732f632f6769746875622f666c6f77736f757263652f666c6f776579652d636c69656e742f 68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f646d2f666c6f776579652f636c69656e74 68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f666c6f776579652f636c69656e74

Versions

State Version Branch Nette PHP
dev ^0.4.0 master 2.4, 3.0 >=7.2
stable ^0.3.0 master 2.4, 3.0 >=7.2

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

Method API
export($include) GET /application/export
import($data) POST /application/import
listGlobals($path) GET /application/globals
editGlobals($globals) PUT /application/globals
listSnippets($limit, $offset, $include) GET /application/snippets
createSnippet($entity) POST /application/snippets
editSnippet($id, $entity) PUT /application/snippets/{id}
deleteSnippet($id) DELETE /application/snippets/{id}

UserService

Method API
list($filter) GET /users
create($entity) POST /users
getById($id, $include) GET /users/{id}
edit($id, $entity) PUT /users/{id}
oneTimeLogin($id) PUT /users/{id}/one-time-login
passwordReset($id) PUT /users/{id}/password-reset
newUserToken($id) PUT /users/{id}/new-user/token
newUserMail($id) PUT /users/{id}/new-user/mail

UserGroupService

Method API
listUserGroups($include) GET /user-groups
createOne($entity) POST /user-groups
findOne($gid, $include) GET /user-groups/{gid}
editOne($gid, $entity) PUT /user-groups/{gid}
deleteOne($gid) DELETE /user-groups/{gid}
appendUsers($gid, $userIds, $includeSystemUsers, $includeBlockedUsers) PATCH /user-groups/{gid}/append-users
detachUsers($gid, $userIds) PATCH /user-groups/{gid}/detach-users