mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[API] Move register platforms to new endpoint.
This commit is contained in:
parent
c7362bce12
commit
9f3aaf6e86
@ -451,9 +451,9 @@ class SzkolnyApi(val app: App) : CoroutineScope {
|
||||
|
||||
@Throws(Exception::class)
|
||||
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) {
|
||||
return response.body()!!
|
||||
return parseResponse(response)
|
||||
}
|
||||
throw SzkolnyApiException(null)
|
||||
}
|
||||
|
@ -45,6 +45,6 @@ interface SzkolnyService {
|
||||
@GET("registerAvailability")
|
||||
fun registerAvailability(): Call<ApiResponse<Map<String, RegisterAvailabilityStatus>>>
|
||||
|
||||
@GET("https://szkolny-eu.github.io/FSLogin/realms/{registerName}.json")
|
||||
fun fsLoginRealms(@Path("registerName") registerName: String): Call<List<LoginInfo.Platform>>
|
||||
@GET("platforms/{registerName}")
|
||||
fun platforms(@Path("registerName") registerName: String): Call<ApiResponse<List<LoginInfo.Platform>>>
|
||||
}
|
||||
|
@ -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.FormField
|
||||
import pl.szczodrzynski.navlib.colorAttr
|
||||
import java.util.*
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
class LoginFormFragment : Fragment(), CoroutineScope {
|
||||
@ -63,8 +62,10 @@ class LoginFormFragment : Fragment(), CoroutineScope {
|
||||
get() = arguments?.getString("platformDescription")
|
||||
private val platformFormFields
|
||||
get() = arguments?.getString("platformFormFields")?.split(";")
|
||||
private val platformRealmData
|
||||
get() = arguments?.getString("platformRealmData")?.toJsonObject()
|
||||
private val platformData
|
||||
get() = arguments?.getString("platformData")?.toJsonObject()
|
||||
private val platformStoreKey
|
||||
get() = arguments?.getString("platformStoreKey")
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
@ -250,7 +251,10 @@ class LoginFormFragment : Fragment(), CoroutineScope {
|
||||
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
|
||||
credentials.forEach { (credential, b) ->
|
||||
|
@ -6,6 +6,7 @@ package pl.szczodrzynski.edziennik.ui.login
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import com.google.gson.JsonObject
|
||||
import com.mikepenz.iconics.typeface.IIcon
|
||||
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||
import pl.szczodrzynski.edziennik.R
|
||||
@ -374,7 +375,8 @@ object LoginInfo {
|
||||
val icon: String,
|
||||
val screenshot: String?,
|
||||
val formFields: List<String>,
|
||||
val realmData: RealmData
|
||||
val data: JsonObject,
|
||||
val storeKey: String?,
|
||||
)
|
||||
|
||||
open class BaseCredential(
|
||||
|
@ -68,7 +68,8 @@ class LoginPlatformListFragment : Fragment(), CoroutineScope {
|
||||
"platformName" to platform.name,
|
||||
"platformDescription" to platform.description,
|
||||
"platformFormFields" to platform.formFields.joinToString(";"),
|
||||
"platformRealmData" to app.gson.toJson(platform.realmData)
|
||||
"platformData" to platform.data,
|
||||
"platformStoreKey" to platform.storeKey,
|
||||
), activity.navOptions)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user