php4ronin

This is a free php class to access the ronin systems via their API.

! notice !

This is the first version and not very well documented. Also not all method and functions are implemented right now.

currently supported functions (version: 2011-08-25)

license

This library is published under LGPL http://www.gnu.org/licenses/lgpl.html

download

By downloading you agree to the license agreement. Download now

good to know

You find your token by clicking your name. There you can find your 'API Token'.

samples

_configSample
<?php

DEFINE('RONIN_SUBDOMAIN', 'sample');
DEFINE('RONIN_TOKEN', '123456789123456789');
addClient
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// create new client object
$client = new stdClass();
$client->address = '123 Main St.';
$client->address_2 = 'Suite 101';
$client->city = 'New York';
$client->country = 'United States';
$client->description = 'A sample API Client';
$client->invoice_extra_fields = null;
$client->name = 'ACME Corp';
$client->number = '101';
$client->state = 'NY';
$client->website = 'http://www.example.com';
$client->zip = '12345';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result = $ronin->addClient($client);

// print new client id
echo $result;
addClientContact
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// create new contact object
$contact = new stdClass();
$contact->avatar = 'default_avatars/avatars/missing_original.jpg';
$contact->email = 'jdoe@example.com';
$contact->ext = '1234';
$contact->mobile = '123-456-7891';
$contact->name = 'John Doe';
$contact->phone = '123-456-7890';
$contact->title = 'Product Manager';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result = $ronin->addClientContact(25601, $contact);

// print new client id
echo $result;
addInvoice
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// create new invoice object
$invoice = new stdClass();
$invoice->number = '123'.date(U); 
$invoice->date = '2011-08-15';
$invoice->due_date = '2011-08-25';
$invoice->currency_code = 'EUR';
$invoice->client_id = 12345;
$invoice->invoice_items_attributes = array();
$invoice->tax = 19;
$invoice->tax_label = 'VAT';
$invoice->compound_tax = false;

$item = new stdClass();
$item->title = 'foo'; 
$item->quantity = 1; 
$item->price = 321;
$item->taxable = true;
$invoice->invoice_items_attributes[] = $item;

$item = new stdClass();
$item->title = 'bar'; 
$item->quantity = 1; 
$item->price = 123;
$item->taxable = true;
$invoice->invoice_items_attributes[] = $item;

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result = $ronin->addInvoice($invoice);

// print new invoice id
echo $result;
getClient
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getClient(12345);
$result2 = $ronin->getClient(12345, 'php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getClientContacts
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getClientContacts(12345);
$result2 = $ronin->getClientContacts(12345, 'php');

// print client as json
print_r($result1);

// print client array
print_r($result2);
getClientEstimates
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getClientEstimates(12345);
$result2 = $ronin->getClientEstimates(12345, 'php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getClientInvoices
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getClientInvoices(12345);
$result2 = $ronin->getClientInvoices(12345, 'php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getContact
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getContact(12345);
$result2 = $ronin->getContact(12345, 'php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getContacts
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getContacts();
$result2 = $ronin->getContacts('php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getEstimate
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getEstimate(12345);
$result2 = $ronin->getEstimate(12345, 'php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getEstimates
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getEstimates();
$result2 = $ronin->getEstimates('php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getInvoice
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getInvoice(12345);
$result2 = $ronin->getInvoice(12345, 'php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getInvoices
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getInvoices();
$result2 = $ronin->getInvoices('php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getStaff
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getStaff();
$result2 = $ronin->getStaff('php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);
getStaffExplicit
<?php 

require_once '../lib/_config.php';
require_once '../lib/ronin.class.php';

// init ronin
$ronin = new Ronin(RONIN_SUBDOMAIN, RONIN_TOKEN);
$result1 = $ronin->getStaff(12345);
$result2 = $ronin->getStaff(12345, 'php');

// print client as json
print_r($result1);

// print client as array
print_r($result2);