From 4b49b973187b0e330c2fc223b36cc0f1b35f280b Mon Sep 17 00:00:00 2001 From: Gandalf Date: Thu, 4 Mar 2021 18:57:12 +0100 Subject: [PATCH] Account balance in Human readable format --- getbalance.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/getbalance.sh b/getbalance.sh index 3ab8fcf..15559ca 100755 --- a/getbalance.sh +++ b/getbalance.sh @@ -1 +1,5 @@ -curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/balance" -s | jq +BAL=$(curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/balance" -s) +AMOUNT=$(echo $BAL | jq '.amount') +CUR=$(echo $BAL | jq '.currency' | sed -e 's:"::g' ) +AMOUNT=$(echo "scale=2; $AMOUNT/10000" | bc -l) +echo $CUR $AMOUNT