class LUSI::API::Person::Student
Attributes
@!attribute [rw] contact_detail
@return [LUSI::API::Person::ContactDetail, nil] the person's contact details
@!attribute [rw] date_of_birth
@return [DateTime, nil] the person's date of birth
@!attribute [rw] fee_status
@return [String, nil] the person's fee status
!@attribute [rw] forenames
@return [String, nil] the person's full forenames (space-separated string)
@!attribute [rw] gender
@return [String, nil] the person's gender
@!attribute [rw] nationality
@return [LUSI::API::Country::Nationality] the person's nationality
@!attribute [rw] preferred_name
@return [String, nil] the person's preferred name
@!attribute [rw] student_records
@return [Array<LUSI::API::Person::StudentRecord>, nil] the person's student record list
!@attribute [rw] surname
@return [String, nil] the person's surname
@!attribute [rw] title
@return [String, nil] the person's title (honourific)
Public Class Methods
Returns an array of Student
instances matching the search parameters @param api [LUSI::API::Core::API] the LUSI
API
instance to use for searching @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @param lancaster_student_id [String, nil] the Lancaster University student ID to search for @param external_student_id [String, nil] the external student ID to search for @param user_login [String, nil] the user login name to search for @param relationship_is_current_only [Boolean, nil] if true, search only current students;
otherwise search current and historic students
@param relationship_identity [String, nil] the relationship identity to search for @return [Array<Student>, nil] the list of matching Student
instances @yield [obj] Pass the Student
instance to the block @yieldparam obj [LUSI::API::Person::Student] the Student
instance
# File lib/lusi_api/person/student.rb, line 482 def self.get_instance(api, lookup = nil, lancaster_student_id: nil, external_student_id: nil, user_login: nil, relationship_is_current_only: nil, relationship_identity: nil) params = get_instance_params(lancaster_student_id: lancaster_student_id, external_student_id: external_student_id, user_login: user_login, relationship_is_current_only: relationship_is_current_only, relationship_identity: relationship_identity) xml = api.call('UserDetails', 'StudentManager.asmx', 'GetFullDetails', **params) LUSI::API::Core::XML.xml(xml, 'xmlns:Person') do |p| obj = Student.new(p, lookup) yield(obj) if block_given? obj end end
Initialises a new Person
instance @param xml [Nokogiri::XML::Document, Nokogiri::XML::Node] the parsed XML root of the person @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @param title [String, nil] the default title (honourific) @param surname [String, nil] the default surname @param forenames [String, nil] the default forenames (space-separated string) @param preferred_name
[String, nil] the default preferred name @param date_of_birth
[DateTime, nil] the default date of birth @param gender [String, nil] the default gender @param fee_status
[String, nil] the default fee status @param nationality [LUSI::API::Country::Nationality, nil] the default nationality @param contact_detail
[LUSI::API::Person::ContactDetail, nil] the default contact detail record @param student_records
[Array<LUSI::API::Person::StudentRecord>, nil] the default student record list @return [void]
# File lib/lusi_api/person/student.rb, line 510 def initialize(xml = nil, lookup = nil, title: nil, surname: nil, forenames: nil, preferred_name: nil, date_of_birth: nil, gender: nil, fee_status: nil, nationality: nil, contact_detail: nil, student_records: nil) @title = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Title', title) @surname = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Surname', surname) @forenames = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Forenames', forenames) @preferred_name = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:PreferredName', preferred_name) @date_of_birth = LUSI::API::Core::XML.xml_datetime_at(xml, 'xmlns:DateOfBirth', date_of_birth) @gender = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:Gender', gender) @fee_status = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:FeeStatus', fee_status) @nationality = LUSI::API::Core::XML.lookup(xml, lookup, :nationality, 'xmlns:Nationality', nationality) @contact_detail = ContactDetail.new(LUSI::API::Core::XML.xml_at(xml, 'xmlns:ContactDetail', contact_detail), lookup) @student_records = LUSI::API::Core::XML.xml(xml, 'xmlns:StudentRecords/xmlns:StudentRecord', student_records) { |r| StudentRecord.new(r, lookup) } end
Protected Class Methods
# File lib/lusi_api/person/student.rb, line 535 def self.get_instance_params(**kwargs) current_relationship_only = kwargs[:relationship_is_current_only] current_relationship_only = current_relationship_only.nil? || current_relationship_only ? 'true' : 'false' { ExternalStudentId: kwargs[:external_student_id] || '', LancasterStudentId: kwargs[:lancaster_student_id ]|| '', RelationshipIsCurrentOnly: current_relationship_only, RelationshipIdentity: kwargs[:relationship_identity] || '', UserLogin: kwargs[:user_login] || '' } end
Public Instance Methods
Returns a string representation of the person (full title and names) @return [String] the string representation of the person
# File lib/lusi_api/person/student.rb, line 529 def to_s "#{@title} #{@sforenames} #{@surname}".squeeze!(' ').strip! end