Quaderno-ruby is a ruby wrapper for [quaderno api] (https://github.com/recrea/quaderno-api). As the API, it's mostly CRUD.
Current version is 1.2.0. See the changelog here
To install add the following to your Gemfile:
gem 'quaderno', require 'quaderno-ruby'
To configure just add this to your initializers
Quaderno::Base.configure do |config|
config.auth_token = 'my_authenticate_token'
config.subdomain = 'my_account_subdomain'
end
You can ping the service in order to check if it is up with:
Quaderno::Base.ping #=> Boolean
This will return true if the service is up or false if it is not.
Quaderno::Base.rate_limit_info #=> { :limit => 100, :remaining => 100 }
This will return a hash with information about the rate limit and your remaining requestes
Quaderno-ruby parses all the json responses in human readable data, so you can access each value just like this:
contact.id
invoice.items
estimates.payments
etc.
Quaderno::Contact.all() #=> Array
Quaderno::Contact.all(page: 1) #=> Array
will return an array with all your contacts on the first page. You can also pass query strings using the attribute :q in order to filter the results by contact name.
Quaderno::Contact.find(id) #=> Quaderno::Contact
will return the contact with the id passed as parameter.
Quaderno::Contact.create(params) #=> Quaderno::Contact
will create a contact using the information of the hash passed as parameter and return an instance of Quaderno::Contact with the created contact.
Quaderno::Contact.update(id, params) #=> Quaderno::Contact
will update the specified contact with the data of the hash passed as second parameter.
Quaderno::Contact.delete(id) #=> Boolean
will delete the contact with the id passed as parameter.
Quaderno::Item #=> Array
will return an array with all your items.
Quaderno::Item.find(id) #=> Quaderno::Item
will return the items with the id passed as parameter.
Quaderno::Item.create(params) #=> Quaderno::Item
will create an item using the information of the hash passed as parameter and return an instance of Quaderno::Item with the created contact.
Quaderno::Item.update(id, params) #=> Quaderno::Item
will update the specified item with the data of the hash passed as second parameter.
Quaderno::Item.delete(id) #=> Boolean
will delete the item with the id passed as parameter.
Quaderno::Invoice.all #=> Array
Quaderno::Invoice.all(page: 1) #=> Array
will return an array with all your invoices on the first page. You can also pass query strings using the attribute :q in order to filter the results by contact name, :state to filter by state or :date to filter by date
Quaderno::Invoice.find(id) #=> Quaderno::Invoice
will return the invoice with the id passed as parameter.
Quaderno::Invoice.create(params) #=> Quaderno::Invoice
will create an invoice using the information of the hash passed as parameter.
Quaderno::Invoice.update(id, params) #=> Quaderno::Invoice
will update the specified invoice with the data of the hash passed as second parameter.
Quaderno::Invoice.delete(id) #=> Boolean
will delete the invoice with the id passed as parameter.
###Adding or removing a payment In order to add a payment you will need the Invoice instance you want to update.
invoice = Quaderno::Invoice.find(invoice_id)
invoice.add_payment(params) #=> Quaderno::Payment
Where params is a hash with the payment information. The method will return an instance of Quaderno::Payment wich contains the information of the payment.
In order to remove a payment you will need the Invoice instance you want to update.
invoice = Quaderno::Invoice.find(invoice_id)
invoice.remove_payment(payment_id) #=> Boolean
###Delivering the invoice
In order to deliver the estimate to the default recipient you will need the estimate you want to send.
invoice = Quaderno::Invoice.find(invoice_id)
invoice.deliver
Quaderno::Estimate.all() #=> Array
Quaderno::Estimate.all(page: 1) #=> Array
will return an array with all your estimates on the first page.
Quaderno::Estimate.find(id) #=> Quaderno::Estimate
will return the estimate with the id passed as parameter.
Quaderno::Estimate.create(params) #=> Quaderno::Estimate
will create an estimate using the information of the hash passed as parameter.
Quaderno::Estimate.update(id, params)
will update the specified estimate with the data of the hash passed as second parameter.
Quaderno::Estimate.delete(id) #=> Boolean
will delete the estimate with the id passed as parameter.
###Adding or removing a payment In order to add a payment you will need the estimate you want to update.
estimate = Quaderno::Estimate.find(estimate_id)
estimate.add_payment(params) #=> Quaderno::Payment
Where params is a hash with the payment information. The method will return an instance of Quaderno::Payment wich contains the information of the payment.
In order to remove a payment you will need the estimate you want to update.
estimate = Quaderno::Estimate.find(estimate_id)
estimate.remove_payment(payment_id) #=> Boolean
###Delivering the estimate In order to deliver the estimate to the default recipient you will need the estimate you want to send.
estimate = Quaderno::Estimate.find(estimate_id)
estimate.deliver
Quaderno::Expense.all() #=> Array
Quaderno::Expense.all(page: 1) #=> Array
will return an array with all your expenses on the first page. You can also pass query strings using the attribute :q in order to filter the results by contact name, :state to filter by state or :date to filter by date.
Quaderno::Expense.find(id) #=> Quaderno::Expense
will return the expense with the id passed as parameter.
Quaderno::Expense.create(params) #=> Quaderno::Expense
will create an expense using the information of the hash passed as parameter and return an instance of Quaderno::Expense with the created expense.
Quaderno::Expense.update(id, params) #=> Quaderno::Expense
will update the specified expense with the data of the hash passed as second parameter.
Quaderno::Expense.delete(id) #=> Boolean
will delete the expense with the id passed as parameter.
For further information, please visit [quaderno api] (https://github.com/recrea/quaderno-api) wiki