Class: Io::Flow::V0::Models::ConsumerInvoiceItem

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 = {}) ⇒ ConsumerInvoiceItem

Returns a new instance of ConsumerInvoiceItem.



19149
19150
19151
19152
19153
19154
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19149

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

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



19147
19148
19149
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19147

def item
  @item
end

#quantityObject (readonly)

Returns the value of attribute quantity.



19147
19148
19149
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19147

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19160
19161
19162
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19160

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

#to_hashObject



19164
19165
19166
19167
19168
19169
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19164

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

#to_jsonObject



19156
19157
19158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19156

def to_json
  JSON.dump(to_hash)
end