Compare commits

...

3 Commits

Author SHA1 Message Date
Gandalf b65a65733c README alias recommendation 2021-03-04 20:25:39 +01:00
Gandalf 59309ba5ed Consider absolute paths 2021-03-04 20:17:30 +01:00
Gandalf 5ca77e7479 Statusabfrage der von diesem Gerät gesendeten Faxe 2021-03-04 20:12:46 +01:00
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.
## 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')
if [ -z "$AUTH_TOKEN" ];
then

View File

@ -1,4 +1,5 @@
#! /bin/bash
. authorization.sh
. getbalance.sh
BASEPATH=$(dirname $(realpath $0))
. $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"
exit 1
fi
. authorization.sh
BASEPATH=$(dirname $(realpath $0))
. $BASEPATH/authorization.sh
#Prepare fax credentials:
FILE=$1
echo -n "Sending file ${FILE} "
@ -28,9 +29,9 @@ then
echo "Something went wrong, I didn't receive some fax id back."
else
echo "Sipgate took your fax as sessionID $FAXID"
echo "$FAXID" >> .fax_history
echo "$FAXID" >> $BASEPATH/.fax_history
fi
#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'
#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