commonlit-clever-ruby 2.1.4 → 2.1.6.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -1
  3. data/Gemfile.lock +46 -41
  4. data/Makefile +1 -1
  5. data/README.md +943 -11
  6. data/clever-ruby.gemspec +3 -10
  7. data/commonlit-clever-ruby-2.1.6.beta1.gem +0 -0
  8. data/docs/AdminName.md +0 -1
  9. data/docs/BadRequest.md +0 -1
  10. data/docs/Contact.md +0 -1
  11. data/docs/ContactObject.md +0 -1
  12. data/docs/ContactResponse.md +0 -1
  13. data/docs/ContactsCreated.md +0 -1
  14. data/docs/ContactsDeleted.md +0 -1
  15. data/docs/ContactsResponse.md +0 -1
  16. data/docs/ContactsUpdated.md +0 -1
  17. data/docs/Course.md +0 -1
  18. data/docs/CourseObject.md +0 -1
  19. data/docs/CourseResponse.md +0 -1
  20. data/docs/CoursesCreated.md +0 -1
  21. data/docs/CoursesDeleted.md +0 -1
  22. data/docs/CoursesResponse.md +0 -1
  23. data/docs/CoursesUpdated.md +0 -1
  24. data/docs/Credentials.md +0 -1
  25. data/docs/DataApi.md +1 -69
  26. data/docs/District.md +0 -1
  27. data/docs/DistrictAdmin.md +0 -1
  28. data/docs/DistrictAdminObject.md +0 -1
  29. data/docs/DistrictAdminResponse.md +0 -1
  30. data/docs/DistrictAdminsResponse.md +0 -1
  31. data/docs/DistrictObject.md +0 -1
  32. data/docs/DistrictResponse.md +0 -1
  33. data/docs/DistrictadminsCreated.md +0 -1
  34. data/docs/DistrictadminsDeleted.md +0 -1
  35. data/docs/DistrictadminsUpdated.md +0 -1
  36. data/docs/DistrictsCreated.md +0 -1
  37. data/docs/DistrictsDeleted.md +0 -1
  38. data/docs/DistrictsResponse.md +0 -1
  39. data/docs/DistrictsUpdated.md +0 -1
  40. data/docs/Event.md +0 -1
  41. data/docs/EventResponse.md +0 -1
  42. data/docs/EventsApi.md +0 -3
  43. data/docs/EventsResponse.md +0 -1
  44. data/docs/InternalError.md +0 -1
  45. data/docs/Link.md +0 -1
  46. data/docs/Location.md +0 -1
  47. data/docs/Name.md +0 -1
  48. data/docs/NotFound.md +0 -1
  49. data/docs/Principal.md +0 -1
  50. data/docs/School.md +0 -1
  51. data/docs/SchoolAdmin.md +0 -1
  52. data/docs/SchoolAdminObject.md +0 -1
  53. data/docs/SchoolAdminResponse.md +0 -1
  54. data/docs/SchoolAdminsResponse.md +0 -1
  55. data/docs/SchoolEnrollment.md +0 -1
  56. data/docs/SchoolObject.md +0 -1
  57. data/docs/SchoolResponse.md +0 -1
  58. data/docs/SchooladminsCreated.md +0 -1
  59. data/docs/SchooladminsDeleted.md +0 -1
  60. data/docs/SchooladminsUpdated.md +0 -1
  61. data/docs/SchoolsCreated.md +0 -1
  62. data/docs/SchoolsDeleted.md +0 -1
  63. data/docs/SchoolsResponse.md +0 -1
  64. data/docs/SchoolsUpdated.md +0 -1
  65. data/docs/Section.md +0 -1
  66. data/docs/SectionObject.md +0 -1
  67. data/docs/SectionResponse.md +0 -1
  68. data/docs/SectionsCreated.md +0 -1
  69. data/docs/SectionsDeleted.md +0 -1
  70. data/docs/SectionsResponse.md +0 -1
  71. data/docs/SectionsUpdated.md +0 -1
  72. data/docs/Student.md +0 -1
  73. data/docs/StudentObject.md +0 -1
  74. data/docs/StudentResponse.md +0 -1
  75. data/docs/StudentsCreated.md +0 -1
  76. data/docs/StudentsDeleted.md +0 -1
  77. data/docs/StudentsResponse.md +0 -1
  78. data/docs/StudentsUpdated.md +0 -1
  79. data/docs/Teacher.md +0 -1
  80. data/docs/TeacherObject.md +0 -1
  81. data/docs/TeacherResponse.md +0 -1
  82. data/docs/TeachersCreated.md +0 -1
  83. data/docs/TeachersDeleted.md +0 -1
  84. data/docs/TeachersResponse.md +0 -1
  85. data/docs/TeachersUpdated.md +0 -1
  86. data/docs/Term.md +0 -1
  87. data/docs/TermObject.md +0 -1
  88. data/docs/TermResponse.md +0 -1
  89. data/docs/TermsCreated.md +0 -1
  90. data/docs/TermsDeleted.md +0 -1
  91. data/docs/TermsResponse.md +0 -1
  92. data/docs/TermsUpdated.md +0 -1
  93. data/full-v2.yml +2541 -0
  94. data/lib/clever-ruby/api/data_api.rb +836 -635
  95. data/lib/clever-ruby/api/events_api.rb +23 -18
  96. data/lib/clever-ruby/api_client.rb +1 -0
  97. data/lib/clever-ruby/api_error.rb +21 -2
  98. data/lib/clever-ruby/configuration.rb +3 -7
  99. data/lib/clever-ruby/models/admin_name.rb +44 -20
  100. data/lib/clever-ruby/models/bad_request.rb +40 -18
  101. data/lib/clever-ruby/models/contact.rb +73 -45
  102. data/lib/clever-ruby/models/contact_object.rb +40 -18
  103. data/lib/clever-ruby/models/contact_response.rb +40 -18
  104. data/lib/clever-ruby/models/contacts_response.rb +42 -20
  105. data/lib/clever-ruby/models/course.rb +48 -24
  106. data/lib/clever-ruby/models/course_object.rb +40 -18
  107. data/lib/clever-ruby/models/course_response.rb +40 -18
  108. data/lib/clever-ruby/models/courses_response.rb +42 -20
  109. data/lib/clever-ruby/models/credentials.rb +40 -18
  110. data/lib/clever-ruby/models/district.rb +75 -47
  111. data/lib/clever-ruby/models/district_admin.rb +49 -26
  112. data/lib/clever-ruby/models/district_admin_object.rb +40 -18
  113. data/lib/clever-ruby/models/district_admin_response.rb +40 -18
  114. data/lib/clever-ruby/models/district_admins_response.rb +42 -20
  115. data/lib/clever-ruby/models/district_object.rb +40 -18
  116. data/lib/clever-ruby/models/district_response.rb +40 -18
  117. data/lib/clever-ruby/models/districts_response.rb +42 -20
  118. data/lib/clever-ruby/models/event.rb +49 -22
  119. data/lib/clever-ruby/models/event_response.rb +40 -18
  120. data/lib/clever-ruby/models/events_response.rb +42 -20
  121. data/lib/clever-ruby/models/internal_error.rb +40 -18
  122. data/lib/clever-ruby/models/link.rb +45 -23
  123. data/lib/clever-ruby/models/location.rb +56 -28
  124. data/lib/clever-ruby/models/name.rb +47 -22
  125. data/lib/clever-ruby/models/not_found.rb +40 -18
  126. data/lib/clever-ruby/models/principal.rb +44 -20
  127. data/lib/clever-ruby/models/school.rb +81 -53
  128. data/lib/clever-ruby/models/school_admin.rb +59 -35
  129. data/lib/clever-ruby/models/school_admin_object.rb +40 -18
  130. data/lib/clever-ruby/models/school_admin_response.rb +40 -18
  131. data/lib/clever-ruby/models/school_admins_response.rb +42 -20
  132. data/lib/clever-ruby/models/school_enrollment.rb +44 -22
  133. data/lib/clever-ruby/models/school_object.rb +40 -18
  134. data/lib/clever-ruby/models/school_response.rb +40 -18
  135. data/lib/clever-ruby/models/schools_response.rb +42 -20
  136. data/lib/clever-ruby/models/section.rb +84 -55
  137. data/lib/clever-ruby/models/section_object.rb +40 -18
  138. data/lib/clever-ruby/models/section_response.rb +40 -18
  139. data/lib/clever-ruby/models/sections_response.rb +42 -20
  140. data/lib/clever-ruby/models/student.rb +121 -100
  141. data/lib/clever-ruby/models/student_object.rb +40 -18
  142. data/lib/clever-ruby/models/student_response.rb +40 -18
  143. data/lib/clever-ruby/models/students_response.rb +42 -20
  144. data/lib/clever-ruby/models/teacher.rb +69 -43
  145. data/lib/clever-ruby/models/teacher_object.rb +40 -18
  146. data/lib/clever-ruby/models/teacher_response.rb +40 -18
  147. data/lib/clever-ruby/models/teachers_response.rb +42 -20
  148. data/lib/clever-ruby/models/term.rb +51 -26
  149. data/lib/clever-ruby/models/term_object.rb +40 -18
  150. data/lib/clever-ruby/models/term_response.rb +40 -18
  151. data/lib/clever-ruby/models/terms_response.rb +42 -20
  152. data/lib/clever-ruby/version.rb +2 -3
  153. data/lib/clever-ruby.rb +1 -2
  154. data/override/README-extension.md +4 -5
  155. data/override/api_client.rb +1 -0
  156. data/override/override.sh +7 -5
  157. data/spec/api/data_api_spec.rb +671 -0
  158. data/spec/api/events_api_spec.rb +61 -0
  159. data/spec/api_client_spec.rb +243 -0
  160. data/spec/spec_helper.rb +26 -18
  161. metadata +34 -150
  162. data/commonlit-clever-ruby-2.1.3.gem +0 -0
  163. data/spec/events.json +0 -227
  164. data/tags +0 -1681
