Class: FedexShip::Request::Base
- Inherits:
-
Object
- Object
- FedexShip::Request::Base
- Includes:
- Helpers, HTTParty
- Defined in:
- lib/fedex_ship/request/base.rb
Direct Known Subclasses
Constant Summary collapse
- TEST_URL =
Fedex Text URL TEST_URL = “wsbeta.fedex.com:443/xml/”
"https://wsbeta.fedex.com:443/web-services"
- PRODUCTION_URL =
Fedex Production URL
"https://ws.fedex.com:443/web-services"
- 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 FedexShip::Request::Base object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fedex_ship/request/base.rb', line 52 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' @preferred_currency = [:preferred_currency] @shipping_options = [:shipping_options] ||= {} @commercial_invoice_options = [:commercial_invoice_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 if .has_key?(:total_insured_value) @total_insured_value = [:total_insured_value] requires!(@total_insured_value, :currency, :amount) else @total_insured_value = {} 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_ship/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
84 85 86 |
# File 'lib/fedex_ship/request/base.rb', line 84 def process_request raise NotImplementedError, "Override process_request in subclass" end |