Update get libraries API call to support updated response payload

This commit is contained in:
advplyr
2022-12-02 17:39:45 -06:00
parent 32dfb3b40a
commit a0faf3f7d4
3 changed files with 18 additions and 11 deletions
@@ -138,12 +138,16 @@ class ApiHandler(var ctx:Context) {
val mapper = jacksonMapper
getRequest("/api/libraries", null,null) {
val libraries = mutableListOf<Library>()
if (it.has("value")) {
val array = it.getJSONArray("value")
for (i in 0 until array.length()) {
val library = mapper.readValue<Library>(array.get(i).toString())
libraries.add(library)
}
var array = JSONArray()
if (it.has("libraries")) { // TODO: Server 2.2.9 changed to this
array = it.getJSONArray("libraries")
} else if (it.has("value")) {
array = it.getJSONArray("value")
}
for (i in 0 until array.length()) {
libraries.add(mapper.readValue(array.get(i).toString()))
}
cb(libraries)
}