boa_vista

wercker statusCode Climate

Library to do requests and generate layouts for BoaVista SCPC.

Features

  • Generate Layout for requests
  • Parse Layouts of responses
  • Do requests in BoaVista

Installation

Add this in your Gemfile

gem 'boa_vista'

Configuration

If you are using Rails add this code in config/initializers

  require 'boa_vista'
  BoaVista.configure do |config|
    config.code     = '<YOUR_CODE>'
    config.password = '<YOUR_PASSWORD>'
    config.url      = '<BOAVISTA_URL>'
    config.timeout  = '<MAX_SEC_TO_COMPLETE_REQUEST>'
  end

Usage

Considering a variable(attributes) equal to this:

   attributes = {
     document_number: '00031030944410'
   }.merge(BoaVista::Request::Default::CPF)
BoaVista::Client

To do a request in BoaVista do

  line = BoaVista::Client.new(attributes).call

Will return an instance of BoaVista::Line, you can use your methods to access attributes of specific layout

line.transaction
=> '   CSR80'

For more information see lib/response/layouts folder

BoaVista::Response

Considering a variable below

line = 'TTTTTTTTVVRRRRRRRRRRBBBBBBBBBBBBBBBBBBBBCCCCCCCCQQQQQQQQQVYCNNNNNNNTTTTZZZPPP'

To parse line you can use BoaVista::Response, a code to do this is

parsed_line = BoaVista::Response.new(line).read

And will return an instance of line similar BoaVista::Client#call

BoaVista::Request

To create an request you need pass your values

   BoaVista::Request.new(attributes).create

and will return a similar line of this

"CSR60   01                              CODE    PASSWORDSINTON  012C100031030944410X"

Contributors