pulibrary / orangelight

PUL Blacklight Project (Ruby 3.1.0, Rails 7.1.4)
21 stars 7 forks source link

Replicate 'Your Account' functionality with Alma #2025

Closed kelynch closed 3 years ago

kelynch commented 4 years ago

Use the switch created in #2362

The following sections of the account page need to be reimplemented for alma:

Relevant areas of the code:

Areas of the page not affected:

Implementation notes:

Other Notes:

kelynch commented 4 years ago

Example from alma_rb gem for accessing user objects:

require 'alma'

Alma.configure do |config|
  config.apikey = 'X'
  # ...
end

$primary_identifier = "john.doe"

u = Alma::User.find($primary_identifier)

# Methods 
$ ls u
Alma::User#methods: 
  []        loans                  preferred_name        save!         
  []=       loggable               preferred_suffix      to_json       
  email     method_missing         renew_all_loans       total_fines   
  fines     preferred_email        renew_loan            total_loans   
  has_key?  preferred_first_name   renew_multiple_loans  total_requests
  id        preferred_last_name    requests              validate      
  keys      preferred_middle_name  response            
hackartisan commented 3 years ago

account_controller#index

First fetches patron "first_name", "last_name", "barcode" from bibdata using the netit.

Then it hits voyager to get the account object with the following properties:

hackartisan commented 3 years ago

Block info needs to be added to the bibdata response so it can be pulled from the patron without an additional API call. Block data from alma looks like

      "user_block": [
        {
          "segment_type": "Internal",
          "block_type": {
            "value": "LOAN"
          },
          "block_description": {
            "value": "CONSORTIA"
          },
          "block_status": "string",
          "block_note": "string",
          "created_by": "string",
          "created_date": "2024-05-30T09:30:10Z",
          "expiry_date": "2019-12-18T14:36:48.659Z"
        }
      ],

How does this map onto our current values?

Here's some example block data from voyager:

            <myac:borrowingBlocks>
                <myac:title>Blocks</myac:title>
                <myac:clusterBorrowingBlocks>
                    <myac:cluster>
                        <myac:clusterName>Princeton University Library</myac:clusterName>
                        <myac:ubSiteId>1@PRINCETONDB20050302104001</myac:ubSiteId>
                    </myac:cluster>
                    <myac:borrowingBlock>
                        <myac:blockReason>odue_recall_limit_patron</myac:blockReason>
                        <myac:blockCount>1</myac:blockCount>
                        <myac:blockCode>21</myac:blockCode>
                        <myac:blockLimit>1</myac:blockLimit>
                        <myac:itemType xsi:nil="true" />
                        <myac:pendingHoldCount xsi:nil="true" />
                        <myac:patronGroupName>Faculty and Professional Staff</myac:patronGroupName>
                    </myac:borrowingBlock>
                </myac:clusterBorrowingBlocks>
            </myac:borrowingBlocks>
hackartisan commented 3 years ago

avail_items and request_items I think would both come from the user requests GET endpoint.

Data coming back looks like: https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_user_requests.xsd/?tags=GET

hackartisan commented 3 years ago

charged_items will come from the user loans get endpoint

use expand=renewable to get renewable value.

loans object

loan object

looks like these will need to be filtered for active loans (see loan_status) value of loan object.

hackartisan commented 3 years ago

fines_fees will come from the user fines endpoint. Returns active fees by default. Is that what we want?

fees object

fee object

kevinreiss commented 3 years ago

Yes, active fees would be what we want to display. We didn't have the option to display past fees in Voyager so that would be new functionality that could potentially added to allow users to see their paid/cancelled fines.

hackartisan commented 3 years ago

https://github.com/tulibraries/alma_rb/blob/main/lib/alma/user.rb#L9 this expand option is making me think there's an undocumented option on https://developers.exlibrisgroup.com/alma/apis/docs/users/R0VUIC9hbG1hd3MvdjEvdXNlcnM=/ to get everything we need in 1 call. If so we'd pull it through the bibdata endpoint.

update: that expand only gives the total numbers / amounts. But if we pull that we can use it to determine whether we need to hit the other endpoints.

hackartisan commented 3 years ago
hackartisan commented 3 years ago

This issue is blocked pending a decision on whether to use alma's "library card" page instead of reimplementing this in blacklight.

Arguments in favor of using the alma page:

  1. The local implementation requires 5 API calls to build the display page. Note that this is 1/5th of the concurrency limit for API calls.
  2. There is functionality we cannot implement via the API, such as:
    1. "renew all" (the api only provides single renewal, and again the concurrency limit)
    2. up-front account limit notifications (e.g. "You can't renew this because you have too many fines" in the API is just "renewable: false")
  3. There is functionality that will be time-consuming to re-develop and maintain locally, such that it starts to make more sense to use the existing page which already does everything we want.
    1. paginated /sortable loans list, fees, and requests. (note we'd probably need to do this in javascript)
  4. Using the alma page would release developer time as we move toward go-live.
  5. Penn went this route and advised us it's a good way to go.

There are a few considerations we need to iron out:

  1. We'll need to do at least a little custom styling on this page, if only to get rid of the big vacation-y icons that display in the content areas when there's no data.
    1. documentation on how to do this: https://knowledge.exlibrisgroup.com/Alma/Product_Documentation/010Alma_Online_Help_(English)/070Alma-Summon_Integration/050Display_Configuration/020Branding_the_Services_Page
    2. We will want a repo to put the CSS file/s in, with a little readme. We may use libapps for this with a directory called either "alma" or "summon"
  2. Information Architecture for linking to the account page
    1. We can't customize the header any more than we've already done, so IA will likely depend on opening the library card in a new tab and trusting users to be able to get back to the catalog when they're done.
  3. What do we do with guest accounts? Options:
    1. Get them netids (preferred)
    2. Provide them with usernames / passwords directly in Alma, managed by circulation
    3. Provide a minimal UI for them in blacklight
    4. Just not provide an online account service for guests

Work for this issue is in progress on branch 2025-alma-account if/when we pick it up again.

hackartisan commented 3 years ago

closing in favor of #2401