Skip to content

Instantly share code, notes, and snippets.

@jgrossiord
Forked from solisoft/ovhfact.rb
Last active August 29, 2015 14:22
Show Gist options
  • Save jgrossiord/d37d1c0253473db87ff8 to your computer and use it in GitHub Desktop.
Save jgrossiord/d37d1c0253473db87ff8 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# Require:
# - linux or Mac
# - ruby 1.8.7
# - Gem soap4r
# - curl
#
# Usage :
# ruby ovhfact.rb 2011
#
# Configuration :
# Update your credentials
require 'soap/wsdlDriver'
year ||= Time.now.year
year = ARGV[0] if ARGV[0]
wsdl = 'https://www.ovh.com/soapi/soapi-re-1.29.wsdl'
soapi = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
#login
session = soapi.login('xxxxxxxx-ovh', 'xxxxxxxx', 'fr', true)
puts "login successfull"
#billingInvoiceList
invoices = soapi.billingInvoiceList(session)
invoices.each do |invoice|
billnum = invoice.billnum
if invoice.date >= "#{year}-01-01 00:00:00" and invoice.date <= "#{year}-12-31 23:59:59"
invoice = soapi.billingInvoiceInfo(session, invoice.billnum, '', invoice.billingCountry)
system("mkdir -p invoices/#{year}")
system("curl 'https://www.ovh.com/cgi-bin/order/facture.pdf?reference=#{billnum}&passwd=#{invoice.password}' > invoices/#{year}/#{billnum}.pdf")
end
end
#logout
soapi.logout(session);
puts "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment