/* tslint:disable */
/* eslint-disable */
/**
 * Jellyfin API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 10.8.9
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  BaseItemDto,
  BaseItemDtoQueryResult,
  BaseItemKind,
  ImageType,
  ItemFields,
  UserItemDataDto,
} from '../models';
import {
    BaseItemDtoFromJSON,
    BaseItemDtoToJSON,
    BaseItemDtoQueryResultFromJSON,
    BaseItemDtoQueryResultToJSON,
    BaseItemKindFromJSON,
    BaseItemKindToJSON,
    ImageTypeFromJSON,
    ImageTypeToJSON,
    ItemFieldsFromJSON,
    ItemFieldsToJSON,
    UserItemDataDtoFromJSON,
    UserItemDataDtoToJSON,
} from '../models';

export interface DeleteUserItemRatingRequest {
    userId: string;
    itemId: string;
}

export interface GetIntrosRequest {
    userId: string;
    itemId: string;
}

export interface GetItemRequest {
    userId: string;
    itemId: string;
}

export interface GetLatestMediaRequest {
    userId: string;
    parentId?: string;
    fields?: Array<ItemFields>;
    includeItemTypes?: Array<BaseItemKind>;
    isPlayed?: boolean;
    enableImages?: boolean;
    imageTypeLimit?: number;
    enableImageTypes?: Array<ImageType>;
    enableUserData?: boolean;
    limit?: number;
    groupItems?: boolean;
}

export interface GetLocalTrailersRequest {
    userId: string;
    itemId: string;
}

export interface GetRootFolderRequest {
    userId: string;
}

export interface GetSpecialFeaturesRequest {
    userId: string;
    itemId: string;
}

export interface MarkFavoriteItemRequest {
    userId: string;
    itemId: string;
}

export interface UnmarkFavoriteItemRequest {
    userId: string;
    itemId: string;
}

export interface UpdateUserItemRatingRequest {
    userId: string;
    itemId: string;
    likes?: boolean;
}

/**
 * 
 */
export class UserLibraryApi extends runtime.BaseAPI {

