Simple client for Fantozzi REST API.
Add this line to your application's Gemfile:
gem 'pina'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pina
To open development environment in docker:
- install prerequisites
gem install docker-sync
- run
docker volume create --name=gem_store_235
docker-sync start
docker-compose run web bash
Resource | All | Find | Find_by | Where | Create | Update | Delete |
---|---|---|---|---|---|---|---|
Contacts | o | o | o | o | o | o | - |
DocumentPairing | o | - | - | - | - | - | - |
MyBankAccount | o | o | - | o | o | o | - |
PettyCashDisburstment | o | o | - | - | - | - | - |
PettyCashIncome | o | o | - | - | - | - | - |
ProcessedDocument | o | o | - | o | - | - | o |
PurchaseInvoice | o | o | - | o | o | o | - |
Receivable | o | o | - | o | - | - | - |
SalesInvoice | o | o | - | o | o | o | - |
SalesOrder | o | o | - | o | - | - | - |
StatProcessedDocument | o | o | - | o | - | - | - |
UploadedDocument | o | o | - | o | o | o | - |
UploadedDocumentPairing | - | - | - | - | o | - | - |
Resources not mentioned = resources not covered.
Before you start using Pina you have to configure it.
Pina.configure do |config|
config.email = 'your_email@domain.com'
config.tenant = 'your tenant database name'
config.api_token = 'your secret token'
end
Optionally, you can configure Pina to run against other than production instance of Fantozzi:
Pina.configure do |config|
config.api_host = 'localhost:3000'
config.use_ssl = true | false # defaults to true
end
Now you can start querying REST API.
Pina::Contact.all
Gets all contacts from your database. Results are paginated and you can access first, next or previous page like this:
contacts = Pina::Contact.all
contacts.next_page
contacts = Pina::Contact.all
contacts.previous_page
contacts.first_page
Pina::Contact.find('contact_name')
contact = Pina::Models::Contact.new
Pina::Contact.create(contact)
contact = Pina::Contact.find('existing')
contact.email = 'brand_new@email.com'
Pina::Contact.update('existing', contact)
Pina::DocumentPairing.all
Gets all document pairings from your database. Results are paginated and you can access first, next or previous page like this:
pairings = Pina::DocumentPairing.all
pairings.next_page
pairings = Pina::DocumentPairing.all
pairings.previous_page
pairings.first_page
Pina::SalesInvoice.all
Gets all sales invocies from your database. Results are paginated and you can access first, next or previous page like this:
invoices = Pina::SalesInvoice.all
invoices.next_page
invoices = Pina::SalesInvoice.all
invoices.previous_page
invoices.first_page
Pina::SalesInvoice.find(invoice_id)
invoice = Pina::Models::SalesInvoice.new
Pina::SalesInvoice.create(invoice)
invoice = Pina::SalesInvoice.find(2016000001)
invoice.status = :confirmed
Pina::SalesInvoice.update(2016000001, invoice)
Pina::SalesOrder.all
Gets all sales orders from your database. Results are paginated and you can access first, next or previous page like this:
orders = Pina::SalesOrder.all
orders.next_page
orders = Pina::SalesOrder.all
orders.previous_page
orders.first_page
Pina::SalesOrder.find(order_id)
Pina::PettyCashDisburstment.all
Pina::PettyCashDisburstment.find(gid)
Pina::PettyCashIncome.all
Pina::PettyCashIncome.find(gid)
Pina::ProcessedDocument.all
Gets all processed documents from your database. Results are paginated and you can access first, next or previous page like this:
documents = Pina::ProcessedDocument.all
documents.next_page
documents = Pina::ProcessedDocument.all
documents.previous_page
documents.first_page
Pina::ProcessedDocument.find(gid)
Pina::ProcessedDocument.delete(gid)
Pina::PurchaseInvoice.all
Gets all purchase invocies from your database. Results are paginated and you can access first, next or previous page like this:
invoices = Pina::PurchaseInvoice.all
invoices.next_page
invoices = Pina::PurchaseInvoice.all
invoices.previous_page
invoices.first_page
Pina::PurchaseInvoice.find(invoice_id)
invoice = Pina::Models::PurchaseInvoice.new
Pina::PurchaseInvoice.create(invoice)
invoice = Pina::PurchaseInvoice.find(2016000001)
invoice.type = :penalty
Pina::PurchaseInvoice.update(2016000001, invoice)
Pina::Receivable.all
Gets all receivables from your database. Results are paginated and you can access first, next or previous page like this:
receivables = Pina::Receivable.all
receivables.next_page
invoices = Pina::Receivable.all
invoices.previous_page
invoices.first_page
Pina::Receivable.find(invoice_id)
Pina::StatProcessedDocument.all
Gets all stat processed documents from your database. Results are paginated and you can access first, next or previous page like this:
stats = Pina::StatProcessedDocument.all
stats.next_page
stats = Pina::StatProcessedDocument.all
stats.previous_page
stats.first_page
Pina::StatProcessedDocument.find(gid)
Pina::MyBankAccount.all
Gets all bank accounts from your database. Results are paginated and you can access first, next or previous page like this:
bank_accounts = Pina::MyBankAccount.all
bank_accounts.next_page
bank_accounts = Pina::MyBankAccount.all
bank_accounts.previous_page
bank_accounts.first_page
Pina::MyBankAccount.find('csob_czk')
This ID you can find under attribute bank_account_id
params = {
bank_account: 'XXXXXXXXX/XXXX',
currency_id: 'CZK',
bank_account_id: 'XXXX'
}
bank_account = Pina::Models::MyBankAccount.new(params)
Pina::MyBankAccount.create(bank_account)
bank_account = Pina::MyBankAccount.find('existing')
bank_account.download_type = 'none'
Pina::MyBankAccount.update('existing', bank_account)
Pina::UploadedDocument.all
Gets all uploaded documents from your database. Results are paginated and you can access first, next or previous page like this:
uploaded_documents = Pina::UploadedDocument.all
uploaded_documents.next_page
uploaded_documents = Pina::UploadedDocument.all
uploaded_documents.previous_page
uploaded_documents.first_page
Pina::UploadedDocument.find(1)
uploaded_document = Pina::UploadedDocument.find(1)
uploaded_document.state = 'processed'
Pina::UploadedDocument.update(1, uploaded_document)
Pina::UploadedDocumentPairing.create(uploaded_document_id: 1,
document_pairable_type: 'purchase_invoice',
document_pairable_id: 201700001)
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Create .env file with following variables in it:
EMAIL
TENANT
API_TOKEN
and fill them with appropriate values.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pina.
The gem is available as open source under the terms of the MIT License.