class LUSI::API::Person::ContactDetail

Holds a person's combined contact details (postal addresses, email addresses, phone numbers)

Attributes

addresses[RW]

@!attribute [rw] addresses

@return [Array<PersonAddress>, nil] postal addresses as an array of PersonAddress instances
institutional_email_address[RW]

@!attribute [rw] lancaster_email_address

@return [Array<String>, nil] and array of institutional email addresses
lancaster_email_address[RW]

@!attribute [rw] lancaster_email_address

@return [Array<String>, nil] and array of institutional email addresses
mobile_phone_number[RW]

!@attribute [rw] mobile_phone_number

@return [String, nil] mobile phone number
personal_email_address[RW]

@!attribute [rw] personal_email_address

@return [Array<String>, nil] an array of personal email addresses

Public Class Methods

new(xml = nil, lookup = nil, addresses: nil, institutional_email_address: nil, mobile_phone_number: nil, personal_email_address: nil) click to toggle source

Initialises a new ContactDetails instance @param xml [Nokogiri::XML::Document, Nokogiri::XML::Node] the parsed XML root of the contact details record @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @param addresses [Array<PersonAddress>, nil] the default array of postal addresses @param institutional_email_address [String, nil] the default semi-colon-separated institutional email addresses @param mobile_phone_number [String, nil] the default mobile phone number @param personal_email_address [String, nil] the default semi-colon-separated personal email addresses @return [void]

# File lib/lusi_api/person/student.rb, line 157
def initialize(xml = nil, lookup = nil, addresses: nil, institutional_email_address: nil, mobile_phone_number: nil,
               personal_email_address: nil)
  @addresses = LUSI::API::Core::XML.xml(xml, 'xmlns:Addresses/xmlns:PersonAddress') { |a| PersonAddress.new(a, lookup) }
  @institutional_email_address = email_list(xml, 'xmlns:LancasterEmailAddress', institutional_email_address)
  @mobile_phone_number = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:MobilePhoneNumber', mobile_phone_number)
  @personal_email_address = email_list(xml, 'xmlns:PersonalEmailAddress', personal_email_address)
end

Protected Instance Methods

email_list(xml, path, default = nil) click to toggle source

Extracts a semi-colon-separated email address from XML and splits into an array of single email addresses. @param xml [Nokogiri::XML::Document, Nokogiri::XML::Node] the parsed XML root of the email address @param path [String] the XPath of the required email address @param default [String, nil] the default email address string @return [Array<String>] the array of single email addresses

# File lib/lusi_api/person/student.rb, line 172
def email_list(xml, path, default = nil)
  # Extract the email address string from XML
  emails = LUSI::API::Core::XML.xml_content_at(xml, path, default).to_s
  # Split the string on semi-colons and remove empty entries
  emails.strip.split(/\s*;\s*/).reject { |email| email.nil? || email.empty? }
end