-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBL-1170: Get token and User, Log in flow completed. (#1954)
- Loading branch information
Showing
17 changed files
with
474 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/kickstarter/services/apirequests/PKCEBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.kickstarter.services.apirequests | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
@Parcelize | ||
class PKCEBody private constructor( | ||
private val code: String, | ||
private val code_verifier: String, | ||
private val client_id: String | ||
) : Parcelable { | ||
|
||
fun code() = this.code | ||
fun codeVerifier() = this.code_verifier | ||
|
||
@Parcelize | ||
data class Builder( | ||
private var code: String = "", | ||
private var codeVerifier: String = "", | ||
private var clientId: String = "" | ||
) : Parcelable { | ||
fun codeVerifier(codeVerifier: String) = apply { this.codeVerifier = codeVerifier } | ||
fun code(code: String) = apply { this.code = code } | ||
|
||
fun clientId(clientId: String) = apply { this.clientId = clientId } | ||
fun build() = PKCEBody( | ||
code_verifier = codeVerifier, | ||
code = code, | ||
client_id = clientId | ||
) | ||
} | ||
|
||
fun toBuilder() = Builder( | ||
codeVerifier = code_verifier, | ||
code = code, | ||
clientId = client_id | ||
) | ||
|
||
override fun equals(obj: Any?): Boolean { | ||
var equals = super.equals(obj) | ||
if (obj is PKCEBody) { | ||
equals = code_verifier == obj.code_verifier && | ||
code == obj.code && | ||
client_id == obj.client_id | ||
} | ||
return equals | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = code.hashCode() | ||
result = 31 * result + code_verifier.hashCode() | ||
result = 31 * result + client_id.hashCode() | ||
return result | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
fun builder() = Builder() | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/com/kickstarter/services/apirequests/UserTokenBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.kickstarter.services.apirequests | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
class UserTokenBody private constructor( | ||
private val oauth_token: String? | ||
) : Parcelable { | ||
fun token() = this.oauth_token | ||
|
||
@Parcelize | ||
data class Builder( | ||
private var pushServer: String? = null, | ||
private var token: String? = null | ||
) : Parcelable { | ||
fun token(token: String?) = apply { this.token = token } | ||
fun build() = UserTokenBody( | ||
oauth_token = token | ||
) | ||
} | ||
|
||
fun toBuilder() = Builder( | ||
token = oauth_token | ||
) | ||
|
||
companion object { | ||
@JvmStatic | ||
fun builder() = Builder() | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
var equals = super.equals(other) | ||
if (other is UserTokenBody) { | ||
equals = | ||
token() == other.token() | ||
} | ||
return equals | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return oauth_token?.hashCode() ?: 0 | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/kickstarter/services/apiresponses/OAuthTokenEnvelope.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.kickstarter.services.apiresponses | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
class OAuthTokenEnvelope private constructor( | ||
private val token: String, | ||
) : Parcelable { | ||
fun accessToken() = this.token | ||
|
||
@Parcelize | ||
data class Builder( | ||
private var token: String = "", | ||
) : Parcelable { | ||
fun accessToken(accessToken: String) = apply { this.token = accessToken } | ||
fun build() = OAuthTokenEnvelope( | ||
token = token | ||
) | ||
} | ||
|
||
override fun equals(obj: Any?): Boolean { | ||
var equals = super.equals(obj) | ||
if (obj is OAuthTokenEnvelope) { | ||
equals = accessToken() == obj.accessToken() | ||
} | ||
return equals | ||
} | ||
|
||
fun toBuilder() = Builder( | ||
token = token | ||
) | ||
|
||
override fun hashCode(): Int { | ||
return token.hashCode() | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
fun builder() = Builder() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.