-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
blog.lisp
32 lines (27 loc) · 1.46 KB
/
blog.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(in-package #:org.tymoonnext.humbler)
(defvar *blog/info* "https://api.tumblr.com/v2/blog/~a.tumblr.com/info")
(defvar *blog/avatar* "https://api.tumblr.com/v2/blog/~a.tumblr.com/avatar/~a")
(defvar *blog/likes* "https://api.tumblr.com/v2/blog/~a.tumblr.com/likes")
(defvar *blog/followers* "https://api.tumblr.com/v2/blog/~a.tumblr.com/followers")
(defun blog/info (blog)
(aget :blog (request (format NIL *blog/info* blog) :parameters `(("api_key" . ,(north:key *client*))))))
(defun blog/avatar (blog &key (size 64))
(assert (find size '(16 24 30 40 48 64 96 128 512))
() "Size must be one of (16 24 30 40 48 64 96 128 512)")
(request (format NIL *blog/avatar* blog size)))
(defun blog/likes (blog &key (limit 20) (offset 0))
(assert (<= 1 limit 20)
() "Limit must be between 1 and 20 (inclusive).")
(assert (<= 0 offset)
() "Offset must be positive.")
(let ((data (request (format NIL *blog/likes* blog) :parameters (cons `("api_key" . ,(north:key *client*)) (prepare* limit offset)))))
(values (aget :liked-posts data)
(aget :liked-count data))))
(defun blog/followers (blog &key (limit 20) (offset 0))
(assert (<= 1 limit 20)
() "Limit must be between 1 and 20 (inclusive).")
(assert (<= 0 offset)
() "Offset must be positive.")
(let ((data (request (format NIL *blog/followers* blog) :oauth T :parameters (prepare* limit offset))))
(values (aget :users data)
(aget :total-users data))))