aboutsummaryrefslogtreecommitdiff
path: root/stack-core.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-11-06 13:49:10 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-11-06 13:49:10 +0000
commit448502d813735d88986ef505c23e65a31ed3ff42 (patch)
treed05ef42a6ff32360ac07e2413b985b6d5e7fc14d /stack-core.el
parent299a0ac21a7bc65383a1cd9a000c9d4cc8750d2d (diff)
parent9fe6cf49f0a01aa27014d565765538f90219e103 (diff)
Merge branch 'master' into question-list-live-data
Diffstat (limited to 'stack-core.el')
-rw-r--r--stack-core.el24
1 files changed, 20 insertions, 4 deletions
diff --git a/stack-core.el b/stack-core.el
index c78c316..496533e 100644
--- a/stack-core.el
+++ b/stack-core.el
@@ -57,6 +57,16 @@
(format "http://api.stackexchange.com/%s/" stack-core-api-version)
"The base URL to make requests from.")
+(defvar stack-core-api-batch-request-separator
+ ";"
+ "The separator character to use when making batch requests.
+
+Do not change this unless you know what you are doing!")
+
+(defconst stack-core-api-key
+ "0TE6s1tveCpP9K5r5JNDNQ(("
+ "When passed, this key provides a higher request quota.")
+
(defcustom stack-core-default-keyword-arguments-alist
'(("filters/create")
("sites")
@@ -110,7 +120,10 @@ a string, just return it."
(cond
((stringp thing) thing)
((symbolp thing) (symbol-name thing))
- ((numberp thing) (number-to-string thing))))
+ ((numberp thing) (number-to-string thing))
+ ((sequencep thing)
+ (mapconcat #'stack-core-thing-as-string
+ thing stack-core-api-batch-request-separator))))
(defun stack-core-get-default-keyword-arguments (method)
"Gets the correct keyword arguments for METHOD."
@@ -164,8 +177,9 @@ entire response as a complex alist."
(call
(stack-core-build-request
method
- (cons `(filter . ,(cond (filter filter)
- ((boundp 'stack-filter) stack-filter)))
+ (append `((filter . ,(cond (filter filter)
+ ((boundp 'stack-filter) stack-filter)))
+ (key . ,stack-core-api-key))
(if keyword-arguments keyword-arguments
(stack-core-get-default-keyword-arguments method))))))
;; TODO: url-retrieve-synchronously can return nil if the call is
@@ -267,7 +281,9 @@ context of `stack-cache-directory'."
"Set the content of CACHE to DATA.
As with `stack-cache-get', CACHE is a file name within the
-context of `stack-cache-directory'."
+context of `stack-cache-directory'.
+
+DATA will be written as returned by `prin1'."
(unless (file-exists-p stack-cache-directory)
(mkdir stack-cache-directory))
(write-region (prin1-to-string data) nil