Class: FriendlyShipping::Services::UpsFreight::RatesOptions

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

Overview

Options for generating UPS Freight rates for a shipment

Direct Known Subclasses

LabelOptions

Constant Summary collapse

BILLING_CODES =
{
  prepaid: '10',
  third_party: '30',
  freight_collect: '40'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FriendlyShipping::ShipmentOptions

#options_for_package

Constructor Details

#initialize(shipper_number:, billing_address:, shipping_method:, billing: :prepaid, customer_context: nil, pickup_request_options: nil, commodity_information_generator: GenerateCommodityInformation, **kwargs) ⇒ RatesOptions

Returns a new instance of RatesOptions.

Parameters:

  • shipper_number (String)

    the shipper number associated with the shipper

  • billing_address (Physical::Location)

    the billing address

  • shipping_method (FriendlyShipping::ShippingMethod)

    the shipping method to use

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

    how the shipment is billed (see BILLING_CODES)

  • customer_context (String) (defaults to: nil)

    a reference to match this request with an order or shipment

  • pickup_request_options (PickupRequestOptions) (defaults to: nil)

    options for the pickup request

  • 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



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 43

def initialize(
  shipper_number:,
  billing_address:,
  shipping_method:,
  billing: :prepaid,
  customer_context: nil,
  pickup_request_options: nil,
  commodity_information_generator: GenerateCommodityInformation,
  **kwargs
)
  @shipper_number = shipper_number
  @billing_address = billing_address
  @shipping_method = shipping_method
  @billing_code = BILLING_CODES.fetch(billing)
  @customer_context = customer_context
  @pickup_request_options = pickup_request_options
  @commodity_information_generator = commodity_information_generator
  super(**kwargs.reverse_merge(package_options_class: RatesPackageOptions))
end

Instance Attribute Details

#billing_addressPhysical::Location (readonly)

Returns:

  • (Physical::Location)


18
19
20
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 18

def billing_address
  @billing_address
end

#billing_codeSymbol (readonly)

Returns:

  • (Symbol)


21
22
23
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 21

def billing_code
  @billing_code
end

#commodity_information_generatorCallable (readonly)

Returns:

  • (Callable)


33
34
35
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 33

def commodity_information_generator
  @commodity_information_generator
end

#customer_contextString (readonly)

Returns:

  • (String)


24
25
26
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 24

def customer_context
  @customer_context
end

#pickup_request_optionsPickupRequestOptions (readonly)



30
31
32
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 30

def pickup_request_options
  @pickup_request_options
end

#shipper_numberString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 15

def shipper_number
  @shipper_number
end

#shipping_methodFriendlyShipping::ShippingMethod (readonly)



27
28
29
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 27

def shipping_method
  @shipping_method
end