Skip to content

Commit e691984

Browse files
committed
modify release date/precision to be nullable - change in spotify api
Signed-off-by: Adam Ratzman <[email protected]>
1 parent d11a9ff commit e691984

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public data class SimpleAlbum(
4545
val name: String,
4646
val type: String,
4747
val restrictions: Restrictions? = null,
48-
@SerialName("release_date") private val releaseDateString: String,
49-
@SerialName("release_date_precision") val releaseDatePrecisionString: String,
48+
@SerialName("release_date") private val releaseDateString: String? = null,
49+
@SerialName("release_date_precision") val releaseDatePrecisionString: String? = null,
5050
@SerialName("total_tracks") val totalTracks: Int? = null,
5151
@SerialName("album_group") private val albumGroupString: String? = null
5252
) : CoreObject() {
@@ -57,7 +57,7 @@ public data class SimpleAlbum(
5757
AlbumResultType.values().first { it.id.equals(albumTypeString, true) }
5858
}
5959

60-
val releaseDate: ReleaseDate get() = getReleaseDate(releaseDateString)
60+
val releaseDate: ReleaseDate? get() = releaseDateString?.let { getReleaseDate(releaseDateString) }
6161

6262
val albumGroup: AlbumResultType?
6363
get() = albumGroupString?.let { _ ->
@@ -78,7 +78,8 @@ public data class SimpleAlbum(
7878
*
7979
* @param market Provide this parameter if you want the list of returned items to be relevant to a particular country.
8080
*/
81-
public fun toFullAlbumRestAction(market: Market? = null): SpotifyRestAction<Album?> = SpotifyRestAction { toFullAlbum(market) }
81+
public fun toFullAlbumRestAction(market: Market? = null): SpotifyRestAction<Album?> =
82+
SpotifyRestAction { toFullAlbum(market) }
8283

8384
override fun getMembersThatNeedApiInstantiation(): List<NeedsApi?> = artists + this
8485
}
@@ -176,9 +177,9 @@ public data class SpotifyCopyright(
176177
) {
177178
val text: String
178179
get() = textString
179-
.removePrefix("(P)")
180-
.removePrefix("(C)")
181-
.trim()
180+
.removePrefix("(P)")
181+
.removePrefix("(C)")
182+
.trim()
182183

183184
val type: CopyrightType get() = CopyrightType.values().match(typeString)!!
184185
}

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ public data class Episode(
103103
private val language: String? = null,
104104
@SerialName("languages") private val showLanguagesPrivate: List<String>,
105105
val name: String,
106-
@SerialName("release_date") private val releaseDateString: String,
107-
@SerialName("release_date_precision") val releaseDatePrecisionString: String,
106+
@SerialName("release_date") private val releaseDateString: String? = null,
107+
@SerialName("release_date_precision") val releaseDatePrecisionString: String? = null,
108108
@SerialName("resume_point") val resumePoint: ResumePoint? = null,
109109
val show: SimpleShow,
110110
val type: String,
111111
override val uri: EpisodeUri
112112
) : CoreObject() {
113-
val releaseDate: ReleaseDate get() = getReleaseDate(releaseDateString)
113+
val releaseDate: ReleaseDate? get() = releaseDateString?.let { getReleaseDate(releaseDateString) }
114114

115115
@Suppress("DEPRECATION")
116116
val languages: List<Locale>
@@ -155,13 +155,13 @@ public data class SimpleEpisode(
155155
private val language: String? = null,
156156
@SerialName("languages") private val showLanguagesPrivate: List<String>,
157157
val name: String,
158-
@SerialName("release_date") private val releaseDateString: String,
159-
@SerialName("release_date_precision") val releaseDatePrecisionString: String,
158+
@SerialName("release_date") private val releaseDateString: String? = null,
159+
@SerialName("release_date_precision") val releaseDatePrecisionString: String? = null,
160160
@SerialName("resume_point") val resumePoint: ResumePoint? = null,
161161
val type: String,
162162
override val uri: SpotifyUri
163163
) : CoreObject() {
164-
val releaseDate: ReleaseDate get() = getReleaseDate(releaseDateString)
164+
val releaseDate: ReleaseDate? get() = releaseDateString?.let { getReleaseDate(releaseDateString) }
165165

166166
@Suppress("DEPRECATION")
167167
val languages: List<Locale>
@@ -180,7 +180,8 @@ public data class SimpleEpisode(
180180
*
181181
* @param market Provide this parameter if you want the list of returned items to be relevant to a particular country.
182182
*/
183-
public fun toFullEpisodeRestAction(market: Market): SpotifyRestAction<Episode?> = SpotifyRestAction { toFullEpisode(market) }
183+
public fun toFullEpisodeRestAction(market: Market): SpotifyRestAction<Episode?> =
184+
SpotifyRestAction { toFullEpisode(market) }
184185

185186
override fun getMembersThatNeedApiInstantiation(): List<NeedsApi?> = listOf(this)
186187
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,4 @@ public data class PlaylistTrackInfo(
154154
)
155155

156156
@Serializable
157-
public data class VideoThumbnail(val url: String?)
157+
public data class VideoThumbnail(val url: String? = null)

0 commit comments

Comments
 (0)