Class: Io::Flow::V0::Models::KlaviyoLineItem

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 = {}) ⇒ KlaviyoLineItem

Returns a new instance of KlaviyoLineItem.



47822
47823
47824
47825
47826
47827
47828
47829
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47822

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:content, :quantity, :price, :line_price], 'KlaviyoLineItem')
  @content = (x = opts.delete(:content); x.is_a?(::Io::Flow::V0::Models::CheckoutItemContent) ? x : ::Io::Flow::V0::Models::CheckoutItemContent.new(x))
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @line_price = (x = opts.delete(:line_price); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



47820
47821
47822
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47820

def content
  @content
end

#line_priceObject (readonly)

Returns the value of attribute line_price.



47820
47821
47822
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47820

def line_price
  @line_price
end

#priceObject (readonly)

Returns the value of attribute price.



47820
47821
47822
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47820

def price
  @price
end

#quantityObject (readonly)

Returns the value of attribute quantity.



47820
47821
47822
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47820

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



47835
47836
47837
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47835

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

#to_hashObject



47839
47840
47841
47842
47843
47844
47845
47846
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47839

def to_hash
  {
    :content => content.to_hash,
    :quantity => quantity,
    :price => price.to_hash,
    :line_price => line_price.to_hash
  }
end

#to_jsonObject



47831
47832
47833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 47831

def to_json
  JSON.dump(to_hash)
end