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.



37080
37081
37082
37083
37084
37085
37086
37087
37088
37089
37090
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37080

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.



37078
37079
37080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37078

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



37078
37079
37080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37078

def duty
  @duty
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



37078
37079
37080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37078

def insurance
  @insurance
end

#shippingObject (readonly)

Returns the value of attribute shipping.



37078
37079
37080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37078

def shipping
  @shipping
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



37078
37079
37080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37078

def subtotal
  @subtotal
end

#totalObject (readonly)

Returns the value of attribute total.



37078
37079
37080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37078

def total
  @total
end

#vatObject (readonly)

Returns the value of attribute vat.



37078
37079
37080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37078

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37096
37097
37098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37096

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

#to_hashObject



37100
37101
37102
37103
37104
37105
37106
37107
37108
37109
37110
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37100

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



37092
37093
37094
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37092

def to_json
  JSON.dump(to_hash)
end