Class: Delivery::CalculateShippingOptions

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/delivery/calculate_shipping_options.rb

Overview

Builds the option payload WyShipping.calculate_shipping_from_options
consumes for one delivery — addresses, country, package dimensions/weights,
residential flag, COD/insurance values, LTL/freight defaults, RMA carrier
restrictions, WWW estimate flags. Pure construction; does not call carriers.

Extracted from Delivery#calculate_shipping_options (god-object
decomposition); the model keeps a thin delegator. The seed hash is mutated
in place and returned, preserving the original method's contract.

Examples:

Delivery::CalculateShippingOptions.new(delivery).process
Delivery::CalculateShippingOptions.new(delivery, ship_date: date).process

Instance Attribute Summary

Attributes inherited from BaseService

#options

Instance Method Summary collapse

Methods inherited from BaseService

#log_debug, #log_error, #log_info, #log_warning, #logger, #tagged_logger

Constructor Details

#initialize(delivery, seed_options = {}) ⇒ CalculateShippingOptions

Returns a new instance of CalculateShippingOptions.



17
18
19
20
21
# File 'app/services/delivery/calculate_shipping_options.rb', line 17

def initialize(delivery, seed_options = {})
  super()
  @delivery = delivery
  @opts = seed_options
end

Instance Method Details

#processHash

Returns the options hash WyShipping consumes.

Returns:

  • (Hash)

    the options hash WyShipping consumes



24
25
26
27
28
29
30
31
32
33
34
# File 'app/services/delivery/calculate_shipping_options.rb', line 24

def process
  apply_resource_shipping_method!
  apply_addresses!
  apply_store_and_service_flags!
  apply_freight_flags!
  apply_packages_and_insurance!
  apply_cod!
  apply_rma_carrier_restrictions!
  apply_www_flags!
  opts
end