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(zip:) ⇒ ZipQuery

Returns a new instance of ZipQuery.



5
6
7
8
9
# File 'lib/sigep_web/zip_query.rb', line 5

def initialize(zip:)
  @zip = zip

  super()
end

Instance Method Details

#requestObject



11
12
13
14
15
16
17
18
19
# File 'lib/sigep_web/zip_query.rb', line 11

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

  {success: true, response: response}
rescue Savon::SOAPFault => e
  {success: false, error: e.message}
end