Skip to content

Instantly share code, notes, and snippets.

@sjenning
Last active September 5, 2021 16:24
Show Gist options
  • Save sjenning/bf98fe1b965ffa5bfc75cd3317a3d769 to your computer and use it in GitHub Desktop.
Save sjenning/bf98fe1b965ffa5bfc75cd3317a3d769 to your computer and use it in GitHub Desktop.
Check for HEB curbside availability
#!/bin/bash
#set -eux
TOKEN=""
ID=""
STATE_FILE="/root/heb-to-go/.state"
#curl https://api.telegram.org/bot$TOKEN/getUpdates | jq .message.chat.id
notify() {
curl -X POST \
-H 'Content-Type: application/json' \
-d "{\"chat_id\": \"$ID\", \"text\": \"$1\", \"disable_notification\": true}" \
https://api.telegram.org/bot$TOKEN/sendMessage
}
for storeid in 31 24 388 373 580 269 529 451 659; do
STORE_STATE_FILE="$STATE_FILE.$storeid"
if [ ! -e $STORE_STATE_FILE ]; then
curl -s "https://www.heb.com/commerce-api/v1/timeslot/timeslots?store_id=${storeid}&fulfillment_type=pickup" > $STORE_STATE_FILE
fi
PREVIOUS=$(jq -r '.items | length' $STORE_STATE_FILE)
curl -s "https://www.heb.com/commerce-api/v1/timeslot/timeslots?store_id=${storeid}&fulfillment_type=pickup" > $STORE_STATE_FILE
CURRENT=$(jq -r '.items | length' $STORE_STATE_FILE)
NAME=$(jq -r '.pickupStore.name' $STORE_STATE_FILE)
ADDRESS=$(jq -r '.pickupStore.address1' $STORE_STATE_FILE)
if [ $PREVIOUS -lt $CURRENT ]; then
declare -i diff
diff="$CURRENT - $PREVIOUS"
#printf "$diff new timeslots ($CURRENT total) are available at\n${NAME}\n${ADDRESS}\n"
notify "$diff new timeslots ($CURRENT total) are available at\n${NAME}\n${ADDRESS}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment