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.



37568
37569
37570
37571
37572
37573
37574
37575
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37568

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.



37566
37567
37568
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37566

def content
  @content
end

#line_priceObject (readonly)

Returns the value of attribute line_price.



37566
37567
37568
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37566

def line_price
  @line_price
end

#priceObject (readonly)

Returns the value of attribute price.



37566
37567
37568
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37566

def price
  @price
end

#quantityObject (readonly)

Returns the value of attribute quantity.



37566
37567
37568
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37566

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37581
37582
37583
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37581

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

#to_hashObject



37585
37586
37587
37588
37589
37590
37591
37592
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37585

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

#to_jsonObject



37577
37578
37579
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37577

def to_json
  JSON.dump(to_hash)
end