class Bipbop
Attributes
api_key[R]
Public Class Methods
new(api_key = nil)
click to toggle source
# File lib/bipbop.rb, line 16 def initialize(api_key = nil) @api_key = api_key || ENV['BIPBOP_API_KEY'] end
Public Instance Methods
cpfcnpj(params)
click to toggle source
# File lib/bipbop.rb, line 20 def cpfcnpj(params) request(:bipbopjs, :cpfcnpj, params) end
perfileconomico(params)
click to toggle source
# File lib/bipbop.rb, line 28 def perfileconomico(params) request(:ecommerce, :perfileconomico, params) end
Private Instance Methods
irql(database, table, params)
click to toggle source
# File lib/bipbop.rb, line 34 def irql(database, table, params) conditions = [] params.each_pair do |key, value| conditions << "'#{key.upcase}' = '#{value}'" end "SELECT FROM '#{database.upcase}'.'#{table.upcase}' WHERE #{conditions.join(" AND ")}" end
query(q)
click to toggle source
# File lib/bipbop.rb, line 50 def query(q) { :query => {'q' => q, 'apiKey' => @api_key}} end
request(database, table, params)
click to toggle source
# File lib/bipbop.rb, line 42 def request(database, table, params) @response = self.class.get("/", query(irql(database, table, params))) if @response.code == 200 body = @response["IRQL"]['body'] body.merge('gender' => body['name'].attributes['gender']) rescue body end end