Class: Business::BR::CEP::Providers::Postmon

Inherits:
Base
  • Object
show all
Defined in:
lib/business-br/cep/providers/postmon.rb

Instance Attribute Summary

Attributes inherited from Base

#zipcode

Instance Method Summary collapse

Instance Method Details

#search_by(cep) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/business-br/cep/providers/postmon.rb', line 8

def search_by(cep)
  @zipcode = cep
  begin
    response = Faraday.get("http://api.postmon.com.br/v1/cep/#{@zipcode}")
    parse_response(response.body)
  rescue Faraday::ClientError => e
    puts e.response if ENV['BUSINESS-BR_DEBUG']
    nil
  end
end