Initial commit
This commit is contained in:
commit
6132875bcf
41
agoradesk.lisp
Normal file
41
agoradesk.lisp
Normal file
@ -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 ())
|
||||
Loading…
x
Reference in New Issue
Block a user