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.



12189
12190
12191
12192
12193
12194
12195
12196
12197
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12189

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.



12187
12188
12189
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12187

def intent
  @intent
end

#keyObject (readonly)

Returns the value of attribute key.



12187
12188
12189
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12187

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



12187
12188
12189
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12187

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options.



12187
12188
12189
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12187

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



12187
12188
12189
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12187

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12203
12204
12205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12203

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

#to_hashObject



12207
12208
12209
12210
12211
12212
12213
12214
12215
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12207

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



12199
12200
12201
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12199

def to_json
  JSON.dump(to_hash)
end