imemento/clients

Client library classes for iMemento Services

v8.1.0 2021-07-26 09:02 UTC

README

Build Status Docs Status Latest Stable Version License Total Downloads

Client library classes for iMemento Services

Check the full docs in here https://imemento-clients.readthedocs.io

Installation

composer require imemento/clients

Quick Usage

use Facades\iMemento\Clients\Profiles;

//...

public function index()
{
    $user = Profiles::showUser(1234);
}

Modifier Methods

// it returns an empty response on failure
$user = Profiles::silent()->showUser(1234);
// it throws an exception on failure
$user = Profiles::critical()->showUser(1234);
// it retries the request 3 times if it fails
$user = Profiles::retries(3)->showUser(1234);

Async

use GuzzleHttp\Promise;

// ...

$promises = [
    'profiles'      => Profiles::async()->showUser(1234),
    'roles'         => Roles::async()->listRoles(),
];

$results = Promise\settle($promises)->wait();

Authentication

// as the current running service (the env variables need to be set)
$org = Profiles::asService()->showOrganization(1234);
// as the currently logged in user
$org = Profiles::asUser()->showOrganization(1234);
// as the given user
$org = Profiles::as($user)->showOrganization(1234);
// with the provided token
$org = Profiles::withToken($token)->showOrganization(1234);
// anonymous calls
$org = Profiles::anonymously()->showOrganization(1234);