clemmy/api.sh

8 lines
523 B
Bash
Raw Normal View History

2023-01-17 01:07:40 +11:00
baseurl(){ echo "https://$INSTANCE/api/v3/"; } # This needs to be a function so updates to INSTANCE affect it. This is a very old bug lmao
#Generics
get(){ curl -s "$(baseurl)$1?${*:3}" | jq "$2"; }
getauth(){ get "$1" "$2" "auth=$TOKE&${*:3}"; }
post(){ curl -s "$(baseurl)$1" --json "$(echo ${*:2} | jq .+{\"auth\":\"$TOKE\"})"; }
# I'm just gonna clone this thing rather than try to palm the -X PUT into post. I can fix it later.
put(){ curl -sX PUT "$(baseurl)$1" --json "$(echo ${*:2} | jq .+{\"auth\":\"$TOKE\"})"; }