Class: FriendlyShipping::Services::ShipEngine::RateEstimatesOptions

Inherits:
FriendlyShipping::ShipmentOptions show all
Defined in:
lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb

Overview

Options for the rate estimates API call.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FriendlyShipping::ShipmentOptions

#options_for_package

Constructor Details

#initialize(carriers:, ship_date: Date.today, **kwargs) ⇒ RateEstimatesOptions

Returns a new instance of RateEstimatesOptions.

Parameters:

  • carriers (Array<Carrier] the carriers for these rate estimates)

    arriers [Array<Carrier] the carriers for these rate estimates

  • ship_date (#strftime) (defaults to: Date.today)

    the date we want to ship on

  • 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



19
20
21
22
23
24
25
26
27
# File 'lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb', line 19

def initialize(
  carriers:,
  ship_date: Date.today,
  **kwargs
)
  @carriers = carriers
  @ship_date = ship_date
  super(**kwargs)
end

Instance Attribute Details

#carriersArray<Carrier> (readonly)

Returns the carriers for these rate estimates.

Returns:

  • (Array<Carrier>)

    the carriers for these rate estimates



9
10
11
# File 'lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb', line 9

def carriers
  @carriers
end

#ship_date#strftime (readonly)

Returns:

  • (#strftime)


12
13
14
# File 'lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb', line 12

def ship_date
  @ship_date
end

Instance Method Details

#carrier_idsArray<String>

Returns the carrier IDs for these rate estimates.

Returns:

  • (Array<String>)

    the carrier IDs for these rate estimates



30
31
32
# File 'lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb', line 30

def carrier_ids
  carriers.map(&:id)
end