brofist/json-api-client

A simple Json Api Client

v0.1.3 2017-06-28 08:38 UTC

This package is not auto-updated.

Last update: 2024-11-15 22:29:59 UTC


README

Simple wrapper for Guzzle.

Code information:

Build Status Coverage Status Code Climate StyleCI

Scrutinizer

Code Coverage Scrutinizer Code Quality Build Status

Package information:

Latest Stable Version Total Downloads Latest Unstable Version License Dependency Status

Installing

Installing via Composer

Append the lib to your requirements key in your composer.json.

composer require brofist/json-api-client

Usage

use Brofist\ApiClient\Json;

$client = new Json([
    'endpoint' => 'http://foo.bar/v1/blah',
    // optional
    'basicAuth' => ['username', 'password'],
]);
 
// basic usage:
$resources = $client->get('/resources', [
    'limit' => 100,
]);
 
$resources = $client->put('/resources/1', [
    'name' => 'foo',
]);
 
$resources = $client->post('/resources', [
    'name' => 'foo',
]);
 
// with optionally supplied custom options per-request:
$resources = $client->post(
    '/resources',
    ['name' => 'foo'],
    ['headers' => ['X-Request-Token' => 'e4d909c290d0fb1ca068ffaddf22cbd0']]
);

Issues/Features proposals

Here is the issue tracker.

Contributing

Only tested code will be accepted. Please follow fix the style guide.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

How to run the tests:

./vendor/bin/phpunit

To check the code standard run:

# Fixes code
./vendor/bin/bro-code fix src
./vendor/bin/bro-code fix tests

License

This software is distributed under the MIT license.

Authors