Class: FriendlyShipping::Services::TForceFreight::BOLOptions

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

Overview

Options for creating a Bill of Lading (BOL).

Constant Summary collapse

BILLING_CODES =

Maps friendly names to billing codes.

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

Maps friendly names to reference number codes.

{
  bill_of_lading_number: "BL",
  purchase_order_number: "PO",
  shipper_reference: "SH",
  consignee_reference: "CO",
  pm: "PM",
  proj: "PROJ",
  quote: "QUOTE",
  sid: "SID",
  task: "TASK",
  vprc: "VPRC",
  other: "OTHER"
}.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(service_code: FriendlyShipping::Services::TForceFreight::SHIPPING_METHODS.first.service_code, pickup_at: Time.now, pickup_time_window: Time.now.beginning_of_day..Time.now.end_of_day, preview_rate: false, time_in_transit: false, billing: :prepaid, reference_numbers: [], pickup_instructions: nil, handling_instructions: nil, delivery_instructions: nil, pickup_options: [], delivery_options: [], document_options: [], commodity_information_generator: GenerateCommodityInformation, **kwargs) ⇒ BOLOptions

Returns a new instance of BOLOptions.

Parameters:

  • service_code (String) (defaults to: FriendlyShipping::Services::TForceFreight::SHIPPING_METHODS.first.service_code)

    the service code to use

  • pickup_at (Time) (defaults to: Time.now)

    date/time of pickup (defaults to now)

  • pickup_time_window (Range) (defaults to: Time.now.beginning_of_day..Time.now.end_of_day)

    time window for pickup (defaults to start/end of today)

  • preview_rate (Boolean) (defaults to: false)

    whether to preview rates in the response

  • time_in_transit (Boolean) (defaults to: false)

    whether to include time in transit in the response

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

    how to bill this shipment (see BILLING_CODES)

  • reference_numbers (Array<Hash>) (defaults to: [])

    reference numbers for this shipment (see REFERENCE_NUMBER_CODES)

  • pickup_instructions (String) (defaults to: nil)

    instructions for pickup

  • handling_instructions (String) (defaults to: nil)

    instructions for handling

  • delivery_instructions (String) (defaults to: nil)

    instructions for delivery

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

    options for pickup (see PICKUP_OPTIONS)

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

    options for delivery (see DELIVERY_OPTIONS)

  • document_options (Array<DocumentOptions>) (defaults to: [])

    options for documents

  • commodity_information_generator (Proc, #call) (defaults to: GenerateCommodityInformation)

    the callable used generate commodity information

  • 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



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 112

def initialize(
  service_code: FriendlyShipping::Services::TForceFreight::SHIPPING_METHODS.first.service_code,
  pickup_at: Time.now,
  pickup_time_window: Time.now.beginning_of_day..Time.now.end_of_day,
  preview_rate: false,
  time_in_transit: false,
  billing: :prepaid,
  reference_numbers: [],
  pickup_instructions: nil,
  handling_instructions: nil,
  delivery_instructions: nil,
  pickup_options: [],
  delivery_options: [],
  document_options: [],
  commodity_information_generator: GenerateCommodityInformation,
  **kwargs
)
  @service_code = service_code
  @pickup_at = pickup_at
  @pickup_time_window = pickup_time_window
  @preview_rate = preview_rate
  @time_in_transit = time_in_transit
  @billing_code = BILLING_CODES.fetch(billing)
  @reference_numbers = fill_codes(reference_numbers)
  @pickup_instructions = pickup_instructions
  @handling_instructions = handling_instructions
  @delivery_instructions = delivery_instructions
  @pickup_options = pickup_options
  @delivery_options = delivery_options
  @document_options = document_options
  @commodity_information_generator = commodity_information_generator

  validate_pickup_options!
  validate_delivery_options!

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

Instance Attribute Details

#billing_codeString (readonly)

Returns code indicating how to bill this shipment (see BILLING_CODES).

Returns:

  • (String)

    code indicating how to bill this shipment (see BILLING_CODES)



69
70
71
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 69

def billing_code
  @billing_code
end

#commodity_information_generatorProc, #call (readonly)

Returns the callable used generate commodity information.

Returns:

  • (Proc, #call)

    the callable used generate commodity information



93
94
95
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 93

def commodity_information_generator
  @commodity_information_generator
end

#delivery_instructionsString (readonly)

Returns instructions for delivery.

Returns:

  • (String)

    instructions for delivery



81
82
83
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 81

def delivery_instructions
  @delivery_instructions
end

#delivery_optionsArray<String> (readonly)

Returns options for delivery (see DELIVERY_OPTIONS).

Returns:



87
88
89
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 87

def delivery_options
  @delivery_options
end

#document_optionsArray<DocumentOptions> (readonly)

Returns options for documents.

Returns:



90
91
92
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 90

def document_options
  @document_options
end

#handling_instructionsString (readonly)

Returns instructions for handling.

Returns:

  • (String)

    instructions for handling



78
79
80
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 78

def handling_instructions
  @handling_instructions
end

#pickup_atTime (readonly)

Returns date/time of pickup.

Returns:

  • (Time)

    date/time of pickup



57
58
59
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 57

def pickup_at
  @pickup_at
end

#pickup_instructionsString (readonly)

Returns instructions for pickup.

Returns:

  • (String)

    instructions for pickup



75
76
77
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 75

def pickup_instructions
  @pickup_instructions
end

#pickup_optionsArray<String> (readonly)

Returns options for pickup (see PICKUP_OPTIONS).

Returns:



84
85
86
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 84

def pickup_options
  @pickup_options
end

#pickup_time_windowRange (readonly)

Returns time window for pickup.

Returns:

  • (Range)

    time window for pickup



60
61
62
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 60

def pickup_time_window
  @pickup_time_window
end

#preview_rateBoolean (readonly)

Returns whether to preview rates in the response.

Returns:

  • (Boolean)

    whether to preview rates in the response



63
64
65
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 63

def preview_rate
  @preview_rate
end

#reference_numbersArray<Hash> (readonly)

Returns reference numbers for this shipment (see REFERENCE_NUMBER_CODES).

Returns:



72
73
74
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 72

def reference_numbers
  @reference_numbers
end

#service_codeString (readonly)

Returns the service code to use.

Returns:

  • (String)

    the service code to use



54
55
56
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 54

def service_code
  @service_code
end

#time_in_transitBoolean (readonly)

Returns whether to include time in transit in the response.

Returns:

  • (Boolean)

    whether to include time in transit in the response



66
67
68
# File 'lib/friendly_shipping/services/tforce_freight/bol_options.rb', line 66

def time_in_transit
  @time_in_transit
end