/
open_data.cljc
44 lines (40 loc) · 1.31 KB
/
open_data.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
(ns milia.api.open-data
(:refer-clojure :exclude [update])
(:require [milia.api.http :refer [parse-http]]
[milia.utils.remote :refer [make-url]]))
(defn create
"Create an open-data object.
`object-id` is the numeric id of the object which can be an xform or a
dataview.
`name` is the name of the open-data object. It's advisable to use either
the id_string or title for an xform or title for a dataview.
`data-type` is class name in onadata and should either be
'xform' or 'dataview'."
[object-id name data-type]
(parse-http :post
(make-url "open-data")
:http-options
{:form-params
{:object_id object-id
:name name
:data_type data-type}}))
(defn update
"Updates an open-data object."
[object-id data-type uuid]
(parse-http :patch
(make-url "open-data" uuid)
:http-options
{:form-params
{:object_id object-id
:data_type data-type}}))
(defn delete
"Delete an open-data object"
[uuid]
(parse-http :delete (make-url "open-data" uuid)))
(defn get-open-data-uuid
"Get uuid of an open-data object."
[object-id data-type]
(parse-http
:get
(make-url
(str "open-data/uuid?object_id=" object-id "&data_type=" data-type))))