Class: Io::Flow::V0::Models::ReservationItem

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ReservationItem

Returns a new instance of ReservationItem.



46445
46446
46447
46448
46449
46450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46445

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:item, :quantity], 'ReservationItem')
  @item = (x = opts.delete(:item); x.is_a?(::Io::Flow::V0::Models::ReservationItemReference) ? x : ::Io::Flow::V0::Models::ReservationItemReference.new(x))
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



46443
46444
46445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46443

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



46443
46444
46445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46443

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



46456
46457
46458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46456

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

#to_hashObject



46460
46461
46462
46463
46464
46465
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46460

def to_hash
  {
    :item => item.to_hash,
    :quantity => quantity
  }
end

#to_jsonObject



46452
46453
46454
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46452

def to_json
  JSON.dump(to_hash)
end