Replace key with value in response mapping
This commit is contained in:
parent
1a1878acd9
commit
f7c24e7725
2 changed files with 57 additions and 49 deletions
|
@ -815,55 +815,66 @@ internal val ApiEndpointsResponseMapping = mapOf(
|
|||
"24.04.0010.58863" to mapOf(
|
||||
"uonetplus-wiadomosciplus" to mapOf(
|
||||
"__common__" to mapOf(
|
||||
"apiGlobalKey" to "rtvrHBuCAwCEEAtIsBtuHJBtFttEtCIJ",
|
||||
"data" to "GFBGBsJGJFHvErwAswuGruutHHtuHEuG",
|
||||
"hasZalaczniki" to "IDJArEArvBsIErGDrsuEuGssHwsHGEts",
|
||||
"id" to "IDwrCCJDGFrHEuIFsvEvDDJwtBFECCHJ",
|
||||
"korespondenci" to "AurrDtEJwwrEEwJtIJvEHHwICuBBDFGF",
|
||||
"nieprzeczytanePrzeczytanePrzez" to "DBtuuvuGvEBsEAHAJrJECsDGuFrFsuGw",
|
||||
"przeczytana" to "FuBsJwBvHErtEDAwJGuHCuIHJwBrrJFI",
|
||||
"skrzynka" to "AuvBvruBGtGvEJHtIrsGvrIBDGAIFJCB",
|
||||
"temat" to "rtBCHvtsICwDEEFuJwvwJDCJBIAvAGCv",
|
||||
"uzytkownikRola" to "twrCEIrHrsuGEIFIsCGEDJHDwrCICwBG",
|
||||
"wazna" to "AtAsGsuEIAurEGBAJBCGIIFsuwFrwsJt",
|
||||
"wycofana" to "twsrwAIrvGJFEutCrBrDvHCGwGHGCAGv",
|
||||
"rtvrHBuCAwCEEAtIsBtuHJBtFttEtCIJ" to "apiGlobalKey",
|
||||
"GFBGBsJGJFHvErwAswuGruutHHtuHEuG" to "data",
|
||||
"IDJArEArvBsIErGDrsuEuGssHwsHGEts" to "hasZalaczniki",
|
||||
"IDwrCCJDGFrHEuIFsvEvDDJwtBFECCHJ" to "id",
|
||||
"AurrDtEJwwrEEwJtIJvEHHwICuBBDFGF" to "korespondenci",
|
||||
"DBtuuvuGvEBsEAHAJrJECsDGuFrFsuGw" to "nieprzeczytanePrzeczytanePrzez",
|
||||
"FuBsJwBvHErtEDAwJGuHCuIHJwBrrJFI" to "przeczytana",
|
||||
"AuvBvruBGtGvEJHtIrsGvrIBDGAIFJCB" to "skrzynka",
|
||||
"rtBCHvtsICwDEEFuJwvwJDCJBIAvAGCv" to "temat",
|
||||
"twrCEIrHrsuGEIFIsCGEDJHDwrCICwBG" to "uzytkownikRola",
|
||||
"AtAsGsuEIAurEGBAJBCGIIFsuwFrwsJt" to "wazna",
|
||||
"twsrwAIrvGJFEutCrBrDvHCGwGHGCAGv" to "wycofana",
|
||||
),
|
||||
"Skrzynki" to mapOf(
|
||||
"globalKey" to "uwtBBGEJtGHCEEvvsuCJEtCJHCrustHu",
|
||||
"nazwa" to "svttEIFJuuvGECBBrGCGtuuBFJBCAtGE",
|
||||
"typUzytkownika" to "BAICCDrJHtAEEtABrJFuFtvGuICrrCGC",
|
||||
"uwtBBGEJtGHCEEvvsuCJEtCJHCrustHu" to "globalKey",
|
||||
"svttEIFJuuvGECBBrGCGtuuBFJBCAtGE" to "nazwa",
|
||||
"BAICCDrJHtAEEtABrJFuFtvGuICrrCGC" to "typUzytkownika",
|
||||
),
|
||||
"WiadomoscSzczegoly" to mapOf(
|
||||
"apiGlobalKey" to "IvDDwGIurwIrEHDHIBvAvBEBvCsstBCC",
|
||||
"data" to "utFsEtBJsrEuEECBJDuuIEsvFDCsEIuv",
|
||||
"dataWycofania" to "DDAtuGHJBIEFErBArstDrsBAvIsvBHHs",
|
||||
"id" to "vFICGIHIAwvBEwIHrvstBvwvCJJIGwJE",
|
||||
"nadawca" to "DuJuEEvwFwAFEsAErCEtuIBtvwDsJutA",
|
||||
"nadawcaInfo" to "DDAtuGHJBIEFErBArstDrsBAvIsvBHHs",
|
||||
"nadawcaTyp" to "DGswFwrIGwFsEEFFrBDwvsrIsFHHCGst",
|
||||
"odbiorcy" to "srBIECHwtJEuEJFIsBHBGsGIrHuBCJAu",
|
||||
"odczytana" to "wwArFDurBrDFEvrAJGrsIIFADCswFuIE",
|
||||
"temat" to "wuEwstuHDJCGEuEvsBJrEGFvIwvuvCJC",
|
||||
"tresc" to "BEDvtCIEBCGJEDGwswIFIvIuAHFDrAJI",
|
||||
"wycofana" to "HrvHItBsstFrEABGIDtuuGJJIGBECwFu",
|
||||
"zalaczniki" to "GvtvvDBGvsAHEBsDsBJIJGtAtCvFswAI",
|
||||
"IvDDwGIurwIrEHDHIBvAvBEBvCsstBCC" to "apiGlobalKey",
|
||||
"utFsEtBJsrEuEECBJDuuIEsvFDCsEIuv" to "data",
|
||||
"DDAtuGHJBIEFErBArstDrsBAvIsvBHHs" to "dataWycofania",
|
||||
"vFICGIHIAwvBEwIHrvstBvwvCJJIGwJE" to "id",
|
||||
"DuJuEEvwFwAFEsAErCEtuIBtvwDsJutA" to "nadawca",
|
||||
"DDAtuGHJBIEFErBArstDrsBAvIsvBHHs" to "nadawcaInfo",
|
||||
"DGswFwrIGwFsEEFFrBDwvsrIsFHHCGst" to "nadawcaTyp",
|
||||
"srBIECHwtJEuEJFIsBHBGsGIrHuBCJAu" to "odbiorcy",
|
||||
"wwArFDurBrDFEvrAJGrsIIFADCswFuIE" to "odczytana",
|
||||
"wuEwstuHDJCGEuEvsBJrEGFvIwvuvCJC" to "temat",
|
||||
"BEDvtCIEBCGJEDGwswIFIvIuAHFDrAJI" to "tresc",
|
||||
"HrvHItBsstFrEABGIDtuuGJJIGBECwFu" to "wycofana",
|
||||
"GvtvvDBGvsAHEBsDsBJIJGtAtCvFswAI" to "zalaczniki",
|
||||
|
||||
// attachments
|
||||
"CtItswwCCvwuEtEDsCGtAutIuuCABEBB" to "nazwaPliku",
|
||||
"HCIICHrHBsvHECCAsFCEGGBsIFJvuHrt" to "url",
|
||||
),
|
||||
"WiadomoscOdpowiedzPrzekaz" to mapOf(
|
||||
"adresaci" to "AsrstFGtsDuuEsHCJFBDuICHHtCuwEuG",
|
||||
"apiGlobalKey" to "CFHDJEstCsAvErGrJFCvvrvEJuABHFuD",
|
||||
"data" to "BArtutvvEurtEwBuJrvrCAHFIsFrJCJu",
|
||||
"id" to "HtIFwvAFwsJIEAsrJIrJCEvGuIrrCAIG",
|
||||
"nadawcaInfo" to "AswHHvHvJDJsEIrJIHvrvDtCFErwBGtE",
|
||||
"nadawcaSkrzynkaGlobalKey" to "BHuHEFHuDGHGEFIwsrssEIFBAuADsrFE",
|
||||
"nadawcaSkrzynkaNazwa" to "DwGFGAHvJtvDEEGFstwICEwEBEDrAFID",
|
||||
"temat" to "CHCsGwHIAIGJErwGsHJAHGBsArsDvBBG",
|
||||
"tresc" to "FJFFFtAFHJvvErrEssGBGIwDJGrEGwrH",
|
||||
"uzytkownikSkrzynkaGlobalKey" to "AsvwvAGGJsCCECrGJJIAvIrtBtwBttFG",
|
||||
"zalaczniki" to "vvtvEJDDIFEGEuCIstEJsHIutAIDGrGJ",
|
||||
"AsrstFGtsDuuEsHCJFBDuICHHtCuwEuG" to "adresaci",
|
||||
"CFHDJEstCsAvErGrJFCvvrvEJuABHFuD" to "apiGlobalKey",
|
||||
"BArtutvvEurtEwBuJrvrCAHFIsFrJCJu" to "data",
|
||||
"HtIFwvAFwsJIEAsrJIrJCEvGuIrrCAIG" to "id",
|
||||
"AswHHvHvJDJsEIrJIHvrvDtCFErwBGtE" to "nadawcaInfo",
|
||||
"BHuHEFHuDGHGEFIwsrssEIFBAuADsrFE" to "nadawcaSkrzynkaGlobalKey",
|
||||
"DwGFGAHvJtvDEEGFstwICEwEBEDrAFID" to "nadawcaSkrzynkaNazwa",
|
||||
"CHCsGwHIAIGJErwGsHJAHGBsArsDvBBG" to "temat",
|
||||
"FJFFFtAFHJvvErrEssGBGIwDJGrEGwrH" to "tresc",
|
||||
"AsvwvAGGJsCCECrGJJIAvIrtBtwBttFG" to "uzytkownikSkrzynkaGlobalKey",
|
||||
"vvtvEJDDIFEGEuCIstEJsHIutAIDGrGJ" to "zalaczniki",
|
||||
|
||||
// nested
|
||||
"nazwa" to "IAACDtCusJrAEJsuJICCvIDCHrrAvEtw",
|
||||
"skrzynkaGlobalKey" to "BrHECCDIvBCJEvsIJtGJAHwBuAFIHDGG",
|
||||
// recipients
|
||||
"IAACDtCusJrAEJsuJICCvIDCHrrAvEtw" to "nazwa",
|
||||
"BrHECCDIvBCJEvsIJtGJAHwBuAFIHDGG" to "skrzynkaGlobalKey",
|
||||
|
||||
// attachments
|
||||
"vvwssJwwwHHEEuFEJtDEIIrwtrCuGJCH" to "id",
|
||||
"FJFEEvAusIvBEvADIEEJwItwrvDtAsCD" to "idZewnetrzne",
|
||||
"AwHsFrrwGIsAEHGCIsvJCtDICCCJItDF" to "nazwaPliku",
|
||||
"wGBHDwCCFHssEJrFrIuIItFvuFtGtDBB" to "url",
|
||||
"FvDrCwEBtwIvECBsIwIuAItCvBvGCvvB" to "zrodlo",
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -227,13 +227,13 @@ internal class AutoLoginInterceptor(
|
|||
val contentType = response.body?.contentType()
|
||||
val body = mapResponseContent(
|
||||
response = Json.decodeFromString<JsonElement>(it.readText()),
|
||||
jsonMappings = jsonMappings,
|
||||
jsonMappings = jsonMappings.orEmpty(),
|
||||
).toString().toResponseBody(contentType)
|
||||
response.newBuilder().body(body).build()
|
||||
} ?: response
|
||||
}
|
||||
|
||||
private fun mapResponseContent(response: JsonElement, jsonMappings: Map<String, String>?): JsonElement {
|
||||
private fun mapResponseContent(response: JsonElement, jsonMappings: Map<String, String>): JsonElement {
|
||||
return when (response) {
|
||||
is JsonArray -> JsonArray(
|
||||
response.jsonArray.map {
|
||||
|
@ -250,13 +250,10 @@ internal class AutoLoginInterceptor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun mapJsonObjectKeys(jsonObject: JsonObject, jsonMappings: Map<String, String>?): JsonObject {
|
||||
val mapping = jsonMappings?.map { (key, value) ->
|
||||
value to key
|
||||
}.orEmpty().toMap()
|
||||
private fun mapJsonObjectKeys(jsonObject: JsonObject, jsonMappings: Map<String, String>): JsonObject {
|
||||
return JsonObject(
|
||||
jsonObject.map {
|
||||
(mapping[it.key] ?: it.key) to mapResponseContent(it.value, jsonMappings)
|
||||
(jsonMappings[it.key] ?: it.key) to mapResponseContent(it.value, jsonMappings)
|
||||
}.toMap(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue