2021-03-04 16:57:48 +00:00
# Sipgate CLI
This is a small hack to send faxes via the sipgate REST API from the command line.
## Deployment
2023-01-09 21:46:38 +00:00
### Dependencies
* `bash >= 4.3`
* `curl`
* `sed`
* `bc`
* `getopt`
* [`jq` ](https://stedolan.github.io/jq/download/ ).
* optional: `ghostscript`
2021-07-20 11:48:50 +00:00
2023-01-09 21:46:38 +00:00
### Configuration
2021-03-13 13:50:48 +00:00
Add your login credentials to `login_credentials_muster.sh` and rename the file to `.env`
2021-04-07 16:36:18 +00:00
2023-01-09 21:21:12 +00:00
Since sipgate enforces 2FA, your usual username and password won't work anymore.
Now, you need a so-called [Personal Access Token ](https://app.sipgate.com/w0/personal-access-token ), that you can retrieve after you login to the web interface.
Enable at least the following scopes:
2023-01-09 21:27:39 +00:00
* `balance:read`
* `devices:callerid:read`
* `devices:callerid:write`
* `history:read`
* `sessions:fax:write`
2023-01-09 21:25:57 +00:00
2023-01-09 21:21:12 +00:00
Enter the token-ID as `SIPUSER` or `TOKENID` and the token as `SIPPWD` or `TOKEN` .
2023-01-09 21:30:05 +00:00
It's prefered to use the `TOKEN*` variables, but in that case, the `SIP*` variables **MUST** be left empty/unset.
2023-01-09 21:21:12 +00:00
2021-04-07 16:23:29 +00:00
If you use Letterheads Address database, uncomment the last line of that file and add `your/path/to/Letterhead`
2021-03-04 16:57:48 +00:00
## Usage
2021-03-04 17:59:13 +00:00
`./fax.sh <letter.pdf> <recipient>`
2021-04-07 17:09:47 +00:00
with a german fax number `<recipient>`
2021-04-07 16:37:16 +00:00
2021-04-07 16:36:18 +00:00
`./fax.sh <letter.pdf> -handle <handle>`
2021-04-07 17:09:47 +00:00
asks Letterhead's address database for < handle > 's fax number.
2021-04-07 16:37:16 +00:00
2021-04-07 17:09:47 +00:00
` ./fax.sh -help`
prints usage Message and exits
2021-03-04 17:59:13 +00:00
2021-03-04 16:57:48 +00:00
sipgate doesn't accept pdf files larger than 30 pages or 10MB.
2021-03-04 17:59:13 +00:00
2021-03-04 17:31:10 +00:00
~~For now, `<recipient>` has to be numbers-only, starting with `+49` . It is planned to parse different number formats.~~ Should be done.
2021-04-07 17:09:47 +00:00
~~Spaces in filename seem to make trouble at the moment - avoid them.~~ Spaces in filenames are difficult. No guarantee, but should be handled now.
2021-03-04 19:41:00 +00:00
`status.sh` shows ID, Date and Status of the last ten fax set from this device.
2021-03-04 17:31:10 +00:00
`balance.sh` just gives your account balance.
2021-03-14 12:56:28 +00:00
`faxreport.sh [options] [id]` loads the report of a given fax id (as shown by status.sh). If no `id` ist given, it takes the last fax sent from this machine.
2021-03-14 11:58:34 +00:00
Options:
* `-p` to only print and not save the report
* `-d` to delete the given id from `.fax_history`
2021-03-14 10:38:08 +00:00
2021-03-04 19:25:39 +00:00
## 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"
2021-04-07 16:31:15 +00:00
# The following is obsolete, but for documentation/compatibility reasons:
2021-03-14 12:56:28 +00:00
fax-from-handle () { fax $1 "$(/your/path/to/this/project/Letterhead/Adressen/address.sh -f $2)"; }
2021-03-04 19:25:39 +00:00
```
2021-03-04 19:26:48 +00:00
into your `.bashrc` or `.bash_aliases`
2021-03-04 19:25:39 +00:00