Skip to content

Instantly share code, notes, and snippets.

@jweisman
jweisman / gist:15bfa5094ea463d6c4c0
Created June 2, 2014 15:31
Primo Feedback Button
<script>
var timer;
var feedbackOn = false;
var isInitial = true;
var cookieName = "feedback";
function showFeedback() {
cleanTimer();
if (!feedbackOn) {
$("#shorttext").css("display", "none");
@jweisman
jweisman / harvest.rb
Last active September 3, 2015 08:23
Harvest OAI to AWS CloudSearch
require 'rest-client'
require 'nokogiri'
require 'aws-sdk-core'
def process_oai(inst, qs, domain, alma)
oai_base = "https://#{alma}.alma.exlibrisgroup.com/view/oai/#{inst}/request"
log "Calling OAI with query string #{qs}"
oai = RestClient.get oai_base + qs
@jweisman
jweisman / add-file.sh
Last active November 1, 2016 09:33
Shell script to add a file to an Alma Digital representation
INSTITUTION="YOUR-INSTITUTION"
AWS_BUCKET="na-st01.ext.exlibrisgroup.com"
APIKEY="YOUR-API-KEY"
FILENAME=`basename "$1"`
if [ $# -lt 2 ]; then
echo "Usage: `basename $0` file-name representation-id [file-label]"
exit 0
fi
@jweisman
jweisman / index.js
Created December 17, 2016 18:15
Twitter Card Proxy
'use strict';
exports.handler = function(event, context) {
var agent = event.headers['User-Agent'] || 'None';
var path = event.path.substring(event.path.indexOf('http'));
if (agent.startsWith('Twitterbot')) {
var proxy = require('./proxy');
proxy(path, (err, status, headers, body) => {
var response = {
@jweisman
jweisman / curl.txt
Last active February 9, 2017 10:29
Alma SWORD Deposits
-----------------1605871705
Content-Type: application/atom+xml; charset="utf-8"
Content-Disposition: attachment; name=atom
MIME-Version: 1.0
<?xml version="1.0"?>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:dcterms="http://purl.org/dc/terms/">
<title>Deposit sample</title>
@jweisman
jweisman / export-set.sh
Last active October 18, 2017 06:24
Process Orchestration in Alma with the Job and Set APIs
#!/bin/bash
echo "Creating new set"
SET_ID=`curl -s --fail -X POST -H "Authorization: apikey $API_KEY" -H "Content-type: application/xml" -H "Accept: application/xml" --data @set.xml "https://api-na.hosted.exlibrisgroup.com/almaws/v1/conf/sets" | xmllint --xpath '/set/id/text()' -`
res=$?
if test $res != 0; then
echo "HTTP request failed with return code $res"
exit $res
fi
@jweisman
jweisman / workflow.json
Last active April 17, 2018 12:23
Azure Logic App for Alma Webhooks
{
"$connections": {
"value": {
"sftp": {
"connectionId": "/subscriptions/78e1da39-3d31-4b09-8636-f49b6fc5223b/resourceGroups/DefaultResourceGroup/providers/Microsoft.Web/connections/sftp-1",
"connectionName": "sftp-1",
"id": "/subscriptions/78e1da39-3d31-4b09-8636-f49b6fc5223b/providers/Microsoft.Web/locations/eastus/managedApis/sftp"
}
}
},
@jweisman
jweisman / Program.cs
Last active May 1, 2018 17:04
Refit for Alma APIs
using Newtonsoft.Json;
using Refit;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace refitalma
{
[Headers("Accept: application/json")]
public interface IAlmaApi
@jweisman
jweisman / parallel.js
Last active January 16, 2019 15:21
Ex Libris Alma - Parallel API Calls
const { PerformanceObserver, performance } = require('perf_hooks');
const alma = require('almarestapi-lib');
const records = 10000;
const limit = 25;
const url = '/users?view=brief';
const arrayName = 'user';
var offset = 0, total = 0, processed = 0;
@jweisman
jweisman / finance.sh
Created May 2, 2019 17:33
Automating Alma API-based integration with ERP
#!/bin/sh
IFS=$'\n' # break on newline only
echo "Getting invoices ready for payment"
invoices=`curl -s --fail -H "Authorization: apikey $ALMA_APIKEY" -H "Accept: application/json" "https://api-na.hosted.exlibrisgroup.com/almaws/v1/acq/invoices?invoice_workflow_status=Waiting%20to%20be%20Sent&view=brief" | jq -c '.invoice | .[]'`;
for id in $invoices; do
echo "Marking invoice $(echo $id | jq -r '.number') as sent to ERP"
curl -s -o /dev/null -X POST -H "Authorization: apikey $ALMA_APIKEY" -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{}' "https://api-na.hosted.exlibrisgroup.com/almaws/v1/acq/invoices/$(echo $id | jq -r '.id')?op=mark_in_erp"