-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathex-request.el
47 lines (29 loc) · 868 Bytes
/
ex-request.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
;;; ex-request.el --- Exercism API request functions
;;; Commentary:
;;; Code:
(require 'url)
(require 'json)
(require 'request)
(require 'ht)
(require 'dash)
(load-file "ex-util.el")
(require 'ex-util)
(defvar user-agent "exercism.el")
(defvar *config* (load-json-config))
(defvar api-host (ht-get *config* "api" "http://exercism.io"))
(defvar x-api-host (ht-get *config* "xapi" "http://x.exercism.io"))
(defvar api-key ht-get *config* "apiKey")
(defun ex-get* (endpoint )
"Get ENDPOINT in a generic fashion."
(request
endpoint
:params '(("key" . api-key))
:parser (lambda ()
(let ((json-object-type 'hash-table))
(json-read)))))
(defun ex-get (endpoint)
(request-response-status-code
(ex-get* (format "%s/v2/exercises" endpoint))))
(ex-get x-api-host)
(provide 'ex-request)
;;; ex-request.el ends here