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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 47

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)


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

def billing_address
  @billing_address
end

#billing_codeSymbol (readonly)

Returns:

  • (Symbol)


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

def billing_code
  @billing_code
end

#commodity_information_generatorCallable (readonly)

Returns:

  • (Callable)


37
38
39
# File 'lib/friendly_shipping/services/ups_freight/rates_options.rb', line 37

def commodity_information_generator
  @commodity_information_generator
end

#customer_contextString (readonly)

Returns:

  • (String)


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

def customer_context
  @customer_context
end

#pickup_request_optionsPickupRequestOptions (readonly)



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

def pickup_request_options
  @pickup_request_options
end

#shipper_numberString (readonly)

Returns:

  • (String)


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

def shipper_number
  @shipper_number
end

#shipping_methodFriendlyShipping::ShippingMethod (readonly)



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

def shipping_method
  @shipping_method
end