Class: Io::Flow::V0::Models::DeliveryOption
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::DeliveryOption
- 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
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#delivered_duty ⇒ Object
readonly
Returns the value of attribute delivered_duty.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#tier ⇒ Object
readonly
Returns the value of attribute tier.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ DeliveryOption
constructor
A new instance of DeliveryOption.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ DeliveryOption
Returns a new instance of DeliveryOption.
9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9929 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
#cost ⇒ Object (readonly)
Returns the value of attribute cost.
9927 9928 9929 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9927 def cost @cost end |
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
9927 9928 9929 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9927 def delivered_duty @delivered_duty end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9927 9928 9929 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9927 def id @id end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
9927 9928 9929 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9927 def price @price end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
9927 9928 9929 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9927 def service @service end |
#tier ⇒ Object (readonly)
Returns the value of attribute tier.
9927 9928 9929 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9927 def tier @tier end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
9927 9928 9929 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9927 def window @window end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
9945 9946 9947 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9945 def copy(incoming={}) DeliveryOption.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9949 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_json ⇒ Object
9941 9942 9943 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9941 def to_json JSON.dump(to_hash) end |