Class: Io::Flow::V0::Models::Line

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

Overview

Provides display data for a line item.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Line

Returns a new instance of Line.



16491
16492
16493
16494
16495
16496
16497
16498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16491

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:item_number, :quantity, :price, :total], 'Line')
  @item_number = HttpClient::Preconditions.assert_class('item_number', opts.delete(:item_number), String)
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
end

Instance Attribute Details

#item_numberObject (readonly)

Returns the value of attribute item_number.



16489
16490
16491
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16489

def item_number
  @item_number
end

#priceObject (readonly)

Returns the value of attribute price.



16489
16490
16491
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16489

def price
  @price
end

#quantityObject (readonly)

Returns the value of attribute quantity.



16489
16490
16491
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16489

def quantity
  @quantity
end

#totalObject (readonly)

Returns the value of attribute total.



16489
16490
16491
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16489

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16504
16505
16506
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16504

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

#to_hashObject



16508
16509
16510
16511
16512
16513
16514
16515
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16508

def to_hash
  {
    :item_number => item_number,
    :quantity => quantity,
    :price => price.to_hash,
    :total => total.to_hash
  }
end

#to_jsonObject



16500
16501
16502
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16500

def to_json
  JSON.dump(to_hash)
end