@@ -6,8 +6,7 @@
6
6
  OpenAPI spec version: 2.1.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.18
10
-
9
+ Swagger Codegen version: 3.0.51
11
10
  =end
12
11
 
13
12
  require 'date'
@@ -91,96 +90,115 @@ module Clever
91
90
  end
92
91
 
93
92
  # Attribute type mapping.
94
- def self.swagger_types
93
+ def self.openapi_types
95
94
  {
96
- :'created' => :'String',
97
- :'district' => :'String',
95
+ :'created' => :'Object',
96
+ :'district' => :'Object',
98
97
  :'ext' => :'Object',
99
- :'high_grade' => :'String',
100
- :'id' => :'String',
101
- :'last_modified' => :'String',
102
- :'location' => :'Location',
103
- :'low_grade' => :'String',
104
- :'mdr_number' => :'String',
105
- :'name' => :'String',
106
- :'nces_id' => :'String',
107
- :'phone' => :'String',
108
- :'principal' => :'Principal',
109
- :'school_number' => :'String',
110
- :'sis_id' => :'String',
111
- :'state_id' => :'String'
98
+ :'high_grade' => :'Object',
99
+ :'id' => :'Object',
100
+ :'last_modified' => :'Object',
101
+ :'location' => :'Object',
102
+ :'low_grade' => :'Object',
103
+ :'mdr_number' => :'Object',
104
+ :'name' => :'Object',
105
+ :'nces_id' => :'Object',
106
+ :'phone' => :'Object',
107
+ :'principal' => :'Object',
108
+ :'school_number' => :'Object',
109
+ :'sis_id' => :'Object',
110
+ :'state_id' => :'Object'
112
111
  }
