Class: Fedex::Request::Base
- Inherits:
-
Object
- Object
- Fedex::Request::Base
- Includes:
- Helpers, HTTParty
- Defined in:
- lib/fedex/request/base.rb
Direct Known Subclasses
Address, Delete, GroundClose, Pickup, PickupAvailability, Rate, ServiceAvailability, Shipment, TrackingInformation
Constant Summary collapse
- TEST_URL =
Fedex Text URL
"https://wsbeta.fedex.com:443/xml/"
- PRODUCTION_URL =
Fedex Production URL
"https://ws.fedex.com:443/xml/"
- SERVICE_TYPES =
List of available Service Types
%w(EUROPE_FIRST_INTERNATIONAL_PRIORITY FEDEX_1_DAY_FREIGHT FEDEX_2_DAY FEDEX_2_DAY_AM FEDEX_2_DAY_FREIGHT FEDEX_3_DAY_FREIGHT FEDEX_EXPRESS_SAVER FEDEX_FIRST_FREIGHT FEDEX_FREIGHT_ECONOMY FEDEX_FREIGHT_PRIORITY FEDEX_GROUND FIRST_OVERNIGHT GROUND_HOME_DELIVERY INTERNATIONAL_ECONOMY INTERNATIONAL_ECONOMY_FREIGHT INTERNATIONAL_FIRST INTERNATIONAL_PRIORITY INTERNATIONAL_PRIORITY_FREIGHT PRIORITY_OVERNIGHT SMART_POST STANDARD_OVERNIGHT)
- PACKAGING_TYPES =
List of available Packaging Type
%w(FEDEX_10KG_BOX FEDEX_25KG_BOX FEDEX_BOX FEDEX_ENVELOPE FEDEX_PAK FEDEX_TUBE YOUR_PACKAGING)
- DROP_OFF_TYPES =
List of available DropOffTypes
%w(BUSINESS_SERVICE_CENTER DROP_BOX REGULAR_PICKUP REQUEST_COURIER STATION)
- CLEARANCE_BROKERAGE_TYPE =
Clearance Brokerage Type
%w(BROKER_INCLUSIVE BROKER_INCLUSIVE_NON_RESIDENT_IMPORTER BROKER_SELECT BROKER_SELECT_NON_RESIDENT_IMPORTER BROKER_UNASSIGNED)
- RECIPIENT_CUSTOM_ID_TYPE =
Recipient Custom ID Type
%w(COMPANY INDIVIDUAL PASSPORT)
- PAYMENT_TYPE =
List of available Payment Types
%w(RECIPIENT SENDER THIRD_PARTY)
- CARRIER_CODES =
List of available Carrier Codes
%w(FDXC FDXE FDXG FDCC FXFR FXSP)
Instance Attribute Summary collapse
-
#debug ⇒ Object
If true the rate method will return the complete response from the Fedex Web Service.
Instance Method Summary collapse
-
#initialize(credentials, options = {}) ⇒ Base
constructor
In order to use Fedex rates API you must first apply for a developer(and later production keys), Visit / Fedex Developer Center for more information about how to obtain your keys.
-
#process_request ⇒ Object
Sends post request to Fedex web service and parse the response.
Constructor Details
#initialize(credentials, options = {}) ⇒ Base
In order to use Fedex rates API you must first apply for a developer(and later production keys), Visit / Fedex Developer Center for more information about how to obtain your keys. return a Fedex::Request::Base object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fedex/request/base.rb', line 50 def initialize(credentials, ={}) requires!(, :shipper, :recipient, :packages) @credentials = credentials @shipper, @recipient, @packages, @service_type, @customs_clearance_detail, @debug = [:shipper], [:recipient], [:packages], [:service_type], [:customs_clearance_detail], [:debug] @origin = [:origin] @debug = ENV['DEBUG'] == 'true' @shipping_options = [:shipping_options] ||={} @payment_options = [:payment_options] ||={} requires!(@payment_options, :type, :account_number, :name, :company, :phone_number, :country_code) if @payment_options.length > 0 if .has_key?(:mps) @mps = [:mps] requires!(@mps, :package_count, :total_weight, :sequence_number) requires!(@mps, :master_tracking_id) if @mps.has_key?(:sequence_number) && @mps[:sequence_number].to_i >= 2 else @mps = {} end # Expects hash with addr and port if [:http_proxy] self.class.http_proxy [:http_proxy][:host], [:http_proxy][:port] end end |
Instance Attribute Details
#debug ⇒ Object
If true the rate method will return the complete response from the Fedex Web Service
13 14 15 |
# File 'lib/fedex/request/base.rb', line 13 def debug @debug end |
Instance Method Details
#process_request ⇒ Object
Sends post request to Fedex web service and parse the response. Implemented by each subclass
74 75 76 |
# File 'lib/fedex/request/base.rb', line 74 def process_request raise NotImplementedError, "Override process_request in subclass" end |