Class: FedexShip::Request::Shipment
- Defined in:
- lib/fedex_ship/request/shipment.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
-
#response_details ⇒ Object
readonly
Returns the value of attribute response_details.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(credentials, options = {}) ⇒ Shipment
constructor
A new instance of Shipment.
-
#process_request ⇒ Object
Sends post request to Fedex web service and parse the response.
Methods inherited from LogsFedex
#delete_ship_serv_log, #pickup_serv_log, #rate_serv_log, #ship_serv_log, #track_serv_log
Constructor Details
#initialize(credentials, options = {}) ⇒ Shipment
Returns a new instance of Shipment.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fedex_ship/request/shipment.rb', line 9 def initialize(credentials, = {}) super requires!(, :service_type) # Label specification is required even if we're not using it. @label_specification = { :label_format_type => 'COMMON2D', :image_type => 'PDF', :label_stock_type => 'PAPER_LETTER' } @label_specification.merge! [:label_specification] if [:label_specification] @customer_specified_detail = [:customer_specified_detail] if [:customer_specified_detail] end |
Instance Attribute Details
#response_details ⇒ Object (readonly)
Returns the value of attribute response_details.
7 8 9 |
# File 'lib/fedex_ship/request/shipment.rb', line 7 def response_details @response_details end |
Instance Method Details
#process_request ⇒ Object
Sends post request to Fedex web service and parse the response. A label file is created with the label at the specified location. The parsed Fedex response is available in #response_details e.g. response_details[:completed_package_details][:tracking_number]
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fedex_ship/request/shipment.rb', line 26 def process_request @build_xml = build_xml ship_serv_log('Final XML Request : ' + @build_xml.to_s) api_url_srv = api_url + "/ship" ship_serv_log('URL for API : ' + api_url_srv.to_s) api_response = self.class.post(api_url_srv, :body => @build_xml) ship_serv_log('API Response : ' + api_response.to_s) puts api_response if @debug response = parse_response(api_response) if success?(response) ship_serv_log('Successfully Done : ' + response.to_s) success_response(api_response, response) else failure_response(api_response, response) end end |