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.



35733
35734
35735
35736
35737
35738
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35733

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.



35731
35732
35733
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35731

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



35731
35732
35733
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35731

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35744
35745
35746
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35744

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

#to_hashObject



35748
35749
35750
35751
35752
35753
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35748

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

#to_jsonObject



35740
35741
35742
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35740

def to_json
  JSON.dump(to_hash)
end