XpensifySDK
This gem is the official library provided by Xpensify to interact with our API.
You can read the API docs directly from here.
Installation
Add this line to your application's Gemfile:
gem 'xpensify-sdk'
And then execute:
$> bundle
Or install it yourself as:
$> gem install xpensify-sdk
Usage
First you need to configure your api key obtained from the platform:
XpensifySDK.configure do |config|
config.api_key = 'API_KEY'
end
Also you can pass the key when creating the client directly:
client = XpensifySDK::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 = XpensifySDK::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 = XpensifySDK::Client.new
invoice = client.invoice(ID)
puts invoice.id
puts invoice.products
Update an invoice
client = XpensifySDK::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/Xpensify/ruby-sdk.