Class: Shippinglogic::FedEx

Inherits:
Object
  • Object
show all
Defined in:
lib/shippinglogic/fedex.rb,
lib/shippinglogic/fedex/rate.rb,
lib/shippinglogic/fedex/ship.rb,
lib/shippinglogic/fedex/error.rb,
lib/shippinglogic/fedex/proxy.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/attributes.rb,
lib/shippinglogic/fedex/validation.rb,
lib/shippinglogic/fedex/enumerations.rb

Defined Under Namespace

Modules: Attributes, Enumerations, Request, Response, Validation Classes: Cancel, Error, Proxy, Rate, Service, Ship, Signature, Track

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, password, account, meter, options = {}) ⇒ FedEx

Before you can use the FedEx web services you need to provide 4 credentials:

  1. Your fedex web service key

  2. Your fedex password

  3. Your fedex account number

  4. 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.



53
54
55
56
57
58
59
# File 'lib/shippinglogic/fedex.rb', line 53

def initialize(key, password, , meter, options = {})
  self.key = key
  self.password = password
  self. = 
  self.meter = meter
  self.options = self.class.options.merge(options)
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



33
34
35
# File 'lib/shippinglogic/fedex.rb', line 33

def 
  @account
end

#keyObject

Returns the value of attribute key.



33
34
35
# File 'lib/shippinglogic/fedex.rb', line 33

def key
  @key
end

#meterObject

Returns the value of attribute meter.



33
34
35
# File 'lib/shippinglogic/fedex.rb', line 33

def meter
  @meter
end

#optionsObject

Returns the value of attribute options.



33
34
35
# File 'lib/shippinglogic/fedex.rb', line 33

def options
  @options
end

#passwordObject

Returns the value of attribute password.



33
34
35
# File 'lib/shippinglogic/fedex.rb', line 33

def password
  @password
end

Class Method Details

.optionsObject

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)



25
26
27
28
29
30
31
# File 'lib/shippinglogic/fedex.rb', line 25

def self.options
  @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



61
62
63
# File 'lib/shippinglogic/fedex.rb', line 61

def cancel(attributes = {})
  @cancel ||= Cancel.new(self, attributes)
end

#rate(attributes = {}) ⇒ Object



65
66
67
# File 'lib/shippinglogic/fedex.rb', line 65

def rate(attributes = {})
  @rate ||= Rate.new(self, attributes)
end

#ship(attributes = {}) ⇒ Object



69
70
71
# File 'lib/shippinglogic/fedex.rb', line 69

def ship(attributes = {})
  @ship ||= Ship.new(self, attributes)
end

#signature(attributes = {}) ⇒ Object



73
74
75
# File 'lib/shippinglogic/fedex.rb', line 73

def signature(attributes = {})
  @signature ||= Signature.new(self, attributes)
end

#track(attributes = {}) ⇒ Object



77
78
79
# File 'lib/shippinglogic/fedex.rb', line 77

def track(attributes = {})
  @track ||= Track.new(self, attributes)
end