Class: Io::Flow::V0::Models::PriceEquation

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PriceEquation

Returns a new instance of PriceEquation.



24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24219

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_priceObject (readonly)

Returns the value of attribute base_price.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def base_price
  @base_price
end

#contracted_rateObject (readonly)

Returns the value of attribute contracted_rate.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def contracted_rate
  @contracted_rate
end

#discountObject (readonly)

Returns the value of attribute discount.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def duty
  @duty
end

#fixed_marginObject (readonly)

Returns the value of attribute fixed_margin.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def fixed_margin
  @fixed_margin
end

#freightObject (readonly)

Returns the value of attribute freight.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def freight
  @freight
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def insurance
  @insurance
end

#percent_marginObject (readonly)

Returns the value of attribute percent_margin.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def percent_margin
  @percent_margin
end

#percent_sales_marginObject (readonly)

Returns the value of attribute percent_sales_margin.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def percent_sales_margin
  @percent_sales_margin
end

#pricingObject (readonly)

Returns the value of attribute pricing.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def pricing
  @pricing
end

#rateObject (readonly)

Returns the value of attribute rate.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def rate
  @rate
end

#taxObject (readonly)

Returns the value of attribute tax.



24217
24218
24219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24217

def tax
  @tax
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



24240
24241
24242
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24240

def copy(incoming={})
  PriceEquation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24244

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_jsonObject



24236
24237
24238
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24236

def to_json
  JSON.dump(to_hash)
end