[API] Move register platforms to new endpoint.

This commit is contained in:
kuba2k2 2022-10-14 14:43:40 +02:00
parent c7362bce12
commit 9f3aaf6e86
No known key found for this signature in database
GPG Key ID: 7919598F25F38819
5 changed files with 17 additions and 10 deletions

View File

@ -451,9 +451,9 @@ class SzkolnyApi(val app: App) : CoroutineScope {
@Throws(Exception::class) @Throws(Exception::class)
fun getRealms(registerName: String): List<LoginInfo.Platform> { fun getRealms(registerName: String): List<LoginInfo.Platform> {
val response = api.fsLoginRealms(registerName).execute() val response = api.platforms(registerName).execute()
if (response.isSuccessful && response.body() != null) { if (response.isSuccessful && response.body() != null) {
return response.body()!! return parseResponse(response)
} }
throw SzkolnyApiException(null) throw SzkolnyApiException(null)
} }

View File

@ -45,6 +45,6 @@ interface SzkolnyService {
@GET("registerAvailability") @GET("registerAvailability")
fun registerAvailability(): Call<ApiResponse<Map<String, RegisterAvailabilityStatus>>> fun registerAvailability(): Call<ApiResponse<Map<String, RegisterAvailabilityStatus>>>
@GET("https://szkolny-eu.github.io/FSLogin/realms/{registerName}.json") @GET("platforms/{registerName}")
fun fsLoginRealms(@Path("registerName") registerName: String): Call<List<LoginInfo.Platform>> fun platforms(@Path("registerName") registerName: String): Call<ApiResponse<List<LoginInfo.Platform>>>
} }

View File

@ -33,7 +33,6 @@ import pl.szczodrzynski.edziennik.ui.login.LoginInfo.BaseCredential
import pl.szczodrzynski.edziennik.ui.login.LoginInfo.FormCheckbox import pl.szczodrzynski.edziennik.ui.login.LoginInfo.FormCheckbox
import pl.szczodrzynski.edziennik.ui.login.LoginInfo.FormField import pl.szczodrzynski.edziennik.ui.login.LoginInfo.FormField
import pl.szczodrzynski.navlib.colorAttr import pl.szczodrzynski.navlib.colorAttr
import java.util.*
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
class LoginFormFragment : Fragment(), CoroutineScope { class LoginFormFragment : Fragment(), CoroutineScope {
@ -63,8 +62,10 @@ class LoginFormFragment : Fragment(), CoroutineScope {
get() = arguments?.getString("platformDescription") get() = arguments?.getString("platformDescription")
private val platformFormFields private val platformFormFields
get() = arguments?.getString("platformFormFields")?.split(";") get() = arguments?.getString("platformFormFields")?.split(";")
private val platformRealmData private val platformData
get() = arguments?.getString("platformRealmData")?.toJsonObject() get() = arguments?.getString("platformData")?.toJsonObject()
private val platformStoreKey
get() = arguments?.getString("platformStoreKey")
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
@ -250,7 +251,10 @@ class LoginFormFragment : Fragment(), CoroutineScope {
payload.putBoolean("fakeLogin", true) payload.putBoolean("fakeLogin", true)
} }
payload.putBundle("webRealmData", platformRealmData?.toBundle()) if (platformStoreKey == null)
payload.putAll(platformData?.toBundle())
else
payload.putBundle(platformStoreKey, platformData?.toBundle())
var hasErrors = false var hasErrors = false
credentials.forEach { (credential, b) -> credentials.forEach { (credential, b) ->

View File

@ -6,6 +6,7 @@ package pl.szczodrzynski.edziennik.ui.login
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import com.google.gson.JsonObject
import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.IIcon
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import pl.szczodrzynski.edziennik.R import pl.szczodrzynski.edziennik.R
@ -374,7 +375,8 @@ object LoginInfo {
val icon: String, val icon: String,
val screenshot: String?, val screenshot: String?,
val formFields: List<String>, val formFields: List<String>,
val realmData: RealmData val data: JsonObject,
val storeKey: String?,
) )
open class BaseCredential( open class BaseCredential(

View File

@ -68,7 +68,8 @@ class LoginPlatformListFragment : Fragment(), CoroutineScope {
"platformName" to platform.name, "platformName" to platform.name,
"platformDescription" to platform.description, "platformDescription" to platform.description,
"platformFormFields" to platform.formFields.joinToString(";"), "platformFormFields" to platform.formFields.joinToString(";"),
"platformRealmData" to app.gson.toJson(platform.realmData) "platformData" to platform.data,
"platformStoreKey" to platform.storeKey,
), activity.navOptions) ), activity.navOptions)
} }