113
112
  end
114
113
 
114
+ # List of attributes with nullable: true
115
+ def self.openapi_nullable
116
+ Set.new([
117
+ :'high_grade',
118
+ :'low_grade',
119
+ :'mdr_number',
120
+ :'nces_id',
121
+ :'phone',
122
+ :'state_id'
123
+ ])
124
+ end
125
+
115
126
  # Initializes the object
116
127
  # @param [Hash] attributes Model attributes in the form of hash
117
128
  def initialize(attributes = {})
118
- return unless attributes.is_a?(Hash)
129
+ if (!attributes.is_a?(Hash))
130
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Clever::School` initialize method"
131
+ end
119
132
 
120
- # convert string to symbol for hash key
121
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
133
+ # check to see if the attribute exists and convert string to symbol for hash key
134
+ attributes = attributes.each_with_object({}) { |(k, v), h|
135
+ if (!self.class.attribute_map.key?(k.to_sym))
136
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Clever::School`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
137
+ end
138
+ h[k.to_sym] = v
139
+ }
122
140
 
123
- if attributes.has_key?(:'created')
141
+ if attributes.key?(:'created')
124
142
  self.created = attributes[:'created']
125
143
  end
126
144
 
127
- if attributes.has_key?(:'district')
145
+ if attributes.key?(:'district')
128
146
  self.district = attributes[:'district']
