paipe/phpclient

There is no license information available for the latest version (v1.0.3) of this package.

Paipe data

v1.0.3 2022-06-02 06:17 UTC

This package is not auto-updated.

Last update: 2024-05-02 15:08:22 UTC


README

Paipe PHP client provides an easy interface for Feba data services, it handles authentication from Paipe Auth, pre-authorize services and validate authorized actions.

Installation

composer require paipe/phpclient

Usage

Firstly get instantiate a client then get a service from it. In this example, we're going to use the config:

  • aaaUrl the Auth endpoint as https://auth.paipe.com.br
  • appKey the app key as app-key
  • appSecret the app secret as app-secret

In order to get the client done, above parameter should be shared to the application.

Example to perform GET with query string:

$client = new paipe\phpclient\Client([
  'aaaUrl' => 'https://auth.paipe.com.br',
  'appKey' => 'app-key',
  'appSecret' => 'app-secret'
];


$response = $client->getService('cep')->request('GET' '/lookup', [ 
    'query' => ['keyword' => 'av paulista']
]);

The response comes as Psr\Http\Message\MessageInterface, then you call common functions and the $options parameter are same as GuzzleHttp\RequestOptions

To post to data service as json:

$service = $client->getService('postal-code')
$resp = $service->request('POST' '/search', [ 
    'json' => ['foo' => 'data']
]);

Injecting a custom header:

$service = $client->getService('postal-code')
$resp = $service->request('POST' '/search', [ 
    'headers' => ['X-My-Header' => 'nice header'],
    'json' => ['foo' => 'data']
]);

© Paipe