diff options
author | Pedro Silva <psilva+git@pedrosilva.pt> | 2013-04-02 15:42:52 +0100 |
---|---|---|
committer | Pedro Silva <psilva+git@pedrosilva.pt> | 2013-04-02 15:42:52 +0100 |
commit | 52aa0c4027ccb6bd8d801fd08f5767657904f913 (patch) | |
tree | 322100d45deb858aa0cc0647ae4cb45ca52fc850 | |
parent | ac1195e8d3487f8ebda0c43da9a391e12943c56f (diff) |
Change nnrss-post-request api so that PROPERTY is required but can be
nil
Before, not passing the optional PROPERTY would break the keyword
arguments after it
-rw-r--r-- | nnttrss.el | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -57,13 +57,14 @@ ;;; Session management -(defun nnttrss-post-request (address &optional property &rest content) +(defun nnttrss-post-request (address property &rest content) "Post urlencoded form data to ADDRESS. PROPERTY is keyword - potentially in the response. CONTENT must be a data structure - that `json-encode' knows how to encode as a JSON object. + potentially in the response or nil. CONTENT must be a data + structure that `json-encode' knows how to encode as a JSON + object. Returns the JSON response as a plist or, optionally, the PROPERTY -in the plist if the response status is 0, nil otherwise." +in the plist, if the response status is 0, nil otherwise." (let ((url-request-method "POST") (url-request-data (json-encode content)) (json-object-type 'plist) @@ -75,9 +76,7 @@ in the plist if the response status is 0, nil otherwise." (status (plist-get response :status)) (content (plist-get response :content))) (if (= status 0) - (if (plist-member content property) - (plist-get content property) - content) + (or (plist-get content property) content) (nnheader-report 'nnttrss (plist-get content :error))))))) (defun nnttrss-login (address user password) @@ -94,15 +93,15 @@ credentials. Returns a session id string or nil." (nnttrss-post-request address :status :op "logout" - :sid session-id)) + :sid session-id) -(defun nnttrss-logged-in-p (address session-id) - "Return t if there is a valid session at ADDRESS with + (defun nnttrss-logged-in-p (address session-id) + "Return t if there is a valid session at ADDRESS with SESSION-ID, false otherwise." - (nnttrss-post-request address - :status - :op "isLoggedIn" - :sid session-id)) + (nnttrss-post-request address + :status + :op "isLoggedIn" + :sid session-id))) (defun nnttrss-api-level (address session-id) "Return an integer corresponding to the API level at ADDRESS |