Class: Io::Flow::V0::Models::KlaviyoOrderPrices

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

Overview

Contains cart related data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ KlaviyoOrderPrices

Returns a new instance of KlaviyoOrderPrices.



42600
42601
42602
42603
42604
42605
42606
42607
42608
42609
42610
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42600

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:subtotal, :total], 'KlaviyoOrderPrices')
  @subtotal = (x = opts.delete(:subtotal); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @vat = (x = opts.delete(:vat); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
  @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
  @discount = (x = opts.delete(:discount); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
  @shipping = (x = opts.delete(:shipping); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
  @insurance = (x = opts.delete(:insurance); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
end

Instance Attribute Details

#discountObject (readonly)

Returns the value of attribute discount.



42598
42599
42600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42598

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



42598
42599
42600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42598

def duty
  @duty
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



42598
42599
42600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42598

def insurance
  @insurance
end

#shippingObject (readonly)

Returns the value of attribute shipping.



42598
42599
42600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42598

def shipping
  @shipping
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



42598
42599
42600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42598

def subtotal
  @subtotal
end

#totalObject (readonly)

Returns the value of attribute total.



42598
42599
42600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42598

def total
  @total
end

#vatObject (readonly)

Returns the value of attribute vat.



42598
42599
42600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42598

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



42616
42617
42618
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42616

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

#to_hashObject



42620
42621
42622
42623
42624
42625
42626
42627
42628
42629
42630
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42620

def to_hash
  {
    :subtotal => subtotal.to_hash,
    :vat => vat.nil? ? nil : vat.to_hash,
    :duty => duty.nil? ? nil : duty.to_hash,
    :discount => discount.nil? ? nil : discount.to_hash,
    :shipping => shipping.nil? ? nil : shipping.to_hash,
    :insurance => insurance.nil? ? nil : insurance.to_hash,
    :total => total.to_hash
  }
end

#to_jsonObject



42612
42613
42614
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42612

def to_json
  JSON.dump(to_hash)
end