Project

xtract-sdk

0.0
No release in over a year
SDK to connect with Xtract's API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.2
~> 13.0

Runtime

~> 5.0
 Project Readme

XtractSDK

This gem is the official library provided by Xtract to interact with our API.

You can read the API docs directly from here.

Installation

Add this line to your application's Gemfile:

gem 'xtract-sdk'

And then execute:

$> bundle

Or install it yourself as:

$> gem install xtract-sdk

Usage

First you need to configure your api key obtained from the platform:

XtractSDK.configure do |config|
  config.api_key = 'API_KEY'
end

Also you can pass the key when creating the client directly:

client = XtractSDK::Client.new(api_key: 'API_KEY')

Then you can create a client and start making requests. We provide a convenient way to do this:

Get invoices

client = XtractSDK::Client.new
invoices = client
    .invoices
    .client_tax_id('SOME_TAX_ID')
    .call

invoices.each do |invoice|
  puts invoice.id
  puts invoice.products
end

These are all the filtering options:

client_business_name
client_tax_id
provider_business_name
provider_tax_id
date_from
date_to
expiration_date_from
expiration_date_to
number
electronic_authorization_id
created_at_from
created_at_to
accounted ('pending', 'in_progress', 'completed', 'with_errors')
imputed (true, false)

Get an invoice

client = XtractSDK::Client.new
invoice = client.invoice(ID)

puts invoice.id
puts invoice.products

Update an invoice

client = XtractSDK::Client.new
client.update_invoice(ID, { accounted: 'completed' }) #=> :ok

Errors

You can check here all the error classes that the library raises.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/xtractapp/ruby-sdk.