lib/clever-ruby/models/student.rb in commonlit-clever-ruby-2.1.6.beta1 vs lib/clever-ruby/models/student.rb in commonlit-clever-ruby-2.1.6.beta2

- old
+ new

@@ -1,23 +1,20 @@ =begin -#Data API +#Clever API -#Serves the Clever Data API +#The Clever API OpenAPI spec version: 2.1.0 Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.4.37 - +Swagger Codegen version: 3.0.51 =end require 'date' module Clever class Student - attr_accessor :id - attr_accessor :created attr_accessor :credentials attr_accessor :district @@ -28,20 +25,24 @@ attr_accessor :email attr_accessor :enrollments + attr_accessor :ext + attr_accessor :gender - attr_accessor :graduation_year - attr_accessor :grade + attr_accessor :graduation_year + attr_accessor :hispanic_ethnicity attr_accessor :home_language + attr_accessor :id + attr_accessor :iep_status attr_accessor :last_modified attr_accessor :location @@ -62,12 +63,10 @@ attr_accessor :unweighted_gpa attr_accessor :weighted_gpa - attr_accessor :ext - class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values def initialize(datatype, allowable_values) @@ -89,23 +88,24 @@ end # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'id' => :'id', :'created' => :'created', :'credentials' => :'credentials', :'district' => :'district', :'dob' => :'dob', :'ell_status' => :'ell_status', :'email' => :'email', :'enrollments' => :'enrollments', + :'ext' => :'ext', :'gender' => :'gender', - :'graduation_year' => :'graduation_year', :'grade' => :'grade', + :'graduation_year' => :'graduation_year', :'hispanic_ethnicity' => :'hispanic_ethnicity', :'home_language' => :'home_language', + :'id' => :'id', :'iep_status' => :'iep_status', :'last_modified' => :'last_modified', :'location' => :'location', :'name' => :'name', :'race' => :'race', @@ -113,282 +113,294 @@ :'schools' => :'schools', :'sis_id' => :'sis_id', :'state_id' => :'state_id', :'student_number' => :'student_number', :'unweighted_gpa' => :'unweighted_gpa', - :'weighted_gpa' => :'weighted_gpa', - :'ext' => :'ext' + :'weighted_gpa' => :'weighted_gpa' } end # Attribute type mapping. - def self.swagger_types + def self.openapi_types { - :'id' => :'String', - :'created' => :'String', - :'credentials' => :'Credentials', - :'district' => :'String', - :'dob' => :'String', - :'ell_status' => :'String', - :'email' => :'String', - :'enrollments' => :'Array<SchoolEnrollment>', - :'gender' => :'String', - :'graduation_year' => :'String', - :'grade' => :'String', - :'hispanic_ethnicity' => :'String', - :'home_language' => :'String', - :'iep_status' => :'String', - :'last_modified' => :'String', - :'location' => :'Location', - :'name' => :'Name', - :'race' => :'String', - :'school' => :'String', - :'schools' => :'Array<String>', - :'sis_id' => :'String', - :'state_id' => :'String', - :'student_number' => :'String', - :'unweighted_gpa' => :'String', - :'weighted_gpa' => :'String', - :'ext' => :'Object' + :'created' => :'Object', + :'credentials' => :'Object', + :'district' => :'Object', + :'dob' => :'Object', + :'ell_status' => :'Object', + :'email' => :'Object', + :'enrollments' => :'Object', + :'ext' => :'Object', + :'gender' => :'Object', + :'grade' => :'Object', + :'graduation_year' => :'Object', + :'hispanic_ethnicity' => :'Object', + :'home_language' => :'Object', + :'id' => :'Object', + :'iep_status' => :'Object', + :'last_modified' => :'Object', + :'location' => :'Object', + :'name' => :'Object', + :'race' => :'Object', + :'school' => :'Object', + :'schools' => :'Object', + :'sis_id' => :'Object', + :'state_id' => :'Object', + :'student_number' => :'Object', + :'unweighted_gpa' => :'Object', + :'weighted_gpa' => :'Object' } end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'dob', + :'ell_status', + :'email', + :'gender', + :'grade', + :'graduation_year', + :'hispanic_ethnicity', + :'home_language', + :'iep_status', + :'race', + :'state_id', + :'student_number', + :'unweighted_gpa', + :'weighted_gpa' + ]) + end + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash 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?(:'id') - self.id = attributes[:'id'] + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Clever::Student` initialize method" end - if attributes.has_key?(:'created') + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Clever::Student`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'created') self.created = attributes[:'created'] end - if attributes.has_key?(:'credentials') + if attributes.key?(:'credentials') self.credentials = attributes[:'credentials'] end - if attributes.has_key?(:'district') + if attributes.key?(:'district') self.district = attributes[:'district'] end - if attributes.has_key?(:'dob') + if attributes.key?(:'dob') self.dob = attributes[:'dob'] end - if attributes.has_key?(:'ell_status') + if attributes.key?(:'ell_status') self.ell_status = attributes[:'ell_status'] end - if attributes.has_key?(:'email') + if attributes.key?(:'email') self.email = attributes[:'email'] end - if attributes.has_key?(:'enrollments') + if attributes.key?(:'enrollments') if (value = attributes[:'enrollments']).is_a?(Array) self.enrollments = value end end - if attributes.has_key?(:'gender') - self.gender = attributes[:'gender'] + if attributes.key?(:'ext') + self.ext = attributes[:'ext'] end - if attributes.has_key?(:'graduation_year') - self.graduation_year = attributes[:'graduation_year'] + if attributes.key?(:'gender') + self.gender = attributes[:'gender'] end - if attributes.has_key?(:'grade') + if attributes.key?(:'grade') self.grade = attributes[:'grade'] end - if attributes.has_key?(:'hispanic_ethnicity') + if attributes.key?(:'graduation_year') + self.graduation_year = attributes[:'graduation_year'] + end + + if attributes.key?(:'hispanic_ethnicity') self.hispanic_ethnicity = attributes[:'hispanic_ethnicity'] end - if attributes.has_key?(:'home_language') + if attributes.key?(:'home_language') self.home_language = attributes[:'home_language'] end - if attributes.has_key?(:'iep_status') + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'iep_status') self.iep_status = attributes[:'iep_status'] end - if attributes.has_key?(:'last_modified') + if attributes.key?(:'last_modified') self.last_modified = attributes[:'last_modified'] end - if attributes.has_key?(:'location') + if attributes.key?(:'location') self.location = attributes[:'location'] end - if attributes.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] end - if attributes.has_key?(:'race') + if attributes.key?(:'race') self.race = attributes[:'race'] end - if attributes.has_key?(:'school') + if attributes.key?(:'school') self.school = attributes[:'school'] end - if attributes.has_key?(:'schools') + if attributes.key?(:'schools') if (value = attributes[:'schools']).is_a?(Array) self.schools = value end end - if attributes.has_key?(:'sis_id') + if attributes.key?(:'sis_id') self.sis_id = attributes[:'sis_id'] end - if attributes.has_key?(:'state_id') + if attributes.key?(:'state_id') self.state_id = attributes[:'state_id'] end - if attributes.has_key?(:'student_number') + if attributes.key?(:'student_number') self.student_number = attributes[:'student_number'] end - if attributes.has_key?(:'unweighted_gpa') + if attributes.key?(:'unweighted_gpa') self.unweighted_gpa = attributes[:'unweighted_gpa'] end - if attributes.has_key?(:'weighted_gpa') + if attributes.key?(:'weighted_gpa') self.weighted_gpa = attributes[:'weighted_gpa'] end - - if attributes.has_key?(:'ext') - self.ext = attributes[:'ext'] - end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new - if !@dob.nil? && @dob !~ Regexp.new(/(?:[0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/) - invalid_properties.push('invalid value for "dob", must conform to the pattern /(?:[0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/.') - end - invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - return false if !@dob.nil? && @dob !~ Regexp.new(/(?:[0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/) - ell_status_validator = EnumAttributeValidator.new('String', ['Y', 'N', '']) + ell_status_validator = EnumAttributeValidator.new('Object', ['Y', 'N', '']) return false unless ell_status_validator.valid?(@ell_status) - gender_validator = EnumAttributeValidator.new('String', ['M', 'F', 'X', '']) + gender_validator = EnumAttributeValidator.new('Object', ['M', 'F', 'X', '']) return false unless gender_validator.valid?(@gender) - 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', '']) + 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', '']) return false unless grade_validator.valid?(@grade) - hispanic_ethnicity_validator = EnumAttributeValidator.new('String', ['Y', 'N', '']) + hispanic_ethnicity_validator = EnumAttributeValidator.new('Object', ['Y', 'N', '']) return false unless hispanic_ethnicity_validator.valid?(@hispanic_ethnicity) - home_language_validator = EnumAttributeValidator.new('String', ['English', 'Albanian', 'Amharic', 'Arabic', 'Bengali', 'Bosnian', 'Burmese', 'Cantonese', 'Chinese', 'Dutch', 'Farsi', 'French', 'German', 'Hebrew', 'Hindi', 'Hmong', 'Ilocano', 'Japanese', 'Javanese', 'Karen', 'Khmer', 'Korean', 'Laotian', 'Latvian', 'Malay', 'Mandarin', 'Nepali', 'Oromo', 'Polish', 'Portuguese', 'Punjabi', 'Romanian', 'Russian', 'Samoan', 'Serbian', 'Somali', 'Spanish', 'Swahili', 'Tagalog', 'Tamil', 'Telugu', 'Thai', 'Tigrinya', 'Turkish', 'Ukrainian', 'Urdu', 'Vietnamese', '']) + home_language_validator = EnumAttributeValidator.new('Object', ['English', 'Albanian', 'Amharic', 'Arabic', 'Bengali', 'Bosnian', 'Burmese', 'Cantonese', 'Chinese', 'Dutch', 'Farsi', 'French', 'German', 'Hebrew', 'Hindi', 'Hmong', 'Ilocano', 'Japanese', 'Javanese', 'Karen', 'Khmer', 'Korean', 'Laotian', 'Latvian', 'Malay', 'Mandarin', 'Nepali', 'Oromo', 'Polish', 'Portuguese', 'Punjabi', 'Romanian', 'Russian', 'Samoan', 'Serbian', 'Somali', 'Spanish', 'Swahili', 'Tagalog', 'Tamil', 'Telugu', 'Thai', 'Tigrinya', 'Turkish', 'Ukrainian', 'Urdu', 'Vietnamese', '']) return false unless home_language_validator.valid?(@home_language) - race_validator = EnumAttributeValidator.new('String', ['Caucasian', 'Asian', 'Black or African American', 'American Indian', 'Hawaiian or Other Pacific Islander', 'Two or More Races', 'Unknown', '']) + race_validator = EnumAttributeValidator.new('Object', ['Caucasian', 'Asian', 'Black or African American', 'American Indian', 'Hawaiian or Other Pacific Islander', 'Two or More Races', 'Unknown', '']) return false unless race_validator.valid?(@race) true end - # Custom attribute writer method with validation - # @param [Object] dob Value to be assigned - def dob=(dob) - if !dob.nil? && dob !~ Regexp.new(/(?:[0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/) - fail ArgumentError, 'invalid value for "dob", must conform to the pattern /(?:[0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/.' - end - - @dob = dob - end - # Custom attribute writer method checking allowed values (enum). # @param [Object] ell_status Object to be assigned def ell_status=(ell_status) - validator = EnumAttributeValidator.new('String', ['Y', 'N', '']) + validator = EnumAttributeValidator.new('Object', ['Y', 'N', '']) unless validator.valid?(ell_status) - fail ArgumentError, 'invalid value for "ell_status", must be one of #{validator.allowable_values}.' + fail ArgumentError, "invalid value for \"ell_status\", must be one of #{validator.allowable_values}." end @ell_status = ell_status end # Custom attribute writer method checking allowed values (enum). # @param [Object] gender Object to be assigned def gender=(gender) - validator = EnumAttributeValidator.new('String', ['M', 'F', 'X', '']) + validator = EnumAttributeValidator.new('Object', ['M', 'F', 'X', '']) unless validator.valid?(gender) - fail ArgumentError, 'invalid value for "gender", must be one of #{validator.allowable_values}.' + fail ArgumentError, "invalid value for \"gender\", must be one of #{validator.allowable_values}." end @gender = gender end # Custom attribute writer method checking allowed values (enum). # @param [Object] grade Object to be assigned def grade=(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', '']) + 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', '']) unless validator.valid?(grade) - fail ArgumentError, 'invalid value for "grade", must be one of #{validator.allowable_values}.' + fail ArgumentError, "invalid value for \"grade\", must be one of #{validator.allowable_values}." end @grade = grade end # Custom attribute writer method checking allowed values (enum). # @param [Object] hispanic_ethnicity Object to be assigned def hispanic_ethnicity=(hispanic_ethnicity) - validator = EnumAttributeValidator.new('String', ['Y', 'N', '']) + validator = EnumAttributeValidator.new('Object', ['Y', 'N', '']) unless validator.valid?(hispanic_ethnicity) - fail ArgumentError, 'invalid value for "hispanic_ethnicity", must be one of #{validator.allowable_values}.' + fail ArgumentError, "invalid value for \"hispanic_ethnicity\", must be one of #{validator.allowable_values}." end @hispanic_ethnicity = hispanic_ethnicity end # Custom attribute writer method checking allowed values (enum). # @param [Object] home_language Object to be assigned def home_language=(home_language) - validator = EnumAttributeValidator.new('String', ['English', 'Albanian', 'Amharic', 'Arabic', 'Bengali', 'Bosnian', 'Burmese', 'Cantonese', 'Chinese', 'Dutch', 'Farsi', 'French', 'German', 'Hebrew', 'Hindi', 'Hmong', 'Ilocano', 'Japanese', 'Javanese', 'Karen', 'Khmer', 'Korean', 'Laotian', 'Latvian', 'Malay', 'Mandarin', 'Nepali', 'Oromo', 'Polish', 'Portuguese', 'Punjabi', 'Romanian', 'Russian', 'Samoan', 'Serbian', 'Somali', 'Spanish', 'Swahili', 'Tagalog', 'Tamil', 'Telugu', 'Thai', 'Tigrinya', 'Turkish', 'Ukrainian', 'Urdu', 'Vietnamese', '']) + validator = EnumAttributeValidator.new('Object', ['English', 'Albanian', 'Amharic', 'Arabic', 'Bengali', 'Bosnian', 'Burmese', 'Cantonese', 'Chinese', 'Dutch', 'Farsi', 'French', 'German', 'Hebrew', 'Hindi', 'Hmong', 'Ilocano', 'Japanese', 'Javanese', 'Karen', 'Khmer', 'Korean', 'Laotian', 'Latvian', 'Malay', 'Mandarin', 'Nepali', 'Oromo', 'Polish', 'Portuguese', 'Punjabi', 'Romanian', 'Russian', 'Samoan', 'Serbian', 'Somali', 'Spanish', 'Swahili', 'Tagalog', 'Tamil', 'Telugu', 'Thai', 'Tigrinya', 'Turkish', 'Ukrainian', 'Urdu', 'Vietnamese', '']) unless validator.valid?(home_language) - fail ArgumentError, 'invalid value for "home_language", must be one of #{validator.allowable_values}.' + fail ArgumentError, "invalid value for \"home_language\", must be one of #{validator.allowable_values}." end @home_language = home_language end # Custom attribute writer method checking allowed values (enum). # @param [Object] race Object to be assigned def race=(race) - validator = EnumAttributeValidator.new('String', ['Caucasian', 'Asian', 'Black or African American', 'American Indian', 'Hawaiian or Other Pacific Islander', 'Two or More Races', 'Unknown', '']) + validator = EnumAttributeValidator.new('Object', ['Caucasian', 'Asian', 'Black or African American', 'American Indian', 'Hawaiian or Other Pacific Islander', 'Two or More Races', 'Unknown', '']) unless validator.valid?(race) - fail ArgumentError, 'invalid value for "race", must be one of #{validator.allowable_values}.' + fail ArgumentError, "invalid value for \"race\", must be one of #{validator.allowable_values}." end @race = race end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && - id == o.id && created == o.created && credentials == o.credentials && district == o.district && dob == o.dob && ell_status == o.ell_status && email == o.email && enrollments == o.enrollments && + ext == o.ext && gender == o.gender && - graduation_year == o.graduation_year && grade == o.grade && + graduation_year == o.graduation_year && hispanic_ethnicity == o.hispanic_ethnicity && home_language == o.home_language && + id == o.id && iep_status == o.iep_status && last_modified == o.last_modified && location == o.location && name == o.name && race == o.race && @@ -396,41 +408,49 @@ schools == o.schools && sis_id == o.sis_id && state_id == o.state_id && student_number == o.student_number && unweighted_gpa == o.unweighted_gpa && - weighted_gpa == o.weighted_gpa && - ext == o.ext + weighted_gpa == o.weighted_gpa end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. - # @return [Fixnum] Hash code + # @return [Integer] Hash code def hash - [id, created, credentials, district, dob, ell_status, email, enrollments, gender, graduation_year, grade, hispanic_ethnicity, home_language, iep_status, last_modified, location, name, race, school, schools, sis_id, state_id, student_number, unweighted_gpa, weighted_gpa, ext].hash + [created, credentials, district, dob, ell_status, email, enrollments, ext, gender, grade, graduation_year, hispanic_ethnicity, home_language, id, iep_status, last_modified, location, name, race, school, schools, sis_id, state_id, student_number, unweighted_gpa, weighted_gpa].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) - self.class.swagger_types.each_pair do |key, type| + self.class.openapi_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 + elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + end end self end @@ -448,11 +468,11 @@ value.to_s when :Integer value.to_i when :Float value.to_f - when :BOOLEAN + when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end @@ -469,12 +489,11 @@ value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model - temp_model = Clever.const_get(type).new - temp_model.build_from_hash(value) + Clever.const_get(type).build_from_hash(value) end end # Returns the string representation of the object # @return [String] String presentation of the object @@ -492,11 +511,15 @@ # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) - next if value.nil? + 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 @@ -514,9 +537,7 @@ elsif value.respond_to? :to_hash value.to_hash else value end - end - - end + end end end