Class: ConnectWise::UserDefinedField

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

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UserDefinedField

Initializes the object

Raises:

  • (ArgumentError)


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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/connect_wise/models/user_defined_field.rb', line 148

def initialize(attributes = {})
  raise ArgumentError, 'The input argument (attributes) must be a hash in `ConnectWise::UserDefinedField` 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::UserDefinedField`. 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.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.field_type_identifier = attributes[:field_type_identifier] if attributes.key?(:field_type_identifier)

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

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

  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.add_all_business_units = attributes[:add_all_business_units] if attributes.key?(:add_all_business_units)

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

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

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

  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.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def _info
  @_info
end

#add_all_business_unitsObject

Returns the value of attribute add_all_business_units.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def add_all_business_units
  @add_all_business_units
end

#add_all_locationsObject

Returns the value of attribute add_all_locations.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def add_all_locations
  @add_all_locations
end

#business_unit_idsObject

Returns the value of attribute business_unit_ids.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def business_unit_ids
  @business_unit_ids
end

#button_urlObject

Only available with Button Field Type. Required when entryTypeIdentifier is button Max length: 1000;



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

def button_url
  @button_url
end

#captionObject

Field caption Max length: 25;



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

def caption
  @caption
end

#date_createdObject

Date in UTC the custom field was created



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

def date_created
  @date_created
end

#display_on_screen_flagObject

Returns the value of attribute display_on_screen_flag.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def display_on_screen_flag
  @display_on_screen_flag
end

#entry_type_identifierObject

Returns the value of attribute entry_type_identifier.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def entry_type_identifier
  @entry_type_identifier
end

#field_type_identifierObject

Returns the value of attribute field_type_identifier.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def field_type_identifier
  @field_type_identifier
end

#help_textObject

Help text to accompany the custom field Max length: 1000;



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

def help_text
  @help_text
end

#idObject

ID of the custom user defined field



28
29
30
# File 'lib/connect_wise/models/user_defined_field.rb', line 28

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.rb', line 37

def list_view_flag
  @list_view_flag
end

#location_idsObject

Returns the value of attribute location_ids.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

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.rb', line 34

def number_decimals
  @number_decimals
end

#optionsObject

Returns the value of attribute options.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def options
  @options
end

#pod_idObject

Id of the Pod where the custom field will be placed



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

def pod_id
  @pod_id
end

#read_only_flagObject

Returns the value of attribute read_only_flag.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def read_only_flag
  @read_only_flag
end

#remove_all_business_unitsObject

Returns the value of attribute remove_all_business_units.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def remove_all_business_units
  @remove_all_business_units
end

#remove_all_locationsObject

Returns the value of attribute remove_all_locations.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

def remove_all_locations
  @remove_all_locations
end

#required_flagObject

Returns the value of attribute required_flag.



25
26
27
# File 'lib/connect_wise/models/user_defined_field.rb', line 25

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



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

def sequence_number
  @sequence_number
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



95
96
97
# File 'lib/connect_wise/models/user_defined_field.rb', line 95

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



67
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
# File 'lib/connect_wise/models/user_defined_field.rb', line 67

def self.attribute_map
  {
    pod_id: :podId,
    caption: :caption,
    sequence_number: :sequenceNumber,
    field_type_identifier: :fieldTypeIdentifier,
    id: :id,
    help_text: :helpText,
    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,
    add_all_business_units: :addAllBusinessUnits,
    remove_all_business_units: :removeAllBusinessUnits,
    add_all_locations: :addAllLocations,
    remove_all_locations: :removeAllLocations,
    date_created: :dateCreated,
    _info: :_info
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash



298
299
300
# File 'lib/connect_wise/models/user_defined_field.rb', line 298

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

.openapi_nullableObject

List of attributes with nullable: true



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/connect_wise/models/user_defined_field.rb', line 128

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
            add_all_business_units
            remove_all_business_units
            add_all_locations
            remove_all_locations
          ])
end

.openapi_typesObject

Attribute type mapping.



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

def self.openapi_types
  {
    pod_id: :Integer,
    caption: :String,
    sequence_number: :Integer,
    field_type_identifier: :String,
    id: :Integer,
    help_text: :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>',
    add_all_business_units: :Boolean,
    remove_all_business_units: :Boolean,
    add_all_locations: :Boolean,
    remove_all_locations: :Boolean,
    date_created: :Time,
    _info: :'Hash<String, String>'
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/connect_wise/models/user_defined_field.rb', line 255

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

  self.class == other.class &&
    pod_id == other.pod_id &&
    caption == other.caption &&
    sequence_number == other.sequence_number &&
    field_type_identifier == other.field_type_identifier &&
    id == other.id &&
    help_text == other.help_text &&
    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 &&
    add_all_business_units == other.add_all_business_units &&
    remove_all_business_units == other.remove_all_business_units &&
    add_all_locations == other.add_all_locations &&
    remove_all_locations == other.remove_all_locations &&
    date_created == other.date_created &&
    _info == other._info
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/connect_wise/models/user_defined_field.rb', line 328

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



399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/connect_wise/models/user_defined_field.rb', line 399

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



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/connect_wise/models/user_defined_field.rb', line 305

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

See Also:

  • `==` method


285
286
287
# File 'lib/connect_wise/models/user_defined_field.rb', line 285

def eql?(other)
  self == other
end

#hashInteger

Calculates hash code according to all attributes.



291
292
293
# File 'lib/connect_wise/models/user_defined_field.rb', line 291

def hash
  [pod_id, caption, sequence_number, field_type_identifier, id, help_text, 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, add_all_business_units, remove_all_business_units, add_all_locations, remove_all_locations, date_created, _info].hash
end

#list_invalid_propertiesObject

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



214
215
216
217
218
219
# File 'lib/connect_wise/models/user_defined_field.rb', line 214

def list_invalid_properties
  invalid_properties = []
  invalid_properties.push('invalid value for "caption", caption cannot be nil.') if @caption.nil?

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



375
376
377
# File 'lib/connect_wise/models/user_defined_field.rb', line 375

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/connect_wise/models/user_defined_field.rb', line 381

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



369
370
371
# File 'lib/connect_wise/models/user_defined_field.rb', line 369

def to_s
  to_hash.to_s
end

#valid?Boolean

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



223
224
225
226
227
228
229
230
231
232
233
# File 'lib/connect_wise/models/user_defined_field.rb', line 223

def valid?
  return false if @caption.nil?

  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