Skip to content

Instantly share code, notes, and snippets.

Josh Weisman jweisman

Block or report user

Report or block jweisman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jweisman
jweisman / add_file.sh
Created May 2, 2019
Automating fulltext extraction in the Alma Digital Repository
View add_file.sh
#!/bin/sh
AWS_BUCKET="na-st01.ext.exlibrisgroup.com"
FILENAME=`basename "$1"`
FOLDER=$((1 + RANDOM % 32767))
if [ $# -lt 2 ]; then
echo "Usage: `basename $0` file-name representation-id institution [file-label]"
exit 0
@jweisman
jweisman / finance.sh
Created May 2, 2019
Automating Alma API-based integration with ERP
View finance.sh
#!/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"
@jweisman
jweisman / SwaggerClientTest.java
Last active Apr 30, 2019
Swagger Codegen with Alma APIs
View SwaggerClientTest.java
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
@jweisman
jweisman / parallel.js
Last active Jan 16, 2019
Ex Libris Alma - Parallel API Calls
View parallel.js
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 / Program.cs
Last active May 1, 2018
Refit for Alma APIs
View Program.cs
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 / bibcard.html.erb
Last active May 10, 2019
Linked Data example - Alma JSONLD and BibCard
View bibcard.html.erb
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title><%= viewmodel[:title] %></title>
</head>
@jweisman
jweisman / export-set.sh
Last active Oct 18, 2017
Process Orchestration in Alma with the Job and Set APIs
View export-set.sh
#!/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 Apr 17, 2018
Azure Logic App for Alma Webhooks
View workflow.json
{
"$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 / index.js
Created Dec 17, 2016
Twitter Card Proxy
View index.js
'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 / add-file.sh
Last active Nov 1, 2016
Shell script to add a file to an Alma Digital representation
View add-file.sh
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
You can’t perform that action at this time.