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.



46383
46384
46385
46386
46387
46388
46389
46390
46391
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46383

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

#idObject (readonly)

Returns the value of attribute id.



46381
46382
46383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46381

def id
  @id
end

#itemsObject (readonly)

Returns the value of attribute items.



46381
46382
46383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46381

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



46381
46382
46383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46381

def key
  @key
end

#orderObject (readonly)

Returns the value of attribute order.



46381
46382
46383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46381

def order
  @order
end

#reserved_untilObject (readonly)

Returns the value of attribute reserved_until.



46381
46382
46383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46381

def reserved_until
  @reserved_until
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



46397
46398
46399
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46397

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

#to_hashObject



46401
46402
46403
46404
46405
46406
46407
46408
46409
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46401

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_jsonObject



46393
46394
46395
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46393

def to_json
  JSON.dump(to_hash)
end