2fa support
This commit is contained in:
@@ -7,14 +7,11 @@ class VKException(var url: String = "", var description: String = "", var error:
|
||||
IOException(description) {
|
||||
|
||||
var captcha: Pair<String, String>? = null
|
||||
var redirectUri: String? = null
|
||||
|
||||
var validationSid: String? = null
|
||||
|
||||
var json: JSONObject? = null
|
||||
|
||||
override fun toString(): String {
|
||||
return "url: $url;\n\nerror: $error; description: $description;"
|
||||
return "error: $error; description: $description;"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,16 +2,19 @@ package com.meloda.fast.api.network
|
||||
|
||||
object VKUrls {
|
||||
|
||||
const val OAUTH = "https://oauth.vk.com"
|
||||
const val API = "https://api.vk.com/method"
|
||||
|
||||
object Auth {
|
||||
const val directAuth = "https://oauth.vk.com/token"
|
||||
const val directAuth = "$OAUTH/token"
|
||||
const val sendSms = "$API/auth.validatePhone"
|
||||
}
|
||||
|
||||
object Conversations {
|
||||
const val get = "messages.getConversations"
|
||||
const val get = "$API/messages.getConversations"
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,4 +7,6 @@ class AuthDataSource @Inject constructor(
|
||||
private val repo: AuthRepo
|
||||
) : AuthRepo {
|
||||
override suspend fun auth(param: Map<String, String?>) = repo.auth(param)
|
||||
|
||||
override suspend fun sendSms(validationSid: String) = repo.sendSms(validationSid)
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.meloda.fast.api.network.repo
|
||||
import com.meloda.fast.api.network.VKUrls
|
||||
import com.meloda.fast.api.network.response.ResponseAuthDirect
|
||||
import com.meloda.fast.api.network.Answer
|
||||
import com.meloda.fast.api.network.response.ResponseSendSms
|
||||
import retrofit2.http.*
|
||||
|
||||
interface AuthRepo {
|
||||
@@ -10,4 +11,7 @@ interface AuthRepo {
|
||||
@GET(VKUrls.Auth.directAuth)
|
||||
suspend fun auth(@QueryMap param: Map<String, String?>): Answer<ResponseAuthDirect>
|
||||
|
||||
@GET(VKUrls.Auth.sendSms)
|
||||
suspend fun sendSms(@Query("sid") validationSid: String): Answer<ResponseSendSms>
|
||||
|
||||
}
|
||||
@@ -10,4 +10,12 @@ data class ResponseAuthDirect(
|
||||
@SerializedName("user_id") val userId: Int? = null,
|
||||
@SerializedName("trusted_hash") val twoFaHash: String? = null,
|
||||
@SerializedName("validation_sid") val validationSid: String? = null
|
||||
) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
data class ResponseSendSms(
|
||||
@SerializedName("sid") val validationSid: String?,
|
||||
@SerializedName("delay") val delay: Int?,
|
||||
@SerializedName("validation_type") val validationType: String?,
|
||||
@SerializedName("validation_resend") val validationResend: String?
|
||||
) : Parcelable
|
||||
Reference in New Issue
Block a user