Skip to content

Commit 01f8805

Browse files
committed
Merge branch 'dev'
2 parents e53fdf4 + 5ba21fc commit 01f8805

File tree

19 files changed

+78
-21
lines changed

19 files changed

+78
-21
lines changed

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
# Kotlin Spotify Web API
2+
A [Kotlin](https://kotlinlang.org/) implementation of the [Spotify Web API](https://developer.spotify.com/web-api/),
3+
supporting Kotlin/JS, Kotlin/Android, Kotlin/JVM, and Kotlin/Native
4+
(macOS, Windows, Linux).
5+
26
[![JCenter](https://maven-badges.herokuapp.com/maven-central/com.adamratzman/spotify-api-kotlin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.adamratzman/spotify-api-kotlin)
3-
[![Build Status](http://144.217.240.243:8111/app/rest/builds/aggregated/strob:(buildType:(project:(id:SpotifyWebApiKotlin)))/statusIcon.svg)](http://144.217.240.243:8111/project.html?projectId=SpotifyWebApiKotlin)
4-
[![](https://img.shields.io/badge/Documentation-latest-orange.svg)](https://adamint.github.io/spotify-web-api-kotlin/spotify-web-api-kotlin/)
7+
[![](https://img.shields.io/badge/Documentation-latest-orange.svg)](https://adamint.github.io/spotify-web-api-kotlin-docs/spotify-web-api-kotlin/)
58
![](https://img.shields.io/badge/License-MIT-blue.svg)
69

7-
This is the [Kotlin](https://kotlinlang.org/) implementation of the [Spotify Web API](https://developer.spotify.com/web-api/). JS/Browser and Node, Android, and JVM targets are currently supported, with Kotlin/Native (Windows, macOS, Linux) support coming soon in the next minor version, 3.5.
810

9-
You can ask questions, get guidance, or get help contributing by joining our [Discord server](https://discord.gg/G6vqP3S).
11+
![Android Tests](https://img.shields.io/teamcity/build/s/SpotifyWebApiKotlin_AndroidTests?label=Kotlin%2FAndroid%20Tests&server=https%3A%2F%2Fadam.beta.teamcity.com)
12+
![JS tests Status](https://img.shields.io/teamcity/build/s/SpotifyWebApiKotlin_JsTests?label=Kotlin%2FJS%20Tests&server=https%3A%2F%2Fadam.beta.teamcity.com)
13+
![JVM tests](https://img.shields.io/teamcity/build/s/SpotifyWebApiKotlin_JvmTests?label=Kotlin%2FJVM%20Tests&server=https%3A%2F%2Fadam.beta.teamcity.com)
14+
![Linux Tests](https://img.shields.io/teamcity/build/s/SpotifyWebApiKotlin_LinuxTests?label=Kotlin%2FLinux%20Tests&server=https%3A%2F%2Fadam.beta.teamcity.com)
15+
![macOS Tests](https://img.shields.io/teamcity/build/s/SpotifyWebApiKotlin_RunTestsMac?label=Kotlin%2FmacOS%20Tests&server=https%3A%2F%2Fadam.beta.teamcity.com)
1016

1117
## Table of Contents
1218
* [Library installing](#library-installing)
13-
+ [JVM, Android, JS](#jvm-android-js)
19+
+ [JVM, Android, JS, Native](#jvm-android-js)
1420
+ [Android information](#android)
1521
* [Documentation](#documentation)
1622
* [Need help, have a question, or want to contribute?](#have-a-question)
@@ -26,20 +32,23 @@ You can ask questions, get guidance, or get help contributing by joining our [Di
2632
* [Tips](#tips)
2733
+ [Building the API](#building-the-api)
2834
* [Notes](#notes)
29-
+ [The benefits of LinkedResults, PagingObjects, and Cursor-based Paging Objects](#the-benefits-of-linkedresults-pagingobjects-and-cursor-based-paging-objects)
35+
+ [LinkedResults, PagingObjects, and Cursor-based Paging Objects](#the-benefits-of-linkedresults-pagingobjects-and-cursor-based-paging-objects)
3036
+ [Generic Requests](#generic-request)
3137
+ [Track Relinking](#track-relinking)
3238
* [Contributing](#contributing)
3339

3440
## Library installing
41+
Current version:
42+
43+
[![JCenter](https://maven-badges.herokuapp.com/maven-central/com.adamratzman/spotify-api-kotlin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.adamratzman/spotify-api-kotlin)
3544

36-
### JVM, Android, JS
45+
### JVM, Android, JS, Native (macOS, Windows, Linux)
3746
```
3847
repositories {
3948
jcenter()
4049
}
4150
42-
implementation("com.adamratzman:spotify-api-kotlin-core:3.4.03")
51+
implementation("com.adamratzman:spotify-api-kotlin-core:VERSION")
4352
```
4453

4554
### Android
@@ -74,7 +83,7 @@ The `spotify-web-api-kotlin` JavaDocs are hosted [here](https://adamint.github.i
7483
## Have a question?
7584
If you have a question, you can:
7685

77-
1. Create an [issue](https://github.com/adamint/spotify-web-api-kotlin/issues) or a discussion.
86+
1. Create an [issue](https://github.com/adamint/spotify-web-api-kotlin/issues)
7887
2. Join our [Discord server](https://discord.gg/G6vqP3S)
7988
3. Contact me using **Adam#9261** on [Discord](https://discordapp.com)
8089

@@ -140,7 +149,7 @@ The `SpotifyClientApi` is a superset of `SpotifyApi`; thus, nothing changes if y
140149
access public data.
141150
This library does not provide a method to retrieve the code from your callback url; instead,
142151
you must implement that with a web server.
143-
Automatic refresh is available *only* when building with an authorization code or a
152+
Automatic Token refresh is available *only* when building with an authorization code or a
144153
`Token` object. Otherwise, it will expire `Token.expiresIn` seconds after creation.
145154

146155
Make sure your application has requested the proper [Scopes](https://developer.spotify.com/web-api/using-spotifyScopes/) in order to
@@ -373,7 +382,7 @@ runBlocking {
373382
```
374383

375384
## Notes
376-
### The benefits of LinkedResults, PagingObjects, and Cursor-based Paging Objects
385+
### LinkedResults, PagingObjects, and Cursor-based Paging Objects
377386
Spotify provides these three object models in order to simplify our lives as developers. So let's see what we
378387
can do with them!
379388

build.gradle.kts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ buildscript {
3232
}
3333

3434
group = "com.adamratzman"
35-
version = "3.5.0-rc.1"
35+
version = System.getenv("SPOTIFY_API_PUBLISH_VERSION") ?: "0.0.0.SNAPSHOT"
36+
37+
System.getenv("signing.keyId")?.let { project.ext["signing.keyId"] = it }
38+
System.getenv("signing.password")?.let { project.ext["signing.password"] = it }
39+
System.getenv("signing.secretKeyRingFile")?.let { project.ext["signing.secretKeyRingFile"] = it }
40+
3641

3742
tasks.withType<Test> {
3843
this.testLogging {
@@ -195,8 +200,8 @@ kotlin {
195200
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
196201

197202
credentials {
198-
val nexusUsername: String? by project.extra
199-
val nexusPassword: String? by project.extra
203+
val nexusUsername: String? = System.getenv("nexus.username")
204+
val nexusPassword: String? = System.getenv("nexus.password")
200205
username = nexusUsername
201206
password = nexusPassword
202207
}
@@ -327,7 +332,6 @@ kotlin {
327332
}
328333
}
329334

330-
331335
signing {
332336
if (project.hasProperty("signing.keyId")
333337
&& project.hasProperty("signing.password")
@@ -376,6 +380,7 @@ tasks {
376380

377381

378382
fun MavenPublication.setupPom(publicationName: String) {
383+
artifactId = artifactId.replace("-web", "")
379384
artifact(dokkaJar.get())
380385

381386
pom {
@@ -390,8 +395,8 @@ fun MavenPublication.setupPom(publicationName: String) {
390395
}
391396
licenses {
392397
license {
393-
name.set("The Apache Software License, Version 2.0")
394-
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
398+
name.set("MIT License")
399+
url.set("https://github.com/adamint/spotify-web-api-kotlin/blob/master/LICENSE")
395400
distribution.set("repo")
396401
}
397402
}

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ pluginManagement {
2828
}
2929
}
3030

31-
rootProject.name = "spotify-api-kotlin"
31+
rootProject.name = "spotify-web-api-kotlin"
3232

src/androidMain/kotlin/com/adamratzman/spotify/Pkce.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import android.os.Build.VERSION_CODES
66
import android.util.Base64
77
import java.security.MessageDigest
88

9+
/**
10+
* A utility to get the pkce code challenge for a corresponding code verifier. Only available on JVM/Android
11+
*/
912
public actual fun getSpotifyPkceCodeChallenge(codeVerifier: String): String {
1013
val sha256 = MessageDigest.getInstance("SHA-256").digest(codeVerifier.toByteArray())
1114
return if (VERSION.SDK_INT >= VERSION_CODES.O) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4+
/**
5+
* Represents a unit of time
6+
*/
47
public actual typealias TimeUnit = java.util.concurrent.TimeUnit
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4+
/**
5+
* The current time in milliseconds since UNIX epoch.
6+
*/
47
public actual fun getCurrentTimeMs(): Long = System.currentTimeMillis()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4+
/**
5+
* Actual platform that this program is run on.
6+
*/
47
public actual val platform: Platform = Platform.ANDROID

src/commonMain/kotlin/com.adamratzman.spotify/http/HttpConnection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public class HttpConnection constructor(
159159
)
160160
throw AuthenticationException(error)
161161
} catch (ignored: ParseException) {
162-
throw e
162+
throw BadRequestException(e)
163163
}
164164
}
165165
}

src/commonMain/kotlin/com.adamratzman.spotify/utils/Concurrency.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4+
/**
5+
* Represents a unit of time
6+
*/
47
public expect enum class TimeUnit {
58
MILLISECONDS, SECONDS;
69

src/commonMain/kotlin/com.adamratzman.spotify/utils/Utils.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import kotlinx.datetime.TimeZone
88
import kotlinx.datetime.toLocalDateTime
99
import kotlinx.serialization.json.JsonElement
1010

11+
/**
12+
* The current time in milliseconds since UNIX epoch.
13+
*/
1114
public expect fun getCurrentTimeMs(): Long
1215

1316
internal fun jsonMap(vararg pairs: Pair<String, JsonElement>) = pairs.toMap().toMutableMap()

src/desktopMain/kotlin/com/adamratzman/spotify/utils/Concurrency.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4-
@Suppress("unused")
4+
/**
5+
* Represents a unit of time
6+
*/
57
public actual enum class TimeUnit(public val multiplier: Int) {
68
MILLISECONDS(1), SECONDS(1000), MINUTES(60000);
79

src/desktopMain/kotlin/com/adamratzman/spotify/utils/Misc.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package com.adamratzman.spotify.utils
33

44
import kotlin.system.getTimeMillis
55

6+
/**
7+
* The current time in milliseconds since UNIX epoch.
8+
*/
69
public actual fun getCurrentTimeMs(): Long {
710
return getTimeMillis()
811
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4+
/**
5+
* Actual platform that this program is run on.
6+
*/
47
public actual val platform: Platform = Platform.NATIVE

src/jsMain/kotlin/com/adamratzman/spotify/utils/Concurrency.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4-
@Suppress("unused")
4+
/**
5+
* Represents a unit of time
6+
*/
57
public actual enum class TimeUnit(public val multiplier: Int) {
68
MILLISECONDS(1), SECONDS(1000), MINUTES(60000);
79

src/jsMain/kotlin/com/adamratzman/spotify/utils/Misc.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package com.adamratzman.spotify.utils
33

44
import kotlin.js.Date
55

6+
/**
7+
* The current time in milliseconds since UNIX epoch.
8+
*/
69
public actual fun getCurrentTimeMs(): Long {
710
return Date().getTime().toLong()
811
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4+
/**
5+
* Actual platform that this program is run on.
6+
*/
47
public actual val platform: Platform = Platform.JS

src/jvmMain/kotlin/com/adamratzman/spotify/Pkce.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ package com.adamratzman.spotify
44
import java.security.MessageDigest
55
import java.util.Base64
66

7+
/**
8+
* A utility to get the pkce code challenge for a corresponding code verifier. Only available on JVM/Android
9+
*/
710
public actual fun getSpotifyPkceCodeChallenge(codeVerifier: String): String {
811
val sha256 = MessageDigest.getInstance("SHA-256").digest(codeVerifier.toByteArray())
912
return Base64.getUrlEncoder()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4+
/**
5+
* Represents a unit of time
6+
*/
47
public actual typealias TimeUnit = java.util.concurrent.TimeUnit
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2021; Original author: Adam Ratzman */
22
package com.adamratzman.spotify.utils
33

4+
/**
5+
* The current time in milliseconds since UNIX epoch.
6+
*/
47
public actual fun getCurrentTimeMs(): Long = System.currentTimeMillis()

0 commit comments

Comments
 (0)