Has anyone else been frustrated by how hard BlinkSale make it to export your
data? Prices keep rising and I've been wanting to cancel my account but I
need the last few years of invoices.

If you're a BlinkSale user then you may want to download all your Invoices
as PDFs using this script I whipped up.

http://mike.bailey.net.au/2011/05/blinksale-how-to-say-goodbye/

#!/usr/bin/env ruby

require 'rubygems'
require 'highline/import'
require 'mechanize'
require 'uri'

# Get details
domain = ask("your blinksale domain prefix") + '.blinksale.com'
login_page_url = "https://#{domain}/sessions/new";
invoice_list_url = "https://#{domain}/invoices/all/date/2001-01-01/2015-12-31";

agent = Mechanize.new
agent.pluggable_parser.pdf = Mechanize::FileSaver

# Login to BlinkSale
page = agent.get(login_page_url)
form = page.forms.first
form.username = ask("your blinksale username")
form.password = ask("your blinksale password") { |q| q.echo = false; }
page = agent.submit form

# Grab list of your invoices
invoice_list = agent.get(invoice_list_url)

# Download all the PDF's
links = invoice_list.links_with(:href => /invoices\/\d+/).collect { |link|
  link.uri.to_s + '.pdf'
}.compact

links.each {|link| agent.get(link) }

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to