/* 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,
  ChannelFeatures,
  ItemFields,
  ItemFilter,
  SortOrder,
} from '../models';
import {
    BaseItemDtoQueryResultFromJSON,
    BaseItemDtoQueryResultToJSON,
    ChannelFeaturesFromJSON,
    ChannelFeaturesToJSON,
    ItemFieldsFromJSON,
    ItemFieldsToJSON,
    ItemFilterFromJSON,
    ItemFilterToJSON,
    SortOrderFromJSON,
    SortOrderToJSON,
} from '../models';

export interface GetChannelFeaturesRequest {
    channelId: string;
}

export interface GetChannelItemsRequest {
    channelId: string;
    folderId?: string;
    userId?: string;
    startIndex?: number;
    limit?: number;
    sortOrder?: Array<SortOrder>;
    filters?: Array<ItemFilter>;
    sortBy?: Array<string>;
    fields?: Array<ItemFields>;
}

export interface GetChannelsRequest {
    userId?: string;
    startIndex?: number;
    limit?: number;
    supportsLatestItems?: boolean;
    supportsMediaDeletion?: boolean;
    isFavorite?: boolean;
}

export interface GetLatestChannelItemsRequest {
    userId?: string;
    startIndex?: number;
    limit?: number;
    filters?: Array<ItemFilter>;
    fields?: Array<ItemFields>;
    channelIds?: Array<string>;
}

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

    /**
     * Get all channel features.
     */
    async getAllChannelFeaturesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ChannelFeatures>>> {
        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: `/Channels/Features`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Get all channel features.
     */
    async getAllChannelFeatures(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ChannelFeatures>> {
        const response = await this.getAllChannelFeaturesRaw(initOverrides);
        return await response.value();
    }

    /**
     * Get channel features.
     */
    async getChannelFeaturesRaw(requestParameters: GetChannelFeaturesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ChannelFeatures>> {
        if (requestParameters.channelId === null || requestParameters.channelId === undefined) {
            throw new runtime.RequiredError('channelId','Required parameter requestParameters.channelId was null or undefined when calling getChannelFeatures.');
        }

        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: `/Channels/{channelId}/Features`.replace(`{${"channelId"}}`, encodeURIComponent(String(requestParameters.channelId))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Get channel features.
     */
    async getChannelFeatures(requestParameters: GetChannelFeaturesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ChannelFeatures> {
        const response = await this.getChannelFeaturesRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Get channel items.
     */
    async getChannelItemsRaw(requestParameters: GetChannelItemsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDtoQueryResult>> {
        if (requestParameters.channelId === null || requestParameters.channelId === undefined) {
            throw new runtime.RequiredError('channelId','Required parameter requestParameters.channelId was null or undefined when calling getChannelItems.');
        }

        const queryParameters: any = {};

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

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

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

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

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Get channel items.
     */
    async getChannelItems(requestParameters: GetChannelItemsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDtoQueryResult> {
        const response = await this.getChannelItemsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets available channels.
     */
    async getChannelsRaw(requestParameters: GetChannelsRequest, 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.supportsLatestItems !== undefined) {
            queryParameters['supportsLatestItems'] = requestParameters.supportsLatestItems;
        }

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

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Gets available channels.
     */
    async getChannels(requestParameters: GetChannelsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDtoQueryResult> {
        const response = await this.getChannelsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets latest channel items.
     */
    async getLatestChannelItemsRaw(requestParameters: GetLatestChannelItemsRequest, 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.filters) {
            queryParameters['filters'] = requestParameters.filters;
        }

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

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Gets latest channel items.
     */
    async getLatestChannelItems(requestParameters: GetLatestChannelItemsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDtoQueryResult> {
        const response = await this.getLatestChannelItemsRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
