class CorreiosSigep::LogisticReverse::RequestSRO
Public Class Methods
new(sro, overrides={})
click to toggle source
Calls superclass method
CorreiosSigep::LogisticReverse::BaseClient::new
# File lib/correios_sigep/logistic_reverse/request_sro.rb, line 4 def initialize(sro, overrides={}) @sro = sro @overrides = overrides super() end
Public Instance Methods
process()
click to toggle source
# File lib/correios_sigep/logistic_reverse/request_sro.rb, line 10 def process xml = Builders::XML::RequestSRO.build_xml(@sro, @overrides) process_response invoke(:acompanhar_pedido, xml) end
Private Instance Methods
check_sro_errors(return_body)
click to toggle source
# File lib/correios_sigep/logistic_reverse/request_sro.rb, line 26 def check_sro_errors return_body error_msg = return_body[:msg_erro] case return_body[:cod_erro].to_i when 0 return when -7 raise Models::Errors::RequiredFields.new(error_msg) when -5 raise Models::Errors::CollectNumberNotFound.new(error_msg) else raise Models::Errors::UnknownError.new(error_msg) end end
correios_response(response)
click to toggle source
# File lib/correios_sigep/logistic_reverse/request_sro.rb, line 22 def correios_response response response.is_a?(Array) ? response.first : response end
process_response(response)
click to toggle source
# File lib/correios_sigep/logistic_reverse/request_sro.rb, line 16 def process_response response correios_hash = response.body[:acompanhar_pedido_response][:acompanhar_pedido] check_sro_errors(correios_hash) correios_response(correios_hash[:coleta][:objeto])[:numero_etiqueta] || begin raise Models::Errors::SRONotReady; end end