From afb1b7bd07013ee5c7a474d06d3b6f8c9b3c2526 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Sat, 24 Apr 2021 21:20:43 +0500 Subject: [PATCH] added settings menu, adding contacts and bugs to fix later --- bml-bash/bml.sh | 64 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/bml-bash/bml.sh b/bml-bash/bml.sh index d931e68..2a79208 100755 --- a/bml-bash/bml.sh +++ b/bml-bash/bml.sh @@ -3,33 +3,28 @@ source .env BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api' +COOKIE=/tmp/bmlcookie red=`tput setaf 1` green=`tput setaf 2` reset=`tput sgr0` -LOGIN=$(curl -s -c /tmp/bmlcookie $BML_URL/login \ +LOGIN=$(curl -s -c $COOKIE $BML_URL/login \ --data-raw username=$BML_USERNAME \ --data-raw password=$BML_PASSWORD \ --compressed \ - | awk -F 'success":' '{print $2}' \ - | cut -f1 -d ',' ) + | jq -r .success) if [ "$LOGIN" = "true" ] then - NAME=$(curl -s -b /tmp/bmlcookie $BML_URL/profile \ + NAME=$(curl -s -b $COOKIE $BML_URL/profile \ | awk -F 'fullname":"' '{print $2}' \ | cut -f1 -d '"') echo "" echo ${green}Welcome ${reset}$NAME echo "" -elif [ "$LOGIN" = "false" ] - then - echo "${red}Username or Password incorrect" 1>&2 - rm /tmp/bmlcookies 2> /dev/null - exit else - echo "${red}Unknown Error" 1>&2 - rm /tmp/bmlcookies 2> /dev/null + echo "${red}An error occured, Please check Username and Password" 1>&2 + rm $COOKIE 2> /dev/null exit fi @@ -39,18 +34,51 @@ echo "1 - Accounts" echo "2 - Contacts" echo "3 - Activities" echo "4 - Services" +echo "5 - Settings" echo "" printf 'Please Input: ' -read -r INPUT1 +read -r MENU -if [ "$INPUT1" = "1" ] +if [ "$MENU" = "1" ] then - curl -s -b /tmp/bmlcookie $BML_URL/dashboard | jq -elif [ "$INPUT1" = "2" ] + curl -s -b $COOKIE $BML_URL/dashboard | jq +elif [ "$MENU" = "2" ] then - curl -s -b /tmp/bml/cookie $BML_URL/contacts | jq + echo "" + echo "Contacts" + echo "" + echo "1 - Transfer" + echo "2 - Add Contact" + echo "3 - Delete Conact" + echo "" + printf 'Please Input:' + read -r CONTACS + + if [ "$CONTACS" = "1" ] + then + curl -s -b $COOKIE $BML_URL/contacts | jq + elif [ "$CONTACS" = "2" ] + then + printf 'Account Number:' + read -r ACCOUNT_NAME + printf 'Name:' + read -r ACCOUNT_NAME + curl -s -b $COOKIE $BML_URL | jq + elif [ "$CONTACS" = "3" ] + then + echo "" + else + exit + fi +elif [ "$MENU" = "3" ] + then + curl -s -b $COOKIE $BML_URL/activities | jq +elif [ "$MENU" = "4" ] + then + curl -s -b $COOKIE $BML_URL/services/applications/context | jq +elif [ "$MENU" = "5" ] + then + curl -s -b $COOKIE $BML_URL/settings | jq else echo "${red}There was an error" fi - -#curl -s -b /tmp/bmlcookie $BML_URL/contacts | jq