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.



28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28889

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::PriceWithBaseAndDetails) ? x : ::Io::Flow::V0::Models::PriceWithBaseAndDetails.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::PriceWithBaseAndDetails) ? x : ::Io::Flow::V0::Models::PriceWithBaseAndDetails.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)))
  @send_to = (x = opts.delete(:send_to); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x)))
  @surcharge = (x = opts.delete(:surcharge); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBaseAndDetails) ? x : ::Io::Flow::V0::Models::PriceWithBaseAndDetails.new(x)))
  @ratecard_owner = (x = opts.delete(:ratecard_owner); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::RatecardOwner) ? x : ::Io::Flow::V0::Models::RatecardOwner.apply(x)))
end

Instance Attribute Details

#costObject (readonly)

Returns the value of attribute cost.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def cost
  @cost
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def delivered_duty
  @delivered_duty
end

#idObject (readonly)

Returns the value of attribute id.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def id
  @id
end

#priceObject (readonly)

Returns the value of attribute price.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def price
  @price
end

#ratecard_ownerObject (readonly)

Returns the value of attribute ratecard_owner.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def ratecard_owner
  @ratecard_owner
end

#rule_outcomeObject (readonly)

Returns the value of attribute rule_outcome.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def rule_outcome
  @rule_outcome
end

#send_toObject (readonly)

Returns the value of attribute send_to.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def send_to
  @send_to
end

#serviceObject (readonly)

Returns the value of attribute service.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def service
  @service
end

#surchargeObject (readonly)

Returns the value of attribute surcharge.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def surcharge
  @surcharge
end

#tierObject (readonly)

Returns the value of attribute tier.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def tier
  @tier
end

#weightObject (readonly)

Returns the value of attribute weight.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def weight
  @weight
end

#windowObject (readonly)

Returns the value of attribute window.



28887
28888
28889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28887

def window
  @window
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

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

#to_hashObject



28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28914

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,
    :send_to => send_to.nil? ? nil : send_to.to_hash,
    :surcharge => surcharge.nil? ? nil : surcharge.to_hash,
    :ratecard_owner => ratecard_owner.nil? ? nil : ratecard_owner.value
  }
end

#to_jsonObject



28906
28907
28908
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28906

def to_json
  JSON.dump(to_hash)
end