-
Notifications
You must be signed in to change notification settings - Fork 1
/
duedate-update
executable file
·45 lines (33 loc) · 1.32 KB
/
duedate-update
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
auth 2>/dev/null || authn 2>/dev/null
tenant=$(cat tenant)
okapi_url=$(cat okapi.url)
okapi_token=$(cat okapi.token)
infile="update"
counter=1
numrecs=$(wc -l ${infile} |cut -d " " -f1)
while IFS=$'\t' read -r search duedate; do
if [[ ${search} =~ ^[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*$ ]];then
item_uuid=${search}
else
apicall=$(curl -s -w '\n' -X GET -D \
-H "Accept: application/json" \
-H "X-Okapi-Tenant: ${tenant}" \
-H "x-okapi-token: ${okapi_token}" \
"${okapi_url}/inventory/items?query=barcode=${barcode}")
item_uuid=$(echo "${apicall}" |jq -r .items[0].id)
fi
apicall=$(curl -s -w '\n' -X GET -D \
-H "Accept: application/json" \
-H "X-Okapi-Tenant: ${tenant}" \
-H "x-okapi-token: ${okapi_token}" \
${okapi_url}/loan-storage/loans?query=itemId=%22${item_uuid}%22)
loan_uuid=$(echo "${apicall}" |jq -r .loans[0].id)
IFS='' read -r -d '' data << EndOfJSON
{
"dueDate":"${duedate}"
}
EndOfJSON
apicall=$(curl --http1.1 -s -w '\n' -X POST -H "Content-type: application/json" -H "X-Okapi-Tenant: ${tenant}" -H "x-okapi-token: ${okapi_token}" -d "${data}" "${okapi_url}/circulation/loans/${loan_uuid}/change-due-date")
echo "Processing ${search} -- record $counter of $numrecs"
counter=$((counter + 1))
done < ${infile}