Class: Io::Flow::V0::Models::Reservation
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Reservation
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Inventory reservation for a set of items in organization that potentially expires at specified date/time
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Reservation
constructor
A new instance of Reservation.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Reservation
Returns a new instance of Reservation.
37287 37288 37289 37290 37291 37292 37293 37294 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37287 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :key, :items], 'Reservation') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String) @order = (x = opts.delete(:order); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ReservationOrderReference) ? x : ::Io::Flow::V0::Models::ReservationOrderReference.new(x))) @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ReservationItem) ? x : ::Io::Flow::V0::Models::ReservationItem.new(x)) } end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
37285 37286 37287 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37285 def id @id end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
37285 37286 37287 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37285 def items @items end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
37285 37286 37287 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37285 def key @key end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
37285 37286 37287 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37285 def order @order end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
37300 37301 37302 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37300 def copy(incoming={}) Reservation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
37304 37305 37306 37307 37308 37309 37310 37311 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37304 def to_hash { :id => id, :key => key, :order => order.nil? ? nil : order.to_hash, :items => items.map { |o| o.to_hash } } end |
#to_json ⇒ Object
37296 37297 37298 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37296 def to_json JSON.dump(to_hash) end |