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.

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)



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)



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)



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)



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)



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

def document_options
  @document_options
end

#handling_instructionsString (readonly)



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

def handling_instructions
  @handling_instructions
end

#pickup_atTime (readonly)



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

def pickup_at
  @pickup_at
end

#pickup_instructionsString (readonly)



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)



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)



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)



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)



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

def reference_numbers
  @reference_numbers
end

#service_codeString (readonly)



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)



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

def time_in_transit
  @time_in_transit
end