129
147
  end
130
148
 
131
- if attributes.has_key?(:'ext')
149
+ if attributes.key?(:'ext')
132
150
  self.ext = attributes[:'ext']
133
151
  end
134
152
 
135
- if attributes.has_key?(:'high_grade')
153
+ if attributes.key?(:'high_grade')
136
154
  self.high_grade = attributes[:'high_grade']
137
155
  end
138
156
 
139
- if attributes.has_key?(:'id')
157
+ if attributes.key?(:'id')
140
158
  self.id = attributes[:'id']
141
159
  end
142
160
 
143
- if attributes.has_key?(:'last_modified')
161
+ if attributes.key?(:'last_modified')
144
162
  self.last_modified = attributes[:'last_modified']
145
163
  end
146
164
 
147
- if attributes.has_key?(:'location')
165
+ if attributes.key?(:'location')
148
166
  self.location = attributes[:'location']
149
167
  end
150
168
 
151
- if attributes.has_key?(:'low_grade')
169
+ if attributes.key?(:'low_grade')
152
170
  self.low_grade = attributes[:'low_grade']
153
171
  end
154
172
 
155
- if attributes.has_key?(:'mdr_number')
173
+ if attributes.key?(:'mdr_number')
156
174
  self.mdr_number = attributes[:'mdr_number']
157
175
  end
158
176
 
159
- if attributes.has_key?(:'name')
177
+ if attributes.key?(:'name')
160
178
  self.name = attributes[:'name']
161
179
  end
162
180
 
163
- if attributes.has_key?(:'nces_id')
181
+ if attributes.key?(:'nces_id')
164
182
  self.nces_id = attributes[:'nces_id']
165
183
  end
166
184
 
167
- if attributes.has_key?(:'phone')
185
+ if attributes.key?(:'phone')
168
186
  self.phone = attributes[:'phone']
169
187
  end
170
188
 
171
- if attributes.has_key?(:'principal')
189
+ if attributes.key?(:'principal')
172
190
  self.principal = attributes[:'principal']
173
191
  end
174
192
 
175
- if attributes.has_key?(:'school_number')
193
+ if attributes.key?(:'school_number')
176
194
  self.school_number = attributes[:'school_number']
177
195
  end
178
196
 
179
- if attributes.has_key?(:'sis_id')
197
+ if attributes.key?(:'sis_id')
180
198
  self.sis_id = attributes[:'sis_id']
181
199
  end
182
200
 
183
- if attributes.has_key?(:'state_id')
201
+ if attributes.key?(:'state_id')
184
202
  self.state_id = attributes[:'state_id']
185
203
  end
186
204
  end
@@ -195,9 +213,9 @@ module Clever
195
213
  # Check to see if the all the properties in the model are valid
196
214
  # @return true if the model is valid
197
215
  def valid?
