From 6132875bcf053f9ae4ec34b0d094734ae1f23339 Mon Sep 17 00:00:00 2001 From: Tobias Eidelpes Date: Thu, 12 Jan 2023 11:03:26 +0100 Subject: [PATCH] Initial commit --- agoradesk.lisp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 agoradesk.lisp diff --git a/agoradesk.lisp b/agoradesk.lisp new file mode 100644 index 0000000..8a02f1b --- /dev/null +++ b/agoradesk.lisp @@ -0,0 +1,41 @@ +(ql:quickload :shasht) +(ql:quickload :dexador) +(ql:quickload :str) + +(defparameter *api-key* "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ6ZW5vbiIsImNyZWF0ZWQiOjE2NzMxMDcyNDQ1NDgsImFwaSI6InB1YmxpYyIsImV4cCI6MTgzMDg5NTI0NCwianRpIjoiZGI3MzFjN2YtOTQxZi00YTdjLWE0NWQtNzRlODNmODg3MWYwIn0.BpEGtFseUOr6pr_rQcWtndIhaJ8SNqGvFURVFRIdXGqTyqwJC0uG1H3hE-8-QTnTGGEdA4-HQizzC3hLNo0OEQ") +(defparameter *base-url* "https://agoradesk.com/api/v1") + +(defmacro with-data (&body body) + `(gethash "data" + (shasht:read-json ,@body))) + +(defmacro with-authorization (type endpoint &body body) + `(,type (str:join "" (list *base-url* ,endpoint)) + :headers (list (cons "User-Agent" "curl/7.87.0") + (cons "Authorization" *api-key*) + (cons "Content-Type" "application/json")) + :content ,@body)) + +(defun get-user-info (user) + (shasht:read-json + (dex:get (format nil "https://agoradesk.com/api/v1/account_info/~a" user)))) + +(defun get-myself () + (with-data (with-authorization dex:get "/myself" ()))) + +(defun get-notifications () + (with-data (with-authorization dex:get "/notifications" ()))) + +(defun get-ads () + (with-data (with-authorization dex:get "/ads" ()))) + +(defun get-ad-by-id (id) + (with-data + (aref + (gethash "ad_list" + (with-data (with-authorization dex:get (format nil "/ad-get/~a" id) ()))) + 0))) + +(defun duplicate-ad (id &optional country-code currency)) + +(defun post-ad ())