Class: Io::Flow::V0::Models::PriceEquation
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::PriceEquation
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#base_price ⇒ Object
readonly
Returns the value of attribute base_price.
-
#contracted_rate ⇒ Object
readonly
Returns the value of attribute contracted_rate.
-
#discount ⇒ Object
readonly
Returns the value of attribute discount.
-
#duty ⇒ Object
readonly
Returns the value of attribute duty.
-
#fixed_margin ⇒ Object
readonly
Returns the value of attribute fixed_margin.
-
#freight ⇒ Object
readonly
Returns the value of attribute freight.
-
#insurance ⇒ Object
readonly
Returns the value of attribute insurance.
-
#percent_margin ⇒ Object
readonly
Returns the value of attribute percent_margin.
-
#percent_sales_margin ⇒ Object
readonly
Returns the value of attribute percent_sales_margin.
-
#pricing ⇒ Object
readonly
Returns the value of attribute pricing.
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
-
#tax ⇒ Object
readonly
Returns the value of attribute tax.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ PriceEquation
constructor
A new instance of PriceEquation.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ PriceEquation
Returns a new instance of PriceEquation.
22344 22345 22346 22347 22348 22349 22350 22351 22352 22353 22354 22355 22356 22357 22358 22359 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22344 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:contracted_rate, :rate, :pricing, :base_price, :discount, :fixed_margin, :percent_margin, :insurance, :freight], 'PriceEquation') @contracted_rate = HttpClient::Preconditions.assert_class('contracted_rate', HttpClient::Helper.to_big_decimal(opts.delete(:contracted_rate)), BigDecimal) @rate = HttpClient::Preconditions.assert_class('rate', HttpClient::Helper.to_big_decimal(opts.delete(:rate)), BigDecimal) @pricing = (x = opts.delete(:pricing); x.is_a?(::Io::Flow::V0::Models::Pricing) ? x : ::Io::Flow::V0::Models::Pricing.new(x)) @base_price = HttpClient::Preconditions.assert_class('base_price', HttpClient::Helper.to_big_decimal(opts.delete(:base_price)), BigDecimal) @discount = HttpClient::Preconditions.assert_class('discount', HttpClient::Helper.to_big_decimal(opts.delete(:discount)), BigDecimal) @fixed_margin = HttpClient::Preconditions.assert_class('fixed_margin', HttpClient::Helper.to_big_decimal(opts.delete(:fixed_margin)), BigDecimal) @percent_margin = HttpClient::Preconditions.assert_class('percent_margin', HttpClient::Helper.to_big_decimal(opts.delete(:percent_margin)), BigDecimal) @insurance = HttpClient::Preconditions.assert_class('insurance', HttpClient::Helper.to_big_decimal(opts.delete(:insurance)), BigDecimal) @freight = HttpClient::Preconditions.assert_class('freight', HttpClient::Helper.to_big_decimal(opts.delete(:freight)), BigDecimal) @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Duty) ? x : ::Io::Flow::V0::Models::Duty.new(x))) @tax = (x = opts.delete(:tax); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Tax) ? x : ::Io::Flow::V0::Models::Tax.new(x))) @percent_sales_margin = HttpClient::Preconditions.assert_class('percent_sales_margin', HttpClient::Helper.to_big_decimal((x = opts.delete(:percent_sales_margin); x.nil? ? 0 : x)), BigDecimal) end |
Instance Attribute Details
#base_price ⇒ Object (readonly)
Returns the value of attribute base_price.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def base_price @base_price end |
#contracted_rate ⇒ Object (readonly)
Returns the value of attribute contracted_rate.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def contracted_rate @contracted_rate end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def discount @discount end |
#duty ⇒ Object (readonly)
Returns the value of attribute duty.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def duty @duty end |
#fixed_margin ⇒ Object (readonly)
Returns the value of attribute fixed_margin.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def fixed_margin @fixed_margin end |
#freight ⇒ Object (readonly)
Returns the value of attribute freight.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def freight @freight end |
#insurance ⇒ Object (readonly)
Returns the value of attribute insurance.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def insurance @insurance end |
#percent_margin ⇒ Object (readonly)
Returns the value of attribute percent_margin.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def percent_margin @percent_margin end |
#percent_sales_margin ⇒ Object (readonly)
Returns the value of attribute percent_sales_margin.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def percent_sales_margin @percent_sales_margin end |
#pricing ⇒ Object (readonly)
Returns the value of attribute pricing.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def pricing @pricing end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def rate @rate end |
#tax ⇒ Object (readonly)
Returns the value of attribute tax.
22342 22343 22344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22342 def tax @tax end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
22365 22366 22367 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22365 def copy(incoming={}) PriceEquation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
22369 22370 22371 22372 22373 22374 22375 22376 22377 22378 22379 22380 22381 22382 22383 22384 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22369 def to_hash { :contracted_rate => contracted_rate, :rate => rate, :pricing => pricing.to_hash, :base_price => base_price, :discount => discount, :fixed_margin => fixed_margin, :percent_margin => percent_margin, :insurance => insurance, :freight => freight, :duty => duty.nil? ? nil : duty.to_hash, :tax => tax.nil? ? nil : tax.to_hash, :percent_sales_margin => percent_sales_margin } end |
#to_json ⇒ Object
22361 22362 22363 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22361 def to_json JSON.dump(to_hash) end |