Class: Io::Flow::V0::Models::Reservation

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Reservation

Returns a new instance of Reservation.



28531
28532
28533
28534
28535
28536
28537
28538
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28531

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

#idObject (readonly)

Returns the value of attribute id.



28529
28530
28531
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28529

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



28529
28530
28531
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28529

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



28529
28530
28531
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28529

def key
  @key
end

#orderObject (readonly)

Returns the value of attribute order.



28529
28530
28531
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28529

def order
  @order
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28544
28545
28546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28544

def copy(incoming={})
  Reservation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



28548
28549
28550
28551
28552
28553
28554
28555
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28548

def to_hash
  {
    :id => id,
    :key => key,
    :order => order.nil? ? nil : order.to_hash,
    :items => items.map { |o| o.to_hash }
  }
end

#to_jsonObject



28540
28541
28542
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28540

def to_json
  JSON.dump(to_hash)
end