mirror of
https://github.com/vale981/ement.el
synced 2025-03-05 09:21:37 -05:00
Change: (ement-api) Add :queue
This commit is contained in:
parent
5c02bc0876
commit
018591e1a2
2 changed files with 11 additions and 6 deletions
15
ement-api.el
15
ement-api.el
|
@ -59,7 +59,7 @@
|
|||
;;;; Functions
|
||||
|
||||
(cl-defun ement-api (session endpoint
|
||||
&key then data params
|
||||
&key then data params queue
|
||||
(content-type "application/json")
|
||||
(data-type 'text)
|
||||
(else #'ement-api-error) (method 'get)
|
||||
|
@ -82,18 +82,23 @@
|
|||
(filename (concat path "?" query))
|
||||
(url (url-recreate-url
|
||||
(url-parse-make-urlobj type nil nil host portspec filename nil data t)))
|
||||
(headers (ement-alist "Content-Type" content-type)))
|
||||
(headers (ement-alist "Content-Type" content-type))
|
||||
(plz-args))
|
||||
(when token
|
||||
;; Almost every request will require a token (only a few, like checking login flows, don't),
|
||||
;; so we simplify the API by using the token automatically when the session has one.
|
||||
(push (cons "Authorization" (concat "Bearer " token)) headers))
|
||||
(setf plz-args (list method url :headers headers :body data :body-type data-type
|
||||
:as json-read-fn :then then :else else
|
||||
:connect-timeout connect-timeout :timeout timeout :noquery t))
|
||||
;; Omit `then' from debugging because if it's a partially applied
|
||||
;; function on the session object, which may be very large, it
|
||||
;; will take a very long time to print into the warnings buffer.
|
||||
;; (ement-debug (current-time) method url headers)
|
||||
(plz method url :headers headers :body data :body-type data-type
|
||||
:as json-read-fn :then then :else else
|
||||
:connect-timeout connect-timeout :timeout timeout :noquery t)))
|
||||
(if queue
|
||||
(plz-run
|
||||
(apply #'plz-queue queue plz-args))
|
||||
(apply #'plz plz-args))))
|
||||
|
||||
(define-error 'ement-api-error "Ement API error" 'error)
|
||||
|
||||
|
|
2
ement.el
2
ement.el
|
@ -6,7 +6,7 @@
|
|||
;; Keywords: comm
|
||||
;; URL: https://github.com/alphapapa/ement.el
|
||||
;; Package-Version: 0.1-pre
|
||||
;; Package-Requires: ((emacs "27.1") (map "2.1") (plz "0.1-pre") (taxy "0.9") (taxy-magit-section "0.9") (svg-lib "0.2.5") (transient "0.3.7"))
|
||||
;; Package-Requires: ((emacs "27.1") (map "2.1") (plz "0.2") (taxy "0.9") (taxy-magit-section "0.9") (svg-lib "0.2.5") (transient "0.3.7"))
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
|
|
Loading…
Add table
Reference in a new issue