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.



8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8533

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::Price) ? x : ::Io::Flow::V0::Models::Price.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::Price) ? x : ::Io::Flow::V0::Models::Price.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::DatetimeRange) ? x : ::Io::Flow::V0::Models::DatetimeRange.new(x))
end

Instance Attribute Details

#costObject (readonly)

Returns the value of attribute cost.



8531
8532
8533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8531

def cost
  @cost
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



8531
8532
8533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8531

def delivered_duty
  @delivered_duty
end

#idObject (readonly)

Returns the value of attribute id.



8531
8532
8533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8531

def id
  @id
end

#priceObject (readonly)

Returns the value of attribute price.



8531
8532
8533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8531

def price
  @price
end

#serviceObject (readonly)

Returns the value of attribute service.



8531
8532
8533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8531

def service
  @service
end

#tierObject (readonly)

Returns the value of attribute tier.



8531
8532
8533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8531

def tier
  @tier
end

#windowObject (readonly)

Returns the value of attribute window.



8531
8532
8533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8531

def window
  @window
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



8549
8550
8551
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8549

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

#to_hashObject



8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8553

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
  }
end

#to_jsonObject



8545
8546
8547
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8545

def to_json
  JSON.dump(to_hash)
end