Class: FriendlyShipping::Services::TForceFreight::RatesOptions

Inherits:
FriendlyShipping::ShipmentOptions show all
Defined in:
lib/friendly_shipping/services/tforce_freight/rates_options.rb

Overview

Options for getting rates for a shipment.

Constant Summary collapse

BILLING_CODES =

Maps friendly names to billing codes.

{
  prepaid: "10",
  third_party: "30",
  freight_collect: "40"
}.freeze
TYPE_CODES =

Maps friendly names to type codes.

{
  l: "L", # LTL (Less Than Truckload) only
  f: "F", # GFP (Ground w/Freight Pricing) only
  b: "B"  # Both (LTL and GFP)
}.freeze
PICKUP_OPTIONS =

Maps friendly names to pickup options.

{
  inside: "INPU",
  liftgate: "LIFO",
  limited_access: "LAPU",
  holiday: "WHPU",
  weekend: "WHPU",
  tradeshow: "TRPU",
  residential: "RESP"
}.freeze
DELIVERY_OPTIONS =

Maps friendly names to delivery options.

{
  inside: "INDE",
  liftgate: "LIFD",
  limited_access: "LADL",
  holiday: "WHDL",
  weekend: "WHDL",
  call_consignee: "NTFN",
  tradeshow: "TRDS",
  residential: "RESD"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FriendlyShipping::ShipmentOptions

#options_for_package

Constructor Details

#initialize(billing_address:, shipping_method:, pickup_date: Date.today, billing: :prepaid, type: :l, density_eligible: false, accessorial_rate: false, time_in_transit: true, quote_number: false, pickup_options: [], delivery_options: [], customer_context: nil, commodity_information_generator: GenerateCommodityInformation, **kwargs) ⇒ RatesOptions

Returns a new instance of RatesOptions.

Parameters:

  • billing_address (Physical::Location)

    the billing address

  • shipping_method (ShippingMethod)

    the shipping method to use

  • pickup_date (Date) (defaults to: Date.today)

    date of the pickup (defaults to today)

  • billing (Symbol) (defaults to: :prepaid)

    how the shipment is billed (see BILLING_CODES)

  • type (String) (defaults to: :l)

    rating call type (defaults to L, see TYPE_CODES)

  • density_eligible (Boolean) (defaults to: false)

    indicates that the rate request is density based (defaults to false)

  • accessorial_rate (Boolean) (defaults to: false)

    indicates that the rate is accessorial (defaults to false)

  • time_in_transit (Boolean) (defaults to: true)

    requests transit timing information be included in the response (defaults to true)

  • quote_number (Boolean) (defaults to: false)

    requests a quote number be included in the response (defaults to false)

  • pickup_options (Array<String>) (defaults to: [])

    shipment pick up service options (see PICKUP_OPTIONS)

  • delivery_options (Array<String] shipment delivery service options (see {DELIVERY_OPTIONS})) (defaults to: [])

    elivery_options [Array<String] shipment delivery service options (see DELIVERY_OPTIONS)

  • customer_context (String) (defaults to: nil)

    a reference to match this request with an order or shipment (defaults to nil)

  • commodity_information_generator (Callable) (defaults to: GenerateCommodityInformation)

    a callable that takes a shipment and an options object to create an Array of commodity fields as per the UPS docs

  • kwargs (Hash)

Options Hash (**kwargs):

  • :package_options (Array<PackageOptions>)

    the options for packages in this shipment

  • :package_options_class (Class)

    the class to use for package options when none are provided



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 101

def initialize(
  billing_address:,
  shipping_method:,
  pickup_date: Date.today,
  billing: :prepaid,
  type: :l,
  density_eligible: false,
  accessorial_rate: false,
  time_in_transit: true,
  quote_number: false,
  pickup_options: [],
  delivery_options: [],
  customer_context: nil,
  commodity_information_generator: GenerateCommodityInformation,
  **kwargs
)
  @pickup_date = pickup_date
  @billing_address = billing_address
  @billing_code = BILLING_CODES.fetch(billing)
  @shipping_method = shipping_method
  @type_code = TYPE_CODES.fetch(type)
  @density_eligible = density_eligible
  @accessorial_rate = accessorial_rate
  @time_in_transit = time_in_transit
  @quote_number = quote_number
  @pickup_options = pickup_options
  @delivery_options = delivery_options
  @customer_context = customer_context
  @commodity_information_generator = commodity_information_generator

  validate_pickup_options!
  validate_delivery_options!

  super(**kwargs.reverse_merge(package_options_class: PackageOptions))
end

Instance Attribute Details

#accessorial_rateBoolean (readonly)

Returns indicates that the rate is accessorial.

Returns:

  • (Boolean)

    indicates that the rate is accessorial



64
65
66
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 64

def accessorial_rate
  @accessorial_rate
end

#billing_addressPhysical::Location (readonly)

Returns the billing address.

Returns:

  • (Physical::Location)

    the billing address



46
47
48
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 46

def billing_address
  @billing_address
end

#billing_codeSymbol (readonly)

Returns how the shipment is billed (see BILLING_CODES).

Returns:



55
56
57
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 55

def billing_code
  @billing_code
end

#commodity_information_generatorCallable (readonly)

Returns a callable that takes a shipment.

Returns:

  • (Callable)

    a callable that takes a shipment



82
83
84
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 82

def commodity_information_generator
  @commodity_information_generator
end

#customer_contextString (readonly)

Returns customer context.

Returns:

  • (String)

    customer context



79
80
81
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 79

def customer_context
  @customer_context
end

#delivery_optionsArray<String] shipment delivery service options (see {DELIVERY_OPTIONS}) (readonly)

Returns Array<String] shipment delivery service options (see DELIVERY_OPTIONS).

Returns:



76
77
78
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 76

def delivery_options
  @delivery_options
end

#density_eligibleBoolean (readonly)

Returns indicates that the rate request is density based.

Returns:

  • (Boolean)

    indicates that the rate request is density based



61
62
63
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 61

def density_eligible
  @density_eligible
end

#pickup_dateDate (readonly)

Returns date of the pickup.

Returns:

  • (Date)

    date of the pickup



52
53
54
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 52

def pickup_date
  @pickup_date
end

#pickup_optionsArray<String> (readonly)

Returns shipment pick up service options (see PICKUP_OPTIONS).

Returns:

  • (Array<String>)

    shipment pick up service options (see PICKUP_OPTIONS)



73
74
75
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 73

def pickup_options
  @pickup_options
end

#quote_numberBoolean (readonly)

Returns requests a quote number be included in the response.

Returns:

  • (Boolean)

    requests a quote number be included in the response



70
71
72
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 70

def quote_number
  @quote_number
end

#shipping_methodShippingMethod (readonly)

Returns the shipping method.

Returns:



49
50
51
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 49

def shipping_method
  @shipping_method
end

#time_in_transitBoolean (readonly)

Returns requests transit timing information be included in the response.

Returns:

  • (Boolean)

    requests transit timing information be included in the response



67
68
69
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 67

def time_in_transit
  @time_in_transit
end

#type_codeString (readonly)

Returns rating call type (see TYPE_CODES).

Returns:



58
59
60
# File 'lib/friendly_shipping/services/tforce_freight/rates_options.rb', line 58

def type_code
  @type_code
end