• 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
/lib/orangelight/illiad_patron_client.rb
1
# frozen_string_literal: true
2

3
require 'faraday'
×
4
require 'faraday-cookie_jar'
×
5

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

17
    def outstanding_ill_requests
×
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)
×
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
×
48
      Faraday.new(url: @illiad_api_base.to_s) do |builder|
×
49
        builder.use :cookie_jar
×
50
        builder.adapter Faraday.default_adapter
×
51
        builder.response :logger
×
52
      end
×
53
    end
×
54

55
    private
×
56

57
      def parse_response(response)
×
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)
×
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