Added support for Delete Contact

This commit is contained in:
Shihaam Abdul Rahman 2021-04-28 18:08:43 +05:00
parent 0c80def5d0
commit 6c982f94cc
4 changed files with 21 additions and 10 deletions

View File

@ -12,19 +12,13 @@ read -r CONTATCS
if [ "$CONTATCS" = "1" ]
then
echo "WIP"
sleep 2
source conactsmenu.sh
source listcontacts.sh
elif [ "$CONTATCS" = "2" ]
then
source addcontact-menu.sh
elif [ "$CONTATCS" = "3" ]
then
echo "WIP"
sleep 2
source conactsmenu.sh
source delete contact.sh
source deletecontact.sh
elif [ "$CONTATCS" = "4" ]
then
source mainmenu.sh

17
deletecontact.sh Normal file
View File

@ -0,0 +1,17 @@
printf "Enter Contact ID: "
read -r CONATACT_ID
DELETESUCCESS=$(curl -s -b $COOKIE $BML_URL/contacts/$CONATACT_ID \
--data-raw _method=delete \
--compressed \
| jq -r .code)
if [ "$DELETESUCCESS" = "0" ]
then
echo Contact Deleted
source contactsmenu.sh
else
echo "${red}There was an error${reset}"
source contactsmenu.sh
fi

View File

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

View File

@ -3,7 +3,7 @@ then
source $CREDENTIALS
if [ "$LOGIN" = "2" ]
then
echo "${red}Password update required${reset}"
echo "${red}Login Required${reset}"
rm $CREDENTIALS 2> /dev/null
read -p 'Username: ' BML_USERNAME
read -s -p 'Password: ' BML_PASSWORD
@ -13,7 +13,7 @@ then
fi
elif [ ! -f $CREDENTIALS ]
then
echo "${red}Username or Password in correct${reset}"
echo "${red}Login Required${reset}"
read -p 'Username: ' BML_USERNAME
read -s -p 'Password: ' BML_PASSWORD
echo ""