Varejonline

Build Status Gem Version Test Coverage Code Climate

This gem simplifies the usage of Varejonline API

For more information regarding the API, visit the documentation

Installation

Add this line to your application's Gemfile:

gem 'varejonline'

And then execute:

$ bundle

Or install it yourself as:

$ gem install varejonline

Usage

Create a new instance of Varejonline class passing your access token:

  client = Varejonline.new(YOUR_ACCESS_TOKEN)

With the client instance, you can access the following resources:

  • Níveis de Categoria (client.category_levels) Only listing
  • Classes de Clientes (client.client_classes) Listing and finding
  • Empresas (client.companies) Listing and finding
  • Limite de Créditos (client.credit_limits) Listing and block history
  • Lançamentos Padrões (client.default_entries) Listing and finding
  • Entidades (client.entities) Listing and finding
  • Configuração de crédito (client.installments) Saving and information
  • Pedidos de venda (client.orders) Listing, finding, creation and cancellation
  • Planos de pagamento (client.payment_conditions) Only listing
  • Categorias de produtos (client.product_categories) Only listing
  • Produtos (client.products) Listing, finding, updating and creation
  • Provisões (client.provisions) Only creation
  • Contas a Receber (client.receivables) Listing and finding
  • Contas a Pagar (client.payables) Listing and finding
  • Histórico de Vendas (client.sales_history) Finding and more details
  • Representantes (client.sellers) Listing and finding
  • Terceiros (client.third_parties) Listing, finding, creation, credit limit information, credit limit updating, blocking/unblocking credit
  • Baixas (client.payments) Only creation
  • Negociações de Cartão (client.card_negotiations) Only listing
  • Dados Login (client.user_data)
  • Unidades (client.units) Listing and finding
  • Saldo de mercadorias(client.product_balances) Listing

Using the resources

Listing

Some resources implement a list method.

It can accept an Entity object that reflects the searchable API fields.

Currently the following entities are implemented:

Finding

Some resources implement a find method.

It finds the resource with the passed ID.

  Varejonline.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.

  Varejonline.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:

  Varejonline.new(YOUR_ACCESS_TOKEN).user_data.get

Reading the response

All methods return a Varejonline::Client::Response object. This object contains the following attributes:

  response = Varejonline.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

  1. Fork it ( https://github.com/coyosoftware/varejonline/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request