Class: ActiveMerchant::Shipping::FedEx

Inherits:
Carrier show all
Defined in:
lib/active_shipping/shipping/carriers/fedex.rb

Overview

:key is your developer API key :password is your API password :account is your FedEx account number :login is your meter number

Constant Summary collapse

TEST_URL =
'https://gatewaybeta.fedex.com:443/xml'
LIVE_URL =
'https://gateway.fedex.com:443/xml'
CarrierCodes =
{
  "fedex_ground" => "FDXG",
  "fedex_express" => "FDXE"
}
ServiceTypes =
{
  "PRIORITY_OVERNIGHT" => "FedEx Priority Overnight",
  "PRIORITY_OVERNIGHT_SATURDAY_DELIVERY" => "FedEx Priority Overnight Saturday Delivery",
  "FEDEX_2_DAY" => "FedEx 2 Day",
  "FEDEX_2_DAY_SATURDAY_DELIVERY" => "FedEx 2 Day Saturday Delivery",
  "STANDARD_OVERNIGHT" => "FedEx Standard Overnight",
  "FIRST_OVERNIGHT" => "FedEx First Overnight",
  "FIRST_OVERNIGHT_SATURDAY_DELIVERY" => "FedEx First Overnight Saturday Delivery",
  "FEDEX_EXPRESS_SAVER" => "FedEx Express Saver",
  "FEDEX_1_DAY_FREIGHT" => "FedEx 1 Day Freight",
  "FEDEX_1_DAY_FREIGHT_SATURDAY_DELIVERY" => "FedEx 1 Day Freight Saturday Delivery",
  "FEDEX_2_DAY_FREIGHT" => "FedEx 2 Day Freight",
  "FEDEX_2_DAY_FREIGHT_SATURDAY_DELIVERY" => "FedEx 2 Day Freight Saturday Delivery",
  "FEDEX_3_DAY_FREIGHT" => "FedEx 3 Day Freight",
  "FEDEX_3_DAY_FREIGHT_SATURDAY_DELIVERY" => "FedEx 3 Day Freight Saturday Delivery",
  "INTERNATIONAL_PRIORITY" => "FedEx International Priority",
  "INTERNATIONAL_PRIORITY_SATURDAY_DELIVERY" => "FedEx International Priority Saturday Delivery",
  "INTERNATIONAL_ECONOMY" => "FedEx International Economy",
  "INTERNATIONAL_FIRST" => "FedEx International First",
  "INTERNATIONAL_PRIORITY_FREIGHT" => "FedEx International Priority Freight",
  "INTERNATIONAL_ECONOMY_FREIGHT" => "FedEx International Economy Freight",
  "GROUND_HOME_DELIVERY" => "FedEx Ground Home Delivery",
  "FEDEX_GROUND" => "FedEx Ground",
  "INTERNATIONAL_GROUND" => "FedEx International Ground"
}
PackageTypes =
{
  "fedex_envelope" => "FEDEX_ENVELOPE",
  "fedex_pak" => "FEDEX_PAK",
  "fedex_box" => "FEDEX_BOX",
  "fedex_tube" => "FEDEX_TUBE",
  "fedex_10_kg_box" => "FEDEX_10KG_BOX",
  "fedex_25_kg_box" => "FEDEX_25KG_BOX",
  "your_packaging" => "YOUR_PACKAGING"
}
DropoffTypes =
{
  'regular_pickup' => 'REGULAR_PICKUP',
  'request_courier' => 'REQUEST_COURIER',
  'dropbox' => 'DROP_BOX',
  'business_service_center' => 'BUSINESS_SERVICE_CENTER',
  'station' => 'STATION'
}
PaymentTypes =
{
  'sender' => 'SENDER',
  'recipient' => 'RECIPIENT',
  'third_party' => 'THIRDPARTY',
  'collect' => 'COLLECT'
}
PackageIdentifierTypes =
{
  'tracking_number' => 'TRACKING_NUMBER_OR_DOORTAG',
  'door_tag' => 'TRACKING_NUMBER_OR_DOORTAG',
  'rma' => 'RMA',
  'ground_shipment_id' => 'GROUND_SHIPMENT_ID',
  'ground_invoice_number' => 'GROUND_INVOICE_NUMBER',
  'ground_customer_reference' => 'GROUND_CUSTOMER_REFERENCE',
  'ground_po' => 'GROUND_PO',
  'express_reference' => 'EXPRESS_REFERENCE',
  'express_mps_master' => 'EXPRESS_MPS_MASTER'
}
@@name =
"FedEx"

Instance Attribute Summary

Attributes inherited from Carrier

#last_request, #test_mode

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Carrier

#initialize, #maximum_weight, #valid_credentials?

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Methods included from RequiresParameters

#requires!

Constructor Details

This class inherits a constructor from ActiveMerchant::Shipping::Carrier

Class Method Details

.service_name_for_code(service_code) ⇒ Object



88
89
90
91
92
93
# File 'lib/active_shipping/shipping/carriers/fedex.rb', line 88

def self.service_name_for_code(service_code)
  ServiceTypes[service_code] || begin
    name = service_code.downcase.split('_').collect{|word| word.capitalize }.join(' ')
    "FedEx #{name.sub(/Fedex /, '')}"
  end
end

Instance Method Details

#find_rates(origin, destination, packages, options = {}) ⇒ Object



99
100
101
102
103
104
105
106
107
108
# File 'lib/active_shipping/shipping/carriers/fedex.rb', line 99

def find_rates(origin, destination, packages, options = {})
  options = @options.update(options)
  packages = Array(packages)
  
  rate_request = build_rate_request(origin, destination, packages, options)
  
  response = commit(save_request(rate_request), (options[:test] || false)).gsub(/<(\/)?.*?\:(.*?)>/, '<\1\2>')
  
  parse_rate_response(origin, destination, packages, response, options)
end

#find_tracking_info(tracking_number, options = {}) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/active_shipping/shipping/carriers/fedex.rb', line 110

def find_tracking_info(tracking_number, options={})
  options = @options.update(options)
  
  tracking_request = build_tracking_request(tracking_number, options)
  response = commit(save_request(tracking_request), (options[:test] || false)).gsub(/<(\/)?.*?\:(.*?)>/, '<\1\2>')
  parse_tracking_response(response, options)
end

#requirementsObject



95
96
97
# File 'lib/active_shipping/shipping/carriers/fedex.rb', line 95

def requirements
  [:key, :password, :account, :login]
end