Class: EdmentumClient::EdApiModelsClass

Inherits:
Object
  • Object
show all
Defined in:
lib/edmentum_client/models/ed_api_models_class.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ EdApiModelsClass

Initializes the object

Parameters:

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

    Model attributes in the form of hash



91
92
93
94
95
96
97
98
99
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 91

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 }

  if attributes.has_key?(:'ProgramId')
    self.program_id = attributes[:'ProgramId']
  end

  if attributes.has_key?(:'ResourceNodeId')
    self.resource_node_id = attributes[:'ResourceNodeId']
  end

  if attributes.has_key?(:'ResourceVersion')
    self.resource_version = attributes[:'ResourceVersion']
  end

  if attributes.has_key?(:'ResourceNodeName')
    self.resource_node_name = attributes[:'ResourceNodeName']
  end

  if attributes.has_key?(:'ClassId')
    self.class_id = attributes[:'ClassId']
  end

  if attributes.has_key?(:'Name')
    self.name = attributes[:'Name']
  end

  if attributes.has_key?(:'Description')
    self.description = attributes[:'Description']
  end

  if attributes.has_key?(:'StartDate')
    self.start_date = attributes[:'StartDate']
  end

  if attributes.has_key?(:'EndDate')
    self.end_date = attributes[:'EndDate']
  end

  if attributes.has_key?(:'LockAssignmentOnDueDate')
    self.lock_assignment_on_due_date = attributes[:'LockAssignmentOnDueDate']
  end

  if attributes.has_key?(:'AllowSelfEnroll')
    self.allow_self_enroll = attributes[:'AllowSelfEnroll']
  end

  if attributes.has_key?(:'IsActive')
    self.is_active = attributes[:'IsActive']
  end

  if attributes.has_key?(:'SelfEnrollCode')
    self.self_enroll_code = attributes[:'SelfEnrollCode']
  end

  if attributes.has_key?(:'SelfEnrollPassword')
    self.self_enroll_password = attributes[:'SelfEnrollPassword']
  end

  if attributes.has_key?(:'MasteryTestAttempts')
    self.mastery_test_attempts = attributes[:'MasteryTestAttempts']
  end
end

Instance Attribute Details

#allow_self_enrollObject

Returns the value of attribute allow_self_enroll.



37
38
39
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 37

def allow_self_enroll
  @allow_self_enroll
end

#class_idObject

Returns the value of attribute class_id.



25
26
27
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 25

def class_id
  @class_id
end

#descriptionObject

Returns the value of attribute description.



29
30
31
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 29

def description
  @description
end

#end_dateObject

Returns the value of attribute end_date.



33
34
35
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 33

def end_date
  @end_date
end

#is_activeObject

Returns the value of attribute is_active.



39
40
41
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 39

def is_active
  @is_active
end

#lock_assignment_on_due_dateObject

Returns the value of attribute lock_assignment_on_due_date.



35
36
37
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 35

def lock_assignment_on_due_date
  @lock_assignment_on_due_date
end

#mastery_test_attemptsObject

Returns the value of attribute mastery_test_attempts.



45
46
47
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 45

def mastery_test_attempts
  @mastery_test_attempts
end

#nameObject

Returns the value of attribute name.



27
28
29
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 27

def name
  @name
end

#program_idObject

Returns the value of attribute program_id.



17
18
19
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 17

def program_id
  @program_id
end

#resource_node_idObject

Returns the value of attribute resource_node_id.



19
20
21
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 19

def resource_node_id
  @resource_node_id
end

#resource_node_nameObject

Returns the value of attribute resource_node_name.



23
24
25
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 23

def resource_node_name
  @resource_node_name
end

#resource_versionObject

Returns the value of attribute resource_version.



21
22
23
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 21

def resource_version
  @resource_version
end

#self_enroll_codeObject

Returns the value of attribute self_enroll_code.



41
42
43
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 41

def self_enroll_code
  @self_enroll_code
end

#self_enroll_passwordObject

Returns the value of attribute self_enroll_password.



43
44
45
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 43

def self_enroll_password
  @self_enroll_password
end

#start_dateObject

Returns the value of attribute start_date.



31
32
33
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 31

def start_date
  @start_date
end

Class Method Details

.attribute_mapObject

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



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 48

