diff --git a/send-grid.release-info b/send-grid.release-info index dcfcf72..a99f650 100644 --- a/send-grid.release-info +++ b/send-grid.release-info @@ -2,4 +2,5 @@ (uri targz "https://github.com/ThomasHintz/chicken-scheme-{egg-name}/tarball/{egg-release}") (release "1") -(release "2") \ No newline at end of file +(release "2") +(release "2.0.1") \ No newline at end of file diff --git a/send-grid.scm b/send-grid.scm index 103193c..63b82af 100644 --- a/send-grid.scm +++ b/send-grid.scm @@ -35,7 +35,7 @@ send-mail) (import scheme chicken) -(use http-client uri-common intarweb json srfi-1 srfi-18) +(use data-structures http-client uri-common intarweb json srfi-1 srfi-18) (define api-user (make-parameter "")) (define api-key (make-parameter "")) @@ -44,7 +44,7 @@ (vector->list (with-input-from-request (make-request method: method uri: (uri-reference url)) parameters json-read))) -(define (send-mail #!key (subject #f) (text #f) (html #f) (from #f) (from-name #f) (to #f) (reply-to #f) (api-user (api-user)) (api-key (api-key))) +(define (send-mail #!key (subject #f) (text #f) (html #f) (from #f) (from-name #f) (to #f) (reply-to #f) (api-user (api-user)) (api-key (api-key)) files) (if (and subject (or text html) from from-name to reply-to) (rest-action "https://sendgrid.com/api/mail.send.json" 'POST `((api_user . ,api-user) @@ -54,6 +54,16 @@ (replyto . ,reply-to) ,(if html `(html . ,html) `(text . ,text)) (from . ,from) - (fromname . ,from-name))) + (fromname . ,from-name) + ,@(map + (lambda (file-details) + `(,(string->symbol + (string-append + "files[" (alist-ref 'filename file-details) "]")) + file: ,(alist-ref 'filepath file-details) + filename: ,(alist-ref 'filename file-details) + headers: ((content-type + ,(alist-ref 'content-type file-details))))) + files))) (abort "All parameters are required for successfully sending mail."))) -) \ No newline at end of file +) diff --git a/send-grid.setup b/send-grid.setup index 503812f..6825aa2 100644 --- a/send-grid.setup +++ b/send-grid.setup @@ -11,5 +11,5 @@ ; Files to install for your extension: '("send-grid.o" "send-grid.so" "send-grid.import.so") ; Assoc list with properties for your extension: - '((version 2) + '((version 2.0.1) (static "send-grid.o"))) ;; for static linking \ No newline at end of file