@@ -3,6 +3,7 @@ package com.ctrlhub.core.datacapture
33import com.ctrlhub.core.Api
44import com.ctrlhub.core.api.response.PaginatedList
55import com.ctrlhub.core.datacapture.response.FormSchema
6+ import com.ctrlhub.core.datacapture.response.FormSchemaLatestMeta
67import com.ctrlhub.core.datacapture.response.FormSchemaMeta
78import com.ctrlhub.core.extractPaginationFromMeta
89import com.ctrlhub.core.router.Router
@@ -59,7 +60,7 @@ class FormSchemasRouter(httpClient: HttpClient) : Router(httpClient) {
5960 val rawContent = json.toString()
6061 val isoFormatter = DateTimeFormatter .ISO_OFFSET_DATE_TIME
6162
62- val formSchemaMeta = json[" meta" ]?.jsonObject?.let {
63+ val formSchemaMeta = json[" meta" ]?.jsonObject?.let { it ->
6364 val createdAtStr = it[" created_at" ]?.jsonPrimitive?.content
6465 val updatedAtStr = it[" updated_at" ]?.jsonPrimitive?.contentOrNull
6566
@@ -69,7 +70,12 @@ class FormSchemasRouter(httpClient: HttpClient) : Router(httpClient) {
6970 updatedAt = updatedAtStr?.takeIf { it.isNotEmpty() }?.let {
7071 ZonedDateTime .parse(it, isoFormatter).toLocalDateTime()
7172 },
72- latest = it[" latest" ]?.jsonPrimitive?.content.orEmpty()
73+ latest = it[" latest" ]?.let { latestJson ->
74+ FormSchemaLatestMeta (
75+ id = latestJson.jsonObject[" id" ]?.jsonPrimitive?.content ? : " " ,
76+ version = latestJson.jsonObject[" version" ]?.jsonPrimitive?.content ? : " " ,
77+ )
78+ }
7379 )
7480 }
7581
0 commit comments