Class: ConnectWise::UserDefinedFieldInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/connect_wise/models/user_defined_field_info.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UserDefinedFieldInfo

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Raises:

  • (ArgumentError)


142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 142

def initialize(attributes = {})
  raise ArgumentError, 'The input argument (attributes) must be a hash in `ConnectWise::UserDefinedFieldInfo` initialize method' unless attributes.is_a?(Hash)

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) do |(k, v), h|
    raise ArgumentError, "`#{k}` is not a valid attribute in `ConnectWise::UserDefinedFieldInfo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect unless self.class.attribute_map.key?(k.to_sym)

    h[k.to_sym] = v
  end

  self.id = attributes[:id] if attributes.key?(:id)

  self.pod_id = attributes[:pod_id] if attributes.key?(:pod_id)

  self.caption = attributes[:caption] if attributes.key?(:caption)

  self.sequence_number = attributes[:sequence_number] if attributes.key?(:sequence_number)

  self.help_text = attributes[:help_text] if attributes.key?(:help_text)

  self.field_type_identifier = attributes[:field_type_identifier] if attributes.key?(:field_type_identifier)

  self.number_decimals = attributes[:number_decimals] if attributes.key?(:number_decimals)

  self.entry_type_identifier = attributes[:entry_type_identifier] if attributes.key?(:entry_type_identifier)

  self.required_flag = attributes[:required_flag] if attributes.key?(:required_flag)

  self.display_on_screen_flag = attributes[:display_on_screen_flag] if attributes.key?(:display_on_screen_flag)

  self.read_only_flag = attributes[:read_only_flag] if attributes.key?(:read_only_flag)

  self.list_view_flag = attributes[:list_view_flag] if attributes.key?(:list_view_flag)

  self.button_url = attributes[:button_url] if attributes.key?(:button_url)

  if attributes.key?(:options) && (value = attributes[:options]).is_a?(Array)
    self.options = value
  end

  if attributes.key?(:business_unit_ids) && (value = attributes[:business_unit_ids]).is_a?(Array)
    self.business_unit_ids = value
  end

  if attributes.key?(:location_ids) && (value = attributes[:location_ids]).is_a?(Array)
    self.location_ids = value
  end

  self.date_created = attributes[:date_created] if attributes.key?(:date_created)

  return unless attributes.key?(:_info)
  return unless (value = attributes[:_info]).is_a?(Hash)

  self._info = value
end

Instance Attribute Details

#_infoObject

Returns the value of attribute _info.



31
32
33
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 31

def _info
  @_info
end

#business_unit_idsObject

List of business unit ids using custom field



43
44
45
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 43

def business_unit_ids
  @business_unit_ids
end

#button_urlObject

Only available with Button Field Type. Required when entryTypeIdentifier is button



40
41
42
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 40

def button_url
  @button_url
end

#captionObject

Field caption



23
24
25
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 23

def caption
  @caption
end

#date_createdObject

Date in UTC the custom field was created



49
50
51
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 49

def date_created
  @date_created
end

#display_on_screen_flagObject

Returns the value of attribute display_on_screen_flag.



31
32
33
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 31

def display_on_screen_flag
  @display_on_screen_flag
end

#entry_type_identifierObject

Returns the value of attribute entry_type_identifier.



31
32
33
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 31

def entry_type_identifier
  @entry_type_identifier
end

#field_type_identifierObject

Returns the value of attribute field_type_identifier.



31
32
33
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 31

def field_type_identifier
  @field_type_identifier
end

#help_textObject

Help text to accompany the custom field



29
30
31
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 29

def help_text
  @help_text
end

#idObject

ID of the custom user defined field



17
18
19
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 17

def id
  @id
end

#list_view_flagObject

Denotes that this custom field is included on a list view



37
38
39
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 37

def list_view_flag
  @list_view_flag
end

#location_idsObject

List of locations ids using custom field



46
47
48
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 46

def location_ids
  @location_ids
end

#number_decimalsObject

Only valid for Number or percent



34
35
36
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 34

def number_decimals
  @number_decimals
end

#optionsObject

Returns the value of attribute options.



31
32
33
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 31

def options
  @options
end

#pod_idObject

Id of the Pod where the custom field will be placed



20
21
22
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 20

def pod_id
  @pod_id
