some comments

This commit is contained in:
Shihaam Abdul Rahman 2021-04-25 22:50:50 +05:00
parent c666844127
commit 1f8e5f9270
2 changed files with 13 additions and 2 deletions

13
bml.sh
View File

@ -1,12 +1,16 @@
#!/bin/bash #!/bin/bash
BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api' BML_URL='https://www.bankofmaldives.com.mv/internetbanking/api'
COOKIE=/tmp/bmlcookie COOKIE=/tmp/bmlcookie
#Setting terminal output colors
red=`tput setaf 1` red=`tput setaf 1`
green=`tput setaf 2` green=`tput setaf 2`
reset=`tput sgr0` reset=`tput sgr0`
#importing saved credentials
source .env 2> /dev/null source .env 2> /dev/null
#what to do if credentials not saved
if [ "$BML_USERNAME" = "" ] if [ "$BML_USERNAME" = "" ]
then then
echo ${red}Credentials not found in .env file${reset} echo ${red}Credentials not found in .env file${reset}
@ -28,28 +32,32 @@ else
: :
fi fi
#login and generate cookie
LOGIN=$(curl -s -c $COOKIE $BML_URL/login \ LOGIN=$(curl -s -c $COOKIE $BML_URL/login \
--data-raw username=$BML_USERNAME \ --data-raw username=$BML_USERNAME \
--data-raw password=${BML_PASSWORD} \ --data-raw password=${BML_PASSWORD} \
--compressed \ --compressed \
| jq -r .success) | jq -r .success)
#check if login was success
if [ "$LOGIN" = "true" ] if [ "$LOGIN" = "true" ]
then then
#Requesting for User profile after login and regex to grap the Full name
NAME=$(curl -s -b $COOKIE $BML_URL/profile \ NAME=$(curl -s -b $COOKIE $BML_URL/profile \
| awk -F 'fullname":"' '{print $2}' \ | awk -F 'fullname":"' '{print $2}' \
| cut -f1 -d '"') | cut -f1 -d '"')
#display a Welcome message with fullname
echo "" echo ""
echo ${green}Welcome ${reset}$NAME echo ${green}Welcome ${reset}$NAME
# curl -s -b $COOKIE $BML_URL/userinfo # curl -s -b $COOKIE $BML_URL/userinfo
echo "" echo ""
else else
#Display error if login was not succuessfull and delete cookie
echo "${red}An error occured, Please check Username and Password" 1>&2 echo "${red}An error occured, Please check Username and Password" 1>&2
rm $COOKIE 2> /dev/null rm $COOKIE 2> /dev/null
exit exit
fi fi
#display menu
echo "Menu" echo "Menu"
echo "" echo ""
echo "1 - Accounts" echo "1 - Accounts"
@ -88,6 +96,7 @@ elif [ "$MENU" = "2" ]
if [ "$VALID_NUMBER" = "true" ] if [ "$VALID_NUMBER" = "true" ]
then then
printf 'Name: ' printf 'Name: '
curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER | jq -r .
read -r ACCOUNT_NAME read -r ACCOUNT_NAME
curl -s -b $COOKIE $BML_URL | jq curl -s -b $COOKIE $BML_URL | jq
else else

View File

@ -14,3 +14,5 @@ curl -s -b $COOKIE $BML_URL/contacts | jq -r '["Account Number","Currency","Acco
#get this to render nicely in a table, similar to contacts #get this to render nicely in a table, similar to contacts
#curl -s -b $COOKIE $BML_URL/dashboard #curl -s -b $COOKIE $BML_URL/dashboard
curl -s -b $COOKIE $BML_URL/api/validate/account/7730000359348