2017 © Pedro Peláez
 

library katsana-sdk-php

KATSANA SDK for PHP

image

katsana/katsana-sdk-php

KATSANA SDK for PHP

  • Thursday, July 26, 2018
  • by crynobone
  • Repository
  • 3 Watchers
  • 5 Stars
  • 312 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 11 Versions
  • 26 % Grown

The README.md

KATSANA SDK for PHP

Build Status Latest Stable Version Total Downloads Latest Unstable Version License Coverage Status, (*1)

Installation

To install through composer, simply put the following in your composer.json file:, (*2)

{
    "require": {
        "katsana/katsana-sdk-php": "^1.2",
        "php-http/guzzle6-adapter": "^2.0"
    }
}

Quick Installation

Above installation can also be simplify by using the following command:, (*3)

composer require "php-http/guzzle6-adapter" "katsana/katsana-sdk-php=^1.2"

HTTP Adapter

Instead of utilizing php-http/guzzle6-adapter you might want to use any other adapter that implements php-http/client-implementation. Check Clients & Adapters for PHP-HTTP., (*4)

Usages

Creating Client

You can start by creating a client by using the following code (which uses php-http/guzzle6-adapter and php-http/discovery to automatically pick available adapter installed via composer):, (*5)

<?php

use Katsana\Sdk\Client;

$katsana = Client::make('client-id', 'client-secret');

In most cases, you will be using the client with Personal Access Token. You can initiate the client using the following code:, (*6)

<?php

use Katsana\Sdk\Client;

$katsana = Client::personal('personal-access-token');

Change Timezone

By default, all request will return date and time data in UTC, however you may set the request to response with a different timezone by setting the client (globally) such as:, (*7)

$katsana->onTimeZone('Asia/Kuala_Lumpur');

Or on each resource such as:, (*8)

$vehicles = $katsana->uses('Vehicles');
$vehicles->onTimeZone('Asia/Kuala_Lumpur');

Handling Response

Every API request using the API would return an instance of Katsana\Sdk\Response which can fallback to \Psr\Http\Message\ResponseInterface, this allow developer to further inspect the response., (*9)

As an example:, (*10)

$response = $katsana->uses('Welcome')->hello();

var_dump($response->toArray());
{
    "platform": "v4.5.13",
    "api": [
        "v1"
    ]
}

Getting the Response

You can get the raw response using the following:, (*11)

$response->getBody();

However we also create a method to parse the return JSON string to array., (*12)

$response->toArray();

Checking the Response HTTP Status

You can get the response status code via:, (*13)

$response->getStatusCode();

$response->isSuccessful();

$response->isUnauthorized();

Checking the Response Header

You can also check the response header via the following code:, (*14)

$response->getHeaders(); // get all headers as array.
$response->hasHeader('Content-Type'); // check if `Content-Type` header exist.
$response->getHeader('Content-Type'); // get `Content-Type` header.

Using the API

There are two way to request an API:, (*15)

Using API Resolver

This method allow you as the developer to automatically select the current selected API version without having to modify the code when KATSANA release new API version., (*16)

$vehicles = $katsana->uses('Vehicles'); 

$response = $vehicles->all(); 

This would resolve an instance of Katsana\Sdk\One\Vehicles class (as v1 would resolve to One namespace)., (*17)

Explicit API Resolver

This method allow you to have more control on which version to be used., (*18)

$vehicles = $katsana->via(new Katsana\Sdk\One\Vehicles());

$response = $vehicles->all();

The Versions

26/07 2018

dev-master

9999999-dev

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

26/07 2018

v1.0.3

1.0.3.0

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

14/07 2018

dev-carbon

dev-carbon

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

29/04 2018

v1.0.2

1.0.2.0

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

25/04 2018

v1.0.1

1.0.1.0

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

07/04 2018

v1.0.0

1.0.0.0

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

06/04 2018

0.4.x-dev

0.4.9999999.9999999-dev

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

12/03 2018

v0.4.0

0.4.0.0

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

04/02 2018

v0.3.0

0.3.0.0

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

31/08 2017

v0.2.0

0.2.0.0

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer

18/07 2017

v0.1.0

0.1.0.0

KATSANA SDK for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by KATSANA Developer