end

#read_only_flagObject

Returns the value of attribute read_only_flag.



31
32
33
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 31

def read_only_flag
  @read_only_flag
end

#required_flagObject

Returns the value of attribute required_flag.



31
32
33
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 31

def required_flag
  @required_flag
end

#sequence_numberObject

Must be between 1 and 500. This defines the order in which the custom fields will appear



26
27
28
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 26

def sequence_number
  @sequence_number
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



97
98
99
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 97

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 73

def self.attribute_map
  {
    id: :id,
    pod_id: :podId,
    caption: :caption,
    sequence_number: :sequenceNumber,
    help_text: :helpText,
    field_type_identifier: :fieldTypeIdentifier,
    number_decimals: :numberDecimals,
    entry_type_identifier: :entryTypeIdentifier,
    required_flag: :requiredFlag,
    display_on_screen_flag: :displayOnScreenFlag,
    read_only_flag: :readOnlyFlag,
    list_view_flag: :listViewFlag,
    button_url: :buttonUrl,
    options: :options,
    business_unit_ids: :businessUnitIds,
    location_ids: :locationIds,
    date_created: :dateCreated,
    _info: :_info
  }
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



275
276
277
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 275

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 126

def self.openapi_nullable
  Set.new(%i[
            pod_id
            sequence_number
            field_type_identifier
            number_decimals
            entry_type_identifier
            required_flag
            display_on_screen_flag
            read_only_flag
            list_view_flag
          ])
end

.openapi_typesObject

Attribute type mapping.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 102

def self.openapi_types
  {
    id: :Integer,
    pod_id: :Integer,
    caption: :String,
    sequence_number: :Integer,
    help_text: :String,
    field_type_identifier: :String,
    number_decimals: :Integer,
    entry_type_identifier: :String,
    required_flag: :Boolean,
    display_on_screen_flag: :Boolean,
    read_only_flag: :Boolean,
    list_view_flag: :Boolean,
    button_url: :String,
    options: :'Array<UserDefinedFieldOption>',
    business_unit_ids: :'Array<Integer>',
    location_ids: :'Array<Integer>',
    date_created: :String,
    _info: :'Hash<String, String>'
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 236

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

  self.class == other.class &&
    id == other.id &&
    pod_id == other.pod_id &&
    caption == other.caption &&
    sequence_number == other.sequence_number &&
    help_text == other.help_text &&
    field_type_identifier == other.field_type_identifier &&
    number_decimals == other.number_decimals &&
    entry_type_identifier == other.entry_type_identifier &&
    required_flag == other.required_flag &&
    display_on_screen_flag == other.display_on_screen_flag &&
    read_only_flag == other.read_only_flag &&
    list_view_flag == other.list_view_flag &&
    button_url == other.button_url &&
    options == other.options &&
    business_unit_ids == other.business_unit_ids &&
    location_ids == other.location_ids &&
    date_created == other.date_created &&
    _info == other._info
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 305

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = ConnectWise.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 376

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
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



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 282

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

  attributes = attributes.transform_keys(&:to_sym)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }) if attributes[self.class.attribute_map[key]].is_a?(Array)
    elsif !attributes[self.class.attribute_map[key]].nil?
      send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


262
263
264
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 262

def eql?(other)
  self == other
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



268
269
270
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 268

def hash
  [id, pod_id, caption, sequence_number, help_text, field_type_identifier, number_decimals, entry_type_identifier, required_flag, display_on_screen_flag, read_only_flag, list_view_flag, button_url, options, business_unit_ids, location_ids, date_created, _info].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



200
201
202
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 200

def list_invalid_properties
  []
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



352
353
354
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 352

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 358

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



346
347
348
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 346

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



206
207
208
209
210
211
212
213
214
# File 'lib/connect_wise/models/user_defined_field_info.rb', line 206

def valid?
  field_type_identifier_validator = EnumAttributeValidator.new('String', %w[TextArea Button Currency Date Hyperlink IPAddress Checkbox Number Percent Text Password])
  return false unless field_type_identifier_validator.valid?(@field_type_identifier)

  entry_type_identifier_validator = EnumAttributeValidator.new('String', %w[Date EntryField List Option])
  return false unless entry_type_identifier_validator.valid?(@entry_type_identifier)

  true
end