Last active
September 5, 2021 16:24
-
-
Save sjenning/bf98fe1b965ffa5bfc75cd3317a3d769 to your computer and use it in GitHub Desktop.
Check for HEB curbside availability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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