added adding contacts

This commit is contained in:
Shihaam Abdul Rahman 2021-04-28 01:24:02 +05:00
parent 0f4be5a79d
commit 3908b5dde9
6 changed files with 92 additions and 5 deletions

40
addcontact-bml.sh Normal file
View File

@ -0,0 +1,40 @@
printf 'Account Number: '
read -r ACCOUNT_NUMBER
VALID_NUMBER=$(curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER \
| jq -r .success)
if [ "$VALID_NUMBER" = "true" ]
then
NAME=$(curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER \
| jq -r '.["payload"] | .name')
CURRENCY=$(curl -s -b $COOKIE $BML_URL/validate/account/$ACCOUNT_NUMBER \
| jq -r '.["payload"] | .currency')
echo "Account Name: $NAME"
echo "Currency: $CURRENCY"
echo ""
printf 'Contact Name: '
read -r CONTACT_NAME
ADDCONTACT=$(curl -s -b $COOKIE $BML_URL/contacts \
--data-raw contact_type=IAT \
--data-raw account=$ACCOUNT_NUMBER \
--data-raw alias=$CONTACT_NAME \
--compressed \
| jq -r .success)
if [ "$ADDCONTACT" = "true" ]
then
echo "Contact added successfully"
else
echo "${red}There was an error${reset}"
source contactsmenu.sh
fi
else
echo "${red}Invalid Account${reset}" 1>&2
source contactsmenu.sh
fi
source contactsmenu.sh

43
addcontact-menu.sh Normal file
View File

@ -0,0 +1,43 @@
echo ""
echo "Add Contact"
echo ""
echo "1 - BML"
echo "2 - Domestic"
echo "3 - International"
echo "4 - BillPay"
echo "5 - Go back"
echo "6 - Exit"
echo ""
printf 'Select contact type[1]: '
read -r CONTACT_TYPE
if [ "$CONTACT_TYPE" = "1" ]
then
source addcontact-bml.sh
elif [ "$CONTACT_TYPE" = "" ]
then
source addcontact-bml.sh
elif [ "$CONTATC_TYPE" = "2" ]
then
echo "${red}WORK IN PROGRESS${reset}"
source addcontact-menu.sh
elif [ "$CONTATC_TYPE" = "3" ]
then
echo "${red}WORK IN PROGRESS${reset}"
source addcontact-manu.sh
elif [ "$CONTATC_TYPE" = "4" ]
then
echo "${red}WORK IN PROGRESS${reset}"
source addcontact-manu.sh
elif [ "$CONTATC_TYPE" = "5" ]
then
source contactsmenu.sh
elif [ "$CONTATC_TYPE" = "6" ]
then
rm $COOKIE
exit
else
clear
echo "${red}There was an error${reset}" 1>&2
source contactsmenu.sh
fi

7
contactsmenu.sh Executable file → Normal file
View File

@ -12,10 +12,10 @@ read -r CONTATCS
if [ "$CONTATCS" = "1" ]
then
source listcontact.sh
source listcontacts.sh
elif [ "$CONTATCS" = "2" ]
then
source addcontact.sh
source addcontact-menu.sh
elif [ "$CONTATCS" = "3" ]
then
source delete contact.sh
@ -25,9 +25,10 @@ elif [ "$CONTATCS" = "4" ]
elif [ "$CONTATCS" = "5" ]
then
rm $COOKIE
echo "Cleaning up.."
exit
else
echo "${red}There was an error${reset}" 1>&2
clear
echo "${red}There was an error${reset}" 1>&2
source contactsmenu.sh
fi

3
listcontacts.sh Normal file
View File

@ -0,0 +1,3 @@
curl -s -b $COOKIE $BML_URL/contacts \
| jq -r '["Account Number","Currency","Account Name","Contact Name"], ["==================================================================="], (.["payload"] | .[] | [.account, .currency, .name, .alias]) | @tsv'
source contactsmenu.sh

0
mainmenu.sh Executable file → Normal file
View File

4
parser_json_test.sh Executable file → Normal file
View File

@ -10,9 +10,9 @@ curl -s -c $COOKIE $BML_URL/login \
--compressed > /dev/null
curl -s -b $COOKIE $BML_URL/profile > /dev/null
curl -s -b $COOKIE $BML_URL/contacts | jq -r '["Account Number","Currency","Account Name","Contact Name"], ["==================================================================="], (.["payload"] | .[] | [.account, .currency, .name, .alias]) | @tsv'
#curl -s -b $COOKIE $BML_URL/contacts | jq -r '["Account Number","Currency","Account Name","Contact Name"], ["==================================================================="], (.["payload"] | .[] | [.account, .currency, .name, .alias]) | @tsv'
#get this to render nicely in a table, similar to contacts
#curl -s -b $COOKIE $BML_URL/dashboard
curl -s -b $COOKIE $BML_URL/api/validate/account/7730000359348
curl -s -b $COOKIE $BML_URL/api/validate/account/7701134192101