Skip to main content

SDKs

You can use our API wrappers to connect and handle our APIs in a nicer way. We provide a Ruby library and a PHP library.

Ruby gem

To install our Ruby library, add the following to your Gemfile:

  gem 'quaderno', require: 'quaderno-ruby'

To configure our Ruby gem, just add this to your initializers:

  Quaderno::Base.configure do |config|
config.auth_token = 'my_authenticate_token'
config.url = 'https://my_subdomain.quadernoapp.com/api/'
config.api_version = API_VERSION # Optional, defaults to the API version set in your account
end

Our Ruby library code is in https://github.com/quaderno/quaderno-ruby.

Please follow the README instructions to learn more.

PHP library

Our PHP library code is in https://github.com/quaderno/quaderno-php and you may install it via Composer.

To setup the library:

require_once 'quaderno_load.php';
QuadernoBase::init('YOUR_API_KEY', 'YOUR_API_URL', API_VERSION);
QuadernoBase::ping(); // optionally test the API connection

Calculating taxes it's as easy as:

$params = array(
'to_country' => 'ES',
'to_postal_code' => '08080'
);

$tax = QuadernoTaxRate::calculate($params); // returns a QuadernoTax
$tax->name; // 'IVA'
$tax->rate; // 21.0
warning

There's a known limitation on the current version of the PHP wrapper which does not allow to easily inspect response headers, like the ones used to facilitate pagination (X-Pages-NextPage and X-Pages-HasMore).

For now, you can workaround that either by playing with more requests with smaller data ranges and higher "limit" to fetch more docs (max 100); or fetch your first find data with any query and then perform another paginated request with the created_before parameter and the ID of the last returned document, until the response is empty.

Simple example to request all pages from the given dates until all invoices have been returned:

$invoices = [];
$filters['limit'] = '50'; // bunches of 50 invoices per request
$filters['date']= "$from,$to"; // please use dates to avoid always getting all invoices
do {
$data = QuadernoInvoice::find($filters);
if (is_array($data) && !empty($data)) {
$invoices = array_merge($invoices, $data);
$last_invoice = end($data); // advances array's internal pointer to the last element, and returns its value
$filters['created_before'] = $last_invoice->id; // paginate from there
}
} while (!empty($data));

Please follow the README instructions to learn more.