• 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_client.rb
1
# frozen_string_literal: true
2
require './lib/orangelight/illiad_patron_client'
×
3
require './lib/orangelight/illiad_account'
×
4

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

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

15
    private
×
16

17
      def get_json_response # rubocop:disable Naming/AccessorMethodName
×
18
        response = ::Orangelight::IlliadAccount.new(patron.patron_hash).illiad_patron_response
×
19
        return {} unless response
×
20
        data = JSON.parse(response.body)
×
21
        if response.status != 200
×
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
×
30
        end
×
31
      end
×
32

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

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

64
      def conn
×
65
        @conn ||= ::Orangelight::IlliadPatronClient.new(patron:).conn
×
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