@@ -17,7 +17,7 @@ class FormSchemasRouter(httpClient: HttpClient) : Router(httpClient) {
17
17
formId : String ,
18
18
requestParameters : RequestParameters = RequestParameters ()
19
19
): PaginatedList <FormSchema > {
20
- val endpoint = " /v3/orgs/$organisationId /data-capture/forms/{ $formId } /schemas"
20
+ val endpoint = " /v3/orgs/$organisationId /data-capture/forms/$formId /schemas"
21
21
22
22
val response = performGet(endpoint, requestParameters.toMap())
23
23
val jsonContent = Json .parseToJsonElement(response.body<String >()).jsonObject
@@ -42,28 +42,21 @@ class FormSchemasRouter(httpClient: HttpClient) : Router(httpClient) {
42
42
val endpoint = " /v3/orgs/$organisationId /data-capture/forms/$formId /schemas/$schemaId "
43
43
44
44
val response = performGet(endpoint, requestParameters.toMap())
45
- val jsonContent = Json .parseToJsonElement(response.body<String >()).jsonObject
46
-
47
- val dataObject = jsonContent[" data" ]?.jsonObject
48
- ? : throw IllegalStateException (" Missing data object" )
45
+ val jsonContent = Json .parseToJsonElement(response.body<String >()).jsonObjectOrNull()
46
+ ? : throw IllegalStateException (" Missing JSON content" )
49
47
50
- return instantiateFormSchemaFromJson(dataObject )
48
+ return instantiateFormSchemaFromJson(jsonContent )
51
49
}
52
50
53
51
private fun instantiateFormSchemaFromJson (json : JsonObject ): FormSchema {
54
52
val id = json[" id" ]?.jsonPrimitive?.content
55
53
? : throw IllegalStateException (" Missing id" )
56
54
57
- val attributes = json[" attributes" ]?.jsonObject ? : JsonObject (emptyMap())
58
- val model = attributes[" model" ]?.jsonObjectOrNull()
59
- val views = attributes[" views" ]?.jsonObjectOrNull()
55
+ val rawContent = json.toString()
60
56
61
57
return FormSchema (
62
58
id = id,
63
- modelConfig = model,
64
- viewsConfig = views,
65
- modelConfigStr = model?.toString() ? : " " ,
66
- viewsConfigStr = views?.toString() ? : " "
59
+ rawSchema = rawContent
67
60
)
68
61
}
69
62
0 commit comments