Class: Io::Flow::V0::Models::ItemMargin
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ItemMargin
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Defines a fixed and percent margin to apply to items matching a query.
Instance Attribute Summary collapse
-
#fixed ⇒ Object
readonly
Returns the value of attribute fixed.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#percent ⇒ Object
readonly
Returns the value of attribute percent.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#q ⇒ Object
readonly
Returns the value of attribute q.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ ItemMargin
constructor
A new instance of ItemMargin.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ItemMargin
Returns a new instance of ItemMargin.
28717 28718 28719 28720 28721 28722 28723 28724 28725 28726 28727 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28717 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :key, :name, :q, :fixed, :percent, :position], 'ItemMargin') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String) @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) @q = HttpClient::Preconditions.assert_class('q', opts.delete(:q), String) @fixed = HttpClient::Preconditions.assert_class('fixed', HttpClient::Helper.to_big_decimal(opts.delete(:fixed)), BigDecimal) @percent = HttpClient::Preconditions.assert_class('percent', HttpClient::Helper.to_big_decimal(opts.delete(:percent)), BigDecimal) @position = HttpClient::Preconditions.assert_class('position', opts.delete(:position), Integer) end |
Instance Attribute Details
#fixed ⇒ Object (readonly)
Returns the value of attribute fixed.
28715 28716 28717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28715 def fixed @fixed end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28715 28716 28717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28715 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
28715 28716 28717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28715 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28715 28716 28717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28715 def name @name end |
#percent ⇒ Object (readonly)
Returns the value of attribute percent.
28715 28716 28717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28715 def percent @percent end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
28715 28716 28717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28715 def position @position end |
#q ⇒ Object (readonly)
Returns the value of attribute q.
28715 28716 28717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28715 def q @q end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
28733 28734 28735 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28733 def copy(incoming={}) ItemMargin.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
28737 28738 28739 28740 28741 28742 28743 28744 28745 28746 28747 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28737 def to_hash { :id => id, :key => key, :name => name, :q => q, :fixed => fixed.to_f.to_s, :percent => percent.to_f.to_s, :position => position } end |
#to_json ⇒ Object
28729 28730 28731 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28729 def to_json JSON.dump(to_hash) end |