Skip to content

Instantly share code, notes, and snippets.

@jgarte
Forked from fiddlerwoaroof/example.lisp
Created September 2, 2022 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgarte/596a7728dbd549ce7eec85f69f24bbae to your computer and use it in GitHub Desktop.
Save jgarte/596a7728dbd549ce7eec85f69f24bbae to your computer and use it in GitHub Desktop.
(xhtmlambda::def-element <::request)
(defun post-to-endpoint (xml)
(let ((drakma:*text-content-types* (acons "application" "xml" drakma:*text-content-types*)))
(drakma:http-request *endpoint*
:basic-authorization (list *api-key* "X")
:method :post
:content (with-output-to-string (s)
(format s "~w" xml)))))
(defmacro define-api-call (name (&rest args) method-name &body elements)
`(defun ,name ,args
(plump:parse
(post-to-endpoint
(<:request (:method ,method-name)
,@elements)))))
(define-api-call list-invoices () "invoice.list")
(define-api-call list-projects () "project.list")
(define-api-call list-tasks () "task.list")
(define-api-call list-payments () "payment.list")
(define-api-call list-clients () "client.list")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment