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.



22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22381

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))
  @cost_details = (x = opts.delete(:cost_details); x.nil? ? nil : HttpClient::Preconditions.assert_class('cost_details', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveryOptionCostDetail) ? x : ::Io::Flow::V0::Models::DeliveryOptionCostDetail.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)))
  @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)))
end

Instance Attribute Details

#costObject (readonly)

Returns the value of attribute cost.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def cost
  @cost
end

#cost_detailsObject (readonly)

Returns the value of attribute cost_details.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def cost_details
  @cost_details
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def delivered_duty
  @delivered_duty
end

#idObject (readonly)

Returns the value of attribute id.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def id
  @id
end

#priceObject (readonly)

Returns the value of attribute price.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def price
  @price
end

#rule_outcomeObject (readonly)

Returns the value of attribute rule_outcome.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def rule_outcome
  @rule_outcome
end

#send_toObject (readonly)

Returns the value of attribute send_to.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def send_to
  @send_to
end

#serviceObject (readonly)

Returns the value of attribute service.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def service
  @service
end

#tierObject (readonly)

Returns the value of attribute tier.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def tier
  @tier
end

#weightObject (readonly)

Returns the value of attribute weight.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def weight
  @weight
end

#windowObject (readonly)

Returns the value of attribute window.



22379
22380
22381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22379

def window
  @window
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22401
22402
22403
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22401

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

#to_hashObject



22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22405

def to_hash
  {
    :id => id,
    :cost => cost.to_hash,
    :cost_details => cost_details.nil? ? nil : cost_details.map { |o| o.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
  }
end

#to_jsonObject



22397
22398
22399
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22397

def to_json
  JSON.dump(to_hash)
end