• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / lsp-data / f0284567-1d9f-4912-9d96-63be1b1d7525

30 Apr 2025 04:21PM UTC coverage: 99.659% (-0.3%) from 100.0%
f0284567-1d9f-4912-9d96-63be1b1d7525

push

circleci

mzelesky
class to convert oit person to alma person

75 of 78 new or added lines in 2 files covered. (96.15%)

876 of 879 relevant lines covered (99.66%)

4.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.1
/lib/lsp-data/oit_person_to_alma.rb
1
# frozen_string_literal: true
2

3
# convert a OIT person hash into alma xml
4
module LspData
1✔
5
  class OitPersonToAlma
1✔
6
    attr_reader :person, :xml
1✔
7

8
    # @param xml [XMLBuilder] builder to insert the person into
9
    # @param person [Hash] oit hash of a person
10
    def initialize(person:, xml:)
1✔
11
      @person = person
1✔
12
      @xml = xml
1✔
13
    end
14

15
    def convert
1✔
16
      xml.user do
1✔
17
        xml.expiry_date person["PATRON_EXPIRATION_DATE"] if person["PATRON_EXPIRATION_DATE"]
1✔
18
        xml.purge_date person["PATRON_PURGE_DATE"] if person["PATRON_PURGE_DATE"]
1✔
19
        create_status(status_flag: person["ELIGIBLE_INELIGIBLE"])
1✔
20
        create_user_statistics(statistic_category: person["PVSTATCATEGORY"])
1✔
21
        xml.user_group person["PVPATRONGROUP"]
1✔
22
        xml.primary_id person["EMPLID"]
1✔
23
        xml.first_name person["PRF_OR_PRI_FIRST_NAM"] if person["PRF_OR_PRI_FIRST_NAM"] # _NAM is not a typo
1✔
24
        xml.last_name person["PRF_OR_PRI_LAST_NAME"] if person["PRF_OR_PRI_LAST_NAME"]
1✔
25
        xml.middle_name person["PRF_OR_PRI_MIDDLE_NAME"] if person["PRF_OR_PRI_MIDDLE_NAME"]
1✔
26
        create_contact_information
1✔
27
        create_identifiers
1✔
28
      end
29
    end
30

31
    private
1✔
32

33
    def create_status(status_flag:)
1✔
34
      return if status_flag.to_s.empty?
1✔
35

36
      if status_flag == "E" && not_a_retiree?
1✔
37
        xml.status 'ACTIVE'
1✔
38
      else
NEW
39
        xml.status 'INACTIVE'
×
40
      end
41
    end
42

43
    def create_user_statistics(statistic_category:)
1✔
44
      return if statistic_category.to_s.empty?
1✔
45
      xml.user_statistics do
1✔
46
        xml.user_statistic(segment_type: "External") do
1✔
47
          xml.statistic_category(desc: statistic_category) { xml.text statistic_category }
2✔
48
        end
49
      end
50
    end
51

52
    def create_contact_information
1✔
53
      return if person["CAMP_EMAIL"].to_s.empty? && person["HOME_EMAIL"].to_s.empty?
1✔
54
      xml.contact_info do
1✔
55
        create_addresses
1✔
56
        create_emails
1✔
57
        # create_phone_numbers
58
      end
59
    end
60

61
    def create_addresses
1✔
62
      xml.addresses do
1✔
63
        if ["UGRD", "SENR"].include?(person["PVPATRONGROUP"])
1✔
NEW
64
          create_address(type: "school", preferred: true, line1: person["DORM_ADDRESS1"], line2: person["DORM_ADDRESS2"], line3: person["DORM_ADDRESS3"],
×
65
                         line4: person["DORM_ADDRESS4"], city: person["DORM_CITY"], state: person["DORM_STATE"], country: person["DORM_COUNTRY"], postal: person["DORM_postal"])
NEW
66
          create_address(type: "home", preferred: person["DORM_ADDRESS1"].to_s.empty?, line1: person["PERM_ADDRESS1"], line2: person["PERM_ADDRESS2"], line3: person["PERM_ADDRESS3"],
×
67
                         line4: person["PERM_ADDRESS4"], city: person["PERM_CITY"], state: person["PERM_STATE"], country: person["PERM_COUNTRY"], postal: person["PERM_postal"])
68
        else
69
          create_address(type: "work", preferred: true, line1: person["CAMP_ADDRESS1"], line2: person["CAMP_ADDRESS2"], line3: person["CAMP_ADDRESS3"],
1✔
70
                         line4: person["CAMP_ADDRESS4"], city: person["CAMP_CITY"], state: person["CAMP_STATE"], country: person["CAMP_COUNTRY"], postal: person["CAMP_postal"])
71
          create_address(type: "home", preferred: person["CAMP_ADDRESS1"].to_s.empty?, line1: person["HOME_ADDRESS1"], line2: person["HOME_ADDRESS2"], line3: person["HOME_ADDRESS3"],
1✔
72
                         line4: person["HOME_ADDRESS4"], city: person["HOME_CITY"], state: person["HOME_STATE"], country: person["HOME_COUNTRY"], postal: person["HOME_postal"])
73
        end
74
      end
75
    end
76

77
    def create_emails
1✔
78
      xml.emails do
1✔
79
        create_email(email: person["CAMP_EMAIL"], preferred: true, type: "work", description: "Work")
1✔
80
        create_email(email: person["HOME_EMAIL"], preferred: false, type: "personal", description: "Personal") if person["CAMP_EMAIL"].to_s.empty?
1✔
81
      end
82
    end
83

84
    def create_email(email:, preferred:, type:, description:)
1✔
85
      return if email.to_s.empty?
1✔
86
      xml.email(preferred:, segment_type: "External") do
1✔
87
        xml.email_address email
1✔
88
        # xml.email_address "stub@example.com"
89
        xml.email_types do
1✔
90
          xml.email_type(desc: description) { xml.text type }
2✔
91
        end
92
      end
93
    end
94

95
    def create_identifiers
1✔
96
      xml.user_identifiers do
1✔
97
        create_identifier(type: "BARCODE", id: person["PU_BARCODE"], description: 'Barcode') if person["PU_BARCODE"]
1✔
98
        create_identifier(type: "NET_ID", id: person["CAMPUS_ID"], description: 'NetID')
1✔
99
      end
100
    end
101

102
    def create_identifier(type:, id:, description:)
1✔
103
      return if id.to_s.empty?
2✔
104
      xml.user_identifier(segment_type: "External") do
2✔
105
        xml.value id
2✔
106
        xml.id_type(desc: description) { xml.text type }
4✔
107
        xml.status "ACTIVE"
2✔
108
      end
109
    end
110

111
    def create_address(type:, preferred:, line1:, line2:, line3:, line4:, city:, state:, country:, postal:)
1✔
112
      return if line1.to_s.empty?
2✔
113
      xml.address(preferred:, segment_type: "External") do
2✔
114
        xml.line1 line1
2✔
115
        xml.line2 line2 if line2
2✔
116
        xml.line3 line3 if line3
2✔
117
        xml.line4 line4 if line4
2✔
118
        xml.city city
2✔
119
        xml.state_province state
2✔
120
        xml.postal_code postal
2✔
121
        xml.country country
2✔
122
        xml.address_types do
2✔
123
          xml.address_type(desc: type) { xml.text type }
4✔
124
        end
125
      end
126
    end
127

128
    def not_a_retiree?
1✔
129
      person["VCURSTATUS"] != 'RETR'
1✔
130
    end
131
  end
132
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc