emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/rt-liberation 0e6c7ca 34/72: Implement ticket history v


From: Stefan Monnier
Subject: [elpa] externals/rt-liberation 0e6c7ca 34/72: Implement ticket history via REST.
Date: Wed, 5 Aug 2020 11:57:38 -0400 (EDT)

branch: externals/rt-liberation
commit 0e6c7ca0c5f3baa7c4e3ffb7019ee4e9a7203200
Author: Yoni Rabkin <yrk@gnu.org>
Commit: Yoni Rabkin <yrk@gnu.org>

    Implement ticket history via REST.
    
    Also, replace the cli version in the code with the rest version.
---
 rt-liberation-rest.el | 28 ++++++++++++++++++++++++++++
 rt-liberation.el      |  2 +-
 2 files changed, 29 insertions(+), 1 deletion(-)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]