marketspot/core

Marketspot application core.


Keywords
core, jub4, marketspot
License
MIT

Documentation

Api-Merger

Latest Version on Packagist Software License Build Status StyleCI Coverage Status Quality Sapi-merger Total Downloads

Marketspot api merger.

Install

Via Composer

$ composer require mercantil/api-merger

Usage

// create a new api
$api = new Mercantil\ApiMerger\Api('http://www.foo.bar');
$api->configure(function ($config) {
    // add a gloabal header
    $config->headers()->put('headerKey', 'headerValue');
    // or
    $config->headers()->headerKey('headerValue');

    // add a operation
    $config->addOperation('get', 'user/{id}', 'getUserInfo');
    // or
    $config->get('user/{id}', 'getUserInfo');

    // add header in the operation
    $operation = $config->getOperation('getUserInfo')->headers()->put('headerKey', 'headerValue');
});

// run a operation
$response = $api->getUserInfo(123)->run([
    'body' => [
        'foo' => 'bar',
    ],
]);

// get Guzzle response object
$psr7Response = $response->getGuzzleResponse();

// get response data
$responseData = $response->getData();

License

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