Skip to content

Commit

Permalink
fix: change return from token to authorized meetacy api
Browse files Browse the repository at this point in the history
  • Loading branch information
y9san9 committed Nov 11, 2023
1 parent 9c5681a commit 2982c62
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 0 additions & 2 deletions api/src/commonMain/kotlin/app/meetacy/sdk/MeetacyApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,5 @@ public class MeetacyApi(
return AuthorizedMeetacyApi(token, base = this)
}



public companion object
}
9 changes: 3 additions & 6 deletions api/src/commonMain/kotlin/app/meetacy/sdk/auth/AuthApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ public class AuthApi(private val api: MeetacyApi) {
public val email: AuthEmailApi = AuthEmailApi(api)
public val telegram: AuthTelegramApi = AuthTelegramApi(api)

public suspend fun generate(nickname: String): Token {
return api.engine.execute(GenerateAuthRequest(nickname)).token
}

public suspend fun generateAuthorizedApi(nickname: String): AuthorizedMeetacyApi {
return api.authorized(generate(nickname))
public suspend fun generate(nickname: String): AuthorizedMeetacyApi {
val token = api.engine.execute(GenerateAuthRequest(nickname)).token
return api.authorized(token)
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package app.meetacy.sdk.auth.telegram

import app.meetacy.sdk.AuthorizedMeetacyApi
import app.meetacy.sdk.MeetacyApi
import app.meetacy.sdk.engine.requests.AwaitTelegramAuthRequest
import app.meetacy.sdk.types.auth.Token

public class AuthTelegramApi(private val api: MeetacyApi) {
public suspend fun await(temporalToken: Token): Token {
return api.engine.execute(AwaitTelegramAuthRequest(temporalToken)).permanentToken
public suspend fun await(temporalToken: Token): AuthorizedMeetacyApi {
val token = api.engine.execute(AwaitTelegramAuthRequest(temporalToken)).permanentToken
return api.authorized(token)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@file:OptIn(UnstableApi::class)

package app.meetacy.sdk.engine

import app.meetacy.sdk.engine.requests.MeetacyRequest
import app.meetacy.sdk.types.annotation.UnstableApi
import app.meetacy.sdk.types.file.FileId
import app.meetacy.sdk.types.url.Url

Expand Down

0 comments on commit 2982c62

Please sign in to comment.