Class: Shippinglogic::FedEx

Inherits:
Object
  • Object
show all
Defined in:
lib/shippinglogic/fedex.rb,
lib/shippinglogic/fedex/ship.rb,
lib/shippinglogic/fedex/rate.rb,
lib/shippinglogic/fedex/error.rb,
lib/shippinglogic/fedex/track.rb,
lib/shippinglogic/fedex/cancel.rb,
lib/shippinglogic/fedex/service.rb,
lib/shippinglogic/fedex/request.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)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

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

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.



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

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

- (Object) account

Returns the value of attribute account



31
32
33
# File 'lib/shippinglogic/fedex.rb', line 31

def 
  @account
end

- (Object) key

Returns the value of attribute key



31
32
33
# File 'lib/shippinglogic/fedex.rb', line 31

def key
  @key
end

- (Object) meter

Returns the value of attribute meter



31
32
33
# File 'lib/shippinglogic/fedex.rb', line 31

def meter
  @meter
end

- (Object) options

Returns the value of attribute options



31
32
33
# File 'lib/shippinglogic/fedex.rb', line 31

def options
  @options
end

- (Object) password

Returns the value of attribute password



31
32
33
# File 'lib/shippinglogic/fedex.rb', line 31

def password
  @password
end

Class Method Details

+ (Object) options

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
  @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

- (Object) cancel(attributes = {})



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

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

- (Object) rate(attributes = {})



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

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

- (Object) ship(attributes = {})



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

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

- (Object) signature(attributes = {})



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

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

- (Object) track(attributes = {})



80
81
82
# File 'lib/shippinglogic/fedex.rb', line 80

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

- (Object) url

A convenience method for accessing the endpoint URL for the FedEx API.



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

def url
  options[:test] ? options[:test_url] : options[:production_url]
end