Class: Io::Flow::V0::Models::Delivery
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Delivery
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents a collection of items, the available delivery option tier for that collection of items, and metadata about those options
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Delivery
constructor
A new instance of Delivery.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Delivery
Returns a new instance of Delivery.
13279 13280 13281 13282 13283 13284 13285 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13279 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :items, :options], 'Delivery') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) } @options = HttpClient::Preconditions.assert_class('options', opts.delete(:options), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveryOption) ? x : ::Io::Flow::V0::Models::DeliveryOption.new(x)) } end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
13277 13278 13279 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13277 def id @id end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
13277 13278 13279 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13277 def items @items end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13277 13278 13279 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13277 def @options end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
13291 13292 13293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13291 def copy(incoming={}) Delivery.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
13295 13296 13297 13298 13299 13300 13301 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13295 def to_hash { :id => id, :items => items.map { |o| o.to_hash }, :options => .map { |o| o.to_hash } } end |
#to_json ⇒ Object
13287 13288 13289 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13287 def to_json JSON.dump(to_hash) end |