• 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

86.36
/app/models/requests/illiad_client.rb
1
# frozen_string_literal: true
2
require './lib/orangelight/illiad_patron_client'
1✔
3
require './lib/orangelight/illiad_account'
1✔
4

5
module Requests
1✔
6
  class IlliadClient
1✔
7
    attr_reader :illiad_api_base, :illiad_api_key, :error
1✔
8

9
    def initialize
1✔
10
      @illiad_api_key = Requests.config[:illiad_api_key].to_s
20✔
11
      @illiad_api_base = Requests.config[:illiad_api_base]
20✔
12
      @error = nil
20✔
13
    end
14

15
    private
1✔
16

17
      def get_json_response # rubocop:disable Naming/AccessorMethodName
1✔
18
        response = ::Orangelight::IlliadAccount.new(patron.patron_hash).illiad_patron_response
10✔
19
        return {} unless response
10✔
20
        data = JSON.parse(response.body)
10✔
21
        if response.status != 200
10✔
22
          if data
×
23
            Rails.logger.warn("Illiad Error Message: #{data[:message]}")
×
24
          else
25
            Rails.logger.warn("Illiad Error Message: #{response.reason_phrase}")
×
26
          end
27
          {}
×
28
        else
29
          data.with_indifferent_access
10✔
30
        end
31
      end
32

33
      def post_json_response(url:, body:)
1✔
34
        response = post_response(url:, body:)
16✔
35
        if response.blank? || response.status != 200
16✔
36
          if response.present? && response.body.present?
2✔
37
            Rails.logger.warn "Illiad Error Message: #{response.body}"
1✔
38
            @error = JSON.parse(response.body)
1✔
39
          else
40
            Rails.logger.warn "An unspecified error occurred with Illiad #{url} #{body}"
1✔
41
          end
42
          nil
2✔
43
        elsif response.present?
14✔
44
          JSON.parse(response.body)
14✔
45
        end
46
      end
47

48
      def post_response(url:, body:)
1✔
49
        Rails.logger.debug { "Illiad Posting #{illiad_api_base}/#{url} #{body}" }
32✔
50
        resp = conn.post do |req|
16✔
51
          req.url url
16✔
52
          req.headers['Content-Type'] = 'application/json'
16✔
53
          req.headers['Accept'] = 'application/json'
16✔
54
          req.headers['ApiKey'] = illiad_api_key
16✔
55
          req.body = body
16✔
56
        end
57
        Rails.logger.debug { "Illiad Post Response #{illiad_api_base}/#{url} #{resp.status} #{resp.body}" }
32✔
58
        resp
16✔
59
      rescue Faraday::ConnectionFailed
60
        Rails.logger.warn("Unable to Connect to #{@illiad_api_base}")
×
61
        nil
×
62
      end
63

64
      def conn
1✔
65
        @conn ||= ::Orangelight::IlliadPatronClient.new(patron:).conn
16✔
66
      end
67
  end
68
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