Class: Shippinglogic::UPS
- Inherits:
-
Object
- Object
- Shippinglogic::UPS
- Defined in:
- lib/shippinglogic/ups.rb,
lib/shippinglogic/ups/rate.rb,
lib/shippinglogic/ups/error.rb,
lib/shippinglogic/ups/label.rb,
lib/shippinglogic/ups/track.rb,
lib/shippinglogic/ups/cancel.rb,
lib/shippinglogic/ups/request.rb,
lib/shippinglogic/ups/service.rb,
lib/shippinglogic/ups/response.rb,
lib/shippinglogic/ups/ship_accept.rb,
lib/shippinglogic/ups/enumerations.rb,
lib/shippinglogic/ups/ship_confirm.rb
Defined Under Namespace
Modules: Enumerations, Request, Response Classes: Cancel, Error, Label, Rate, Service, ShipAccept, ShipConfirm, Track
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#key ⇒ Object
Returns the value of attribute key.
-
#number ⇒ Object
Returns the value of attribute number.
-
#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, number, options = {}) ⇒ UPS
constructor
Before you can use the UPS web services you need to provide 4 credentials:.
- #label(attributes = {}) ⇒ Object
- #rate(attributes = {}) ⇒ Object
- #ship(attributes = {}) ⇒ Object
- #ship_accept(attributes = {}) ⇒ Object
- #ship_confirm(attributes = {}) ⇒ Object
- #track(attributes = {}) ⇒ Object
-
#url ⇒ Object
A convenience method for accessing the endpoint URL for the UPS API.
Constructor Details
#initialize(key, password, account, number, options = {}) ⇒ UPS
Before you can use the UPS web services you need to provide 4 credentials:
-
Your UPS access key
-
Your UPS password
-
Your UPS user ID
-
Your 6-character UPS account number
TODO Explain how to acquire those 4 credentials.
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.
42 43 44 45 46 47 48 |
# File 'lib/shippinglogic/ups.rb', line 42 def initialize(key, password, account, number, = {}) self.key = key self.password = password self.account = account self.number = number self. = self.class..merge() end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
28 29 30 |
# File 'lib/shippinglogic/ups.rb', line 28 def account @account end |
#key ⇒ Object
Returns the value of attribute key.
28 29 30 |
# File 'lib/shippinglogic/ups.rb', line 28 def key @key end |
#number ⇒ Object
Returns the value of attribute number.
28 29 30 |
# File 'lib/shippinglogic/ups.rb', line 28 def number @number end |
#options ⇒ Object
Returns the value of attribute options.
28 29 30 |
# File 'lib/shippinglogic/ups.rb', line 28 def @options end |
#password ⇒ Object
Returns the value of attribute password.
28 29 30 |
# File 'lib/shippinglogic/ups.rb', line 28 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 UPS 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 UPS’s webservices. (default: wwwcie.ups.com:443/ups.app/xml) -
:production_url
- the production URL for UPS’s webservices. (default: www.ups.com:443/ups.app/xml)
20 21 22 23 24 25 26 |
# File 'lib/shippinglogic/ups.rb', line 20 def self. @options ||= { :test => !!(defined?(Rails) && !Rails.env.production?), :production_url => "https://www.ups.com:443/ups.app/xml", :test_url => "https://wwwcie.ups.com:443/ups.app/xml" } end |
Instance Method Details
#cancel(attributes = {}) ⇒ Object
55 56 57 |
# File 'lib/shippinglogic/ups.rb', line 55 def cancel(attributes = {}) @cancel ||= Cancel.new(self, attributes) end |
#label(attributes = {}) ⇒ Object
79 80 81 |
# File 'lib/shippinglogic/ups.rb', line 79 def label(attributes = {}) @label ||= Label.new(self, attributes) end |
#rate(attributes = {}) ⇒ Object
59 60 61 |
# File 'lib/shippinglogic/ups.rb', line 59 def rate(attributes = {}) @rate ||= Rate.new(self, attributes) end |
#ship(attributes = {}) ⇒ Object
71 72 73 |
# File 'lib/shippinglogic/ups.rb', line 71 def ship(attributes = {}) @ship ||= ship_accept(:digest => ship_confirm(attributes).digest) end |
#ship_accept(attributes = {}) ⇒ Object
67 68 69 |
# File 'lib/shippinglogic/ups.rb', line 67 def ship_accept(attributes = {}) @ship_accept ||= ShipAccept.new(self, attributes) end |
#ship_confirm(attributes = {}) ⇒ Object
63 64 65 |
# File 'lib/shippinglogic/ups.rb', line 63 def ship_confirm(attributes = {}) @ship_confirm ||= ShipConfirm.new(self, attributes) end |
#track(attributes = {}) ⇒ Object
75 76 77 |
# File 'lib/shippinglogic/ups.rb', line 75 def track(attributes = {}) @track ||= Track.new(self, attributes) end |
#url ⇒ Object
A convenience method for accessing the endpoint URL for the UPS API.
51 52 53 |
# File 'lib/shippinglogic/ups.rb', line 51 def url [:test] ? [:test_url] : [:production_url] end |