class Io::Flow::V0::Models::Reservation

Inventory reservation for a set of items in organization that potentially expires at specified date/time

Attributes

id[R]
items[R]
key[R]
order[R]
reserved_until[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 63732
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

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 63746
def copy(incoming={})
  Reservation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 63750
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() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 63742
def to_json
  JSON.dump(to_hash)
end