Class: Fedex::Request::Delete

Inherits:
Base
  • Object
show all
Defined in:
lib/fedex/request/delete.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 = {}) ⇒ Delete


9
10
11
12
13
14
15
# File 'lib/fedex/request/delete.rb', line 9

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

  @tracking_number  = options[:tracking_number]
  @deletion_control = options[:deletion_control] || 'DELETE_ALL_PACKAGES'
  @credentials  = credentials
end

Instance Attribute Details

#tracking_numberObject (readonly)

Returns the value of attribute tracking_number


7
8
9
# File 'lib/fedex/request/delete.rb', line 7

def tracking_number
  @tracking_number
end

Instance Method Details

#process_requestObject


17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fedex/request/delete.rb', line 17

def process_request
  api_response = self.class.post(api_url, :body => build_xml)
  puts api_response if @debug == true
  response = parse_response(api_response)
  unless success?(response)
    error_message = if response[:shipment_reply]
      [response[:shipment_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