rohinigeeks/vbc-sdk

SDK to access the VBC API

dev-master 2015-03-31 10:24 UTC

This package is not auto-updated.

Last update: 2024-12-21 18:53:43 UTC


README

An SDK for the VBC API in PHP. Enjoy!

Installation

The library uses Composer as it's dependency manager. Thus, installing this library follows Composers and the PSR standards. You can read more about composer at this link https://getcomposer.org/

Before anything, you must create/update your Composer.json and add the library to the require block..

...
    "require": {
        "incube8/vbc-sdk": "dev-master"
    }
...

Run composer update or composer install to include the library to your application

Usage

You must obtain an AppKey and a SecretKey from VBC before using this SDK.

<?php
require_once 'vendor/autoload.php';
 
$config = [
    'AppKey' => '',
    'SecretKey' => '',
    'Version' => 'V2' // or V1
];
 
// oop
$client = new Vbc\Client($config);
$request = new Vbc\Request($client);
 
// static
$request = Vbc\Request::factory($config);
 
// create a request
$tokenOrPin = $request->create([
    'uid' => 1234567890,
    'caption' => 'Hi! my name is john from the lovely island of Singapore',
    'data' => [
        'foo' => 'bar'
    ],
    'thumbnail' => 'http://link.to/thumbnail',
    'steps' => [
        'VTYPE_VIDEO' => true,
        'VTYPE_ESIGN' => 'http://link.to/pdf'
    ]
]);
 
print_r($tokenOrPin);

As you can see there are 2 ways to create a Vbc\Request instance, by either the object oriented way, or statically; both yield the same result.

API Reference

Request

create(array $data [, array $options])

Starts the create a request workflow and issue tokens to the App.

Parameters
data

An array of data to be passed to the API to help create the request.

options

An array of options to help create the request

--

verify(string $requestId)

Verify a Request.

Parameters
requestId

A Mongo ObjectId that corresponds to the request specified.

--

reject(string $requestId)

Reject a Request.

Parameters
requestId

A Mongo ObjectId that corresponds to the request specified.

--

list()

... not available yet

--

Client

__constructor(array $config)

Creates a GuzzleHttp client to the API url.

Parameters
config

An array of data to help create the GuzzleHttp Client.

--

getInstance()

A static alias of __constructor.

--

Example of steps payload

{
    "VTYPE_ESIGN": "http://link.to/pdf",
    "VTYPE_VIDEO": true,
    "VTYPE_DOCUMENT": true
}

License

The MIT License (MIT)

Copyright (c) 2014 Incube8

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.