Class: LUSI::API::Person::Student

Inherits:
Object
  • Object
show all
Defined in:
lib/lusi_api/person/student.rb

Overview

Represents a person (student) in the LUSI API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#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) ⇒ void

Initialises a new Person instance

Parameters:

  • xml (Nokogiri::XML::Document, Nokogiri::XML::Node) (defaults to: nil)

    the parsed XML root of the person

  • lookup (LUSI::API::Core::Lookup::LookupService, nil) (defaults to: nil)

    the lookup service for object resolution

  • title (String, nil) (defaults to: nil)

    the default title (honourific)

  • surname (String, nil) (defaults to: nil)

    the default surname

  • forenames (String, nil) (defaults to: nil)

    the default forenames (space-separated string)

  • preferred_name (String, nil) (defaults to: nil)

    the default preferred name

  • date_of_birth (DateTime, nil) (defaults to: nil)

    the default date of birth

  • gender (String, nil) (defaults to: nil)

    the default gender

  • fee_status (String, nil) (defaults to: nil)

    the default fee status

  • nationality (LUSI::API::Country::Nationality, nil) (defaults to: nil)

    the default nationality

  • contact_detail (LUSI::API::Person::ContactDetail, nil) (defaults to: nil)

    the default contact detail record

  • student_records (Array<LUSI::API::Person::StudentRecord>, nil) (defaults to: nil)

    the default student record list



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# 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

Instance Attribute Details

#contact_detailLUSI::API::Person::ContactDetail?

Returns the person’s contact details.

Returns:



464
465
466
# File 'lib/lusi_api/person/student.rb', line 464

def contact_detail
  @contact_detail
end

#date_of_birthDateTime?

Returns the person’s date of birth.

Returns:

  • (DateTime, nil)

    the person’s date of birth



448
449
450
# File 'lib/lusi_api/person/student.rb', line 448

def date_of_birth
  @date_of_birth
end

#fee_statusString?

Returns the person’s fee status.

Returns:

  • (String, nil)

    the person’s fee status



456
457
458
# File 'lib/lusi_api/person/student.rb', line 456

def fee_status
  @fee_status
end

#forenamesObject

!@attribute [rw] forenames

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


440
441
442
# File 'lib/lusi_api/person/student.rb', line 440

def forenames
  @forenames
end

#genderString?

Returns the person’s gender.

Returns:

  • (String, nil)

    the person’s gender



452
453
454
# File 'lib/lusi_api/person/student.rb', line 452

def gender
  @gender
end

#nationalityLUSI::API::Country::Nationality

Returns the person’s nationality.

Returns:



460
461
462
# File 'lib/lusi_api/person/student.rb', line 460

def nationality
  @nationality
end

#preferred_nameString?

Returns the person’s preferred name.

Returns:

  • (String, nil)

    the person’s preferred name



444
445
446
# File 'lib/lusi_api/person/student.rb', line 444

def preferred_name
  @preferred_name
end

#student_recordsArray<LUSI::API::Person::StudentRecord>?

Returns the person’s student record list.

Returns:



468
469
470
# File 'lib/lusi_api/person/student.rb', line 468

def student_records
  @student_records
end

#surnameObject

!@attribute [rw] surname

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


436
437
438
# File 'lib/lusi_api/person/student.rb', line 436

def surname
  @surname
end

#titleString?

Returns the person’s title (honourific).

Returns:

  • (String, nil)

    the person’s title (honourific)



432
433
434
# File 'lib/lusi_api/person/student.rb', line 432

def title
  @title
end

Class Method Details

.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| ... } ⇒ Array<Student>?

Returns an array of Student instances matching the search parameters

Parameters:

  • api (LUSI::API::Core::API)

    the LUSI API instance to use for searching

  • lookup (LUSI::API::Core::Lookup::LookupService, nil) (defaults to: nil)

    the lookup service for object resolution

  • lancaster_student_id (String, nil) (defaults to: nil)

    the Lancaster University student ID to search for

  • external_student_id (String, nil) (defaults to: nil)

    the external student ID to search for

  • user_login (String, nil) (defaults to: nil)

    the user login name to search for

  • relationship_is_current_only (Boolean, nil) (defaults to: nil)

    if true, search only current students; otherwise search current and historic students

  • relationship_identity (String, nil) (defaults to: nil)

    the relationship identity to search for

Yields:

  • (obj)

    Pass the Student instance to the block

Yield Parameters:

Returns:

  • (Array<Student>, nil)

    the list of matching Student instances



482
483
484
485
486
487
488
489
490
491
492
493
494
# 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: ,
                               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

Instance Method Details

#to_sString

Returns a string representation of the person (full title and names)

Returns:

  • (String)

    the string representation of the person



529
530
531
# File 'lib/lusi_api/person/student.rb', line 529

def to_s
  "#{@title} #{@sforenames} #{@surname}".squeeze!(' ').strip!
end