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.
18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18203 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.
18201 18202 18203 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18201 def fixed @fixed end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
18201 18202 18203 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18201 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
18201 18202 18203 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18201 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18201 18202 18203 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18201 def name @name end |
#percent ⇒ Object (readonly)
Returns the value of attribute percent.
18201 18202 18203 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18201 def percent @percent end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
18201 18202 18203 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18201 def position @position end |
#q ⇒ Object (readonly)
Returns the value of attribute q.
18201 18202 18203 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18201 def q @q end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
18219 18220 18221 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18219 def copy(incoming={}) ItemMargin.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18223 def to_hash { :id => id, :key => key, :name => name, :q => q, :fixed => fixed, :percent => percent, :position => position } end |
#to_json ⇒ Object
18215 18216 18217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18215 def to_json JSON.dump(to_hash) end |