Exception: Correios::Sigep::SearchZipCode

Inherits:
CorreiosException show all
Defined in:
lib/sigep/requests/search_zip_code.rb

Constant Summary collapse

HELPER =
Helper.new
CLIENT =
Client.new

Instance Method Summary collapse

Methods inherited from CorreiosException

#format_error_message, #generate_exception

Constructor Details

#initialize(data = {}) ⇒ SearchZipCode

Returns a new instance of SearchZipCode.



14
15
16
17
18
# File 'lib/sigep/requests/search_zip_code.rb', line 14

def initialize(data = {})
  @show_request = data[:show_request]
  @zip_code = data[:zip_code]
  super()
end

Instance Method Details

#requestObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/sigep/requests/search_zip_code.rb', line 20

def request
  puts xml if @show_request == true
  begin
    format_response(CLIENT.client.call(:consulta_cep,
                                       soap_action: '',
                                       xml: xml).to_hash)
  rescue Savon::SOAPFault => error
    generate_exception(error)
  end
end