def self.attribute_map
  {
    :'program_id' => :'ProgramId',
    :'resource_node_id' => :'ResourceNodeId',
    :'resource_version' => :'ResourceVersion',
    :'resource_node_name' => :'ResourceNodeName',
    :'class_id' => :'ClassId',
    :'name' => :'Name',
    :'description' => :'Description',
    :'start_date' => :'StartDate',
    :'end_date' => :'EndDate',
    :'lock_assignment_on_due_date' => :'LockAssignmentOnDueDate',
    :'allow_self_enroll' => :'AllowSelfEnroll',
    :'is_active' => :'IsActive',
    :'self_enroll_code' => :'SelfEnrollCode',
    :'self_enroll_password' => :'SelfEnrollPassword',
    :'mastery_test_attempts' => :'MasteryTestAttempts'
  }
end

.swagger_typesObject

Attribute type mapping.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 69

def self.swagger_types
  {
    :'program_id' => :'Integer',
    :'resource_node_id' => :'Integer',
    :'resource_version' => :'Integer',
    :'resource_node_name' => :'String',
    :'class_id' => :'Integer',
    :'name' => :'String',
    :'description' => :'String',
    :'start_date' => :'DateTime',
    :'end_date' => :'DateTime',
    :'lock_assignment_on_due_date' => :'BOOLEAN',
    :'allow_self_enroll' => :'BOOLEAN',
    :'is_active' => :'BOOLEAN',
    :'self_enroll_code' => :'String',
    :'self_enroll_password' => :'String',
    :'mastery_test_attempts' => :'Integer'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 232

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      program_id == o.program_id &&
      resource_node_id == o.resource_node_id &&
      resource_version == o.resource_version &&
      resource_node_name == o.resource_node_name &&
      class_id == o.class_id &&
      name == o.name &&
      description == o.description &&
      start_date == o.start_date &&
      end_date == o.end_date &&
      lock_assignment_on_due_date == o.lock_assignment_on_due_date &&
      allow_self_enroll == o.allow_self_enroll &&
      is_active == o.is_active &&
      self_enroll_code == o.self_enroll_code &&
      self_enroll_password == o.self_enroll_password &&
      mastery_test_attempts == o.mastery_test_attempts
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



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 288

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.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
    temp_model = SwaggerClient.const_get(type).new
    temp_model.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



354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 354

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



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 267

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if 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
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(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?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


254
255
256
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 254

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



260
261
262
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 260

def hash
  [program_id, resource_node_id, resource_version, resource_node_name, class_id, name, description, start_date, end_date, lock_assignment_on_due_date, allow_self_enroll, is_active, self_enroll_code, self_enroll_password, mastery_test_attempts].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 160

def list_invalid_properties
  invalid_properties = Array.new
  if @resource_node_id.nil?
    invalid_properties.push('invalid value for "resource_node_id", resource_node_id cannot be nil.')
  end

  if @name.nil?
    invalid_properties.push('invalid value for "name", name cannot be nil.')
  end

  if @start_date.nil?
    invalid_properties.push('invalid value for "start_date", start_date cannot be nil.')
  end

  if @is_active.nil?
    invalid_properties.push('invalid value for "is_active", is_active cannot be nil.')
  end

  if !@self_enroll_password.nil?
    invalid_properties.push('must include a non-blank password')
  end

  if !@mastery_test_attempts.nil? && @mastery_test_attempts > 10
    invalid_properties.push('invalid value for "mastery_test_attempts", must be smaller than or equal to 10.')
  end

  if !@mastery_test_attempts.nil? && @mastery_test_attempts < 0
    invalid_properties.push('invalid value for "mastery_test_attempts", must be greater than or equal to 0.')
  end

  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



334
335
336
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 334

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



340
341
342
343
344
345
346
347
348
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 340

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



328
329
330
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 328

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



195
196
197
198
199
200
201
202
203
204
# File 'lib/edmentum_client/models/ed_api_models_class.rb', line 195

def valid?
  return false if @resource_node_id.nil?
  return false if @name.nil?
  return false if @start_date.nil?
  return false if @is_active.nil?
  return false if !@self_enroll_password.nil? && @self_enroll_password !~ Regexp.new(/^[a-zA-Z0-9@#$%&*+\\-_(),+':;?.,!\\[\\]\\s\\\\]{1,40}$/)
  return false if !@mastery_test_attempts.nil? && @mastery_test_attempts > 10
  return false if !@mastery_test_attempts.nil? && @mastery_test_attempts < 0
  true
end