Exception: Correios::Pricefier::CalculateDeadline

Inherits:
Helper show all
Defined in:
lib/pricefier/requests/calculate_deadline.rb

Instance Method Summary collapse

Methods inherited from Helper

#array_to_string, #array_to_string_comma, #bool_to_int, #bool_to_string, #calculate_reverse_shipping_deadline, #calculate_shipping_deadline, #date_to_string, #decimal_to_string, #generate_http_exception, #generate_revese_logistics_exception, #generate_soap_fault_exception, #generate_sro_exception, #inverse_card_status, #inverse_object_type, #inverse_payment_method, #inverse_reverse_shipping_type, #inverse_service_availability, #inverse_shipping_cancellation, #inverse_tracking_event_status, #object_type, #payment_method, #pricefier_object_type, #remove_label_digit_checker, #reverse_shipping_service, #reverse_shipping_type, #reverse_tracking_result_type, #string_to_bool, #string_to_date, #string_to_decimal, #string_to_time, #string_to_time_no_second, #ticket_type, #tracking_language, #tracking_query_type, #tracking_result_type

Methods inherited from CorreiosException

#generate_exception

Constructor Details

#initialize(data = {}) ⇒ CalculateDeadline

Returns a new instance of CalculateDeadline.



4
5
6
7
8
9
10
11
12
# File 'lib/pricefier/requests/calculate_deadline.rb', line 4

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

#request(method) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pricefier/requests/calculate_deadline.rb', line 14

def request(method)
  @method = method
  @method_snake = method.underscore

  puts xml if @show_request == true
  begin
    format_response(Pricefier.client.call(
      @method_snake.to_sym,
      soap_action: "http://tempuri.org/#{@method}",
      xml: xml
    ).to_hash)
  rescue Savon::SOAPFault => error
    generate_soap_fault_exception(error)
  rescue Savon::HTTPError => error
    generate_http_exception(error.http.code)
  end
end