diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/ApiEndpoints.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/ApiEndpoints.kt index fa2daaf7..8ff6d3c5 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/ApiEndpoints.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/ApiEndpoints.kt @@ -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", ), ), ), diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/interceptor/AutoLoginInterceptor.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/interceptor/AutoLoginInterceptor.kt index 87d9f3aa..6e3a4be9 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/interceptor/AutoLoginInterceptor.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/interceptor/AutoLoginInterceptor.kt @@ -227,13 +227,13 @@ internal class AutoLoginInterceptor( val contentType = response.body?.contentType() val body = mapResponseContent( response = Json.decodeFromString(it.readText()), - jsonMappings = jsonMappings, + jsonMappings = jsonMappings.orEmpty(), ).toString().toResponseBody(contentType) response.newBuilder().body(body).build() } ?: response } - private fun mapResponseContent(response: JsonElement, jsonMappings: Map?): JsonElement { + private fun mapResponseContent(response: JsonElement, jsonMappings: Map): JsonElement { return when (response) { is JsonArray -> JsonArray( response.jsonArray.map { @@ -250,13 +250,10 @@ internal class AutoLoginInterceptor( } } - private fun mapJsonObjectKeys(jsonObject: JsonObject, jsonMappings: Map?): JsonObject { - val mapping = jsonMappings?.map { (key, value) -> - value to key - }.orEmpty().toMap() + private fun mapJsonObjectKeys(jsonObject: JsonObject, jsonMappings: Map): 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(), ) }