Make setters for endpoints mapping public

This commit is contained in:
Mikołaj Pich 2024-05-11 20:54:17 +02:00
parent 2f4bbfdc70
commit f50690a95a
No known key found for this signature in database
6 changed files with 42 additions and 3 deletions

View file

@ -25,6 +25,7 @@ public final class io/github/wulkanowy/sdk/scrapper/Scrapper {
public final fun getDomainSuffix ()Ljava/lang/String;
public final fun getEmail ()Ljava/lang/String;
public final fun getEmptyCookieJarInterceptor ()Z
public final fun getEndpointsMapping ()Ljava/util/Map;
public final fun getExams (Ljava/time/LocalDate;Ljava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun getExams$default (Lio/github/wulkanowy/sdk/scrapper/Scrapper;Ljava/time/LocalDate;Ljava/time/LocalDate;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun getFreeDays (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@ -81,6 +82,7 @@ public final class io/github/wulkanowy/sdk/scrapper/Scrapper {
public final fun getUserAgent ()Ljava/lang/String;
public final fun getUserAgentTemplate ()Ljava/lang/String;
public final fun getUserSubjects (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getVTokenMapping ()Ljava/util/Map;
public final fun isEduOne ()Z
public final fun isSymbolNotExist (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun restoreMessages (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@ -96,6 +98,7 @@ public final class io/github/wulkanowy/sdk/scrapper/Scrapper {
public final fun setEduOne (Z)V
public final fun setEmail (Ljava/lang/String;)V
public final fun setEmptyCookieJarInterceptor (Z)V
public final fun setEndpointsMapping (Ljava/util/Map;)V
public final fun setHost (Ljava/lang/String;)V
public final fun setKindergartenDiaryId (I)V
public final fun setLogLevel (Lokhttp3/logging/HttpLoggingInterceptor$Level;)V
@ -108,6 +111,7 @@ public final class io/github/wulkanowy/sdk/scrapper/Scrapper {
public final fun setSymbol (Ljava/lang/String;)V
public final fun setUnitId (I)V
public final fun setUserAgentTemplate (Ljava/lang/String;)V
public final fun setVTokenMapping (Ljava/util/Map;)V
public final fun unregisterDevice (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

View file

@ -212,6 +212,23 @@ class Scrapper {
}
}
var endpointsMapping: Map<String, Map<String, Map<String, String>>>
get() = endpointsMap
set(value) {
endpointsMap = value
}
var vTokenMapping: Map<String, Map<String, Map<String, String>>>
get() = vTokenMap
set(value) {
vTokenMap = value
}
internal companion object {
var endpointsMap: Map<String, Map<String, Map<String, String>>> = ApiEndpointsMap
var vTokenMap: Map<String, Map<String, Map<String, String>>> = ApiEndpointsVTokenMap
}
private val appInterceptors: MutableList<Pair<Interceptor, Boolean>> = mutableListOf()
fun addInterceptor(interceptor: Interceptor, network: Boolean = false) {

View file

@ -204,7 +204,7 @@ internal fun String.md5(): String {
internal fun HttpUrl.mapModuleUrls(moduleHost: String, appVersion: String?): HttpUrl {
val pathSegmentIndex = getPathIndexByModuleHost(moduleHost)
val pathKey = pathSegments.getOrNull(pathSegmentIndex)
val mappedPath = ApiEndpointsMap[appVersion]
val mappedPath = Scrapper.endpointsMap[appVersion]
?.get(moduleHost)
?.get(pathKey?.substringBefore(".mvc"))
@ -216,7 +216,9 @@ internal fun HttpUrl.mapModuleUrls(moduleHost: String, appVersion: String?): Htt
else -> mappedPath
},
).build()
} else this
} else {
this
}
}
internal fun getPathIndexByModuleHost(moduleHost: String): Int = when (moduleHost) {
@ -228,7 +230,7 @@ internal fun getPathIndexByModuleHost(moduleHost: String): Int = when (moduleHos
internal fun Request.Builder.attachVToken(moduleHost: String, url: HttpUrl, headers: ModuleHeaders?): Request.Builder {
val pathSegmentIndex = getPathIndexByModuleHost(moduleHost)
val pathKey = url.pathSegments.getOrNull(pathSegmentIndex)
val mappedUuid = ApiEndpointsVTokenMap[headers?.appVersion]
val mappedUuid = Scrapper.vTokenMap[headers?.appVersion]
?.get(moduleHost)
?.get(pathKey)
?: return this

View file

@ -24,6 +24,7 @@ public final class io/github/wulkanowy/sdk/Sdk {
public final fun getDomainSuffix ()Ljava/lang/String;
public final fun getEmail ()Ljava/lang/String;
public final fun getEmptyCookieJarInterceptor ()Z
public final fun getEndpointsMapping ()Ljava/util/Map;
public final fun getExams (Ljava/time/LocalDate;Ljava/time/LocalDate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getFreeDays (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getGrades (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
@ -89,6 +90,7 @@ public final class io/github/wulkanowy/sdk/Sdk {
public final fun getUserSubjectsFromScrapper (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getUserSubjectsFromScrapper (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun getUserSubjectsFromScrapper$default (Lio/github/wulkanowy/sdk/Sdk;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun getVTokenMapping ()Ljava/util/Map;
public final fun isEduOne ()Z
public final fun isSymbolNotExist (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun restoreMessages (Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@ -103,6 +105,7 @@ public final class io/github/wulkanowy/sdk/Sdk {
public final fun setEduOne (Z)V
public final fun setEmail (Ljava/lang/String;)V
public final fun setEmptyCookieJarInterceptor (Z)V
public final fun setEndpointsMapping (Ljava/util/Map;)V
public final fun setKeyId (Ljava/lang/String;)V
public final fun setKindergartenDiaryId (I)V
public final fun setLogLevel (Lokhttp3/logging/HttpLoggingInterceptor$Level;)V
@ -119,6 +122,7 @@ public final class io/github/wulkanowy/sdk/Sdk {
public final fun setSymbol (Ljava/lang/String;)V
public final fun setUnitId (I)V
public final fun setUserAgentTemplate (Ljava/lang/String;)V
public final fun setVTokenMapping (Ljava/util/Map;)V
public final fun switchDiary (III)Lio/github/wulkanowy/sdk/Sdk;
public final fun switchDiary (IIII)Lio/github/wulkanowy/sdk/Sdk;
public static synthetic fun switchDiary$default (Lio/github/wulkanowy/sdk/Sdk;IIIIILjava/lang/Object;)Lio/github/wulkanowy/sdk/Sdk;

View file

@ -235,6 +235,18 @@ class Sdk {
scrapper.buildTag = value
}
var endpointsMapping
get() = scrapper.endpointsMapping
set(value) {
scrapper.endpointsMapping = value
}
var vTokenMapping
get() = scrapper.vTokenMapping
set(value) {
scrapper.vTokenMapping = value
}
var emptyCookieJarInterceptor: Boolean = false
set(value) {
field = value