onrails.org home

Blinksale API

Today Blinksale published it’s data API. See http://www.blinksale.com/api for the details.

It’s good news for time.onrails.org as now we can use the api to generate a draft Blinksale invoice with one click. I have started coding the integration and expect to release it once I have completed extensive testing.

In short, time.onrails.org interacts in the following way with Blinksale:

  1. get list of client names
  2. get highest invoice number
  3. create invoice

Let’s have a peek at how this is implemented.

Accessing Blinksale

A Blinksale class is provided to interact with your Blinksale data. You need to provide your blinksale id, username, and password.

@blinksale = Blinksale.new ‘blinksaleid’, ‘username’, ‘password’

In time.onrails.org we will let you define your Blinksale credentials once to avoid having to retype them each time you create an invoice. Storing the password is optional, and if not provided it will be prompted each time. A use_ssl flag can also be specified if you have a paid Blinksale subscription. This is of course recommended for security reasons.

Get the list of clients

clients = @blinksale.clients
names = clients.collect { |c| c.name }

Get the highest invoice number

invoices = @blinksale.invoices
invoices.collect{|invoice| invoice.number}.max

Create An Invoice

invoice_data = BlinksaleGenerator.to_xml(INVOICE)
new_invoice = @blinksale.invoices.new invoice_data

BlinksaleGenerator is a time.onrails.org class that helps creating the following ‘invoice’ xml.

<?xml version="1.0" encoding="UTF-8"?>

The integration is pretty straight forward. Don’t you think? Thanks Scott and your team for this cool application. To find out more on the blinksale api see the online documentation at http://www.blinksale.com/api

Fork me on GitHub