forked from Tripletex/tripletex-api2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.sh
More file actions
42 lines (32 loc) · 1.47 KB
/
example.sh
File metadata and controls
42 lines (32 loc) · 1.47 KB
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
#!/bin/Bash
# Example use of experimental "checksum" feature in Tripletex API
# See README.md for important notes on the checksum feature.
# IMPORTANT: Everything regarding checksum is subject to change.
# Integrations trying out the checksum feature will _not_ break if
# we decide to change the implementation. However, the advantages
# of using checksum may be lost and the integration has to be updated.
# CONFIGURATION:
sessionToken="*** CHANGE ME ***"
proxyEmployeeId=0
# Set up auth header
basicAuthToken=$(echo -n "$proxyEmployeeId:$sessionToken" | base64)
# Enable new checksum feature by sending in a non-empty checksum
dummyChecksum="someNonEmptyValue"
# Call the API with a dummy checksum to get the initial data set as well as the initial checksum
result=$(
curl https://tripletex.no/v2/project \
--header "Authorization: Basic $basicAuthToken" \
--header "If-None-Match: $dummyChecksum" \
--silent
);
# Checksum is currently stored
versionDigest=$(echo "$result" | jq --raw-output .versionDigest)
count=$(echo "$result" | jq --raw-output .count)
echo "Got $count results with checksum $versionDigest"
# Call the same API endpoint with the previously received checksum (versionDigest).
# This should result in HTTP 304 (Not Modified) indicating no changes – unless the dataset has changes, of course.
curl https://tripletex.no/v2/project \
--header "Authorization: Basic $basicAuthToken" \
--header "If-None-Match: $versionDigest" \
--verbose \
--silent