FreshBooks, Ruby, and Rack
If you’re a or developer looking to get started with the FreshBooks API, I recommend taking a look at the latest sample code we’ve put together: invoice_getter.rb.
It uses , a Ruby wrapper I’ve written, to fetch a particular invoice’s details and render it as HTML. A call to invoice.list populates a select box letting you choose from your last 25 invoices. It might be a useful starting point for businesses that want to customize and style their invoice formats.
For fun, I’ve coded invoice_getter.rb using , the modular web server interface, so it can be either launched traditionally using Apache/CGI, or using Ruby’s . As a Rails enthusiast, I love working with WEBrick – you can quickly launch and re-start your app from the command-line, skipping the messiness of an Apache conf file.
If you’ve already got Ruby and installed, you can quickly install Rack and launch invoice_getter.rb like so:
# gem install rack -–include-dependencies ... Successfully installed rack-0.2.0 Installing ri documentation for rack-0.2.0… Installing RDoc documentation for rack-0.2.0 # ruby invoice_getter.rb [2007-07-09 10:50:34] INFO WEBrick 1.3.1 [2007-07-09 10:50:34] INFO ruby 1.8.6 (2007-03-13) [i386-mswin32] [2007-07-09 10:50:34] INFO WEBrick::HTTPServer#start: pid =3944, port=3000
Now, fire up your web browser to and you’re good to go.
In case you missed the link above, you can download the sample code here.