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.



47885
47886
47887
47888
47889
47890
47891
47892
47893
47894
47895
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47885

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.



47883
47884
47885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47883

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



47883
47884
47885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47883

def duty
  @duty
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



47883
47884
47885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47883

def insurance
  @insurance
end

#shippingObject (readonly)

Returns the value of attribute shipping.



47883
47884
47885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47883

def shipping
  @shipping
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



47883
47884
47885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47883

def subtotal
  @subtotal
end

#totalObject (readonly)

Returns the value of attribute total.



47883
47884
47885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47883

def total
  @total
end

#vatObject (readonly)

Returns the value of attribute vat.



47883
47884
47885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47883

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



47901
47902
47903
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47901

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

#to_hashObject



47905
47906
47907
47908
47909
47910
47911
47912
47913
47914
47915
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47905

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



47897
47898
47899
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47897

def to_json
  JSON.dump(to_hash)
end