Class: Io::Flow::V0::Models::AttributeForm

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

Returns a new instance of AttributeForm.



10399
10400
10401
10402
10403
10404
10405
10406
10407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10399

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:key, :options], 'AttributeForm')
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @options = (x = opts.delete(:options); x.is_a?(::Io::Flow::V0::Models::Options) ? x : ::Io::Flow::V0::Models::Options.new(x))
  @label = (x = opts.delete(:label); x.nil? ? nil : HttpClient::Preconditions.assert_class('label', x, String))
  @intent = (x = opts.delete(:intent); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::AttributeIntent) ? x : ::Io::Flow::V0::Models::AttributeIntent.apply(x)))
  @type = (x = opts.delete(:type); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::AttributeDataType) ? x : ::Io::Flow::V0::Models::AttributeDataType.apply(x)))
end

Instance Attribute Details

#intentObject (readonly)

Returns the value of attribute intent.



10397
10398
10399
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10397

def intent
  @intent
end

#keyObject (readonly)

Returns the value of attribute key.



10397
10398
10399
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10397

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



10397
10398
10399
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10397

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options.



10397
10398
10399
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10397

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



10397
10398
10399
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10397

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



10413
10414
10415
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10413

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

#to_hashObject



10417
10418
10419
10420
10421
10422
10423
10424
10425
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10417

def to_hash
  {
    :key => key,
    :options => options.to_hash,
    :label => label,
    :intent => intent.nil? ? nil : intent.value,
    :type => type.nil? ? nil : type.value
  }
end

#to_jsonObject



10409
10410
10411
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10409

def to_json
  JSON.dump(to_hash)
end