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.
-
#reserved_until ⇒ Object
readonly
Returns the value of attribute reserved_until.
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.
56529 56530 56531 56532 56533 56534 56535 56536 56537 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56529 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)) } @reserved_until = (x = opts.delete(:reserved_until); x.nil? ? nil : HttpClient::Preconditions.assert_class('reserved_until', HttpClient::Helper.to_date_time_iso8601(x), DateTime)) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
56527 56528 56529 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56527 def id @id end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
56527 56528 56529 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56527 def items @items end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
56527 56528 56529 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56527 def key @key end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
56527 56528 56529 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56527 def order @order end |
#reserved_until ⇒ Object (readonly)
Returns the value of attribute reserved_until.
56527 56528 56529 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56527 def reserved_until @reserved_until end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
56543 56544 56545 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56543 def copy(incoming={}) Reservation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
56547 56548 56549 56550 56551 56552 56553 56554 56555 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56547 def to_hash { :id => id, :key => key, :order => order.nil? ? nil : order.to_hash, :items => items.map { |o| o.to_hash }, :reserved_until => reserved_until } end |
#to_json ⇒ Object
56539 56540 56541 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 56539 def to_json JSON.dump(to_hash) end |