198
- high_grade_validator = EnumAttributeValidator.new('String', ['InfantToddler', 'Preschool', 'PreKindergarten', 'TransitionalKindergarten', 'Kindergarten', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', 'PostGraduate', 'Ungraded', 'Other', ''])
216
+ high_grade_validator = EnumAttributeValidator.new('Object', ['InfantToddler', 'Preschool', 'PreKindergarten', 'TransitionalKindergarten', 'Kindergarten', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', 'PostGraduate', 'Ungraded', 'Other', ''])
199
217
  return false unless high_grade_validator.valid?(@high_grade)
200
- low_grade_validator = EnumAttributeValidator.new('String', ['InfantToddler', 'Preschool', 'PreKindergarten', 'TransitionalKindergarten', 'Kindergarten', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', 'PostGraduate', 'Ungraded', 'Other', ''])
218
+ low_grade_validator = EnumAttributeValidator.new('Object', ['InfantToddler', 'Preschool', 'PreKindergarten', 'TransitionalKindergarten', 'Kindergarten', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', 'PostGraduate', 'Ungraded', 'Other', ''])
201
219
  return false unless low_grade_validator.valid?(@low_grade)
202
220
  true
203
221
  end
@@ -205,9 +223,9 @@ module Clever
205
223
  # Custom attribute writer method checking allowed values (enum).
206
224
  # @param [Object] high_grade Object to be assigned
207
225
  def high_grade=(high_grade)
208
- validator = EnumAttributeValidator.new('String', ['InfantToddler', 'Preschool', 'PreKindergarten', 'TransitionalKindergarten', 'Kindergarten', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', 'PostGraduate', 'Ungraded', 'Other', ''])
226
+ validator = EnumAttributeValidator.new('Object', ['InfantToddler', 'Preschool', 'PreKindergarten', 'TransitionalKindergarten', 'Kindergarten', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', 'PostGraduate', 'Ungraded', 'Other', ''])
209
227
  unless validator.valid?(high_grade)
210
- fail ArgumentError, 'invalid value for "high_grade", must be one of #{validator.allowable_values}.'
228
+ fail ArgumentError, "invalid value for \"high_grade\", must be one of #{validator.allowable_values}."
211
229
  end
212
230
  @high_grade = high_grade
213
231
  end
@@ -215,9 +233,9 @@ module Clever
215
233
  # Custom attribute writer method checking allowed values (enum).
216
234
  # @param [Object] low_grade Object to be assigned
217
235
  def low_grade=(low_grade)
218
- validator = EnumAttributeValidator.new('String', ['InfantToddler', 'Preschool', 'PreKindergarten', 'TransitionalKindergarten', 'Kindergarten', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', 'PostGraduate', 'Ungraded', 'Other', ''])
236
+ validator = EnumAttributeValidator.new('Object', ['InfantToddler', 'Preschool', 'PreKindergarten', 'TransitionalKindergarten', 'Kindergarten', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', 'PostGraduate', 'Ungraded', 'Other', ''])
219
237
  unless validator.valid?(low_grade)
220
- fail ArgumentError, 'invalid value for "low_grade", must be one of #{validator.allowable_values}.'
238
+ fail ArgumentError, "invalid value for \"low_grade\", must be one of #{validator.allowable_values}."
221
239
  end
222
240
  @low_grade = low_grade
223
241
  end
@@ -252,17 +270,24 @@ module Clever
252
270
  end
253
271
 
254
272
  # Calculates hash code according to all attributes.
255
- # @return [Fixnum] Hash code
273
+ # @return [Integer] Hash code
256
274
  def hash
257
275
  [created, district, ext, high_grade, id, last_modified, location, low_grade, mdr_number, name, nces_id, phone, principal, school_number, sis_id, state_id].hash
258
276
  end
259
277
 
278
+ # Builds the object from hash
279
+ # @param [Hash] attributes Model attributes in the form of hash
280
+ # @return [Object] Returns the model itself
281
+ def self.build_from_hash(attributes)
282
+ new.build_from_hash(attributes)
283
+ end
284
+
260
285
  # Builds the object from hash
261
286
  # @param [Hash] attributes Model attributes in the form of hash
262
287
  # @return [Object] Returns the model itself
263
288
  def build_from_hash(attributes)
264
289
  return nil unless attributes.is_a?(Hash)
265
- self.class.swagger_types.each_pair do |key, type|
290
+ self.class.openapi_types.each_pair do |key, type|
266
291
  if type =~ /\AArray<(.*)>/i
267
292
  # check to ensure the input is an array given that the attribute
268
293
  # is documented as an array but the input is not
@@ -271,7 +296,9 @@ module Clever
271
296
  end
272
297
  elsif !attributes[self.class.attribute_map[key]].nil?
273
298
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
274
- end # or else data not found in attributes(hash), not an issue as the data can be optional
299
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
300
+ self.send("#{key}=", nil)
301
+ end
275
302
  end
276
303
 
277
304
  self
@@ -293,7 +320,7 @@ module Clever
293
320
  value.to_i
294
321
  when :Float
295
322
  value.to_f
296
- when :BOOLEAN
323
+ when :Boolean
297
324
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
298
325
  true
299
326
  else
@@ -314,8 +341,7 @@ module Clever
314
341
  end
315
342
  end
316
343
  else # model
317
- temp_model = Clever.const_get(type).new
318
- temp_model.build_from_hash(value)
344
+ Clever.const_get(type).build_from_hash(value)
319
345
  end
320
346
  end
321
347
 
@@ -337,7 +363,11 @@ module Clever
337
363
  hash = {}
338
364
  self.class.attribute_map.each_pair do |attr, param|
339
365
  value = self.send(attr)
340
- next if value.nil?
366
+ if value.nil?
367
+ is_nullable = self.class.openapi_nullable.include?(attr)
368
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
369
+ end
370
+
341
371
  hash[param] = _to_hash(value)
342
372
  end
343
373
  hash
@@ -359,7 +389,5 @@ module Clever
359
389
  else
360
390
  value
361
391
  end
362
- end
363
-
364
- end
392
+ end end
365
393
  end
@@ -6,8 +6,7 @@
6
6
  OpenAPI spec version: 2.1.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.18
10
-
9
+ Swagger Codegen version: 3.0.51
11
10
  =end
12
11
 
13
12
  require 'date'
@@ -51,68 +50,83 @@ module Clever
51
50
  end
52
51
 
53
52
  # Attribute type mapping.
54
- def self.swagger_types
53
+ def self.openapi_types
55
54
  {
56
- :'credentials' => :'Credentials',
57
- :'department' => :'String',
58
- :'district' => :'String',
59
- :'email' => :'String',
55
+ :'credentials' => :'Object',
56
+ :'department' => :'Object',
57
+ :'district' => :'Object',
58
+ :'email' => :'Object',
60
59
  :'ext' => :'Object',
61
- :'id' => :'String',
62
- :'name' => :'AdminName',
63
- :'schools' => :'Array<String>',
64
- :'staff_id' => :'String',
65
- :'title' => :'String'
60
+ :'id' => :'Object',
61
+ :'name' => :'Object',
62
+ :'schools' => :'Object',
63
+ :'staff_id' => :'Object',
64
+ :'title' => :'Object'
66
65
  }
67
66
  end
68
67
 
68
+ # List of attributes with nullable: true
69
+ def self.openapi_nullable
70
+ Set.new([
71
+ :'department',
72
+ :'title'
73
+ ])
74
+ end
75
+
69
76
  # Initializes the object
70
77
  # @param [Hash] attributes Model attributes in the form of hash
71
78
  def initialize(attributes = {})
72
- return unless attributes.is_a?(Hash)
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Clever::SchoolAdmin` initialize method"
81
+ end
73
82
 
74
- # convert string to symbol for hash key
75
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Clever::SchoolAdmin`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
76
90
 
77
- if attributes.has_key?(:'credentials')
91
+ if attributes.key?(:'credentials')
78
92
  self.credentials = attributes[:'credentials']
79
93
  end
80
94
 
81
- if attributes.has_key?(:'department')
95
+ if attributes.key?(:'department')
82
96
  self.department = attributes[:'department']
83
97
  end
84
98
 
85
- if attributes.has_key?(:'district')
99
+ if attributes.key?(:'district')
86
100
  self.district = attributes[:'district']
87
101
  end
88
102
 
89
- if attributes.has_key?(:'email')
103
+ if attributes.key?(:'email')
90
104
  self.email = attributes[:'email']
91
105
  end
92
106
 
93
- if attributes.has_key?(:'ext')
107
+ if attributes.key?(:'ext')
94
108
  self.ext = attributes[:'ext']
95
109
  end
96
110
 
97
- if attributes.has_key?(:'id')
111
+ if attributes.key?(:'id')
98
112
  self.id = attributes[:'id']
99
113
  end
100
114
 
101
- if attributes.has_key?(:'name')
115
+ if attributes.key?(:'name')
102
116
  self.name = attributes[:'name']
103
117
  end
104
118
 
105
- if attributes.has_key?(:'schools')
119
+ if attributes.key?(:'schools')
106
120
  if (value = attributes[:'schools']).is_a?(Array)
107
121
  self.schools = value
108
122
  end
109
123
  end
110
124
 
111
- if attributes.has_key?(:'staff_id')
125
+ if attributes.key?(:'staff_id')
112
126
  self.staff_id = attributes[:'staff_id']
113
127
  end
114
128
 
115
- if attributes.has_key?(:'title')
129
+ if attributes.key?(:'title')
116
130
  self.title = attributes[:'title']
117
131
  end
118
132
  end
@@ -154,17 +168,24 @@ module Clever
154
168
  end
155
169
 
156
170
  # Calculates hash code according to all attributes.
157
- # @return [Fixnum] Hash code
171
+ # @return [Integer] Hash code
158
172
  def hash
159
173
  [credentials, department, district, email, ext, id, name, schools, staff_id, title].hash
160
174
  end
161
175
 
176
+ # Builds the object from hash
177
+ # @param [Hash] attributes Model attributes in the form of hash
178
+ # @return [Object] Returns the model itself
179
+ def self.build_from_hash(attributes)
180
+ new.build_from_hash(attributes)
181
+ end
182
+
162
183
  # Builds the object from hash
163
184
  # @param [Hash] attributes Model attributes in the form of hash
164
185
  # @return [Object] Returns the model itself
165
186
  def build_from_hash(attributes)
166
187
  return nil unless attributes.is_a?(Hash)
167
- self.class.swagger_types.each_pair do |key, type|
188
+ self.class.openapi_types.each_pair do |key, type|
168
189
  if type =~ /\AArray<(.*)>/i
169
190
  # check to ensure the input is an array given that the attribute
170
191
  # is documented as an array but the input is not
@@ -173,7 +194,9 @@ module Clever
173
194
  end
174
195
  elsif !attributes[self.class.attribute_map[key]].nil?
175
196
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
176
- end # or else data not found in attributes(hash), not an issue as the data can be optional
197
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
198
+ self.send("#{key}=", nil)
199
+ end
177
200
  end
178
201
 
179
202
  self
@@ -195,7 +218,7 @@ module Clever
195
218
  value.to_i
196
219
  when :Float
197
220
  value.to_f
198
- when :BOOLEAN
221
+ when :Boolean
199
222
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
223
  true
201
224
  else
@@ -216,8 +239,7 @@ module Clever
216
239
  end
217
240
  end
218
241
  else # model
219
- temp_model = Clever.const_get(type).new
220
- temp_model.build_from_hash(value)
242
+ Clever.const_get(type).build_from_hash(value)
221
243
  end
222
244
  end
223
245
 
@@ -239,7 +261,11 @@ module Clever
239
261
  hash = {}
240
262
  self.class.attribute_map.each_pair do |attr, param|
241
263
  value = self.send(attr)
242
- next if value.nil?
264
+ if value.nil?
265
+ is_nullable = self.class.openapi_nullable.include?(attr)
266
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
267
+ end
268
+
243
269
  hash[param] = _to_hash(value)
244
270
  end
245
271
  hash
@@ -261,7 +287,5 @@ module Clever
261
287
  else
262
288
  value
263
289
  end
264
- end
265
-
266
- end
290
+ end end
267
291
  end
@@ -6,8 +6,7 @@
6
6
  OpenAPI spec version: 2.1.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.18
10
-
9
+ Swagger Codegen version: 3.0.51
11
10
  =end
12
11
 
13
12
  require 'date'
@@ -24,21 +23,34 @@ module Clever
24
23
  end
25
24
 
26
25
  # Attribute type mapping.
27
- def self.swagger_types
26
+ def self.openapi_types
28
27
  {
29
- :'object' => :'SchoolAdmin'
28
+ :'object' => :'Object'
30
29
  }
31
30
  end
32
31
 
32
+ # List of attributes with nullable: true
33
+ def self.openapi_nullable
34
+ Set.new([
35
+ ])
36
+ end
37
+
33
38
  # Initializes the object
34
39
  # @param [Hash] attributes Model attributes in the form of hash
35
40
  def initialize(attributes = {})
36
- return unless attributes.is_a?(Hash)
41
+ if (!attributes.is_a?(Hash))
42
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Clever::SchoolAdminObject` initialize method"
43
+ end
37
44
 
38
- # convert string to symbol for hash key
39
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
45
+ # check to see if the attribute exists and convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}) { |(k, v), h|
47
+ if (!self.class.attribute_map.key?(k.to_sym))
48
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Clever::SchoolAdminObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
49
+ end
50
+ h[k.to_sym] = v
51
+ }
40
52
 
41
- if attributes.has_key?(:'object')
53
+ if attributes.key?(:'object')
42
54
  self.object = attributes[:'object']
43
55
  end
44
56
  end
@@ -71,17 +83,24 @@ module Clever
71
83
  end
72
84
 
73
85
  # Calculates hash code according to all attributes.
74
- # @return [Fixnum] Hash code
86
+ # @return [Integer] Hash code
75
87
  def hash
76
88
  [object].hash
77
89
  end
78
90
 
91
+ # Builds the object from hash
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ # @return [Object] Returns the model itself
94
+ def self.build_from_hash(attributes)
95
+ new.build_from_hash(attributes)
96
+ end
97
+
79
98
  # Builds the object from hash
80
99
  # @param [Hash] attributes Model attributes in the form of hash
81
100
  # @return [Object] Returns the model itself
82
101
  def build_from_hash(attributes)
83
102
  return nil unless attributes.is_a?(Hash)
84
- self.class.swagger_types.each_pair do |key, type|
103
+ self.class.openapi_types.each_pair do |key, type|
85
104
  if type =~ /\AArray<(.*)>/i
86
105
  # check to ensure the input is an array given that the attribute
87
106
  # is documented as an array but the input is not
@@ -90,7 +109,9 @@ module Clever
90
109
  end
91
110
  elsif !attributes[self.class.attribute_map[key]].nil?
92
111
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
93
- end # or else data not found in attributes(hash), not an issue as the data can be optional
112
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
113
+ self.send("#{key}=", nil)
114
+ end
94
115
  end
95
116
 
96
117
  self
@@ -112,7 +133,7 @@ module Clever
112
133
  value.to_i
113
134
  when :Float
114
135
  value.to_f
115
- when :BOOLEAN
136
+ when :Boolean
116
137
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
117
138
  true
118
139
  else
@@ -133,8 +154,7 @@ module Clever
133
154
  end
134
155
  end
135
156
  else # model
136
- temp_model = Clever.const_get(type).new
137
- temp_model.build_from_hash(value)
157
+ Clever.const_get(type).build_from_hash(value)
138
158
  end
139
159
  end
140
160
 
@@ -156,7 +176,11 @@ module Clever
156
176
  hash = {}
157
177
  self.class.attribute_map.each_pair do |attr, param|
158
178
  value = self.send(attr)
159
- next if value.nil?
179
+ if value.nil?
180
+ is_nullable = self.class.openapi_nullable.include?(attr)
181
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
182
+ end
183
+
160
184
  hash[param] = _to_hash(value)
161
185
  end
162
186
  hash
@@ -178,7 +202,5 @@ module Clever
178
202
  else
179
203
  value
180
204
  end
181
- end
182
-
183
- end
205
+ end end
184
206
  end