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.



44612
44613
44614
44615
44616
44617
44618
44619
44620
44621
44622
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44612

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.



44610
44611
44612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44610

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



44610
44611
44612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44610

def duty
  @duty
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



44610
44611
44612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44610

def insurance
  @insurance
end

#shippingObject (readonly)

Returns the value of attribute shipping.



44610
44611
44612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44610

def shipping
  @shipping
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



44610
44611
44612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44610

def subtotal
  @subtotal
end

#totalObject (readonly)

Returns the value of attribute total.



44610
44611
44612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44610

def total
  @total
end

#vatObject (readonly)

Returns the value of attribute vat.



44610
44611
44612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44610

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



44628
44629
44630
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44628

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

#to_hashObject



44632
44633
44634
44635
44636
44637
44638
44639
44640
44641
44642
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44632

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



44624
44625
44626
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44624

def to_json
  JSON.dump(to_hash)
end