-
-
Save jgrossiord/d37d1c0253473db87ff8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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