ocw/webroot/api/packages.shs

21 lines
825 B
Plaintext
Raw Normal View History

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
data=''
2020-09-19 17:21:38 +02:00
while [[ "$data" == '' ]]; do
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")
done
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