diff options
author | Sean Allred <code@seanallred.com> | 2014-11-29 09:36:59 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2014-11-29 09:36:59 -0500 |
commit | f5ca9c6d7629817569c3bd58e5569fee88cd5f2b (patch) | |
tree | bcbbdcb2e2fdc91f9431d3b3ad605aa0a7fa0bde /sx-request.el | |
parent | a8e882d99a037075595260dc74fad0fb67c69d81 (diff) | |
parent | 00a187f5bb7dc08117965eae05df51d0eedac90e (diff) |
Merge branch 'master' into issue-100
Conflicts:
sx-question-mode.el
Diffstat (limited to 'sx-request.el')
-rw-r--r-- | sx-request.el | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/sx-request.el b/sx-request.el index 6b09988..6be363d 100644 --- a/sx-request.el +++ b/sx-request.el @@ -71,7 +71,7 @@ "gunzip" "Program used to unzip the response if it is compressed. This program must accept compressed data on standard input." - :group 'sx-request + :group 'sx :type 'string) (defvar sx-request-remaining-api-requests @@ -85,15 +85,14 @@ Set by `sx-request-make'.") After `sx-request-remaining-api-requests' drops below this number, `sx-request-make' will begin printing out the number of requests left every time it finishes a call." - :group 'sx-request + :group 'sx :type 'integer) ;;; Making Requests -(defun sx-request-make - (method &optional args request-method) - "Make a request to the API, executing METHOD with ARGS. +(defun sx-request-make (method &optional args request-method) + "Make a request to the API, executing METHOD with ARGS. You should almost certainly be using `sx-method-call' instead of this function. REQUEST-METHOD is one of `GET' (default) or `POST'. @@ -116,8 +115,7 @@ then read with `json-read-from-string'. the main content of the response is returned." (let* ((url-automatic-caching t) (url-inhibit-uncompression t) - (url-request-data (sx-request--build-keyword-arguments args - nil)) + (url-request-data (sx-request--build-keyword-arguments args nil)) (request-url (concat sx-request-api-root method)) (url-request-method request-method) (url-request-extra-headers @@ -168,15 +166,11 @@ Currently returns nil." ;;; Support Functions - -(defun sx-request--build-keyword-arguments (alist &optional - kv-sep need-auth) +(defun sx-request--build-keyword-arguments (alist &optional kv-sep) "Format ALIST as a key-value list joined with KV-SEP. If authentication is needed, include it also or error if it is not available. -If NEED-AUTH is non-nil, authentication is required. - Build a \"key=value&key=value&...\"-style string with the elements of ALIST. If any value in the alist is nil, that pair will not be included in the return. If you wish to pass a notion of @@ -185,7 +179,7 @@ false, use the symbol `false'. Each element is processed with ;; Add API key to list of arguments, this allows for increased quota ;; automatically. (let ((api-key (cons "key" sx-request-api-key)) - (auth (car (sx-cache-get 'auth)))) + (auth (car (sx-cache-get 'auth)))) (push api-key alist) (when auth (push auth alist)) |