2017 © Pedro Peláez
 

library apigility-client

Client for REST and RPC webservices

image

argezeit/apigility-client

Client for REST and RPC webservices

  • Monday, October 10, 2016
  • by argezeit
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Client for Apigility REST and RPC webservices

Installation

composer require jolicht/apigility-client, (*1)

Configuration for Zend Framework 2

Register Abstract Service Factory

Register Jolicht\\ApigilityClient\\ClientAbstractServiceFactory as abstract service in service manager:, (*2)

'service_manager' => [
    'abstract_factories' => [
        'Jolicht\\ApigilityClient\\ClientAbstractServiceFactory'
    ]
],

Configure Apigility Http Client

Add config key apigility_http_client to your prefered config file. (Applicaction Level e.g.: 'config/autoload/global.php; Module level e.g.: config/module.config.php, (*3)

'apigility_http_client' => [
    'NameOfFirstClient' => [
        'base_uri' => 'http://your-apigility-service-uri.dev',
            'default_headers' => [
                'Accept' => 'application/json',
                'Content-Type' => 'application/json'
            ],
            'http_client_options' => [
                'timeout' => 42
            ],
            'throw_exceptions' => false,
        ]
    ],
    'NameOfSecondClient' => [
        'base_uri' => 'http://your-second-apigility-service-uri.dev',
            'default_headers' => [
                'Accept' => 'application/json',
                'Content-Type' => 'application/json'
            ],
            'http_client_options' => [
                'timeout' => 10
            ],
        ]
    ],
],

Always set default_headers Accept and Content-Type to prevent content type errors. If throw_exceptions is true exception is thrown on invalid response status code., (*4)

Usage

Get Apigility http client instance

Call ServiceManager::get or ServiceLocator::get with configured Service Name as param:, (*5)

$firstClient = $serviceManager->get('NameOfFirstClient');
$secondClient = $serviceManager->get('NameOfSecondClient');

Operations

Create:, (*6)

$response = $client->create('/api-route', $data);

Fetch:, (*7)

$response = $client->fetch('/api-route', 17);

FetchAll:, (*8)

$response =  $client->fetchAll('/api-route'); // without query data 
$response =  $client->fetchAll('/api-route', $queryData); // with query data

Patch:, (*9)

$response = $client->patch('/api-route', 17, $data);

Update:, (*10)

$response = $client->update('/api-route', 17, $data);

Call any Http Method:, (*11)

$response = $client->call('/api-route'); // HTTP GET
$response = $client->call('/api-route/3'); // HTTP GET
$response = $client->call('/api-route', 'GET', $data); // HTTP GET with query parameters
$response = $client->call('/api-route', 'POST', $data); // HTTP POST with content data

Not yet implemented:, (*12)

  • delete
  • deleteList
  • replaceList

The Versions

10/10 2016

dev-master

9999999-dev https://github.com/argezeit/apigility-client

Client for REST and RPC webservices

  Sources   Download

MIT

The Requires

 

The Development Requires

rest zf2 apigility

31/05 2016

0.1.4

0.1.4.0 https://github.com/jolicht/apigility-client

Client for REST and RPC webservices

  Sources   Download

MIT

The Requires

 

The Development Requires

rest zf2 apigility

05/04 2016

0.1.3

0.1.3.0 https://github.com/jolicht/apigility-client

Client for REST and RPC webservices

  Sources   Download

MIT

The Requires

 

The Development Requires

rest zf2 apigility

04/04 2016

0.1.2

0.1.2.0 https://github.com/jolicht/apigility-client

Client for REST and RPC webservices

  Sources   Download

MIT

The Requires

 

The Development Requires

rest zf2 apigility

04/03 2016

0.1.1

0.1.1.0 https://github.com/jolicht/apigility-client

Client for REST and RPC webservices

  Sources   Download

MIT

The Requires

 

The Development Requires

rest zf2 apigility

04/03 2016

0.1.0

0.1.0.0 https://github.com/jolicht/apigility-client

Client for REST and RPC webservices

  Sources   Download

MIT

The Requires

 

The Development Requires

rest zf2 apigility