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

pulibrary / orangelight / 00dbc10b-d747-4ad7-b211-7b26d753abbb

14 Aug 2025 01:25PM UTC coverage: 0.483% (-94.9%) from 95.343%
00dbc10b-d747-4ad7-b211-7b26d753abbb

push

circleci

web-flow
Merge pull request #5181 from pulibrary/dependabot/bundler/activestorage-7.2.2.2

Bump activestorage from 7.2.2.1 to 7.2.2.2

47 of 9721 relevant lines covered (0.48%)

0.01 hits per line

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

0.0
/app/models/requests/illiad_patron.rb
1
# frozen_string_literal: true
2
require './lib/orangelight/illiad_patron_client'
×
3
require './lib/orangelight/illiad_account'
×
4

5
module Requests
×
6
  # Creates patron for Illiad requests
7
  class IlliadPatron < IlliadClient
×
8
    attr_reader :netid, :patron_id, :patron, :attributes
×
9

10
    def initialize(patron)
×
11
      super()
×
12
      @patron = patron
×
13
      @patron_id = patron.patron_id
×
14
      @netid = patron.netid
×
15
      @attributes = illiad_patron_attributes
×
16
    end
×
17

18
    def illiad_patron
×
19
      get_json_response
×
20
    end
×
21

22
    def create_illiad_patron
×
23
      return nil if patron.blank?
×
24

25
      patron_response = post_json_response(url: 'ILLiadWebPlatform/Users', body: attributes.to_json)
×
26
      patron_response = illiad_patron if patron_response.blank? && error.dig("ModelState", "UserName") == ["Username #{netid} already exists."]
×
27
      patron_response
×
28
    end
×
29

30
    private
×
31

32
      def illiad_patron_attributes
×
33
        return {} if status.blank?
×
34
        return {} if illiad_status.blank?
×
35
        {
×
36
          "Username" => netid, "ExternalUserId" => netid, "FirstName" => patron.first_name,
×
37
          "LastName" => patron.last_name, "LoanDeliveryMethod" => "Hold for Pickup", "NotificationMethod" => "Electronic",
×
38
          "EmailAddress" => patron.active_email, "DeliveryMethod" => "Hold for Pickup",
×
39
          "Phone" => patron.telephone, "Status" => illiad_status, "Number" => patron.university_id,
×
40
          "AuthType" => "Default", "NVTGC" => "ILL", "Department" => department, "Web" => true,
×
41
          "Address" => addresses&.shift, "Address2" => addresses&.join(', '), "City" => "Princeton", "State" => "NJ",
×
42
          "Zip" => "08544", "SSN" => patron.barcode, "Cleared" => "Yes", "Site" => "Firestone"
×
43
        }
×
44
      end
×
45

46
      def addresses
×
47
        @addresses ||= patron.address&.split('$')
×
48
      end
×
49

50
      def status
×
51
        patron.status
×
52
      end
×
53

54
      def pustatus
×
55
        patron.pustatus
×
56
      end
×
57

58
      def title
×
59
        patron.title
×
60
      end
×
61

62
      def department
×
63
        patron.department
×
64
      end
×
65

66
      def illiad_status
×
67
        return nil if pustatus.blank? || pustatus[0] == 'x'
×
68

69
        if status == "staff"
×
70
          illiad_staff_status
×
71
        elsif status == "student"
×
72
          student_mappings = { "gradetdc" => "GS - Graduate Student", "undergraduate" => "U - Undergraduate", "graduate" => "GS - Graduate Student" }
×
73
          student_mappings[pustatus]
×
74
        elsif status == "faculty"
×
75
          if title.present? && title.include?("Visiting")
×
76
            "F - Visiting Faculty"
×
77
          else
×
78
            "F - Faculty"
×
79
          end
×
80
        end
×
81
      end
×
82

83
      def illiad_staff_status
×
84
        if department.present? && department.include?("Library")
×
85
          "GS - Library Staff"
×
86
        elsif title.present?
×
87
          illiad_staff_title_status(ldap_title: patron.title)
×
88
        else
×
89
          "GS - University Staff"
×
90
        end
×
91
      end
×
92

93
      def illiad_staff_title_status(ldap_title:)
×
94
        if ldap_title.include?("Visiting Research")
×
95
          "GS - Visiting Research Scholar"
×
96
        elsif title.include?("Senior Research Scholar")
×
97
          "F - Senior Research Scholar"
×
98
        elsif title.include?("Research Scholar")
×
99
          "F - Research Scholar"
×
100
        elsif title.include?("Senior Professional")
×
101
          "F - Senior Professional Specialist"
×
102
        elsif title.match?(/Post*doc*Reseach*/i)
×
103
          "GS - Post doc Research Associate"
×
104
        elsif title.match?(/Post*doc*Fellow*/i)
×
105
          "F - Postdoctoral Fellow -- Teaching"
×
106
        elsif title.match?(/Visit*Fellow*/i)
×
107
          "GS - Visiting Fellow"
×
108
        else
×
109
          "GS - University Staff"
×
110
        end
×
111
      end
×
112
  end
×
113
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