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.



37359
37360
37361
37362
37363
37364
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37359

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.



37357
37358
37359
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37357

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



37357
37358
37359
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37357

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37370
37371
37372
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37370

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

#to_hashObject



37374
37375
37376
37377
37378
37379
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37374

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

#to_jsonObject



37366
37367
37368
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37366

def to_json
  JSON.dump(to_hash)
end