Class: SigepWeb::ZipQuery

Inherits:
WebServiceInterfaceApi show all
Defined in:
lib/sigep_web/zip_query.rb

Instance Method Summary collapse

Methods inherited from WebServiceInterfaceApi

#process

Constructor Details

#initialize(options = {}) ⇒ ZipQuery

Returns a new instance of ZipQuery.



3
4
5
6
# File 'lib/sigep_web/zip_query.rb', line 3

def initialize(options = {})
  @zip = options[:zip]
  super()
end

Instance Method Details

#requestObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sigep_web/zip_query.rb', line 8

def request
  begin
    response = process(:consulta_cep, {
      cep: @zip
    }).to_hash[:consulta_cep_response][:return]

    {
      success: true,
      response: response
    }
  rescue Savon::SOAPFault => msg
    {
      success: false,
      error: msg
    }
  end
end