Skip to content

Temporary repository of freshbooks gem with quick bug fix on date setting for invoices

License

Notifications You must be signed in to change notification settings

fmalamitsas/freshbooks-rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

= About

This gem is a copy of the elc-freshbooks.rb gem.
The only difference is a quick fix on default date setting for invoices.

FreshBooks.rb is a Ruby interface to the FreshBooks API. It exposes easy-to-use classes and methods for interacting with your FreshBooks account. Read more on ELC's blog:
http://elctech.com/tags/freshbooks

= Examples

Installation:
  gem install elc-freshbooks.rb --source http://gems.github.com

Initialization:

  FreshBooks::Base.establish_connection( 'sample.freshbooks.com', 'mytoken' )

Updating a client name:

  clients = FreshBooks::Client.list
  client = clients[0]
  client.first_name = 'Suzy'
  client.update

Updating an invoice:

  invoice = FreshBooks::Invoice.get(4)
  invoice.lines[0].quantity += 1
  invoice.update

Creating a new item

  item = FreshBooks::Item.new
  item.name = 'A sample item'
  item.create

Getting an invoice pdf:

  invoice = FreshBooks::Invoice.get(4)
  original_status = invoice.status
  invoice.status = "sent"
  raise "API Change or error" unless invoice.update
  html_url = invoice.client_view
  cookiejar = Tempfile.new("cookies")
  pdf_file = Tempfile.new("pdf")
  html_doc = `wget "#{html_url}"  --no-check-certificate --cookies=on --keep-session-cookies --save-cookies='#{cookiejar.path}'  -O -`
  `wget 'https://#{freshbooks_api_host}/getPDF.php' --post-data='invoice_id[]=#{invoice.number}' --cookies=on --keep-session-cookies 
    --load-cookies='#{cookiejar.path}'  --no-check-certificate -O '#{pdf_file.path}'"`
  invoice.status = original_status
  raise "API Change or error" unless invoice.update
  pdf_file.path # Here's the PDF!

= License

This work is distributed under the MIT License. Use/modify the code however you like.

= Download

FreshBooks.rb is distributed as a gem via Rubyforge. The easiest way to install it is like so:

  gem install freshbooks

Alternatively, you can download it from the Rubyforge project page.

= Credits

FreshBooks.rb is written and maintained by Ben Vinegar, with contributions from Flinn Meuller, Kenneth Kalmer, and others. 

About

Temporary repository of freshbooks gem with quick bug fix on date setting for invoices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages