/* 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 {
  BaseItemDtoQueryResult,
  ImageType,
  ItemFields,
  ProblemDetails,
} from '../models';
import {
    BaseItemDtoQueryResultFromJSON,
    BaseItemDtoQueryResultToJSON,
    ImageTypeFromJSON,
    ImageTypeToJSON,
    ItemFieldsFromJSON,
    ItemFieldsToJSON,
    ProblemDetailsFromJSON,
    ProblemDetailsToJSON,
} from '../models';

export interface GetEpisodesRequest {
    seriesId: string;
    userId?: string;
    fields?: Array<ItemFields>;
    season?: number;
    seasonId?: string;
    isMissing?: boolean;
    adjacentTo?: string;
    startItemId?: string;
    startIndex?: number;
    limit?: number;
    enableImages?: boolean;
    imageTypeLimit?: number;
    enableImageTypes?: Array<ImageType>;
    enableUserData?: boolean;
    sortBy?: string;
}

export interface GetNextUpRequest {
    userId?: string;
    startIndex?: number;
    limit?: number;
    fields?: Array<ItemFields>;
    seriesId?: string;
    parentId?: string;
    enableImages?: boolean;
    imageTypeLimit?: number;
    enableImageTypes?: Array<ImageType>;
    enableUserData?: boolean;
    nextUpDateCutoff?: Date;
    enableTotalRecordCount?: boolean;
    disableFirstEpisode?: boolean;
    enableRewatching?: boolean;
}

export interface GetSeasonsRequest {
    seriesId: string;
    userId?: string;
    fields?: Array<ItemFields>;
    isSpecialSeason?: boolean;
    isMissing?: boolean;
    adjacentTo?: string;
    enableImages?: boolean;
    imageTypeLimit?: number;
    enableImageTypes?: Array<ImageType>;
    enableUserData?: boolean;
}

export interface GetUpcomingEpisodesRequest {
    userId?: string;
    startIndex?: number;
    limit?: number;
    fields?: Array<ItemFields>;
    parentId?: string;
    enableImages?: boolean;
    imageTypeLimit?: number;
    enableImageTypes?: Array<ImageType>;
    enableUserData?: boolean;
}

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

    /**
     * Gets episodes for a tv season.
     */
    async getEpisodesRaw(requestParameters: GetEpisodesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDtoQueryResult>> {
        if (requestParameters.seriesId === null || requestParameters.seriesId === undefined) {
            throw new runtime.RequiredError('seriesId','Required parameter requestParameters.seriesId was null or undefined when calling getEpisodes.');
        }

        const queryParameters: any = {};

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

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

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

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

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

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

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

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

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

        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.sortBy !== undefined) {
            queryParameters['sortBy'] = requestParameters.sortBy;
        }

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Gets episodes for a tv season.
     */
    async getEpisodes(requestParameters: GetEpisodesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDtoQueryResult> {
        const response = await this.getEpisodesRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets a list of next up episodes.
     */
    async getNextUpRaw(requestParameters: GetNextUpRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDtoQueryResult>> {
        const queryParameters: any = {};

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

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

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

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

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

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

        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.nextUpDateCutoff !== undefined) {
            queryParameters['nextUpDateCutoff'] = (requestParameters.nextUpDateCutoff as any).toISOString();
        }

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

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

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

        const headerParameters: runtime.HTTPHeaders = {};

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

        const response = await this.request({
            path: `/Shows/NextUp`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Gets a list of next up episodes.
     */
    async getNextUp(requestParameters: GetNextUpRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDtoQueryResult> {
        const response = await this.getNextUpRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets seasons for a tv series.
     */
    async getSeasonsRaw(requestParameters: GetSeasonsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDtoQueryResult>> {
        if (requestParameters.seriesId === null || requestParameters.seriesId === undefined) {
            throw new runtime.RequiredError('seriesId','Required parameter requestParameters.seriesId was null or undefined when calling getSeasons.');
        }

        const queryParameters: any = {};

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

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

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

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

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

        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;
        }

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Gets seasons for a tv series.
     */
    async getSeasons(requestParameters: GetSeasonsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDtoQueryResult> {
        const response = await this.getSeasonsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets a list of upcoming episodes.
     */
    async getUpcomingEpisodesRaw(requestParameters: GetUpcomingEpisodesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDtoQueryResult>> {
        const queryParameters: any = {};

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

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

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

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

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

        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;
        }

        const headerParameters: runtime.HTTPHeaders = {};

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

        const response = await this.request({
            path: `/Shows/Upcoming`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Gets a list of upcoming episodes.
     */
    async getUpcomingEpisodes(requestParameters: GetUpcomingEpisodesRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDtoQueryResult> {
        const response = await this.getUpcomingEpisodesRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
