VPSA
This gem simplifies the usage of VPSA API
For more information regarding the API, visit the documentation
Installation
Add this line to your application's Gemfile:
gem 'vpsa'
And then execute:
$ bundle
Or install it yourself as:
$ gem install vpsa
Usage
Create a new instance of VPSA class passing your access token:
client = Vpsa.new(YOUR_ACCESS_TOKEN)
With the client instance, you can access the following resources:
- Classes de Clientes (client.client_classes) Listing and finding
- Configuração de crédito (client.installments) Saving and information
- Contas a Receber (client.receipts) Listing and finding
- Dados Login (client.user_data)
- Empresas (client.companies) Listing and finding
- Entidades (client.entities) Listing and finding
- Histórico de Vendas (client.sales_history) *Finding and more details *
- Lançamentos Padrões (client.default_entries) Listing and finding
- Limite de Créditos (client.credit_limits) Listing and block history
- Pedidos de venda (client.orders) Listing and finding
- Provisões (client.provisions) Only Creation
- Representantes (client.sellers) Listing and finding
- Terceiros (client.third_parties) Listing, finding, creation, credit limit information, credit limit updating, blocking/unblocking credit
Using the resources
Listing
All resources implement a list method.
It can accept an Entity object that reflects the searchable API fields.
Currently the following entities are implemented:
- Classes de Clientes
- Contas a Receber
- Empresas
- Entidades
- Lançamentos Padrões
- Limite de Crédito
- Pedidos de Venda
- Representantes
- Terceiros
Finding
All resources implement a find method.
It finds the resource with the passed ID.
Vpsa.new(YOUR_ACCESS_TOKEN).third_parties.find(4)
Creation
Some resources implement a create method.
It creates a new resource base on the information passed via Hash.
Vpsa.new(YOUR_ACCESS_TOKEN).provisions.create({:"idLancamentoPadrao" => 3, :"idEntidade" => 1, :"idTerceiro" => 15, :"data" => "21-10-2012", :"valor" =>123.40, :"historico" => "histórico da provisão"})
Getting User Data
You can get the token owner information by calling the following method:
Vpsa.new(YOUR_ACCESS_TOKEN).user_data.get
Reading the response
All methods return a Vpsa::Client::Response object. This object contains the following attributes:
response = Vpsa.new(YOUR_ACCESS_TOKEN).third_parties.list
response.status # Contains the status code of the request
response.payload # Contains the return data (JSON) of the request
response.raw_response # Contains the HTTParty response object
Contributing
- Fork it ( https://github.com/coyosoftware/vpsa/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request