From 21bef67ff67f67b8bd2e6a351d75e4e9cf94e786 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 7 May 2022 02:21:19 +0200 Subject: Move issues fetch to a function --- src/main.lisp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main.lisp b/src/main.lisp index 4c1c498..7f6973f 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -7,11 +7,21 @@ ;; Send email to ^maildir^program^ containing message with issue metadata ;; Continue to next page - (dex:post "https://example.atlassian.net/rest/api/3/search" - :content - "{ - \"jql\": \"project = \\\"FAKE\\\" AND watcher != currentUser() AND key > \\\"FAKE-100\\\" ORDER BY created DESC\", - \"fields\": [\"id\", \"key\", \"self\"] - }" - :headers '((:content-type . "application/json") - (:authorization . "Basic TOKEN")))) + (fetch-issues + "project = \\\"FAKE\\\" AND watcher != currentUser() AND key > \\\"FAKE-100\\\" ORDER BY created DESC" + :basic-auth-token "TOKEN")) + +(defun fetch-issues (jql &key basic-auth-token) + (multiple-value-bind (body code) + (dex:post "https://example.atlassian.net/rest/api/3/search" + :content + (format nil "{ + \"jql\": \"~A\", + \"fields\": [\"id\", \"key\", \"self\"] + }" + jql) + :headers `((:content-type . "application/json") + (:authorization + . ,(format nil "Basic ~A" basic-auth-token)))) + + body)) -- cgit v1.2.3