Class: FriendlyShipping::ShipmentOptions
- Inherits:
-
Object
- Object
- FriendlyShipping::ShipmentOptions
- Defined in:
- lib/friendly_shipping/shipment_options.rb
Overview
Base class for shipment options. Used when serializing API requests.
Direct Known Subclasses
FriendlyShipping::Services::RL::BOLOptions, FriendlyShipping::Services::RL::ShipmentOptions, FriendlyShipping::Services::ShipEngine::LabelOptions, FriendlyShipping::Services::ShipEngine::RateEstimatesOptions, FriendlyShipping::Services::ShipEngine::RatesOptions, FriendlyShipping::Services::ShipEngineLTL::QuoteOptions, FriendlyShipping::Services::ShipEngineLTL::ShipmentOptions, FriendlyShipping::Services::TForceFreight::BOLOptions, FriendlyShipping::Services::TForceFreight::PickupOptions, FriendlyShipping::Services::TForceFreight::RatesOptions, FriendlyShipping::Services::TForceFreight::ShipmentOptions, FriendlyShipping::Services::USPSShip::RateEstimateOptions, FriendlyShipping::Services::Ups::LabelOptions, FriendlyShipping::Services::Ups::RateEstimateOptions, FriendlyShipping::Services::UpsFreight::RatesOptions, FriendlyShipping::Services::UpsFreight::ShipmentOptions, FriendlyShipping::Services::UpsJson::LabelOptions, FriendlyShipping::Services::UpsJson::RatesOptions, FriendlyShipping::Services::Usps::RateEstimateOptions, FriendlyShipping::Services::UspsInternational::RateEstimateOptions
Instance Method Summary collapse
-
#initialize(package_options: Set.new, package_options_class: PackageOptions) ⇒ ShipmentOptions
constructor
A new instance of ShipmentOptions.
-
#options_for_package(package) ⇒ PackageOptions
Finds and returns package options for the given item.
Constructor Details
#initialize(package_options: Set.new, package_options_class: PackageOptions) ⇒ ShipmentOptions
Returns a new instance of ShipmentOptions.
8 9 10 11 12 13 14 |
# File 'lib/friendly_shipping/shipment_options.rb', line 8 def initialize( package_options: Set.new, package_options_class: PackageOptions ) @package_options = @package_options_class = end |
Instance Method Details
#options_for_package(package) ⇒ PackageOptions
Finds and returns package options for the given item. If options cannot be
found, the package_options_class
is used to construct new options.
21 22 23 24 25 |
# File 'lib/friendly_shipping/shipment_options.rb', line 21 def (package) .detect do |package_option| package_option.package_id == package.id end || .new(package_id: nil) end |