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
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#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.
42994 42995 42996 42997 42998 42999 43000 43001 43002 43003 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42994 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:item_number, :quantity, :price, :total], 'Line') @id = (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, String)) @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)) @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
42992 42993 42994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42992 def attributes @attributes end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
42992 42993 42994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42992 def id @id end |
#item_number ⇒ Object (readonly)
Returns the value of attribute item_number.
42992 42993 42994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42992 def item_number @item_number end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
42992 42993 42994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42992 def price @price end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
42992 42993 42994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42992 def quantity @quantity end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
42992 42993 42994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42992 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
43009 43010 43011 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43009 def copy(incoming={}) Line.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
43013 43014 43015 43016 43017 43018 43019 43020 43021 43022 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43013 def to_hash { :id => id, :item_number => item_number, :quantity => quantity, :price => price.to_hash, :total => total.to_hash, :attributes => attributes.nil? ? nil : attributes } end |
#to_json ⇒ Object
43005 43006 43007 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43005 def to_json JSON.dump(to_hash) end |