aboutsummaryrefslogtreecommitdiff
path: root/sx-method.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-02-21 15:23:56 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-02-21 15:25:55 -0200
commitfb70d2798482057943f4301c75ad09fb8653f27c (patch)
tree5cdaf4d39f1795dc8cbdc340433c4bd77f14d686 /sx-method.el
parentca121c0c65e0e689af2ee859fdd8ebea8bc44bc5 (diff)
Define sx-method-post-from-data
Diffstat (limited to 'sx-method.el')
-rw-r--r--sx-method.el28
1 files changed, 28 insertions, 0 deletions
diff --git a/sx-method.el b/sx-method.el
index 9d61e60..f2e68b3 100644
--- a/sx-method.el
+++ b/sx-method.el
@@ -142,6 +142,34 @@ Return the entire response as a complex alist."
url-method
(or get-all process-function))))
+(defun sx-method-post-from-data (data &rest keys)
+ "Make a POST `sx-method-call', deriving parameters from DATA.
+KEYS are [KEYWORD VALUE] pairs passed to `sx-method-call', except
+the following which are decided by this function:
+
+ METHOD :site and :id are derived from DATA, where METHOD is
+ either \"answers\", \"comments\", or \"questions\".
+ :url-method is post.
+ :filter is `sx-browse-filter'.
+ :auth is warn.
+
+As a special exception, if KEYS is a single argument, it is
+assumed to be the :submethod argument."
+ (declare (indent 1))
+ (sx-assoc-let data
+ (apply #'sx-method-call
+ (cond (.comment_id "comments")
+ (.answer_id "answers")
+ (.question_id "questions"))
+ :id (or .comment_id .answer_id .question_id)
+ :auth 'warn
+ :url-method 'post
+ :filter sx-browse-filter
+ :site .site_par
+ (if (= 1 (length keys))
+ (cons :submethod keys)
+ keys))))
+
(provide 'sx-method)
;;; sx-method.el ends here