shrimpwagon / digium-switchvox-api

API XML/JSON wrapper for the Digium Switchvox service. Does not require PECL/PEAR extensions.
MIT License
4 stars 5 forks source link

Digium Switchvox API

Build Status Latest Stable Version Total Downloads License

PHP wrapper for the Digium Switchvox API.

Features

This makes simple Switchvox's requests in JSON or XML.

Digium's PHP client library requires a PEAR and PECL package whereas this implementation does not require them.

Usage

$client = new Switchvox\SwitchvoxClient();
$client->user = 'admin';
$client->password = '1234';
$client->uri = 'https://somedigiumendpoint.com';

// By default it will not care if the SSL cert is valid, to change:
$client->strict_ssl = true;

// Timeout in seconds, default is 10 seconds
$client->timeout = 15;

// If JSON is preferred (default):
$client->data_type = 'json';

// If XML is preferred:
$client->data_type = 'xml';

// Request a method with parameters
$params = [
    'sort_field' => 'number',
    'sort_order' => 'ASC',
    'items_per_page' => '9999',
    'page_number' => '1'
];

$response = $client->send('switchvox.directories.getExtensionList', $params);

// Request without parameters
$response = $client->send('switchvox.directories.getInfo');

Notes

The strict_ssl feature correlates to the Httpful\Request timeout.

All Digium Switchvox web service methods can be found here.

The send method returns a Httpful\Response object.

Testing

To run tests in phpunit you must use your own environment variables for user and password:

$ SWITCHVOX_USER=<user> SWITCHVOX_PASSWORD=<password> phpunit -v --debug

For development you can get a free demo Digium Switchbox account.

They will send you a user name and passowrd to your email address.

Once you log into the admin portal take note of the domain name and use that as the uri.

The uri property for this client and the phpunit.xml file is pre-populated with:

https://switchvoxdemo1.digiumcloud.net

Requirements

Installation

Composer

Digium Switchvox API is PSR-0 compliant and can be installed using composer. Simply add shrimpwagon/digium-switchvox-api to your composer.json file. Composer is the sane alternative to PEAR. It is excellent for managing dependencies in larger projects.

{
    "require": {
        "shrimpwagon/digium-switchvox-api": "*"
    }
}

Contributing

Digium Switchvox API highly encourages sending in pull requests. When submitting a pull request please:

Changelog

1.0.0