Sha256: a6da70dc0aa8c9a393e40b7d5b1051621c97620b98ef383287ccbaa1ada090c9

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

require 'friendly_shipping/shipment_options'

module FriendlyShipping
  module Services
    class ShipEngine
      # Options for the rate estimates API call.
      class RateEstimatesOptions < ShipmentOptions
        # @return [Array<Carrier>] the carriers for these rate estimates
        attr_reader :carriers

        # @return [#strftime]
        attr_reader :ship_date

        # @param carriers [Array<Carrier] the carriers for these rate estimates
        # @param ship_date [#strftime] the date we want to ship on
        # @param kwargs [Hash]
        # @option kwargs [Array<PackageOptions>] :package_options the options for packages in this shipment
        # @option kwargs [Class] :package_options_class the class to use for package options when none are provided
        def initialize(
          carriers:,
          ship_date: Date.today,
          **kwargs
        )
          @carriers = carriers
          @ship_date = ship_date
          super(**kwargs)
        end

        # @return [Array<String>] the carrier IDs for these rate estimates
        def carrier_ids
          carriers.map(&:id)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
friendly_shipping-0.9.0 lib/friendly_shipping/services/ship_engine/rate_estimates_options.rb