Class: Io::Flow::V0::Models::CheckoutAttribute

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

A Checkout Attribute defines an attribute that will be made available via the checkout item content. This is useful if you would like to surface a specific attribute (like ‘size’ or ‘color’) in checkout.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ CheckoutAttribute

Returns a new instance of CheckoutAttribute.



19442
19443
19444
19445
19446
19447
19448
19449
19450
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19442

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :experience, :key, :attribute_keys, :position], 'CheckoutAttribute')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @experience = (x = opts.delete(:experience); x.is_a?(::Io::Flow::V0::Models::ExperienceReference) ? x : ::Io::Flow::V0::Models::ExperienceReference.new(x))
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @attribute_keys = HttpClient::Preconditions.assert_class('attribute_keys', opts.delete(:attribute_keys), Array).map { |v| HttpClient::Preconditions.assert_class('attribute_keys', v, String) }
  @position = HttpClient::Preconditions.assert_class('position', opts.delete(:position), Integer)
end

Instance Attribute Details

#attribute_keysObject (readonly)

Returns the value of attribute attribute_keys.



19440
19441
19442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19440

def attribute_keys
  @attribute_keys
end

#experienceObject (readonly)

Returns the value of attribute experience.



19440
19441
19442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19440

def experience
  @experience
end

#idObject (readonly)

Returns the value of attribute id.



19440
19441
19442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19440

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



19440
19441
19442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19440

def key
  @key
end

#positionObject (readonly)

Returns the value of attribute position.



19440
19441
19442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19440

def position
  @position
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19456
19457
19458
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19456

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

#to_hashObject



19460
19461
19462
19463
19464
19465
19466
19467
19468
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19460

def to_hash
  {
    :id => id,
    :experience => experience.to_hash,
    :key => key,
    :attribute_keys => attribute_keys,
    :position => position
  }
end

#to_jsonObject



19452
19453
19454
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19452

def to_json
  JSON.dump(to_hash)
end