mirror of
https://github.com/Phundrak/appwrite.el.git
synced 2025-05-09 10:24:56 +00:00
Add compatibility for Emacs 27 and earlier
This commit is contained in:
parent
e91c6a80aa
commit
2f712b8a4d
16
appwrite.el
16
appwrite.el
@ -66,6 +66,15 @@ the internet, even if it’s a private repository.")
|
|||||||
|
|
||||||
;;; Internal functions
|
;;; Internal functions
|
||||||
|
|
||||||
|
(defun appwrite--plistp (object)
|
||||||
|
"Non-nil if and only if OBJECT is a valid plist.
|
||||||
|
Compatibility function for Emacs 27 and earlier, the code source
|
||||||
|
in the else branch is the definition of `plistp' in Emacs 29."
|
||||||
|
(if (boundp #'plistp)
|
||||||
|
(plistp object)
|
||||||
|
(let ((len (proper-list-p object)))
|
||||||
|
(and len (zerop (% len 2))))))
|
||||||
|
|
||||||
(defun appwrite--get-full-url (api)
|
(defun appwrite--get-full-url (api)
|
||||||
"Get the full url for API.
|
"Get the full url for API.
|
||||||
If API does not begin with an initial forward slash, add it
|
If API does not begin with an initial forward slash, add it
|
||||||
@ -115,8 +124,8 @@ CONTENT-TYPE is whichever miime-type is being used.
|
|||||||
|
|
||||||
If CONTENT-TYPE is \"application/json\", PAYLOAD is subject ot
|
If CONTENT-TYPE is \"application/json\", PAYLOAD is subject ot
|
||||||
automatic conversion depending on its type.
|
automatic conversion depending on its type.
|
||||||
- If PAYLOAD passes `plistp', it will be converted to JSON as a
|
- If PAYLOAD passes `appwrite--plistp', it will be converted to
|
||||||
plist.
|
JSON as a plist.
|
||||||
- If PAYLOAD passes `hash-table-p', it will be converted to JSON
|
- If PAYLOAD passes `hash-table-p', it will be converted to JSON
|
||||||
as a hash table.
|
as a hash table.
|
||||||
- If PAYLOAD-ALIST-P is t, PAYLOAD will be converted to JSON as an
|
- If PAYLOAD-ALIST-P is t, PAYLOAD will be converted to JSON as an
|
||||||
@ -137,7 +146,8 @@ Content-Type in the headers is \"application/json\"."
|
|||||||
("Content-type" . ,content-type)))
|
("Content-type" . ,content-type)))
|
||||||
(url-request-data (cond ((not (string= content-type "application/json"))
|
(url-request-data (cond ((not (string= content-type "application/json"))
|
||||||
payload)
|
payload)
|
||||||
((plistp payload) (json-encode-plist payload))
|
((appwrite--plistp payload)
|
||||||
|
(json-encode-plist payload))
|
||||||
((hash-table-p payload) (json-encode payload))
|
((hash-table-p payload) (json-encode payload))
|
||||||
(payload-alist-p (json-encode-alist payload))
|
(payload-alist-p (json-encode-alist payload))
|
||||||
(t payload))))
|
(t payload))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user