-
Notifications
You must be signed in to change notification settings - Fork 2
/
rest_services.cljc
64 lines (58 loc) · 2.08 KB
/
rest_services.cljc
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(ns milia.api.rest-services
(:require [milia.api.http :refer [parse-http]]
[milia.utils.remote :refer [make-url]]))
(defn create
"Create a rest service.
`xform-id` is the numeric id of the x-form to associate the service with
`name` is one of 1. `generic_json`
2. `generic_xml`
3. `textit`
4. `f2dhis2`
5. `bamboo`
`service-url` is the URL of the webhook receiving endpoint
`options` is a map for additional configuration, containing the following
keys in the case of textit:
1. `:service` - Service being configured
2. `:auth_token` - Authentication token
3. `:flow_uuid` - UUID of the flow in textit
4. `:contacts` - The contact in the flow"
[xform-id name service-url & [options]]
(parse-http :post
(make-url "restservices")
:http-options
{:form-params
(merge
{:xform xform-id
:name name
:service_url service-url}
options)}))
(defn update-restservice
"Updates a rest service."
[id xform-id name service-url & [options]]
(parse-http :put
(make-url "restservices" id)
:http-options
{:form-params
(merge
{:xform xform-id
:name name
:service_url service-url}
options)}))
(defn delete
"Delete a rest service"
[id]
(parse-http :delete (make-url "restservices" id)))
(defn get-all
"Get all rest services the requesting user has access to"
[]
(parse-http :get (make-url "restservices")))
(defn get-by-id
"Get information for a specific rest service"
[id & {:keys [no-cache?]}]
(parse-http :get (make-url "restservices" id)
:no-cache? no-cache?))
(defn get-by-form-id
"Get rest services for a form"
[formid & {:keys [no-cache?]}]
(parse-http :get (make-url (str "restservices?xform="formid))
:no-cache? no-cache?))