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.



25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25031

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :experience, :key, :name, :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)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), 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.



25029
25030
25031
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25029

def attribute_keys
  @attribute_keys
end

#experienceObject (readonly)

Returns the value of attribute experience.



25029
25030
25031
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25029

def experience
  @experience
end

#idObject (readonly)

Returns the value of attribute id.



25029
25030
25031
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25029

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



25029
25030
25031
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25029

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



25029
25030
25031
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25029

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



25029
25030
25031
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25029

def position
  @position
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



25046
25047
25048
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25046

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

#to_hashObject



25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25050

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

#to_jsonObject



25042
25043
25044
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25042

def to_json
  JSON.dump(to_hash)
end