Make firebaseToken non-required and default-nullable

This commit is contained in:
Mikołaj Pich 2023-04-16 21:57:10 +02:00
parent 8dfcd24753
commit c55d0bf251
5 changed files with 12 additions and 5 deletions

View file

@ -10,6 +10,7 @@ public final class io/github/wulkanowy/sdk/hebe/Hebe {
public final fun getSchoolSymbol ()Ljava/lang/String;
public final fun getStudents (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun register (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun register$default (Lio/github/wulkanowy/sdk/hebe/Hebe;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun setBaseUrl (Ljava/lang/String;)V
public final fun setDeviceModel (Ljava/lang/String;)V
public final fun setKeyId (Ljava/lang/String;)V

View file

@ -68,7 +68,7 @@ class Hebe {
private val routes by resettableLazy(resettableManager) { serviceManager.getRoutesRepository() }
suspend fun register(firebaseToken: String, token: String, pin: String, symbol: String): RegisterDevice {
suspend fun register(token: String, pin: String, symbol: String, firebaseToken: String? = null): RegisterDevice {
val (publicPem, privatePem, publicHash) = generateKeyPair()
this.keyId = publicHash

View file

@ -10,18 +10,18 @@ import io.github.wulkanowy.sdk.hebe.service.RegisterService
internal class RegisterRepository(private val service: RegisterService) {
suspend fun register(
firebaseToken: String,
token: String,
pin: String,
deviceModel: String,
certificatePem: String,
certificateId: String,
firebaseToken: String?,
): RegisterResponse {
val response = registerDevice(
privateKey = certificatePem,
certificateId = certificateId,
deviceModel = deviceModel,
firebaseToken = firebaseToken,
firebaseToken = firebaseToken.orEmpty(),
pin = pin,
token = token,
)

View file

@ -70,6 +70,7 @@ public final class io/github/wulkanowy/sdk/Sdk {
public final fun getStudentPhoto (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getStudentThreats (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getStudentsFromHebe (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun getStudentsFromHebe$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 getStudentsHybrid (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun getStudentsHybrid$default (Lio/github/wulkanowy/sdk/Sdk;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun getStudentsTrips (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;

View file

@ -268,7 +268,12 @@ class Sdk {
}
}
suspend fun getStudentsFromHebe(token: String, pin: String, symbol: String, firebaseToken: String): RegisterUser {
suspend fun getStudentsFromHebe(
token: String,
pin: String,
symbol: String,
firebaseToken: String? = null,
): RegisterUser {
val registerDevice = hebe.register(
firebaseToken = firebaseToken,
token = token,
@ -284,8 +289,8 @@ class Sdk {
email: String,
password: String,
scrapperBaseUrl: String,
firebaseToken: String,
startSymbol: String = "Default",
firebaseToken: String? = null,
): RegisterUser = withContext(Dispatchers.IO) {
val scrapperUser = getUserSubjectsFromScrapper(email, password, scrapperBaseUrl, startSymbol)
scrapperUser.copy(