diff options
author | Peter Bex <peter@more-magic.net> | 2011-06-22 19:52:19 +0200 |
---|---|---|
committer | Peter Bex <peter@more-magic.net> | 2011-06-22 19:52:19 +0200 |
commit | 26e775444ad2c7603e8564d02d370211e83294e8 (patch) | |
tree | 7bd2ebc4e83c3433fb5b918d004db23d6f489fc2 | |
parent | 4051efaf481afb1606c0e833f3c6eae0f075ed3f (diff) | |
download | smsmatrix-26e775444ad2c7603e8564d02d370211e83294e8.tar.gz |
Implement fax API (which I haven't been able to test successfully and which isn't supported)
-rw-r--r-- | smsmatrix.scm | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/smsmatrix.scm b/smsmatrix.scm index 61d6a8a..008184e 100644 --- a/smsmatrix.scm +++ b/smsmatrix.scm @@ -37,7 +37,7 @@ (module smsmatrix (smsmatrix-username smsmatrix-password get-credits get-rate carrier-name message-status call-with-csv-report - send-sms) + send-sms send-fax) (import chicken scheme) @@ -277,4 +277,39 @@ entry)) res)))) +;; The fax API is undocumented except for a Perl example and unsupported +(define (send-fax recipients filename #!key + username password group (error-on-failure #t)) + (let-auth 'send-fax username password + (let* ((recipient-type (if group 'group 'phone)) ;; TODO: test if group works for faxes + (recipients (if (string? recipients) ;; TODO: Check if multi-recipients works + recipients + (string-intersperse recipients ","))) + (res (api-request 'send-fax fax-uri + `((username . ,username) + (password . ,password) + (,recipient-type . ,recipients) + (file file: ,filename filename: ,filename + headers: ((content-type application/pdf)))) + 'pin '(id statuscode statustxt timestamp)))) + (print res) + ;; Check for errors in phone number recipients if it was asked for + (when error-on-failure + (for-each (lambda (entry) + (let ((status (alist-ref 'statuscode entry)) + (status-text (alist-ref 'statustxt entry)) + (pin (alist-ref 'pin entry))) + (error-on-bad-result-code + 'send-fax status status-text pin))) + res)) + (map (lambda (entry) + (map (lambda (key/value) + (let ((key (car key/value)) + (value (cdr key/value))) + (case key + ((statuscode timestamp) (cons key (string->number value))) + (else key/value)))) + entry)) + res)))) + )
\ No newline at end of file |