Class: Io::Flow::V0::Models::Line
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Line
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Provides display data for a line item.
Instance Attribute Summary collapse
-
#item_number ⇒ Object
readonly
Returns the value of attribute item_number.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Line
constructor
A new instance of Line.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Line
Returns a new instance of Line.
19030 19031 19032 19033 19034 19035 19036 19037 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19030 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_number ⇒ Object (readonly)
Returns the value of attribute item_number.
19028 19029 19030 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19028 def item_number @item_number end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
19028 19029 19030 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19028 def price @price end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
19028 19029 19030 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19028 def quantity @quantity end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
19028 19029 19030 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19028 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
19043 19044 19045 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19043 def copy(incoming={}) Line.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
19047 19048 19049 19050 19051 19052 19053 19054 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19047 def to_hash { :item_number => item_number, :quantity => quantity, :price => price.to_hash, :total => total.to_hash } end |
#to_json ⇒ Object
19039 19040 19041 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19039 def to_json JSON.dump(to_hash) end |