Skip to content

Ruby Quickstart

Work in progress

The contents of this page currently mirror the README file in the Ruby SDK repository. For an up-to-date version, make sure to check the repository itself.

Interested?

Are you interested in a stand-alone Quickstart for your language? Let us know, or contribute one yourself!

Not receiving invoices in the live environment?

Ensure your correspondents use 7HD37X0 as the value of their invoices' Codice Destinatario field. That is how SDI knows they should be forwarded to the Invoicetronic API.

Installation

Build a gem

To build the Ruby code into a gem:

gem build invoicetronic_invoice_sdk.gemspec

Then either install the gem locally:

gem install ./invoicetronic_invoice_sdk-1.0.0.gem

(for development, run gem install --dev ./invoicetronic_invoice_sdk-1.0.0.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'invoicetronic_invoice_sdk', '~> 1.0.0'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/invoicetronic/ruby-sdk, then add the following in the Gemfile:

gem 'invoicetronic_invoice_sdk', :git => 'https://github.com/invoicetronic/ruby-sdk.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'invoicetronic_invoice_sdk'

# Setup authorization
Invoice_Sdk.configure do |config|
  # Configure HTTP basic authorization: Basic
  config.username = 'YOUR_USERNAME'
  config.password = 'YOUR_PASSWORD'
end

api_instance = Invoice_Sdk::CompanyApi.new
opts = {
  page: 56, # Integer | Page number. Defaults to 1.
  page_size: 56 # Integer | Items per page. Defaults to 50. Cannot be greater than 200.
}

begin
  #List companies
  result = api_instance.invoice_v1_company_get(opts)
  p result
rescue Invoice_Sdk::ApiError => e
  puts "Exception when calling CompanyApi->invoice_v1_company_get: #{e}"
end