aboutsummaryrefslogtreecommitdiff
path: root/oneliners.api-client.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'oneliners.api-client.lisp')
-rw-r--r--oneliners.api-client.lisp88
1 files changed, 50 insertions, 38 deletions
diff --git a/oneliners.api-client.lisp b/oneliners.api-client.lisp
index bd7ba72..5fc6f10 100644
--- a/oneliners.api-client.lisp
+++ b/oneliners.api-client.lisp
@@ -5,11 +5,11 @@
(defpackage #:ONELINERS.API-CLIENT
(:use :cl :lazybones-client.shared)
(:export #:*host* #:*body* #:*headers* #:*cookies* #:request-with
- #:PUT--CONTRIBUTOR-WHO-PASSWORD
-#:GET--ONELINERS
+ #:GET--ONELINERS
#:GET--ONELINERS-ALL-FLAGGED
#:GET--ONELINERS-NEWEST
#:PUT--ONELINER-ENTRY-FLAG
+#:GET--ONELINER-ENTRY
#:PATCH--ONELINER-ENTRY-EDIT
#:PUT--ONELINER-ONELINER-LOCKED
#:POST--ONELINER
@@ -19,6 +19,7 @@
#:POST--ACCESS
#:POST--INVITE-REDEEM-CODE
#:PUT--CONTRIBUTOR-WHO-SIGNATURE
+#:PUT--CONTRIBUTOR-WHO-PASSWORD
#:PUT--CONTRIBUTOR-WHO-LOCKED
#:GET--CONTRIBUTOR-WHO))
(in-package :ONELINERS.API-CLIENT)
@@ -69,39 +70,6 @@ COOKIES should be an instance of CL-COOKIE:COOKIE-JAR. Defaults to
(dex:response-body ,http-error-var)))))))
-(DEFUN PUT--CONTRIBUTOR-WHO-PASSWORD (WHO &KEY VALUE REPEATED CURRENT TOKEN)
- "Change a contributor's password."
- (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
- (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
- (FORMAT NIL "/contributor/~a/password" WHO)
- (WHEN (OR VALUE REPEATED CURRENT TOKEN)
- (LIST "?"
- (IF VALUE
- (CONCATENATE 'STRING (SYMBOL-NAME 'VALUE) "="
- (FORMAT NIL "~a" VALUE))
- "")
- (IF REPEATED
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'REPEATED)
- "=" (FORMAT NIL "~a" REPEATED))
- "")
- (IF CURRENT
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'CURRENT) "="
- (FORMAT NIL "~a" CURRENT))
- "")
- (IF TOKEN
- (CONCATENATE 'STRING "&" (SYMBOL-NAME 'TOKEN) "="
- (FORMAT NIL "~a" TOKEN))
- ""))))))
- (IF LAZYBONES-CLIENT.SHARED:*BODY*
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
- (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-
-
(DEFUN GET--ONELINERS (&KEY TAGS LIMIT NOTFLAGGED)
"A search endpoint returning a JSON encoded array of Oneliner
Entries. TAGS cannot be empty. Returns a [Search
@@ -186,6 +154,16 @@ Result](#search-result) object."
LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+(DEFUN GET--ONELINER-ENTRY (ENTRY)
+ "Gets a oneliner by id."
+ (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
+ (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
+ (FORMAT NIL "/oneliner/~a" ENTRY) NIL)))
+ (DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+
+
(DEFUN PATCH--ONELINER-ENTRY-EDIT (ENTRY &KEY TOKEN)
"Edit the fields of a oneliner."
(LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
@@ -337,7 +315,7 @@ Result](#search-result) object."
(DEFUN PUT--CONTRIBUTOR-WHO-SIGNATURE (WHO &KEY TOKEN)
- NIL
+ "Update a [contributor's](#contributor) signature."
(LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
(APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
(FORMAT NIL "/contributor/~a/signature" WHO)
@@ -357,8 +335,42 @@ Result](#search-result) object."
LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+(DEFUN PUT--CONTRIBUTOR-WHO-PASSWORD (WHO &KEY VALUE REPEATED CURRENT TOKEN)
+ "Change a contributor's password."
+ (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
+ (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
+ (FORMAT NIL "/contributor/~a/password" WHO)
+ (WHEN (OR VALUE REPEATED CURRENT TOKEN)
+ (LIST "?"
+ (IF VALUE
+ (CONCATENATE 'STRING (SYMBOL-NAME 'VALUE) "="
+ (FORMAT NIL "~a" VALUE))
+ "")
+ (IF REPEATED
+ (CONCATENATE 'STRING "&" (SYMBOL-NAME 'REPEATED)
+ "=" (FORMAT NIL "~a" REPEATED))
+ "")
+ (IF CURRENT
+ (CONCATENATE 'STRING "&" (SYMBOL-NAME 'CURRENT) "="
+ (FORMAT NIL "~a" CURRENT))
+ "")
+ (IF TOKEN
+ (CONCATENATE 'STRING "&" (SYMBOL-NAME 'TOKEN) "="
+ (FORMAT NIL "~a" TOKEN))
+ ""))))))
+ (IF LAZYBONES-CLIENT.SHARED:*BODY*
+ (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ (DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+
+
(DEFUN PUT--CONTRIBUTOR-WHO-LOCKED (WHO &KEY VALUE TOKEN)
- NIL
+ "Admin users may lock a particular contributor, preventing that
+contributor for making edits or adding new oneliners."
(LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
(APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
(FORMAT NIL "/contributor/~a/locked" WHO)
@@ -383,7 +395,7 @@ Result](#search-result) object."
(DEFUN GET--CONTRIBUTOR-WHO (WHO)
- NIL
+ "Return a [contributor](#contributor) data object."
(LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
(APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
(FORMAT NIL "/contributor/~a" WHO) NIL)))