Class: OCI::AiDocument::Models::DocumentField

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/ai_document/models/document_field.rb

Overview

Form field.

Constant Summary collapse

FIELD_TYPE_ENUM =
[
  FIELD_TYPE_LINE_ITEM_GROUP = 'LINE_ITEM_GROUP'.freeze,
  FIELD_TYPE_LINE_ITEM = 'LINE_ITEM'.freeze,
  FIELD_TYPE_LINE_ITEM_FIELD = 'LINE_ITEM_FIELD'.freeze,
  FIELD_TYPE_KEY_VALUE = 'KEY_VALUE'.freeze,
  FIELD_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ DocumentField

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/oci/ai_document/models/document_field.rb', line 68

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.field_type = attributes[:'fieldType'] if attributes[:'fieldType']

  raise 'You cannot provide both :fieldType and :field_type' if attributes.key?(:'fieldType') && attributes.key?(:'field_type')

  self.field_type = attributes[:'field_type'] if attributes[:'field_type']

  self.field_label = attributes[:'fieldLabel'] if attributes[:'fieldLabel']

  raise 'You cannot provide both :fieldLabel and :field_label' if attributes.key?(:'fieldLabel') && attributes.key?(:'field_label')

  self.field_label = attributes[:'field_label'] if attributes[:'field_label']

  self.field_name = attributes[:'fieldName'] if attributes[:'fieldName']

  raise 'You cannot provide both :fieldName and :field_name' if attributes.key?(:'fieldName') && attributes.key?(:'field_name')

  self.field_name = attributes[:'field_name'] if attributes[:'field_name']

  self.field_value = attributes[:'fieldValue'] if attributes[:'fieldValue']

  raise 'You cannot provide both :fieldValue and :field_value' if attributes.key?(:'fieldValue') && attributes.key?(:'field_value')

  self.field_value = attributes[:'field_value'] if attributes[:'field_value']
end

Instance Attribute Details

#field_labelOCI::AiDocument::Models::FieldLabel



25
26
27
# File 'lib/oci/ai_document/models/document_field.rb', line 25

def field_label
  @field_label
end

#field_nameOCI::AiDocument::Models::FieldName



28
29
30
# File 'lib/oci/ai_document/models/document_field.rb', line 28

def field_name
  @field_name
end

#field_typeString

[Required] The field type.

Returns:

  • (String)


22
23
24
# File 'lib/oci/ai_document/models/document_field.rb', line 22

def field_type
  @field_type
end

#field_valueOCI::AiDocument::Models::FieldValue

This attribute is required.



32
33
34
# File 'lib/oci/ai_document/models/document_field.rb', line 32

def field_value
  @field_value
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



35
36
37
38
39
40
41
42
43
44
# File 'lib/oci/ai_document/models/document_field.rb', line 35

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'field_type': :'fieldType',
    'field_label': :'fieldLabel',
    'field_name': :'fieldName',
    'field_value': :'fieldValue'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



47
48
49
50
51
52
53
54
55
56
# File 'lib/oci/ai_document/models/document_field.rb', line 47

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'field_type': :'String',
    'field_label': :'OCI::AiDocument::Models::FieldLabel',
    'field_name': :'OCI::AiDocument::Models::FieldName',
    'field_value': :'OCI::AiDocument::Models::FieldValue'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



119
120
121
122
123
124
125
126
127
# File 'lib/oci/ai_document/models/document_field.rb', line 119

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    field_type == other.field_type &&
    field_label == other.field_label &&
    field_name == other.field_name &&
    field_value == other.field_value
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/oci/ai_document/models/document_field.rb', line 152

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


132
133
134
# File 'lib/oci/ai_document/models/document_field.rb', line 132

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



141
142
143
# File 'lib/oci/ai_document/models/document_field.rb', line 141

def hash
  [field_type, field_label, field_name, field_value].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



185
186
187
188
189
190
191
192
193
194
# File 'lib/oci/ai_document/models/document_field.rb', line 185

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



179
180
181
# File 'lib/oci/ai_document/models/document_field.rb', line 179

def to_s
  to_hash.to_s
end