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.



21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21882

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.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def base_price
  @base_price
end

#contracted_rateObject (readonly)

Returns the value of attribute contracted_rate.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def contracted_rate
  @contracted_rate
end

#discountObject (readonly)

Returns the value of attribute discount.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def duty
  @duty
end

#fixed_marginObject (readonly)

Returns the value of attribute fixed_margin.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def fixed_margin
  @fixed_margin
end

#freightObject (readonly)

Returns the value of attribute freight.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def freight
  @freight
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def insurance
  @insurance
end

#percent_marginObject (readonly)

Returns the value of attribute percent_margin.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def percent_margin
  @percent_margin
end

#percent_sales_marginObject (readonly)

Returns the value of attribute percent_sales_margin.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def percent_sales_margin
  @percent_sales_margin
end

#pricingObject (readonly)

Returns the value of attribute pricing.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def pricing
  @pricing
end

#rateObject (readonly)

Returns the value of attribute rate.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def rate
  @rate
end

#taxObject (readonly)

Returns the value of attribute tax.



21880
21881
21882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21880

def tax
  @tax
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21903
21904
21905
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21903

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

#to_hashObject



21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21907

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



21899
21900
21901
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21899

def to_json
  JSON.dump(to_hash)
end