File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
src/main/kotlin/com/ctrlhub/core/datacapture Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.ctrlhub.core.datacapture
2
+
3
+ import com.ctrlhub.core.api.response.PaginatedList
4
+ import com.ctrlhub.core.datacapture.response.FormSchema
5
+ import com.ctrlhub.core.router.Router
6
+ import com.ctrlhub.core.router.request.RequestParameters
7
+ import io.ktor.client.HttpClient
8
+
9
+ /* *
10
+ * A router that interacts with the form schemas realm of the Ctrl Hub API
11
+ */
12
+ class FormSchemasRouter (httpClient : HttpClient ): Router(httpClient) {
13
+
14
+ /* *
15
+ * Get all form schemas for a given form and organisation
16
+ *
17
+ * @param organisationId String The organisation ID to retrieve all for schemas for
18
+ * @param formId String The form ID to retrieve all schemas for
19
+ *
20
+ * @return A paginated response of all form schemas
21
+ */
22
+ suspend fun all (organisationId : String , formId : String , requestParameters : RequestParameters = RequestParameters ()): PaginatedList <FormSchema > {
23
+ val endpoint = " /v3/orgs/${organisationId} /data-capture/forms/{$formId }/schemas"
24
+
25
+ return fetchPaginatedJsonApiResources(endpoint, requestParameters.toMap(), FormSchema ::class .java)
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ package com.ctrlhub.core.datacapture.response
2
+
3
+ import com.fasterxml.jackson.annotation.JsonCreator
4
+ import com.fasterxml.jackson.annotation.JsonProperty
5
+ import com.fasterxml.jackson.databind.JsonNode
6
+ import com.github.jasminb.jsonapi.annotations.Type
7
+
8
+ @Type(" " )
9
+ data class FormSchema @JsonCreator constructor(
10
+ val id : String ,
11
+
12
+ @JsonProperty(" model" )
13
+ private val modelNode : JsonNode ,
14
+
15
+ @JsonProperty(" views" )
16
+ private val viewsNode : JsonNode ?
17
+ ) {
18
+ val model: String = modelNode.toString()
19
+ val views: String? = viewsNode?.toString()
20
+ }
You can’t perform that action at this time.
0 commit comments