2020-09-19 17:21:38 +02:00
|
|
|
#!/bin/bash
|
2020-11-06 00:27:48 +01:00
|
|
|
if ! silent=yes source "${cfg[namespace]}/webroot/api/session.shs"; then
|
|
|
|
return
|
|
|
|
fi
|
2020-09-19 17:21:38 +02:00
|
|
|
|
2020-11-12 13:06:17 +01:00
|
|
|
data=''
|
2020-09-19 17:21:38 +02:00
|
|
|
|
2020-11-12 13:06:17 +01:00
|
|
|
while [[ "$data" == '' ]]; do
|
2021-11-11 02:46:35 +01:00
|
|
|
auth="$(get_auth_string)"
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
broken_session=true # whatever, this works
|
|
|
|
fi
|
|
|
|
data=$(curl -s -H "$auth" "https://api-inmobile-pl.easypack24.net/v1/parcel?updatedAfter=1970-01-01T00:00:00.000Z")
|
2020-11-12 13:06:17 +01:00
|
|
|
done
|
|
|
|
|
2021-11-11 02:46:35 +01:00
|
|
|
if [[ "$broken_session" == true ]]; then
|
|
|
|
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args "-4" "The session went bork"
|
|
|
|
else
|
|
|
|
echo "$data" | jq -c "[.[] | {shipmentNumber: .shipmentNumber, status: .status, openCode: .openCode, senderName: .senderName, pickupPoint: {name: .pickupPoint.name, status: .pickupPoint.status, location: .pickupPoint.location, description: .pickupPoint.locationDescription, address: .pickupPoint.addressDetails}}]"
|
|
|
|
fi
|