Class: Fedex::Request::Address
- Defined in:
- lib/fedex/request/address.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
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(credentials, options = {}) ⇒ Address
constructor
A new instance of Address.
- #process_request ⇒ Object
Constructor Details
#initialize(credentials, options = {}) ⇒ Address
Returns a new instance of Address.
8 9 10 11 12 13 14 |
# File 'lib/fedex/request/address.rb', line 8 def initialize(credentials, ={}) requires!(, :address) @credentials = credentials @address = [:address] @address[:address] ||= @address[:street] end |
Instance Method Details
#process_request ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fedex/request/address.rb', line 16 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) = response[:address_validation_reply][:address_results][:proposed_address_details] = .first if .is_a? Array Fedex::Address.new() else = if response[:address_validation_reply] [response[:address_validation_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, end end |