Exception: Correios::Pricefier::CalculateDeadlineWithDate

Inherits:
CorreiosException
  • Object
show all
Defined in:
lib/pricefier/requests/calculate_deadline_with_date.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 = {}) ⇒ CalculateDeadlineWithDate

Returns a new instance of CalculateDeadlineWithDate.



14
15
16
17
18
19
20
21
# File 'lib/pricefier/requests/calculate_deadline_with_date.rb', line 14

def initialize(data = {})
  @show_request = data[:show_request]
  @service_codes = data[:service_codes]
  @source_zip_code = data[:source_zip_code]
  @target_zip_code = data[:target_zip_code]
  @reference_date = data[:reference_date]
  super()
end

Instance Method Details

#requestObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pricefier/requests/calculate_deadline_with_date.rb', line 23

def request
  puts xml if @show_request == true
  begin
    format_response(CLIENT.client.call(:calc_prazo_data,
                                       soap_action: 'http://tempuri.org/CalcPrazoData',
                                       xml: xml).to_hash)
  rescue Savon::SOAPFault => error
    generate_exception(error)
  rescue Savon::HTTPError => error
    if error.http.code == 401
      generate_exception("Unauthorized (#{error.http.code}).")
    end
    generate_exception("Unknown HTTP error (#{error.http.code}).")
  end
end