Exception: Correios::Sigep::RequestShippingsXML

Inherits:
CorreiosException show all
Defined in:
lib/sigep/requests/request_shippings_xml.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 = {}) ⇒ RequestShippingsXML

Returns a new instance of RequestShippingsXML.



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

def initialize(data = {})
  @credentials = Correios.credentials

  @show_request = data[:show_request]
  @request_id = data[:request_id]
  super()
end

Instance Method Details

#requestObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/sigep/requests/request_shippings_xml.rb', line 22

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