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.



14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14589

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)))
end

Instance Attribute Details

#base_priceObject (readonly)

Returns the value of attribute base_price.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def base_price
  @base_price
end

#contracted_rateObject (readonly)

Returns the value of attribute contracted_rate.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def contracted_rate
  @contracted_rate
end

#discountObject (readonly)

Returns the value of attribute discount.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def duty
  @duty
end

#fixed_marginObject (readonly)

Returns the value of attribute fixed_margin.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def fixed_margin
  @fixed_margin
end

#freightObject (readonly)

Returns the value of attribute freight.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def freight
  @freight
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def insurance
  @insurance
end

#percent_marginObject (readonly)

Returns the value of attribute percent_margin.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def percent_margin
  @percent_margin
end

#pricingObject (readonly)

Returns the value of attribute pricing.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def pricing
  @pricing
end

#rateObject (readonly)

Returns the value of attribute rate.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def rate
  @rate
end

#taxObject (readonly)

Returns the value of attribute tax.



14587
14588
14589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14587

def tax
  @tax
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14609
14610
14611
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14609

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

#to_hashObject



14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14613

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
  }
end

#to_jsonObject



14605
14606
14607
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14605

def to_json
  JSON.dump(to_hash)
end