2017 © Pedro Peláez
 

library cems-php-sdk

PHP SDK for SSS CEMS platform

image

siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  • Wednesday, August 6, 2014
  • by pnghai
  • Repository
  • 36 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

cems-php-sdk

This is the official PHP-SDK for CEMS's API. View api documentation and examples., (*1)

Build Status

Build Status, (*2)

Installation

Requirements

  1. PHP >= 5.3.2
  2. PHP curl extensions.

You don't need to clone the repo directly to use this SDK, the entire library and its dependencies can be installed through Composer ( https://getcomposer.org/doc/00-intro.md )., (*3)

  • First, install Composer if you haven't had it already
curl -sS https://getcomposer.org/installer | php
  • Create composer.json and add the following
{
   "require": {
       "siliconstraits/cems-php-sdk": "dev-master"
   }
}
  • Install cems-php-sdk package via Composer
php composer.phar install
  • Include the library in your script
require_once 'vendor/autoload.php';
  • See below for how to configure your Client class.

Configuration

All CEMS API requests can be made using the CEMS\Client class. This class must be initialized with your authentication details such as an API key (preferred), email/password combo. Remember to declare the API URL from CEMS service for proper connection to your own server., (*4)

API key Config

$client = new CEMS\Client($access_token, $apiUrl);

Email/Password Config

$client = new CEMS\Client($email, $password, $apiUrl);

Your app users are almost ready to start signing! See below for the most common use cases for this wrapper., (*5)

##Usage

Create a RESTful Request

You can create a RESTful request by using one of following method from an instance of Client class:, (*6)

$client->post($path, $params=array());
$client->get($path, $params=array());
$client->get($path, $params=array());
$client->get($path, $params=array());

For example:, (*7)

try {
  $response= $client->get(
    'events',
    array(
        'category_id' => array(1, 2)
    )
  ); // CEMS\Response
}
catch (CEMS\Error $e) {
    echo $e;
}

NOTE: You must provide the right path from API documentation. NOTE2: For the compatibility problem of Guzzle between PHP 5.3 and 5.4, and Composer still not support multiple package version with correspond PHP environment, we assure you that the local test has been passed before release each iterative version., (*8)

The request will automatically return a Response object contain JSON data return from API if success. Then you can retrieve the proper result by using the method getObject($type='CEMS\Resource') or getObjectList($type='CEMS\Resource'), (*9)

$customer = $client->get('customers/$id')->getObject(); // CEMS\Resource
$customers = $client->get('customers')->getObjectList('customer'); // CEMS\Collection Class contains many CEMS\Customer elements

Retrieving fields returned from the API

Using magic methods to set or get fields, (*10)

$customer->name = 'Nguyen Le Xuan';
echo $customer->name;

Or if you want to get all attributes in an array, (*11)

foreach ($customers as $customer) {
  print_r($customer->toArray());
  // toObject()
}

##Testing

This project contains PHPUnit tests that check the SDK code and can also be referenced for examples. Most are functional and integrated tests that walk through real user scenarios. In some cases, this means you must have an active network connection with access to CEMS system to execute all tests., (*12)

To run the tests

  • Copy file phpunit.xml.sample to phpunit.xml
  • Edit the new file, uncomment and enter your API_KEY, CLIENT_ID, CLIENT_SECRET and CALLBACK_URL
  • Make sure your account has at least 1 template
  • Run ./vendor/bin/phpunit

The Versions

06/08 2014

dev-master

9999999-dev https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

15/07 2014

1.0.2

1.0.2.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

14/07 2014

1.0.1

1.0.1.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

13/07 2014

1.0

1.0.0.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

12/07 2014

0.9.7

0.9.7.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

12/07 2014

0.9.8

0.9.8.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

12/07 2014

0.9.5

0.9.5.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

12/07 2014

0.9

0.9.0.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

11/07 2014

0.8.1.1

0.8.1.1 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

11/07 2014

0.8.1

0.8.1.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

11/07 2014

0.8

0.8.0.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems

09/07 2014

0.5.1

0.5.1.0 https://github.com/siliconstraits/cems-php-sdk

PHP SDK for SSS CEMS platform

  Sources   Download

MIT

The Requires

 

The Development Requires

by Hai Phan Nguyen
by Khoi Vu Dinh

sdk cems