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

pulibrary / orangelight / 4c391e0e-519a-40cb-8ad3-354445f4ce03

12 Aug 2025 08:47PM UTC coverage: 85.348% (-10.0%) from 95.335%
4c391e0e-519a-40cb-8ad3-354445f4ce03

push

circleci

web-flow
[#5143] Use access restriction note as Aeon ItemInfo1 if available (#5173)

With this commit, if a user visits a record with an access
restrictions note and presses the Reading Room Request
button, they will get to an Aeon form with the 'Restrictions'
field pre-filled with the restriction note.

If the record does not have an access restrictions note,
the field will be pre-filled with 'Reading Room Access Only',
as it has been previously.

Closes #5143

5493 of 6436 relevant lines covered (85.35%)

251.82 hits per line

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

46.67
/lib/orangelight/illiad_patron_client.rb
1
# frozen_string_literal: true
2

3
require 'faraday'
1✔
4
require 'faraday-cookie_jar'
1✔
5

6
module Orangelight
1✔
7
  class IlliadPatronClient
1✔
8
    def initialize(patron)
1✔
9
      @barcode = patron['barcode']
19✔
10
      @last_name = patron['last_name']
19✔
11
      @patron_id = patron['patron_id']
19✔
12
      @netid = patron['netid']
19✔
13
      @illiad_api_key = Requests.config["illiad_api_key"]
19✔
14
      @illiad_api_base = Requests.config["illiad_api_base"]
19✔
15
    end
16

17
    def outstanding_ill_requests
1✔
18
      # Use "ProcessType eq Borrowing" for interlibrary loan and digital requests
19
      begin
20
        response = conn.get do |req|
×
21
          # If we wanted to divide the results RequestType%20eq%20'Loan' is Inter Library Loan and RequestType%20eq%20'Article' is digitization
22
          req.url "/ILLiadWebPlatform/Transaction/UserRequests/#{@netid}?$filter=ProcessType%20eq%20'Borrowing'%20and%20" \
×
23
                  "TransactionStatus%20ne%20'Request%20Finished'%20and%20not%20startswith%28TransactionStatus,'Cancelled'%29"
24
          req.headers['Accept'] = 'application/json'
×
25
          req.headers['ApiKey'] = @illiad_api_key
×
26
        end
27
      rescue Faraday::ConnectionFailed
28
        Rails.logger.info("Unable to Connect to #{@illiad_api_base}")
×
29
        return []
×
30
      end
31
      parse_response(response)
×
32
    end
33

34
    def cancel_ill_requests(transactions)
1✔
35
      begin
36
        response = []
×
37
        transactions.each do |transaction|
×
38
          response << cancel_ill_request(transaction)
×
39
        end
40
      rescue Faraday::ConnectionFailed
41
        Rails.logger.info("Unable to Connect to #{@illiad_api_base}")
×
42
        return false
×
43
      end
44
      response
×
45
    end
46

47
    def conn
1✔
48
      Faraday.new(url: @illiad_api_base.to_s) do |builder|
19✔
49
        builder.use :cookie_jar
19✔
50
        builder.adapter Faraday.default_adapter
19✔
51
        builder.response :logger
19✔
52
      end
53
    end
54

55
    private
1✔
56

57
      def parse_response(response)
1✔
58
        return [] unless response.success?
×
59
        json_data = JSON.parse(response.body)
×
60
        # allow dispplay of either Loan or Article fields
61
        json_data.each do |item|
×
62
          item["PhotoJournalTitle"] ||= item["LoanTitle"]
×
63
          item["PhotoArticleAuthor"] ||= item["LoanAuthor"]
×
64
        end
65
        json_data
×
66
      end
67

68
      def cancel_ill_request(transaction)
1✔
69
        conn.put do |req|
×
70
          req.url "ILLiadWebPlatform/transaction/#{transaction}/route"
×
71
          req.headers['ApiKey'] = @illiad_api_key
×
72
          req.headers['Content-Type'] = 'application/json'
×
73
          req.body = { Status: 'Cancelled by Customer' }.to_json
×
74
        end
75
      end
76
  end
77
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