Class: SimpleShipping::Demo::Ups
- Defined in:
- lib/simple_shipping/demo/ups.rb
Overview
Helper object to send demo requests to UPS in order to test credentials and the library.
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Ups
constructor
A new instance of Ups.
-
#package ⇒ SimpleShipping::Package
Build the package object.
-
#ship_client ⇒ SimpleShipping::Ups::ShipClient
Initialize the UPS client for shipment requests.
-
#shipment_identification_number ⇒ String
Shipment Id.
-
#shipment_request ⇒ ShipClient::Ups::ShipmentResponse
Send a shipment request.
-
#void_client ⇒ SimpleShipping::Ups::VoidClient
Initialize the UPS client for void requests.
-
#void_request ⇒ ShipClient::Ups::VoidResponse
Send a request to void a shipment.
Methods inherited from Base
#recipient, #recipient_address, #recipient_contact, #shipper, #shipper_address, #shipper_contact
Constructor Details
#initialize(options = {}) ⇒ Ups
Returns a new instance of Ups.
10 11 12 13 14 15 |
# File 'lib/simple_shipping/demo/ups.rb', line 10 def initialize( = {}) @options = .reverse_merge( :log => false, :service_type => :second_day_air ) end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
8 9 10 |
# File 'lib/simple_shipping/demo/ups.rb', line 8 def credentials @credentials end |
Instance Method Details
#package ⇒ SimpleShipping::Package
Build the package object.
20 21 22 23 24 25 |
# File 'lib/simple_shipping/demo/ups.rb', line 20 def package @package ||= SimpleShipping::Package.new( :weight => 0.5, :packaging_type => :envelope ) end |
#ship_client ⇒ SimpleShipping::Ups::ShipClient
Initialize the UPS client for shipment requests.
30 31 32 33 34 35 |
# File 'lib/simple_shipping/demo/ups.rb', line 30 def ship_client @ship_client ||= SimpleShipping::Ups::ShipClient.new( :credentials => .slice(:username, :password, :access_license_number), :log => [:log] ) end |
#shipment_identification_number ⇒ String
Shipment Id. The number is picked randomly.
51 52 53 |
# File 'lib/simple_shipping/demo/ups.rb', line 51 def shipment_identification_number @shipment_identification_number ||= '1234567890' end |
#shipment_request ⇒ ShipClient::Ups::ShipmentResponse
Send a shipment request.
58 59 60 |
# File 'lib/simple_shipping/demo/ups.rb', line 58 def shipment_request ship_client.shipment_request(shipper, recipient, package, :service_type => [:service_type]) end |
#void_client ⇒ SimpleShipping::Ups::VoidClient
Initialize the UPS client for void requests.
40 41 42 43 44 45 46 |
# File 'lib/simple_shipping/demo/ups.rb', line 40 def void_client @void_client ||= SimpleShipping::Ups::VoidClient.new( :credentials => .slice(:username, :password, :access_license_number), :log => [:log], :live => [:live] ) end |
#void_request ⇒ ShipClient::Ups::VoidResponse
Send a request to void a shipment.
65 66 67 |
# File 'lib/simple_shipping/demo/ups.rb', line 65 def void_request void_client.void_request(shipment_identification_number) end |