Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pluto-kotlin-client-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'

buildscript {
ext.versionCode = 12
ext.versionName = '0.6'
ext.versionCode = 13
ext.versionName = '0.6.1'
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import retrofit2.Response
val availableLoginTypes: Array<Pluto.LoginType>
get() = arrayOf(Pluto.LoginType.mail, Pluto.LoginType.mail)

val Pluto.availableBindings: Array<PlutoUserBinding>?
val Pluto.availableBindings: Array<PlutoUser.Binding>?
get() = data.user?.bindings

fun Pluto.bind(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,3 @@ internal class PlutoModel(context: Context) {
infoJSONString = null
}
}

data class PlutoUser(
@field:SerializedName("sub") var id: Int,
@field:SerializedName("user_id") var userId: String,
@field:SerializedName("user_id_updated") var userIdUpdated: Boolean,
@field:SerializedName("avatar") var avatar: String,
@field:SerializedName("name") var name: String,
@field:SerializedName("bindings") var bindings: Array<PlutoUserBinding>
)

data class PlutoUserBinding(
@field:SerializedName("login_type") val loginType: Pluto.LoginType,
@field:SerializedName("mail") var mail: String?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.mushare.plutosdk

import com.google.gson.annotations.SerializedName

data class PlutoUser(
@field:SerializedName("sub") var id: Int,
@field:SerializedName("user_id") var userId: String,
@field:SerializedName("user_id_updated") var userIdUpdated: Boolean,
@field:SerializedName("avatar") var avatar: String,
@field:SerializedName("name") var name: String,
@field:SerializedName("bindings") var bindings: Array<Binding>
) {
data class Binding(
@field:SerializedName("login_type") val loginType: Pluto.LoginType,
@field:SerializedName("mail") var mail: String?
)

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as PlutoUser

if (id != other.id) return false
if (userId != other.userId) return false
if (userIdUpdated != other.userIdUpdated) return false
if (avatar != other.avatar) return false
if (name != other.name) return false
if (!bindings.contentEquals(other.bindings)) return false

return true
}

override fun hashCode(): Int {
var result = id
result = 31 * result + userId.hashCode()
result = 31 * result + userIdUpdated.hashCode()
result = 31 * result + avatar.hashCode()
result = 31 * result + name.hashCode()
result = 31 * result + bindings.contentHashCode()
return result
}

val mail: Binding?
get() = bindings.firstOrNull { it.loginType == Pluto.LoginType.mail }

val google: Binding?
get() = bindings.firstOrNull { it.loginType == Pluto.LoginType.google }
}