diff options
author | Yoni Rabkin <yrk@gnu.org> | 2015-03-06 13:35:56 -0500 |
---|---|---|
committer | Yoni Rabkin <yrk@gnu.org> | 2015-03-06 13:35:56 -0500 |
commit | 0e6c7ca0c5f3baa7c4e3ffb7019ee4e9a7203200 (patch) | |
tree | 924f1e27c27331b74fb96d6dc4b82830e3740a69 | |
parent | 1aa3ed01bbdabce77885f0c22226b36c574ae052 (diff) |
Implement ticket history via REST.
Also, replace the cli version in the code with the rest version.
-rw-r--r-- | rt-liberation-rest.el | 28 | ||||
-rw-r--r-- | rt-liberation.el | 2 |
2 files changed, 29 insertions, 1 deletions
diff --git a/rt-liberation-rest.el b/rt-liberation-rest.el index aa06caf..85cabf4 100644 --- a/rt-liberation-rest.el +++ b/rt-liberation-rest.el @@ -91,6 +91,19 @@ "user=" user "&" "pass=" pass "&"))) +(defun rt-liber-rest-history-string (scheme url ticket-id username password) + "Return the ticket show string." + (let ((user (url-encode-url username)) + (pass (url-encode-url password))) + (concat scheme + "://" + url + "/REST/1.0/ticket/" ticket-id + "/history" "?" + "format=l" "&" + "user=" user "&" + "pass=" pass))) + (defun rt-liber-rest-call (url) "Perform a REST call with URL." (let ((url-request-method "POST")) @@ -126,6 +139,13 @@ rt-liber-rest-username rt-liber-rest-password query-string))) + ((string= op "history") + (rt-liber-rest-call + (rt-liber-rest-history-string rt-liber-rest-scheme + rt-liber-rest-url + query-string + rt-liber-rest-username + rt-liber-rest-password))) (t (error "unknown op [%s]" op)))) (defun rt-liber-rest-parse-http-header () @@ -196,6 +216,14 @@ (rt-liber-rest-show-query-runner idsublist) #'rt-liber-ticket-base-retriever-parser-f)) +(defun rt-liber-rest-run-ticket-history-base-query (ticket-id) + "Run history query against server for TICKET-ID." + (rt-liber-parse-answer + (rt-liber-rest-query-runner "history" ticket-id) + #'(lambda () + (rt-liber-rest-parse-http-header) + (buffer-substring (point) (point-max))))) + (provide 'rt-liberation-rest) diff --git a/rt-liberation.el b/rt-liberation.el index c7a3a33..1997adc 100644 --- a/rt-liberation.el +++ b/rt-liberation.el @@ -625,7 +625,7 @@ AFTER date after predicate." TICKET-ALIST alist of ticket data. ASSOC-BROWSER if non-nil should be a ticket browser." (let* ((ticket-id (rt-liber-ticket-id-only ticket-alist)) - (contents (rt-liber-run-ticket-history-base-query ticket-id)) + (contents (rt-liber-rest-run-ticket-history-base-query ticket-id)) (new-ticket-buffer (get-buffer-create (concat "*RT Ticket #" ticket-id "*")))) (with-current-buffer new-ticket-buffer |