Class: FriendlyShipping::Services::RL::RateQuoteOptions

Inherits:
ShipmentOptions show all
Defined in:
lib/friendly_shipping/services/rl/rate_quote_options.rb

Overview

Rate quote options for serializing R+L API requests.

Constant Summary collapse

ADDITIONAL_SERVICE_CODES =

Optional service codes that can be used for R+L shipments.

%w[
  InsideDelivery
  LimitedAccessPickup
  LimitedAccessDelivery
  OriginLiftgate
  DestinationLiftgate
  DeliveryAppointment
  Hazmat
  InsidePickup
  Freezable
  SortAndSegregate
  OverDimension
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ShipmentOptions

#options_for_structure

Methods inherited from FriendlyShipping::ShipmentOptions

#options_for_package

Constructor Details

#initialize(pickup_date:, declared_value: nil, additional_service_codes: [], structures_serializer: RateQuoteStructuresSerializer, packages_serializer: RateQuotePackagesSerializer, **kwargs) ⇒ RateQuoteOptions

Returns a new instance of RateQuoteOptions.

Parameters:

  • pickup_date (Time)

    the pickup date

  • declared_value (Numeric) (defaults to: nil)

    the declared value of this shipment

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

    additional service codes

  • structures_serializer (Callable) (defaults to: RateQuoteStructuresSerializer)

    a callable that takes structures and an options object to create an Array of item hashes per the R+L Carriers docs

  • packages_serializer (Callable) (defaults to: RateQuotePackagesSerializer)

    a callable that takes packages and an options object to create an Array of item hashes per the R+L Carriers docs (DEPRECATED: use structures_serializer instead)

  • 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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/friendly_shipping/services/rl/rate_quote_options.rb', line 34

def initialize(
  pickup_date:,
  declared_value: nil,
  additional_service_codes: [],
  structures_serializer: RateQuoteStructuresSerializer,
  packages_serializer: RateQuotePackagesSerializer,
  **kwargs
)
  @pickup_date = pickup_date
  @declared_value = declared_value
  @additional_service_codes = additional_service_codes
  @structures_serializer = structures_serializer
  @packages_serializer = packages_serializer
  validate_additional_service_codes!
  super(**kwargs.reverse_merge(package_options_class: PackageOptions))
end

Instance Attribute Details

#additional_service_codesArray<String> (readonly)

Returns additional service codes.

Returns:

  • (Array<String>)

    additional service codes



15
16
17
# File 'lib/friendly_shipping/services/rl/rate_quote_options.rb', line 15

def additional_service_codes
  @additional_service_codes
end

#declared_valueNumeric (readonly)

Returns the declared value of this shipment.

Returns:

  • (Numeric)

    the declared value of this shipment



12
13
14
# File 'lib/friendly_shipping/services/rl/rate_quote_options.rb', line 12

def declared_value
  @declared_value
end

#packages_serializerCallable (readonly)

Deprecated.

Returns the serializer for this shipment's packages.

Returns:

  • (Callable)

    the serializer for this shipment's packages



22
23
24
# File 'lib/friendly_shipping/services/rl/rate_quote_options.rb', line 22

def packages_serializer
  @packages_serializer
end

#pickup_dateTime (readonly)

Returns the pickup date.

Returns:

  • (Time)

    the pickup date



9
10
11
# File 'lib/friendly_shipping/services/rl/rate_quote_options.rb', line 9

def pickup_date
  @pickup_date
end

#structures_serializerCallable (readonly)

Returns the serializer for this shipment's structures.

Returns:

  • (Callable)

    the serializer for this shipment's structures



18
19
20
# File 'lib/friendly_shipping/services/rl/rate_quote_options.rb', line 18

def structures_serializer
  @structures_serializer
end