bin/misc/lmm_test (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#!/bin/sh ADMIN_TOKEN="" BASE_URL="https://lmmdev.tk" #BASE_URL="http://localhost:8000" if [ -z $LT_ENV ] then printf 'set $LT_ENV to local or remote\n' else if [ $LT_ENV = "local" ] then BASE_URL="localhost:8000" else # BASE_URL="https://lmmdev.tk" BASE_URL="https://lmm.gdaschools.com" fi fi method="$1" if [ $method = "POST" ] then file="$2" api_endpoint="$3" if [ -n "$4" ] then if [ "$4" = none ] then token="" auth_header="" else token="$4" auth_header="Authorization: Bearer $token" fi else token="$ADMIN_TOKEN" auth_header="Authorization: Bearer $token" fi url="$BASE_URL$api_endpoint" curl -X POST\ -d@"$file"\ -H 'Content-Type: application/json'\ -H "$auth_header"\ "$url" elif [ $method = "GET" ] then api_endpoint="$2" if [ -n "$3" ] then if [ "$3" = none ] then token="" auth_header="" else token="$3" auth_header="Authorization: Bearer $token" fi else token=$ADMIN_TOKEN auth_header="Authorization: Bearer $token" fi url="$BASE_URL$api_endpoint" curl -L -X GET\ -H 'Content-Type: application/json'\ -H "$auth_header"\ "$url" fi |