summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2016-10-18 16:24:47 +0500
committerAnton Bobov <abobov@gmail.com>2016-10-18 16:24:47 +0500
commit0a6657b3a4b8153d1c42302486a8a61800fde9b1 (patch)
treeaaf0e8ca3462c2daae92cae44a082e9c9d0823ee
parent1e9e8fc03369fd63f2de8bd0d5f46f06e10b552f (diff)
Add TTS balance script.
-rwxr-xr-xtts-balance.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/tts-balance.sh b/tts-balance.sh
new file mode 100755
index 0000000..0ae5a0b
--- /dev/null
+++ b/tts-balance.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+
+help() {
+ echo "Print TTS card balance."
+ echo
+ echo "First argument should be card number (10 or 19 digits)."
+}
+
+if [[ $1 =~ ^([0-9]{10}|[0-9]{19})$ ]] ; then
+ CARD_NUMBER=$1
+else
+ help
+ exit 1
+fi
+
+hash=($(echo -n $(date +%d.%m.%Y).$CARD_NUMBER | md5sum))
+
+url=$(printf "%s?numberCard=%s&h=%s&hi=1&tf=json" "http://oao-tts.ru/services/lnt/infoBalansCard.php" $CARD_NUMBER $hash)
+
+bal=$(curl --silent "$url" | jq ".balance | tonumber")
+echo "Balance: $bal"