    /**
     * Deletes a user\'s saved personal rating for an item.
     */
    async deleteUserItemRatingRaw(requestParameters: DeleteUserItemRatingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserItemDataDto>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling deleteUserItemRating.');
        }

        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling deleteUserItemRating.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/Items/{itemId}/Rating`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => UserItemDataDtoFromJSON(jsonValue));
    }

    /**
     * Deletes a user\'s saved personal rating for an item.
     */
    async deleteUserItemRating(requestParameters: DeleteUserItemRatingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserItemDataDto> {
        const response = await this.deleteUserItemRatingRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets intros to play before the main media item plays.
     */
    async getIntrosRaw(requestParameters: GetIntrosRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDtoQueryResult>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling getIntros.');
        }

        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling getIntros.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/Items/{itemId}/Intros`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => BaseItemDtoQueryResultFromJSON(jsonValue));
    }

    /**
     * Gets intros to play before the main media item plays.
     */
    async getIntros(requestParameters: GetIntrosRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDtoQueryResult> {
        const response = await this.getIntrosRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets an item from a user\'s library.
     */
    async getItemRaw(requestParameters: GetItemRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDto>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling getItem.');
        }

        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling getItem.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/Items/{itemId}`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => BaseItemDtoFromJSON(jsonValue));
    }

    /**
     * Gets an item from a user\'s library.
     */
    async getItem(requestParameters: GetItemRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDto> {
        const response = await this.getItemRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets latest media.
     */
    async getLatestMediaRaw(requestParameters: GetLatestMediaRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<BaseItemDto>>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling getLatestMedia.');
        }

        const queryParameters: any = {};

        if (requestParameters.parentId !== undefined) {
            queryParameters['parentId'] = requestParameters.parentId;
        }

        if (requestParameters.fields) {
            queryParameters['fields'] = requestParameters.fields;
        }

        if (requestParameters.includeItemTypes) {
            queryParameters['includeItemTypes'] = requestParameters.includeItemTypes;
        }

        if (requestParameters.isPlayed !== undefined) {
            queryParameters['isPlayed'] = requestParameters.isPlayed;
        }

        if (requestParameters.enableImages !== undefined) {
            queryParameters['enableImages'] = requestParameters.enableImages;
        }

        if (requestParameters.imageTypeLimit !== undefined) {
            queryParameters['imageTypeLimit'] = requestParameters.imageTypeLimit;
        }

        if (requestParameters.enableImageTypes) {
            queryParameters['enableImageTypes'] = requestParameters.enableImageTypes;
        }

        if (requestParameters.enableUserData !== undefined) {
            queryParameters['enableUserData'] = requestParameters.enableUserData;
        }

        if (requestParameters.limit !== undefined) {
            queryParameters['limit'] = requestParameters.limit;
        }

        if (requestParameters.groupItems !== undefined) {
            queryParameters['groupItems'] = requestParameters.groupItems;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/Items/Latest`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(BaseItemDtoFromJSON));
    }

    /**
     * Gets latest media.
     */
    async getLatestMedia(requestParameters: GetLatestMediaRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<BaseItemDto>> {
        const response = await this.getLatestMediaRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets local trailers for an item.
     */
    async getLocalTrailersRaw(requestParameters: GetLocalTrailersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<BaseItemDto>>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling getLocalTrailers.');
        }

        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling getLocalTrailers.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/Items/{itemId}/LocalTrailers`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(BaseItemDtoFromJSON));
    }

    /**
     * Gets local trailers for an item.
     */
    async getLocalTrailers(requestParameters: GetLocalTrailersRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<BaseItemDto>> {
        const response = await this.getLocalTrailersRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets the root folder from a user\'s library.
     */
    async getRootFolderRaw(requestParameters: GetRootFolderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDto>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling getRootFolder.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/Items/Root`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => BaseItemDtoFromJSON(jsonValue));
    }

    /**
     * Gets the root folder from a user\'s library.
     */
    async getRootFolder(requestParameters: GetRootFolderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDto> {
        const response = await this.getRootFolderRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets special features for an item.
     */
    async getSpecialFeaturesRaw(requestParameters: GetSpecialFeaturesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<BaseItemDto>>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling getSpecialFeatures.');
        }

        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling getSpecialFeatures.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/Items/{itemId}/SpecialFeatures`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(BaseItemDtoFromJSON));
    }

    /**
     * Gets special features for an item.
     */
    async getSpecialFeatures(requestParameters: GetSpecialFeaturesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<BaseItemDto>> {
        const response = await this.getSpecialFeaturesRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Marks an item as a favorite.
     */
    async markFavoriteItemRaw(requestParameters: MarkFavoriteItemRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserItemDataDto>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling markFavoriteItem.');
        }

        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling markFavoriteItem.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/FavoriteItems/{itemId}`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => UserItemDataDtoFromJSON(jsonValue));
    }

    /**
     * Marks an item as a favorite.
     */
    async markFavoriteItem(requestParameters: MarkFavoriteItemRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserItemDataDto> {
        const response = await this.markFavoriteItemRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Unmarks item as a favorite.
     */
    async unmarkFavoriteItemRaw(requestParameters: UnmarkFavoriteItemRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserItemDataDto>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling unmarkFavoriteItem.');
        }

        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling unmarkFavoriteItem.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/FavoriteItems/{itemId}`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => UserItemDataDtoFromJSON(jsonValue));
    }

    /**
     * Unmarks item as a favorite.
     */
    async unmarkFavoriteItem(requestParameters: UnmarkFavoriteItemRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserItemDataDto> {
        const response = await this.unmarkFavoriteItemRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Updates a user\'s rating for an item.
     */
    async updateUserItemRatingRaw(requestParameters: UpdateUserItemRatingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserItemDataDto>> {
        if (requestParameters.userId === null || requestParameters.userId === undefined) {
            throw new runtime.RequiredError('userId','Required parameter requestParameters.userId was null or undefined when calling updateUserItemRating.');
        }

        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling updateUserItemRating.');
        }

        const queryParameters: any = {};

        if (requestParameters.likes !== undefined) {
            queryParameters['likes'] = requestParameters.likes;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.apiKey) {
            headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // CustomAuthentication authentication
        }

        const response = await this.request({
            path: `/Users/{userId}/Items/{itemId}/Rating`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => UserItemDataDtoFromJSON(jsonValue));
    }

    /**
     * Updates a user\'s rating for an item.
     */
    async updateUserItemRating(requestParameters: UpdateUserItemRatingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserItemDataDto> {
        const response = await this.updateUserItemRatingRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
