Class: Io::Flow::V0::Models::DeliveryOption

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Represents a way to fulfill a delivery, including an estimates for the date range and cost

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ DeliveryOption

Returns a new instance of DeliveryOption.



14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14709

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :cost, :delivered_duty, :price, :service, :tier, :window], 'DeliveryOption')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @cost = (x = opts.delete(:cost); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @delivered_duty = (x = opts.delete(:delivered_duty); x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x))
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @service = (x = opts.delete(:service); x.is_a?(::Io::Flow::V0::Models::ServiceSummary) ? x : ::Io::Flow::V0::Models::ServiceSummary.new(x))
  @tier = (x = opts.delete(:tier); x.is_a?(::Io::Flow::V0::Models::TierSummary) ? x : ::Io::Flow::V0::Models::TierSummary.new(x))
  @window = (x = opts.delete(:window); x.is_a?(::Io::Flow::V0::Models::DeliveryWindow) ? x : ::Io::Flow::V0::Models::DeliveryWindow.new(x))
  @rule_outcome = (x = opts.delete(:rule_outcome); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::TierRuleOutcome) ? x : ::Io::Flow::V0::Models::TierRuleOutcome.from_json(x)))
  @weight = (x = opts.delete(:weight); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OptionWeightEstimates) ? x : ::Io::Flow::V0::Models::OptionWeightEstimates.new(x)))
end

Instance Attribute Details

#costObject (readonly)

Returns the value of attribute cost.



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def cost
  @cost
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def delivered_duty
  @delivered_duty
end

#idObject (readonly)

Returns the value of attribute id.



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def id
  @id
end

#priceObject (readonly)

Returns the value of attribute price.



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def price
  @price
end

#rule_outcomeObject (readonly)

Returns the value of attribute rule_outcome.



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def rule_outcome
  @rule_outcome
end

#serviceObject (readonly)

Returns the value of attribute service.



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def service
  @service
end

#tierObject (readonly)

Returns the value of attribute tier.



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def tier
  @tier
end

#weightObject (readonly)

Returns the value of attribute weight.



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def weight
  @weight
end

#windowObject (readonly)

Returns the value of attribute window.



14707
14708
14709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14707

def window
  @window
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14727
14728
14729
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14727

def copy(incoming={})
  DeliveryOption.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14731

def to_hash
  {
    :id => id,
    :cost => cost.to_hash,
    :delivered_duty => delivered_duty.value,
    :price => price.to_hash,
    :service => service.to_hash,
    :tier => tier.to_hash,
    :window => window.to_hash,
    :rule_outcome => rule_outcome.nil? ? nil : rule_outcome.to_hash,
    :weight => weight.nil? ? nil : weight.to_hash
  }
end

#to_jsonObject



14723
14724
14725
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14723

def to_json
  JSON.dump(to_hash)
end