Last active
April 23, 2021 21:20
-
-
Save ajmarkow/f04f440870353625f6ad1075c28657cb to your computer and use it in GitHub Desktop.
This file contains 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 | |
while getopts n: flag | |
do | |
case "${flag}" in | |
n) query=${OPTARG};; | |
esac | |
done | |
APICALL=$(curl -s -b "session=YOURSESSIONCOOKIEVALUE" "https://admin.rechargeapps.com/admin/search?query=$query" |jq ".[] | .id") | |
RED='\033[0;31m' | |
NC='\033[0m' # No Color | |
echo "${RED}---------------------------${NC}" | |
echo " " | |
echo "The store ID is ${RED}$APICALL${NC}"; | |
echo " " | |
echo "${RED}---------------------------${NC}" |
Also you must have jq installed for this to work as it uses jq to parse the JSON from the API. I recommend installing brew, then using brew to install jq.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will search the ReCharge API for a store ID. Pass the flag -n "YOUR STORE URL" along with the script name in order to run it. It is designed for a unique identifier currently, so it does not work with queries that return more than one store.
To set it up initially you need to make YOURSESSIONCOOKIEVALUE equal to the value of your session cooklie listed in Dev Tools on your browser when accessing the ReCharge Admin Sites.