Class: Io::Flow::V0::Models::KlaviyoOrderContent

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

Returns a new instance of KlaviyoOrderContent.



37049
37050
37051
37052
37053
37054
37055
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37049

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:line_items, :prices, :checkout_url], 'KlaviyoOrderContent')
  @line_items = HttpClient::Preconditions.assert_class('line_items', opts.delete(:line_items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::KlaviyoLineItem) ? x : ::Io::Flow::V0::Models::KlaviyoLineItem.new(x)) }
  @prices = (x = opts.delete(:prices); x.is_a?(::Io::Flow::V0::Models::KlaviyoOrderPrices) ? x : ::Io::Flow::V0::Models::KlaviyoOrderPrices.new(x))
  @checkout_url = HttpClient::Preconditions.assert_class('checkout_url', opts.delete(:checkout_url), String)
end

Instance Attribute Details

#checkout_urlObject (readonly)

Returns the value of attribute checkout_url.



37047
37048
37049
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37047

def checkout_url
  @checkout_url
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



37047
37048
37049
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37047

def line_items
  @line_items
end

#pricesObject (readonly)

Returns the value of attribute prices.



37047
37048
37049
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37047

def prices
  @prices
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37061
37062
37063
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37061

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

#to_hashObject



37065
37066
37067
37068
37069
37070
37071
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37065

def to_hash
  {
    :line_items => line_items.map { |o| o.to_hash },
    :prices => prices.to_hash,
    :checkout_url => checkout_url
  }
end

#to_jsonObject



37057
37058
37059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37057

def to_json
  JSON.dump(to_hash)
end