added support for bml api proxy

This commit is contained in:
Shihaam Abdul Rahman 2022-08-08 01:07:02 +05:00
parent cd677157f2
commit d054bc0ee5
Signed by: shihaam
GPG Key ID: 16ADCF6871CB2A56

42
bml-cli
View File

@ -3,7 +3,7 @@
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
CONFIG=~/.config/bml-cli/config
CREDENTIALS=~/.config/bml-cli/.credentials
COOKIE=cookie #~/.cache/bml-cli/.cookie
COOKIE=~/.cache/bml-cli/.cookie
BML_RESETPASS='https://www.bankofmaldives.com.mv/internetbanking/forgot_password'
#Setting terminal output colors
@ -76,13 +76,13 @@ check_connection(){
echo ${red}Check your connection and try again.${reset}
exit 1
fi
DOS=$($curl -s https://www.bankofmaldives.com.mv/ | grep -oE "error code: 1020")
if [ "$DOS" = "error code: 1020" ]
then
echo ${red}Access denied${reset}
echo Try again later
exit
fi
# DOS=$(curl -s https://www.bankofmaldives.com.mv/ | grep -oE "error code: 1020")
# if [ "$DOS" = "error code: 1020" ]
# then
# echo ${red}Access denied${reset}
# echo Try again later
# exit
# fi
}
os_detect(){
@ -228,7 +228,7 @@ savepass(){
################################################################################################
login(){
LOGIN=$($curl -s -c $COOKIE $BML_URL/login \
LOGIN=$(curl -s -c $COOKIE $BML_URL/login \
--data-raw username=$BML_USERNAME_UNSAFE \
--data-raw password=${BML_PASSWORD_UNSAFE} \
| jq -r .code)
@ -293,11 +293,11 @@ enter_credentials(){
################################################################################################
select_profile(){
REQPRO=$($curl -s -b $COOKIE $BML_URL/profile)
REQPRO=$(curl -s -b $COOKIE $BML_URL/profile)
PERSONALPROFILE=$(echo $REQPRO \
| jq -r '.payload | .profile | .[] | .profile' \
| head -n 1)
$curl -s -b $COOKIE $BML_URL/profile \
curl -s -b $COOKIE $BML_URL/profile \
--data-raw profile=$PERSONALPROFILE \
--compressed > /dev/null
}
@ -305,7 +305,7 @@ $curl -s -b $COOKIE $BML_URL/profile \
################################################################################################
userinfo(){
USERINFO=$($curl -s -b $COOKIE $BML_URL/userinfo)
USERINFO=$(curl -s -b $COOKIE $BML_URL/userinfo)
SUCCESS=$(echo $USERINFO | jq -r .success)
if [ "$SUCCESS" != "true" ]
then
@ -331,7 +331,7 @@ accounts(){
}
################################################################################################
api_dashboard(){
DASHBOARD=$($curl -s -b $COOKIE $BML_URL/dashboard)
DASHBOARD=$(curl -s -b $COOKIE $BML_URL/dashboard)
SUCCESS=$(echo $DASHBOARD | jq -r .success)
if [ "$SUCCESS" != "true" ]
then
@ -349,7 +349,7 @@ list_contacts(){
}
################################################################################################
api_contacts(){
API_CONATACTS=$($curl -s -b $COOKIE $BML_URL/contacts)
API_CONATACTS=$(curl -s -b $COOKIE $BML_URL/contacts)
SUCCESS=$(echo $API_CONATACTS | jq -r .code)
if [ "$SUCCESS" = "17" ]
then
@ -372,7 +372,7 @@ transfer(){
################################################################################################
api_account(){
API_ACCOUNT=$($curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER)
API_ACCOUNT=$(curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER)
SUCCESS=$(echo $API_ACCOUNT | jq -r .code)
if [ "$SUCCESS" = "17" ]
then
@ -418,7 +418,7 @@ then
CONTACT_NAME=$ACCOUNT_NAME
fi
CONTACT_NAME_SED=`echo "$CONTACT_NAME" | sed "s/ /%20/g"`
ADDCONTACT=$($curl -s -b $COOKIE $BML_URL/contacts \
ADDCONTACT=$(curl -s -b $COOKIE $BML_URL/contacts \
--data-raw contact_type=IAT \
--data-raw account=$ACCOUNT_NUMBER \
--data-raw alias=$CONTACT_NAME_SED \
@ -452,7 +452,7 @@ fi
delete_contact(){
printf "Enter Contact ID: "
read -r CONATACT_ID
DELETESUCCESS=$($curl -s -b $COOKIE $BML_URL/contacts/$CONATACT_ID \
DELETESUCCESS=$(curl -s -b $COOKIE $BML_URL/contacts/$CONATACT_ID \
--data-raw _method=delete \
--compressed \
| jq -r .code)
@ -468,7 +468,7 @@ delete_contact(){
}
#################################
api_activites(){
API_ACTIVITES=$($curl -s -b $COOKIE $BML_URL/activities)
API_ACTIVITES=$(curl -s -b $COOKIE $BML_URL/activities)
SUCCESS=$(echo $API_ACTIVITES | jq -r .code)
if [ "$SUCCESS" = "17" ]
then
@ -497,7 +497,7 @@ activities(){
then
display_banner && display_name && display_userinfo
echo Current Page: $PAGENO
$curl -s -b $COOKIE $BML_URL/activities?page=$PAGENO \
curl -s -b $COOKIE $BML_URL/activities?page=$PAGENO \
| jq -r '["Type","Date","Time","Contact","Amount","Remarks","Status"], ["====","==========","=========","==========================","============","==================","==========="],(.payload | .content | .data | .[] | [.type, .datetime, .creditName, .formattedAmount, .message, .status]) | @tsv' \
| sed "s/+05:00//g" \
| sed 's/\([0-9]\{4\}-[0-9][0-9]-[0-9][0-9]\)T\([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\)/\1 \2/g' \
@ -681,7 +681,7 @@ change_password(){
done
$curl -s -b $COOKIE $BML_URL/user/changepassword \
curl -s -b $COOKIE $BML_URL/user/changepassword \
--data-raw currentPassword=$OLD_PASSWORD \
--data-raw newPassword=$NEW_PASSWORD \
--data-raw newPasswordConfirmation=$REPEAT_NEWPASSWORD \
@ -689,7 +689,7 @@ change_password(){
echo ${lightgreen}OTP sent to ${yellow}${ECHOOTPCHANNEL}${reset}
read -n 6 -p 'Enter OTP: ' OTP
CHANGEPASSWORD=$($curl -s -b $COOKIE $BML_URL/user/changepassword \
CHANGEPASSWORD=$(curl -s -b $COOKIE $BML_URL/user/changepassword \
--data-raw currentPassword=$OLD_PASSWORD \
--data-raw newPassword=$NEW_PASSWORD \
--data-raw newPasswordConfirmation=$REPEAT_NEWPASSWORD \