Skip to content

Commit 3e49d5e

Browse files
committed
add Token.from instantiation helper, bump version
1 parent 9ea3f68 commit 3e49d5e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515
}
1616

1717
group = "com.adamratzman"
18-
version = "3.0.0"
18+
version = "3.0.01"
1919

2020
java {
2121
withSourcesJar()

src/commonMain/kotlin/com.adamratzman.spotify/models/Authentication.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ data class Token(
3737
} ?: listOf()
3838

3939
fun shouldRefresh(): Boolean = getCurrentTimeMs() > expiresAt
40+
41+
companion object {
42+
fun from(accessToken: String?, refreshToken: String?, scopes: List<SpotifyScope>, expiresIn: Int = 1) =
43+
Token(accessToken ?: "", "Bearer", expiresIn, refreshToken).apply { this.scopes = scopes }
44+
}
4045
}
4146

4247
data class TokenValidityResponse(val isValid: Boolean, val exception: Exception?)

0 commit comments

Comments
 (0)