From 74b62ae824ebacbbe9e4fc1969a47fc6879212bc Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Thu, 20 May 2021 08:13:20 +0500 Subject: [PATCH] added activites --- 63 | 0 bml-cli.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 63 diff --git a/63 b/63 new file mode 100644 index 0000000..e69de29 diff --git a/bml-cli.sh b/bml-cli.sh index 3b8bcf4..88ef726 100755 --- a/bml-cli.sh +++ b/bml-cli.sh @@ -435,10 +435,51 @@ delete_contact(){ delete_contact fi } +################################# +api_activites(){ + API_ACTIVITES=$(curl -s -b $COOKIE $BML_URL/activities) + SUCCESS=$(echo $API_ACTIVITES | jq -r .code) + if [ "$SUCCESS" = "17" ] + then + echo ${red}Login Required${reset} + init_login + display_banner && display_name && display_userinfo + api_activites + fi + PAGETOTAL=$(echo $API_ACTIVITES | jq -r '.payload | .content | .last_page') + +} ################################################################################################ activities(){ -curl -s -b $COOKIE $BML_URL/activities?page=1 | jq - + echo Current Page: 1 + echo $API_ACTIVITES | jq -r '["Type","Date","Contact","Amount","Remarks","Status"], ["=====","=========","============","=======","==================","==========="],(.payload | .content | .data | .[] | [.type, .datetime, .creditName, .formattedAmount, .message, .status]) | @tsv' \ + | perl -pe 's/((?<=\t)|(?<=^))\t/ \t/g;' "$@" | column -t -s $'\t' | exec less -F -S -X -K + while true; do + echo "" + echo Total Pages: $PAGETOTAL + read -p "Enter Page Number: " PAGENO + if [ "$PAGENO" = "" ] + then + display_banner && display_name && display_userinfo + echo ${red}Invalid Input${reset} + echo Enter x to go back + elif [ "$PAGENO" -le "$PAGETOTAL" ] + then + display_banner && display_name && display_userinfo + echo Current Page: $PAGENO + curl -s -b $COOKIE $BML_URL/activities?page=$PAGENO \ + | jq -r '["Type","Date","Contact","Amount","Remarks","Status"], ["=====","=========","============","=======","==================","==========="],(.payload | .content | .data | .[] | [.type, .datetime, .creditName, .formattedAmount, .message, .status]) | @tsv' \ + | perl -pe 's/((?<=\t)|(?<=^))\t/ \t/g;' "$@" | column -t -s $'\t' | exec less -F -S -X -K + elif [ "$PAGENO" -gt "$PAGETOTAL" ] + then + display_banner && display_name && display_userinfo + echo ${red}value too high${reset} + elif [ "$PAGENO" = "x" ] + then + display_banner && display_name && display_userinfo + main_menu + fi + done } ################################################################################################ main_menu(){ @@ -474,6 +515,7 @@ read -r MENU elif [ "$MENU" = "4" ] then display_banner && display_name && display_userinfo + api_activites activities elif [ "$MENU" = "5" ] then