Class: FriendlyShipping::Services::USPSShip::RateEstimateOptions

Inherits:
FriendlyShipping::ShipmentOptions show all
Defined in:
lib/friendly_shipping/services/usps_ship/rate_estimate_options.rb

Constant Summary collapse

DESTINATION_ENTRY_FACILITY_TYPES =
{
  none: "NONE",
  destination_network_distribution_center: "DESTINATION_NETWORK_DISTRIBUTION_CENTER",
  destination_sectional_center_facility: "DESTINATION_SECTIONAL_CENTER_FACILITY",
  destination_delivery_unit: "DESTINATION_DELIVERY_UNIT",
  destination_service_hub: "DESTINATION_SERVICE_HUB"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FriendlyShipping::ShipmentOptions

#options_for_package

Constructor Details

#initialize(shipping_method:, destination_entry_facility_type: :none, mailing_date: Date.today, package_options_class: FriendlyShipping::Services::USPSShip::RateEstimatePackageOptions, **kwargs) ⇒ RateEstimateOptions

Returns a new instance of RateEstimateOptions.

Parameters:

  • shipping_method (ShippingMethod)

    the shipping method for which we want a rate

  • destination_entry_facility_type (Symbol) (defaults to: :none)
  • mailing_date (#strftime) (defaults to: Date.today)

    the date on which we want to ship

  • package_options_class (Class) (defaults to: FriendlyShipping::Services::USPSShip::RateEstimatePackageOptions)

    the class to use for package options

  • kwargs (Hash)

Options Hash (**kwargs):

  • :package_options (Array<PackageOptions>)

    the options for packages in this shipment



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/friendly_shipping/services/usps_ship/rate_estimate_options.rb', line 30

def initialize(
  shipping_method:,
  destination_entry_facility_type: :none,
  mailing_date: Date.today,
  package_options_class: FriendlyShipping::Services::USPSShip::RateEstimatePackageOptions,
  **kwargs
)
  @shipping_method = shipping_method
  @destination_entry_facility_type = DESTINATION_ENTRY_FACILITY_TYPES.fetch(destination_entry_facility_type)
  @mailing_date = mailing_date
  super(**kwargs.reverse_merge(package_options_class: package_options_class))
end

Instance Attribute Details

#destination_entry_facility_typeString (readonly)

Returns:

  • (String)


19
20
21
# File 'lib/friendly_shipping/services/usps_ship/rate_estimate_options.rb', line 19

def destination_entry_facility_type
  @destination_entry_facility_type
end

#mailing_date#strftime (readonly)

Returns:

  • (#strftime)


22
23
24
# File 'lib/friendly_shipping/services/usps_ship/rate_estimate_options.rb', line 22

def mailing_date
  @mailing_date
end

#shipping_methodShippingMethod (readonly)

Returns:



16
17
18
# File 'lib/friendly_shipping/services/usps_ship/rate_estimate_options.rb', line 16

def shipping_method
  @shipping_method
end