libern/someline-starter-api-client

Rest API Client for Someline Starter

v1.0.7 2016-07-15 15:08 UTC

This package is auto-updated.

Last update: 2024-11-09 04:54:10 UTC


README

Latest Version Software License Total Downloads

Someline Starter API Client is a client for accessing APIs created using Someline Starter framework.

Install

Via Composer

Install composer package to your laravel project

composer require libern/someline-starter-api-client

Add Service Provider to config/app.php

    'providers' => [
        ...
        Libern\Rest\RestClientServiceProvider::class,
        ...
    ],

Publishing config file.

php artisan vendor:publish

After published, config file for Rest Client is config/rest-client.php, you will need to config it to use Rest Client.

Usage

$restClient = new \Libern\Rest\RestClient('someline-starter');

$restClient->setOAuthUserCredentials([
    'username' => 'libern@someline.com',
    'password' => 'Abc12345',
]);
$restClient->withOAuthTokenTypeUser();

$response = $restClient->get("users")->getResponse();
if (!$restClient->isResponseStatusCode(200)) {
    $restClient->printResponseOriginContent();
    $responseMessage = $restClient->getResponseMessage();
    print_r($responseMessage);
} else {
    $responseData = $restClient->getResponseData();
    print_r($responseData);
}

Testing

phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.