Class: Shippinglogic::FedEx
- Inherits:
-
Object
- Object
- Shippinglogic::FedEx
- Defined in:
- lib/shippinglogic/fedex.rb,
lib/shippinglogic/fedex/rate.rb,
lib/shippinglogic/fedex/ship.rb,
lib/shippinglogic/fedex/error.rb,
lib/shippinglogic/fedex/track.rb,
lib/shippinglogic/fedex/cancel.rb,
lib/shippinglogic/fedex/request.rb,
lib/shippinglogic/fedex/service.rb,
lib/shippinglogic/fedex/response.rb,
lib/shippinglogic/fedex/signature.rb,
lib/shippinglogic/fedex/enumerations.rb
Defined Under Namespace
Modules: Enumerations, Request, Response Classes: Cancel, Error, Rate, Service, Ship, Signature, Track
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#key ⇒ Object
Returns the value of attribute key.
-
#meter ⇒ Object
Returns the value of attribute meter.
-
#options ⇒ Object
Returns the value of attribute options.
-
#password ⇒ Object
Returns the value of attribute password.
Class Method Summary collapse
-
.options ⇒ Object
A hash representing default the options.
Instance Method Summary collapse
- #cancel(attributes = {}) ⇒ Object
-
#initialize(key, password, account, meter, options = {}) ⇒ FedEx
constructor
Before you can use the FedEx web services you need to provide 4 credentials:.
- #rate(attributes = {}) ⇒ Object
- #ship(attributes = {}) ⇒ Object
- #signature(attributes = {}) ⇒ Object
- #track(attributes = {}) ⇒ Object
-
#url ⇒ Object
A convenience method for accessing the endpoint URL for the FedEx API.
Constructor Details
#initialize(key, password, account, meter, options = {}) ⇒ FedEx
Before you can use the FedEx web services you need to provide 4 credentials:
-
Your fedex web service key
-
Your fedex password
-
Your fedex account number
-
Your fedex meter number
You can easily get these things by logging into your fedex account and going to:
www.fedex.com/wpor/wpor/editConsult.do
If for some reason this link no longer works because FedEx changed it, just go to the developer resources area and then navigate to the FedEx web services for shipping area. Once there you should see a link to apply for a develop test key.
The last parameter allows you to modify the class options on an instance level. It accepts the same options that the class level method #options accepts. If you don’t want to change any of them, don’t supply this parameter.
51 52 53 54 55 56 57 |
# File 'lib/shippinglogic/fedex.rb', line 51 def initialize(key, password, account, meter, = {}) self.key = key self.password = password self.account = account self.meter = meter self. = self.class..merge() end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
31 32 33 |
# File 'lib/shippinglogic/fedex.rb', line 31 def account @account end |
#key ⇒ Object
Returns the value of attribute key.
31 32 33 |
# File 'lib/shippinglogic/fedex.rb', line 31 def key @key end |
#meter ⇒ Object
Returns the value of attribute meter.
31 32 33 |
# File 'lib/shippinglogic/fedex.rb', line 31 def meter @meter end |
#options ⇒ Object
Returns the value of attribute options.
31 32 33 |
# File 'lib/shippinglogic/fedex.rb', line 31 def @options end |
#password ⇒ Object
Returns the value of attribute password.
31 32 33 |
# File 'lib/shippinglogic/fedex.rb', line 31 def password @password end |
Class Method Details
.options ⇒ Object
A hash representing default the options. If you are using this in a Rails app the best place to modify or change these options is either in an initializer or your specific environment file. Keep in mind that these options can be modified on the instance level when creating an object. See #initialize for more details.
Options
-
:test
- this basically tells us which url to use. If set to true we will use the FedEx test URL, if false we will use the production URL. If you are using this in a rails app, unless you are in your production environment, this will default to true automatically. -
:test_url
- the test URL for FedEx’s webservices. (default: gatewaybeta.fedex.com:443/xml) -
:production_url
- the production URL for FedEx’s webservices. (default: gateway.fedex.com:443/xml)
23 24 25 26 27 28 29 |
# File 'lib/shippinglogic/fedex.rb', line 23 def self. @options ||= { :test => !!(defined?(Rails) && !Rails.env.production?), :production_url => "https://gateway.fedex.com:443/xml", :test_url => "https://gatewaybeta.fedex.com:443/xml" } end |
Instance Method Details
#cancel(attributes = {}) ⇒ Object
64 65 66 |
# File 'lib/shippinglogic/fedex.rb', line 64 def cancel(attributes = {}) @cancel ||= Cancel.new(self, attributes) end |
#rate(attributes = {}) ⇒ Object
68 69 70 |
# File 'lib/shippinglogic/fedex.rb', line 68 def rate(attributes = {}) @rate ||= Rate.new(self, attributes) end |
#ship(attributes = {}) ⇒ Object
72 73 74 |
# File 'lib/shippinglogic/fedex.rb', line 72 def ship(attributes = {}) @ship ||= Ship.new(self, attributes) end |
#signature(attributes = {}) ⇒ Object
76 77 78 |
# File 'lib/shippinglogic/fedex.rb', line 76 def signature(attributes = {}) @signature ||= Signature.new(self, attributes) end |
#track(attributes = {}) ⇒ Object
80 81 82 |
# File 'lib/shippinglogic/fedex.rb', line 80 def track(attributes = {}) @track ||= Track.new(self, attributes) end |
#url ⇒ Object
A convenience method for accessing the endpoint URL for the FedEx API.
60 61 62 |
# File 'lib/shippinglogic/fedex.rb', line 60 def url [:test] ? [:test_url] : [:production_url] end |