ocw/webroot/api/collect.shs

18 lines
904 B
Bash

#!/bin/bash
silent=yes source "${cfg[namespace]}/webroot/api/session.shs"
source "${cfg[namespace]}/code/common.sh"
data=$(curl -s -X POST -H "$(get_auth_string)" -H "Content-type: application/json" "https://api-inmobile-pl.easypack24.net/v1/collect/validate" --data '{"geoPoint":{"accuracy":"1","latitude":"'"${post_data[lat]}"'","longitude":"'"${post_data[lon]}"'"},"parcel":{"openCode":"'"${post_data[openCode]}"'","shipmentNumber":"'"${post_data[id]}"'"}}')
if [[ $(echo $data | jq .status) == "403" ]]; then
echo $data | jq "{status: .status, msg: .error}"
else
uuid=$(echo $data | jq -r ".sessionUuid")
data=$(curl -X POST -H "$(get_auth_string)" "https://api-inmobile-pl.easypack24.net/v1/collect/compartment/open/$uuid")
if [[ $(echo $data | jq ".compartment") != "" ]]; then
echo $data
else
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "emptyPage"
fi
fi