someline / rest-api-client by libern

An elegant and smart Rest API Client with OAuth2 authentication support. Build for Laravel and Someline Starter.
13,238
8
3
Package Data
Maintainer Username: libern
Maintainer Contact: libernlin@gmail.com (Libern Lin)
Package Create Date: 2016-07-22
Package Last Update: 2019-08-12
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-04-23 03:05:08
Package Statistics
Total Downloads: 13,238
Monthly Downloads: 11
Daily Downloads: 0
Total Stars: 8
Total Watchers: 3
Total Forks: 7
Total Open Issues: 0

Someline Rest API Client

Latest Version Software License Total Downloads

Someline Starter API Client is an elegant and smart Rest API Client with OAuth2 authentication support.

Build for Laravel and Someline Starter.

It can be used for accessing APIs created using Someline Starter framework.

Install

Via Composer

Install composer package to your laravel project

composer require someline/rest-api-client

Add Service Provider to config/app.php

    'providers' => [
        ...
        Someline\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 \Someline\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.