From ea1b96f2c86199ea6161eafe72cc4c05350a2f5b Mon Sep 17 00:00:00 2001 From: "t@thintz.com" Date: Sat, 14 Jan 2012 16:54:06 -0800 Subject: [PATCH] first --- send-grid.meta | 15 +++++++++++++++ send-grid.release-info | 4 ++++ send-grid.scm | 21 +++++++++++++++++++++ send-grid.setup | 15 +++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 send-grid.meta create mode 100644 send-grid.release-info create mode 100644 send-grid.scm create mode 100644 send-grid.setup diff --git a/send-grid.meta b/send-grid.meta new file mode 100644 index 0000000..f5dcd5e --- /dev/null +++ b/send-grid.meta @@ -0,0 +1,15 @@ +; author: Thomas Hintz +; email: t@thintz.com +; license: bsd + +( +(license "BSD") + +(category web) + +(needs http-client uri-common intarweb json srfi-1 srfi-18) + +(test-depends test srfi-1) + +(author "Thomas Hintz") +(synopsis "Provides a simple interface to the SendGrid mailer service.")) \ No newline at end of file diff --git a/send-grid.release-info b/send-grid.release-info new file mode 100644 index 0000000..0f3830e --- /dev/null +++ b/send-grid.release-info @@ -0,0 +1,4 @@ +(repo git "git://github.com/ThomasHintz/chicken-scheme-{egg-name}.git") ; optional + +(uri targz "https://github.com/ThomasHintz/chicken-scheme-{egg-name}/tarball/{egg-release}") +(release "1") \ No newline at end of file diff --git a/send-grid.scm b/send-grid.scm new file mode 100644 index 0000000..ee68a66 --- /dev/null +++ b/send-grid.scm @@ -0,0 +1,21 @@ +(use http-client uri-common intarweb json srfi-1 srfi-18) + +(define api-user (make-parameter "")) +(define api-key (make-parameter "")) + +(define (rest-action url method parameters) + (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))) + (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) + (api_key . ,api-key) + (subject . ,subject) + (to . ,to) + (replyto . ,reply-to) + ,(if html `(html . ,html) `(text . ,text)) + (from . ,from) + (fromname . ,from-name))) + (abort "You must specify all keyword parameters!"))) \ No newline at end of file diff --git a/send-grid.setup b/send-grid.setup new file mode 100644 index 0000000..14d0328 --- /dev/null +++ b/send-grid.setup @@ -0,0 +1,15 @@ +; author: Thomas Hintz +; email: t@thintz.com +; license: bsd + +(compile -s -O2 -d1 send-grid.scm -j amazon-s3) +(compile -s send-grid.import.scm -O2 -d0) +(compile -c -O2 -d1 send-grid.scm -unit send-grid -j send-grid) + +(install-extension + 'send-grid + ; Files to install for your extension: + '("send-grid.o" "send-grid.so" "send-grid.import.so") + ; Assoc list with properties for your extension: + '((version 1) + (static "send-grid.o"))) ;; for static linking \ No newline at end of file