@@ -3,6 +3,7 @@ package com.ctrlhub.core.datacapture
3
3
import com.ctrlhub.core.Api
4
4
import com.ctrlhub.core.api.response.PaginatedList
5
5
import com.ctrlhub.core.datacapture.response.FormSchema
6
+ import com.ctrlhub.core.datacapture.response.FormSchemaLatestMeta
6
7
import com.ctrlhub.core.datacapture.response.FormSchemaMeta
7
8
import com.ctrlhub.core.extractPaginationFromMeta
8
9
import com.ctrlhub.core.router.Router
@@ -59,7 +60,7 @@ class FormSchemasRouter(httpClient: HttpClient) : Router(httpClient) {
59
60
val rawContent = json.toString()
60
61
val isoFormatter = DateTimeFormatter .ISO_OFFSET_DATE_TIME
61
62
62
- val formSchemaMeta = json[" meta" ]?.jsonObject?.let {
63
+ val formSchemaMeta = json[" meta" ]?.jsonObject?.let { it ->
63
64
val createdAtStr = it[" created_at" ]?.jsonPrimitive?.content
64
65
val updatedAtStr = it[" updated_at" ]?.jsonPrimitive?.contentOrNull
65
66
@@ -69,7 +70,12 @@ class FormSchemasRouter(httpClient: HttpClient) : Router(httpClient) {
69
70
updatedAt = updatedAtStr?.takeIf { it.isNotEmpty() }?.let {
70
71
ZonedDateTime .parse(it, isoFormatter).toLocalDateTime()
71
72
},
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
+ }
73
79
)
74
80
}
75
81
0 commit comments