Class: Fedex::Request::GroundClose

Inherits:
Base
  • Object
show all
Defined in:
lib/fedex/request/ground_close.rb

Constant Summary

Constants inherited from Base

Base::CARRIER_CODES, Base::CLEARANCE_BROKERAGE_TYPE, Base::DROP_OFF_TYPES, Base::PACKAGING_TYPES, Base::PAYMENT_TYPE, Base::PRODUCTION_URL, Base::RECIPIENT_CUSTOM_ID_TYPE, Base::SERVICE_TYPES, Base::TEST_URL

Instance Attribute Summary collapse

Attributes inherited from Base

#debug

Instance Method Summary collapse

Constructor Details

#initialize(credentials, options = {}) ⇒ GroundClose

Returns a new instance of GroundClose.



10
11
12
13
14
15
16
17
# File 'lib/fedex/request/ground_close.rb', line 10

def initialize(credentials, options={})
  requires!(options, :up_to_time)

  @credentials = credentials
  @up_to_time = options[:up_to_time]
  @filename = options[:filename]
  @debug = ENV['DEBUG'] == 'true'
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



8
9
10
# File 'lib/fedex/request/ground_close.rb', line 8

def filename
  @filename
end

#up_to_timeObject (readonly)

Returns the value of attribute up_to_time.



8
9
10
# File 'lib/fedex/request/ground_close.rb', line 8

def up_to_time
  @up_to_time
end

Instance Method Details

#process_requestObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fedex/request/ground_close.rb', line 19

def process_request
  api_response = self.class.post(api_url, :body => build_xml)
  puts api_response if @debug == true
  response = parse_response(api_response)
  if success?(response)
    success_response(response)
  else
    error_message = if response[:ground_close_reply]
      [response[:ground_close_reply][:notifications]].flatten.first[:message]
    else
      "#{api_response["Fault"]["detail"]["fault"]["reason"]}\n
      --#{api_response["Fault"]["detail"]["fault"]["details"]["ValidationFailureDetail"]["message"].join("\n--")}"
    end rescue $1
    raise RateError, error_message
  end
end