class LUSI::API::Person::Student

Represents a person (student) in the LUSI API

Attributes

contact_detail[RW]

@!attribute [rw] contact_detail

@return [LUSI::API::Person::ContactDetail, nil] the person's contact details
date_of_birth[RW]

@!attribute [rw] date_of_birth

@return [DateTime, nil] the person's date of birth
fee_status[RW]

@!attribute [rw] fee_status

@return [String, nil] the person's fee status
forenames[RW]

!@attribute [rw] forenames

@return [String, nil] the person's full forenames (space-separated string)
gender[RW]

@!attribute [rw] gender

@return [String, nil] the person's gender
nationality[RW]

@!attribute [rw] nationality

@return [LUSI::API::Country::Nationality] the person's nationality
preferred_name[RW]

@!attribute [rw] preferred_name

@return [String, nil] the person's preferred name
student_records[RW]

@!attribute [rw] student_records

@return [Array<LUSI::API::Person::StudentRecord>, nil] the person's student record list
surname[RW]

!@attribute [rw] surname

@return [String, nil] the person's surname
title[RW]

@!attribute [rw] title

@return [String, nil] the person's title (honourific)

Public Class Methods

get_instance(api, lookup = nil, lancaster_student_id: nil, external_student_id: nil, user_login: nil, relationship_is_current_only: nil, relationship_identity: nil) { |obj| ... } click to toggle source

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
new(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) click to toggle source

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

get_instance_params(**kwargs) click to toggle source
# 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

to_s() click to toggle source

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