Sha256: bc99d7b7d1b272d68ae18096a13a46ef89b4844c8f36aee13ea37d22eac28b58

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module PsuIdentity::SearchService
  class Person
    attr_reader :data

    # @param [Hash] data parsed from the json reponse from the API
    def initialize(data = {})
      @data = data
    end

    def psu_id
      data['psuid']
    end

    def user_id
      data['userid']
    end

    def cpr_id
      data['cprid']
    end

    def given_name
      data['givenName']
    end

    def middle_name
      data['middleName']
    end

    def family_name
      data['familyName']
    end
    alias :surname :family_name

    def honorific_suffix
      data['honorificSuffix']
    end

    def preferred_given_name
      data.fetch('preferredGivenName', given_name)
    end

    def preferred_middle_name
      data.fetch('preferredMiddleName', middle_name)
    end

    def preferred_family_name
      data.fetch('preferredFamilyName', family_name)
    end

    def preferred_honorific_suffix
      data.fetch('preferredHonorificSuffix', honorific_suffix)
    end

    def active?
      data['active'].is_a?(TrueClass) || data['active'] == 'true'
    end

    def conf_hold?
      data['confHold'] == 'true'
    end

    def university_email
      data['universityEmail']
    end

    def other_email
      data['otherEmail']
    end

    def affiliation
      data.fetch('affiliation', [])
    end

    def display_name
      data['displayName']
    end

    def link
      AtomicLink.new(data['link'])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
psu_identity-0.5.1 lib/psu_identity/search_service/person.rb
psu_identity-0.5.0 lib/psu_identity/search_service/person.rb
psu_identity-0.4.0 lib/psu_identity/search_service/person.rb
psu_identity-0.3.0 lib/psu_identity/search_service/person.rb