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.



47009
47010
47011
47012
47013
47014
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47009

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.



47007
47008
47009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47007

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



47007
47008
47009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47007

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



47020
47021
47022
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47020

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

#to_hashObject



47024
47025
47026
47027
47028
47029
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47024

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

#to_jsonObject



47016
47017
47018
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47016

def to_json
  JSON.dump(to_hash)
end