Compare commits

...

3 commits

5 changed files with 30 additions and 6 deletions

View file

@ -13,3 +13,12 @@ sipgate doesn't accept pdf files larger than 30 pages or 10MB.
`balance.sh` just gives your account balance. `balance.sh` just gives your account balance.
## Recommendation
Put
```
alias fax="/your/path/to/this/project/fax.sh"
alias faxstatus="/your/path/to/this/project/status.sh"
alias faxbalance="/your/path/to/this/project/balance.sh"
```
into your `.bash_rc`

View file

@ -1,4 +1,5 @@
. login_credentials.sh BASEPATH=$(dirname $(realpath $0))
. $BASEPATH/login_credentials.sh
AUTH_TOKEN=$(echo $(curl --request POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --data-urlencode client_id=sipgate-app-web --data-urlencode grant_type=password --data-urlencode username=$SIPUSER --data-urlencode password=$SIPPWD https://api.sipgate.com/login/sipgate-apps/protocol/openid-connect/token -s | jq '.access_token') | sed 's/\"//g') AUTH_TOKEN=$(echo $(curl --request POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --data-urlencode client_id=sipgate-app-web --data-urlencode grant_type=password --data-urlencode username=$SIPUSER --data-urlencode password=$SIPPWD https://api.sipgate.com/login/sipgate-apps/protocol/openid-connect/token -s | jq '.access_token') | sed 's/\"//g')
if [ -z "$AUTH_TOKEN" ]; if [ -z "$AUTH_TOKEN" ];
then then

View file

@ -1,4 +1,5 @@
#! /bin/bash #! /bin/bash
. authorization.sh BASEPATH=$(dirname $(realpath $0))
. getbalance.sh . $BASEPATH/authorization.sh
. $BASEPATH/getbalance.sh

7
fax.sh
View file

@ -8,7 +8,8 @@ then
where <recipient> has to be a german faxline number" where <recipient> has to be a german faxline number"
exit 1 exit 1
fi fi
. authorization.sh BASEPATH=$(dirname $(realpath $0))
. $BASEPATH/authorization.sh
#Prepare fax credentials: #Prepare fax credentials:
FILE=$1 FILE=$1
echo -n "Sending file ${FILE} " echo -n "Sending file ${FILE} "
@ -28,9 +29,9 @@ then
echo "Something went wrong, I didn't receive some fax id back." echo "Something went wrong, I didn't receive some fax id back."
else else
echo "Sipgate took your fax as sessionID $FAXID" echo "Sipgate took your fax as sessionID $FAXID"
echo "$FAXID" >> .fax_history echo "$FAXID" >> $BASEPATH/.fax_history
fi fi
#Check if fax request was accepted by sipgate #Check if fax request was accepted by sipgate
curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/history/$FAXID" -s | jq '.faxStatusType' curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/history/$FAXID" -s | jq '.faxStatusType'
#And show the account balance #And show the account balance
. getbalance.sh . $BASEPATH/getbalance.sh

12
status.sh Executable file
View file

@ -0,0 +1,12 @@
#! /bin/bash
BASEPATH=$(dirname $(realpath $0))
. $BASEPATH/authorization.sh
while read LINE;
do
JSON=$(curl --request GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $AUTH_TOKEN" "https://api.sipgate.com/v2/history/$LINE" -s)
STATUS=$(echo $JSON | jq '.faxStatusType' | sed -e 's:"::g' )
DATE=$(echo $JSON | jq '.created' | sed -e 's:"::g' )
TARGET=$(echo $JSON | jq '.target' | sed -e 's:"::g' )
echo "Fax $LINE vom $(date +%d.%m.%Y -d $DATE) an $TARGET: $STATUS"
done < $BASEPATH/.fax_history