class SimpleShipping::Demo::Ups

Helper object to send demo requests to UPS in order to test credentials and the library.

@example

demo = SimpleShipping::Demo::Ups.new(credentials)
response = demo.shipment_request

Attributes

credentials[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/simple_shipping/demo/ups.rb, line 10
def initialize(options = {})
  @options = options.reverse_merge(
      :log          => false,
      :service_type => :second_day_air
  )
end

Public Instance Methods

package() click to toggle source

Build the package object.

@return [SimpleShipping::Package]

# File lib/simple_shipping/demo/ups.rb, line 20
def package
  @package ||= SimpleShipping::Package.new(
      :weight         => 0.5,
      :packaging_type => :envelope
  )
end
ship_client() click to toggle source

Initialize the UPS client for shipment requests.

@return [SimpleShipping::Ups::ShipClient]

# File lib/simple_shipping/demo/ups.rb, line 30
def ship_client
  @ship_client ||= SimpleShipping::Ups::ShipClient.new(
      :credentials => options.slice(:username, :password, :access_license_number),
      :log         => options[:log]
  )
end
shipment_identification_number() click to toggle source

Shipment Id. The number is picked randomly.

@return [String]

# File lib/simple_shipping/demo/ups.rb, line 51
def shipment_identification_number
  @shipment_identification_number ||= '1234567890'
end
shipment_request() click to toggle source

Send a shipment request.

@return [ShipClient::Ups::ShipmentResponse]

# File lib/simple_shipping/demo/ups.rb, line 58
def shipment_request
  ship_client.shipment_request(shipper, recipient, package, :service_type => options[:service_type])
end
void_client() click to toggle source

Initialize the UPS client for void requests.

@return [SimpleShipping::Ups::VoidClient]

# File lib/simple_shipping/demo/ups.rb, line 40
def void_client
  @void_client ||= SimpleShipping::Ups::VoidClient.new(
      :credentials => options.slice(:username, :password, :access_license_number),
      :log         => options[:log],
      :live        => options[:live]
  )
end
void_request() click to toggle source

Send a request to void a shipment.

@return [ShipClient::Ups::VoidResponse]

# File lib/simple_shipping/demo/ups.rb, line 65
def void_request
  void_client.void_request(shipment_identification_number)
end