Skip to content

Commit

Permalink
Merge pull request #272 from nielsvanvelzen/userid-hook
Browse files Browse the repository at this point in the history
Add userId default value hook
  • Loading branch information
Maxr1998 authored Jun 13, 2021
2 parents f2f46ef + 3eeac38 commit 2b936a9
Show file tree
Hide file tree
Showing 27 changed files with 238 additions and 77 deletions.
40 changes: 38 additions & 2 deletions jellyfin-api/api/jellyfin-api.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlin.String
import kotlin.Unit
import org.jellyfin.sdk.api.client.KtorClient
import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.exception.MissingUserIdException
import org.jellyfin.sdk.model.api.DisplayPreferencesDto

public class DisplayPreferencesApi(
Expand All @@ -25,7 +26,7 @@ public class DisplayPreferencesApi(
*/
public suspend fun getDisplayPreferences(
displayPreferencesId: String,
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
client: String
): Response<DisplayPreferencesDto> {
val pathParameters = mutableMapOf<String, Any?>()
Expand All @@ -48,7 +49,7 @@ public class DisplayPreferencesApi(
*/
public suspend fun updateDisplayPreferences(
displayPreferencesId: String,
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
client: String,
`data`: DisplayPreferencesDto
): Response<Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import kotlin.Unit
import kotlin.collections.List
import org.jellyfin.sdk.api.client.KtorClient
import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.exception.MissingUserIdException
import org.jellyfin.sdk.model.api.ImageFormat
import org.jellyfin.sdk.model.api.ImageInfo
import org.jellyfin.sdk.model.api.ImageType
Expand Down Expand Up @@ -77,7 +78,7 @@ public class ImageApi(
* @param index (Unused) Image index.
*/
public suspend fun deleteUserImage(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
imageType: ImageType,
index: Int? = null
): Response<Unit> {
Expand All @@ -100,7 +101,7 @@ public class ImageApi(
* @param index (Unused) Image index.
*/
public suspend fun deleteUserImageByIndex(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
imageType: ImageType,
index: Int
): Response<Unit> {
Expand Down Expand Up @@ -1934,7 +1935,7 @@ public class ImageApi(
* @param imageIndex Image index.
*/
public suspend fun getUserImage(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
imageType: ImageType,
tag: String? = null,
format: ImageFormat? = null,
Expand Down Expand Up @@ -2009,7 +2010,7 @@ public class ImageApi(
* @param includeCredentials Add the access token to the url to make an authenticated request.
*/
public fun getUserImageUrl(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
imageType: ImageType,
tag: String? = null,
format: ImageFormat? = null,
Expand Down Expand Up @@ -2082,7 +2083,7 @@ public class ImageApi(
* @param foregroundLayer Optional. Apply a foreground layer on top of the image.
*/
public suspend fun getUserImageByIndex(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
imageType: ImageType,
imageIndex: Int,
tag: String? = null,
Expand Down Expand Up @@ -2157,7 +2158,7 @@ public class ImageApi(
* @param includeCredentials Add the access token to the url to make an authenticated request.
*/
public fun getUserImageByIndexUrl(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
imageType: ImageType,
imageIndex: Int,
tag: String? = null,
Expand Down Expand Up @@ -2211,7 +2212,7 @@ public class ImageApi(
* @param index (Unused) Image index.
*/
public suspend fun postUserImage(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
imageType: ImageType,
index: Int? = null
): Response<Unit> {
Expand All @@ -2234,7 +2235,7 @@ public class ImageApi(
* @param index (Unused) Image index.
*/
public suspend fun postUserImageByIndex(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
imageType: ImageType,
index: Int
): Response<Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlin.String
import kotlin.collections.List
import org.jellyfin.sdk.api.client.KtorClient
import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.exception.MissingUserIdException
import org.jellyfin.sdk.model.api.BaseItemDtoQueryResult
import org.jellyfin.sdk.model.api.ImageType
import org.jellyfin.sdk.model.api.ItemFields
Expand Down Expand Up @@ -445,7 +446,7 @@ public class ItemsApi(
* @param enableImages Optional, include image information in output.
*/
public suspend fun getItemsByUserId(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
maxOfficialRating: String? = null,
hasThemeSong: Boolean? = null,
hasThemeVideo: Boolean? = null,
Expand Down Expand Up @@ -639,7 +640,7 @@ public class ItemsApi(
* @param enableImages Optional. Include image information in output.
*/
public suspend fun getResumeItems(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
startIndex: Int? = null,
limit: Int? = null,
searchTerm: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import kotlin.String
import kotlin.Unit
import org.jellyfin.sdk.api.client.KtorClient
import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.exception.MissingUserIdException
import org.jellyfin.sdk.model.api.LiveStreamResponse
import org.jellyfin.sdk.model.api.OpenLiveStreamDto
import org.jellyfin.sdk.model.api.PlaybackInfoDto
Expand Down Expand Up @@ -73,7 +74,8 @@ public class MediaInfoApi(
* @param itemId The item id.
* @param userId The user id.
*/
public suspend fun getPlaybackInfo(itemId: UUID, userId: UUID): Response<PlaybackInfoResponse> {
public suspend fun getPlaybackInfo(itemId: UUID, userId: UUID = api.userId ?: throw
MissingUserIdException()): Response<PlaybackInfoResponse> {
val pathParameters = mutableMapOf<String, Any?>()
pathParameters["itemId"] = itemId
val queryParameters = mutableMapOf<String, Any?>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlin.Unit
import kotlin.collections.List
import org.jellyfin.sdk.api.client.KtorClient
import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.exception.MissingUserIdException
import org.jellyfin.sdk.model.api.AdminNotificationDto
import org.jellyfin.sdk.model.api.NameIdPair
import org.jellyfin.sdk.model.api.NotificationResultDto
Expand Down Expand Up @@ -57,7 +58,8 @@ public class NotificationsApi(
/**
* Gets a user's notifications.
*/
public suspend fun getNotifications(userId: String): Response<NotificationResultDto> {
public suspend fun getNotifications(userId: String = api.userId.toString() ?: throw
MissingUserIdException()): Response<NotificationResultDto> {
val pathParameters = mutableMapOf<String, Any?>()
pathParameters["userId"] = userId
val queryParameters = emptyMap<String, Any?>()
Expand All @@ -70,7 +72,8 @@ public class NotificationsApi(
/**
* Gets a user's notification summary.
*/
public suspend fun getNotificationsSummary(userId: String): Response<NotificationsSummaryDto> {
public suspend fun getNotificationsSummary(userId: String = api.userId.toString() ?: throw
MissingUserIdException()): Response<NotificationsSummaryDto> {
val pathParameters = mutableMapOf<String, Any?>()
pathParameters["userId"] = userId
val queryParameters = emptyMap<String, Any?>()
Expand All @@ -83,7 +86,8 @@ public class NotificationsApi(
/**
* Sets notifications as read.
*/
public suspend fun setRead(userId: String): Response<Unit> {
public suspend fun setRead(userId: String = api.userId.toString() ?: throw
MissingUserIdException()): Response<Unit> {
val pathParameters = mutableMapOf<String, Any?>()
pathParameters["userId"] = userId
val queryParameters = emptyMap<String, Any?>()
Expand All @@ -96,7 +100,8 @@ public class NotificationsApi(
/**
* Sets notifications as unread.
*/
public suspend fun setUnread(userId: String): Response<Unit> {
public suspend fun setUnread(userId: String = api.userId.toString() ?: throw
MissingUserIdException()): Response<Unit> {
val pathParameters = mutableMapOf<String, Any?>()
pathParameters["userId"] = userId
val queryParameters = emptyMap<String, Any?>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlin.String
import kotlin.Unit
import org.jellyfin.sdk.api.client.KtorClient
import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.exception.MissingUserIdException
import org.jellyfin.sdk.model.api.PlayMethod
import org.jellyfin.sdk.model.api.PlaybackProgressInfo
import org.jellyfin.sdk.model.api.PlaybackStartInfo
Expand All @@ -33,7 +34,7 @@ public class PlayStateApi(
* @param datePlayed Optional. The date the item was played.
*/
public suspend fun markPlayedItem(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
itemId: UUID,
datePlayed: LocalDateTime? = null
): Response<UserItemDataDto> {
Expand All @@ -54,7 +55,8 @@ public class PlayStateApi(
* @param userId User id.
* @param itemId Item id.
*/
public suspend fun markUnplayedItem(userId: UUID, itemId: UUID): Response<UserItemDataDto> {
public suspend fun markUnplayedItem(userId: UUID = api.userId ?: throw MissingUserIdException(),
itemId: UUID): Response<UserItemDataDto> {
val pathParameters = mutableMapOf<String, Any?>()
pathParameters["userId"] = userId
pathParameters["itemId"] = itemId
Expand Down Expand Up @@ -83,7 +85,7 @@ public class PlayStateApi(
* @param isMuted Indicates if the player is muted.
*/
public suspend fun onPlaybackProgress(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
itemId: UUID,
mediaSourceId: String? = null,
positionTicks: Long? = null,
Expand Down Expand Up @@ -132,7 +134,7 @@ public class PlayStateApi(
* @param canSeek Indicates if the client can seek.
*/
public suspend fun onPlaybackStart(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
itemId: UUID,
mediaSourceId: String? = null,
audioStreamIndex: Int? = null,
Expand Down Expand Up @@ -172,7 +174,7 @@ public class PlayStateApi(
* @param playSessionId The play session id.
*/
public suspend fun onPlaybackStopped(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
itemId: UUID,
mediaSourceId: String? = null,
nextMediaType: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlin.Unit
import kotlin.collections.List
import org.jellyfin.sdk.api.client.KtorClient
import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.exception.MissingUserIdException
import org.jellyfin.sdk.model.api.BaseItemDtoQueryResult
import org.jellyfin.sdk.model.api.CreatePlaylistDto
import org.jellyfin.sdk.model.api.ImageType
Expand Down Expand Up @@ -106,7 +107,7 @@ public class PlaylistsApi(
*/
public suspend fun getPlaylistItems(
playlistId: UUID,
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
startIndex: Int? = null,
limit: Int? = null,
fields: List<ItemFields>? = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlin.Unit
import kotlin.collections.List
import org.jellyfin.sdk.api.client.KtorClient
import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.exception.MissingUserIdException
import org.jellyfin.sdk.model.api.ClientCapabilitiesDto
import org.jellyfin.sdk.model.api.GeneralCommand
import org.jellyfin.sdk.model.api.GeneralCommandType
Expand All @@ -33,7 +34,8 @@ public class SessionApi(
* @param sessionId The session id.
* @param userId The user id.
*/
public suspend fun addUserToSession(sessionId: String, userId: UUID): Response<Unit> {
public suspend fun addUserToSession(sessionId: String, userId: UUID = api.userId ?: throw
MissingUserIdException()): Response<Unit> {
val pathParameters = mutableMapOf<String, Any?>()
pathParameters["sessionId"] = sessionId
pathParameters["userId"] = userId
Expand Down Expand Up @@ -208,7 +210,8 @@ public class SessionApi(
* @param sessionId The session id.
* @param userId The user id.
*/
public suspend fun removeUserFromSession(sessionId: String, userId: UUID): Response<Unit> {
public suspend fun removeUserFromSession(sessionId: String, userId: UUID = api.userId ?: throw
MissingUserIdException()): Response<Unit> {
val pathParameters = mutableMapOf<String, Any?>()
pathParameters["sessionId"] = sessionId
pathParameters["userId"] = userId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlin.String
import kotlin.collections.List
import org.jellyfin.sdk.api.client.KtorClient
import org.jellyfin.sdk.api.client.Response
import org.jellyfin.sdk.api.client.exception.MissingUserIdException
import org.jellyfin.sdk.model.api.BaseItemDtoQueryResult

public class SuggestionsApi(
Expand All @@ -29,7 +30,7 @@ public class SuggestionsApi(
* @param enableTotalRecordCount Whether to enable the total record count.
*/
public suspend fun getSuggestions(
userId: UUID,
userId: UUID = api.userId ?: throw MissingUserIdException(),
mediaType: List<String>? = emptyList(),
type: List<String>? = emptyList(),
startIndex: Int? = null,
Expand Down
Loading

0 comments on commit 2b936a9

Please sign in to comment.