21 lines
825 B
Bash
21 lines
825 B
Bash
#!/bin/bash
|
|
if ! silent=yes source "${cfg[namespace]}/webroot/api/session.shs"; then
|
|
return
|
|
fi
|
|
|
|
data=''
|
|
|
|
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
|