Class: FriendlyShipping::Services::TForceFreight::PickupOptions

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

Overview

Options for creating a pickup.

Constant Summary collapse

SERVICE_OPTIONS =

Maps friendly names to service options.

{
  inside: "INPU",
  liftgate: "LIFO",
  freezable: "PFFF",
  residential: "RESP",
  extreme_length: "EXLT",
  trade_show: "TRPU"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FriendlyShipping::ShipmentOptions

#options_for_package

Constructor Details

#initialize(pickup_at: Time.now, pickup_time_window: Time.now.beginning_of_day..Time.now.end_of_day, service_options: [], pickup_instructions: nil, handling_instructions: nil, delivery_instructions: nil, **kwargs) ⇒ PickupOptions

Returns a new instance of PickupOptions.

Parameters:

  • 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)

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

    shipment pickup service options (see SERVICE_OPTIONS)

  • 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

  • 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



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

def initialize(
  pickup_at: Time.now,
  pickup_time_window: Time.now.beginning_of_day..Time.now.end_of_day,
  service_options: [],
  pickup_instructions: nil,
  handling_instructions: nil,
  delivery_instructions: nil,
  **kwargs
)
  @pickup_at = pickup_at
  @pickup_time_window = pickup_time_window
  @service_options = service_options
  @pickup_instructions = pickup_instructions
  @handling_instructions = handling_instructions
  @delivery_instructions = delivery_instructions

  validate_service_options!

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

Instance Attribute Details

#delivery_instructionsString (readonly)

Returns instructions for delivery.

Returns:

  • (String)

    instructions for delivery



34
35
36
# File 'lib/friendly_shipping/services/tforce_freight/pickup_options.rb', line 34

def delivery_instructions
  @delivery_instructions
end

#handling_instructionsString (readonly)

Returns instructions for handling.

Returns:

  • (String)

    instructions for handling



31
32
33
# File 'lib/friendly_shipping/services/tforce_freight/pickup_options.rb', line 31

def handling_instructions
  @handling_instructions
end

#pickup_atTime (readonly)

Returns date/time of pickup.

Returns:

  • (Time)

    date/time of pickup



19
20
21
# File 'lib/friendly_shipping/services/tforce_freight/pickup_options.rb', line 19

def pickup_at
  @pickup_at
end

#pickup_instructionsString (readonly)

Returns instructions for pickup.

Returns:

  • (String)

    instructions for pickup



28
29
30
# File 'lib/friendly_shipping/services/tforce_freight/pickup_options.rb', line 28

def pickup_instructions
  @pickup_instructions
end

#pickup_time_windowRange (readonly)

Returns time window for pickup.

Returns:

  • (Range)

    time window for pickup



22
23
24
# File 'lib/friendly_shipping/services/tforce_freight/pickup_options.rb', line 22

def pickup_time_window
  @pickup_time_window
end

#service_optionsArray<String> (readonly)

Returns shipment pickup service options (see SERVICE_OPTIONS).

Returns:

  • (Array<String>)

    shipment pickup service options (see SERVICE_OPTIONS)



25
26
27
# File 'lib/friendly_shipping/services/tforce_freight/pickup_options.rb', line 25

def service_options
  @service_options
end