Sha256: 91b84038db6c0f8640d24acdb7a4f4fdcbe742f157a1d80bb984a9355864f619

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module PennState::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['preferredGivenName']
    end

    def preferred_middle_name
      data['preferredMiddleName']
    end

    def preferred_family_name
      data['preferredFamilyName']
    end

    def preferred_honorific_suffix
      data['preferredHonorificSuffix']
    end

    def active?
      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

3 entries across 3 versions & 1 rubygems

Version Path
psu_identity-0.1.2 lib/penn_state/search_service/person.rb
psu_identity-0.1.1 lib/penn_state/search_service/person.rb
psu_identity-0.1.0 lib/penn_state/search_service/person.rb