-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathposts.lisp
54 lines (49 loc) · 2.57 KB
/
posts.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(in-package #:org.tymoonnext.humbler)
(defvar *blog/posts* "https://api.tumblr.com/v2/blog/~a.tumblr.com/posts~@[/~a~]")
(defvar *blog/posts/queue* "https://api.tumblr.com/v2/blog/~a.tumblr.com/posts/queue")
(defvar *blog/posts/draft* "https://api.tumblr.com/v2/blog/~a.tumblr.com/posts/draft")
(defvar *blog/posts/submission* "https://api.tumblr.com/v2/blog/~a.tumblr.com/posts/submission")
(defun blog/posts (blog &key type id tag (limit 20) (offset 0) reblog-info notes-info filter)
(assert (member type '(NIL :text :quote :link :answer :video :audio :photo :chat))
() "Type has to be one of (NIL :text :quote :link :answer :video :audio :photo :chat)")
(assert (<= 1 limit 20)
() "Limit must be between 1 and 20 (inclusive).")
(assert (<= 0 offset)
() "Offset must be positive.")
(assert (member filter '(NIL :text :raw))
() "Filter must be one of (NIL :text :raw)")
(if reblog-info (setf reblog-info T))
(if notes-info (setf notes-info T))
(let ((data (request (format NIL *blog/posts* blog (when type (string-downcase type)))
:oauth (not (null (north:token-secret *client*)))
:parameters (cons `("api_key" . ,(north:key *client*))
(prepare* id tag limit offset reblog-info notes-info filter)))))
(values (aget :posts data)
(aget :total-posts data)
(aget :blog data))))
(defun blog/posts/queue (blog &key (limit 20) (offset 0) filter)
(assert (<= 1 limit 20)
() "Limit must be between 1 and 20 (inclusive).")
(assert (<= 0 offset)
() "Offset must be positive.")
(assert (member filter '(NIL :text :raw))
() "Filter must be one of (NIL :text :raw)")
(aget :posts
(request (format NIL *blog/posts/queue* blog)
:oauth T :parameters (prepare* limit offset filter))))
(defun blog/posts/draft (blog &key (before-id 0) filter)
(assert (<= 0 before-id)
() "Before-ID must be positive.")
(assert (member filter '(NIL :text :raw))
() "Filter must be one of (NIL :text :raw)")
(aget :posts
(request (format NIL *blog/posts/draft* blog)
:oauth T :parameters (prepare* before-id filter))))
(defun blog/posts/submission (blog &key (offset 0) filter)
(assert (<= 0 offset)
() "Offset must be positive.")
(assert (member filter '(NIL :text :raw))
() "Filter must be one of (NIL :text :raw)")
(aget :posts
(request (format NIL *blog/posts/submission* blog)
:oauth T :parameters (prepare* offset filter))))