Class: Shippinglogic::UPS::Rate

Inherits:
Service show all
Defined in:
lib/shippinglogic/ups/rate.rb

Overview

An interface to the rate services provided by UPS. Allows you to get an array of rates from UPS for a shipment, or a single rate for a specific service.

Options

Shipper options

  • shipper_name - name of the shipper.

  • shipper_streets - street part of the address, separate multiple streets with a new line, dont include blank lines.

  • shipper_city - city part of the address.

  • shipper_state_ - state part of the address, use state abreviations.

  • shipper_postal_code - postal code part of the address. Ex: zip for the US.

  • shipper_country - country code part of the address. UPS expects abbreviations, but Shippinglogic will convert full names to abbreviations for you.

Recipient options

  • recipient_name - name of the recipient.

  • recipient_streets - street part of the address, separate multiple streets with a new line, dont include blank lines.

  • recipient_city - city part of the address.

  • recipient_state - state part of the address, use state abreviations.

  • recipient_postal_code - postal code part of the address. Ex: zip for the US.

  • recipient_country - country code part of the address. UPS expects abbreviations, but Shippinglogic will convert full names to abbreviations for you.

  • recipient_residential - a boolean value representing if the address is redential or not (default: false)

Packaging options

One thing to note is that UPS does support multiple package shipments. The problem is that all of the packages must be identical. UPS specifically notes in their documentation that mutiple package specifications are not allowed. So your only option for a multi package shipment is to increase the package_count option and keep the dimensions and weight the same for all packages. Then again, the documentation for the UPS web services is terrible, so I could be wrong. Any tests I tried resulted in an error though.

  • packaging_type - one of PACKAGE_TYPES. (default: YOUR_PACKAGING)

  • package_count - the number of packages in your shipment. (default: 1)

  • package_weight - a single packages weight.

  • package_weight_units - either LB or KG. (default: LB)

  • package_length - a single packages length, only required if using YOUR_PACKAGING for packaging_type.

  • package_width - a single packages width, only required if using YOUR_PACKAGING for packaging_type.

  • package_height - a single packages height, only required if using YOUR_PACKAGING for packaging_type.

  • package_dimension_units - either IN or CM. (default: IN)

Monetary options

  • currency_type - the type of currency. (default: nil, because UPS will default to your account preferences)

  • insured_value - the value you want to insure, if any. (default: nil)

  • payor_account_number - if the account paying for this ship is different than the account you specified then you can specify that here. (default: your account number)

Delivery options

  • service_type - one of SERVICE_TYPES, this is optional, leave this blank if you want a list of all available services. (default: nil)

  • delivery_deadline - whether or not to include estimated transit times. (default: true)

  • dropoff_type - one of DROP_OFF_TYPES. (default: REGULAR_PICKUP)

Misc options

  • documents_only - whether the package consists of only documents (default: false)

Simple Example

Here is a very simple example. Mix and match the options above to get more accurate rates:

ups = Shippinglogic::UPS.new(key, password, )
rates = ups.rate(
  :shipper_postal_code => "10007",
  :shipper_country => "US",
  :recipient_postal_code => "75201",
  :recipient_country_code => "US",
  :package_weight => 24,
  :package_length => 12,
  :package_width => 12,
  :package_height => 12
)

rates.first
#<Shippinglogic::UPS::Rate::Service:0x10354d108 @currency="USD", @speed=nil,
  @rate=#<BigDecimal:10353ac10,'0.1885E2',18(18)>, @type="Ground", @name="Ground">

# to show accessor methods
rates.first.name
# => "Ground"

Defined Under Namespace

Classes: Service

Instance Attribute Summary

Attributes inherited from Service

#base

Class Method Summary (collapse)

Methods inherited from Service

#initialize

Methods included from Validation

#errors, #valid?

Methods included from Attributes

included

Methods inherited from Proxy

#initialize

Constructor Details

This class inherits a constructor from Shippinglogic::Service

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Shippinglogic::Proxy

Class Method Details

+ (Object) path



84
85
86
# File 'lib/shippinglogic/ups/rate.rb', line 84

def self.path
  "/Rate"
end