jellyfin-discord-bot/jellyfin/api/searchApi.ts

254 lines
10 KiB
TypeScript
Raw Normal View History

2023-04-15 22:02:40 +02:00
/**
* 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 localVarRequest from 'request';
import http from 'http';
/* tslint:disable:no-unused-locals */
import { BaseItemKind } from '../model/baseItemKind';
import { SearchHintResult } from '../model/searchHintResult';
import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models';
import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models';
import { HttpError, RequestFile } from './apis';
let defaultBasePath = 'http://localhost';
// ===============================================
// This file is autogenerated - Please do not edit
// ===============================================
export enum SearchApiApiKeys {
CustomAuthentication,
}
export class SearchApi {
protected _basePath = defaultBasePath;
protected _defaultHeaders : any = {};
protected _useQuerystring : boolean = false;
protected authentications = {
'default': <Authentication>new VoidAuth(),
'CustomAuthentication': new ApiKeyAuth('header', 'Authorization'),
}
protected interceptors: Interceptor[] = [];
constructor(basePath?: string);
constructor(basePathOrUsername: string, password?: string, basePath?: string) {
if (password) {
if (basePath) {
this.basePath = basePath;
}
} else {
if (basePathOrUsername) {
this.basePath = basePathOrUsername
}
}
}
set useQuerystring(value: boolean) {
this._useQuerystring = value;
}
set basePath(basePath: string) {
this._basePath = basePath;
}
set defaultHeaders(defaultHeaders: any) {
this._defaultHeaders = defaultHeaders;
}
get defaultHeaders() {
return this._defaultHeaders;
}
get basePath() {
return this._basePath;
}
public setDefaultAuthentication(auth: Authentication) {
this.authentications.default = auth;
}
public setApiKey(key: SearchApiApiKeys, value: string) {
(this.authentications as any)[SearchApiApiKeys[key]].apiKey = value;
}
public addInterceptor(interceptor: Interceptor) {
this.interceptors.push(interceptor);
}
/**
*
* @summary Gets the search hint result.
* @param searchTerm The search term to filter on.
* @param startIndex Optional. The record index to start at. All items with a lower index will be dropped from the results.
* @param limit Optional. The maximum number of records to return.
* @param userId Optional. Supply a user id to search within a user\&#39;s library or omit to search all.
* @param includeItemTypes If specified, only results with the specified item types are returned. This allows multiple, comma delimeted.
* @param excludeItemTypes If specified, results with these item types are filtered out. This allows multiple, comma delimeted.
* @param mediaTypes If specified, only results with the specified media types are returned. This allows multiple, comma delimeted.
* @param parentId If specified, only children of the parent are returned.
* @param isMovie Optional filter for movies.
* @param isSeries Optional filter for series.
* @param isNews Optional filter for news.
* @param isKids Optional filter for kids.
* @param isSports Optional filter for sports.
* @param includePeople Optional filter whether to include people.
* @param includeMedia Optional filter whether to include media.
* @param includeGenres Optional filter whether to include genres.
* @param includeStudios Optional filter whether to include studios.
* @param includeArtists Optional filter whether to include artists.
*/
public async get (searchTerm: string, startIndex?: number, limit?: number, userId?: string, includeItemTypes?: Array<BaseItemKind>, excludeItemTypes?: Array<BaseItemKind>, mediaTypes?: Array<string>, parentId?: string, isMovie?: boolean, isSeries?: boolean, isNews?: boolean, isKids?: boolean, isSports?: boolean, includePeople?: boolean, includeMedia?: boolean, includeGenres?: boolean, includeStudios?: boolean, includeArtists?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: SearchHintResult; }> {
const localVarPath = this.basePath + '/Search/Hints';
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
const produces = ['application/json', 'application/json; profile=CamelCase', 'application/json; profile=PascalCase'];
// give precedence to 'application/json'
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
} else {
localVarHeaderParams.Accept = produces.join(',');
}
let localVarFormParams: any = {};
// verify required parameter 'searchTerm' is not null or undefined
if (searchTerm === null || searchTerm === undefined) {
throw new Error('Required parameter searchTerm was null or undefined when calling get.');
}
if (startIndex !== undefined) {
localVarQueryParameters['startIndex'] = ObjectSerializer.serialize(startIndex, "number");
}
if (limit !== undefined) {
localVarQueryParameters['limit'] = ObjectSerializer.serialize(limit, "number");
}
if (userId !== undefined) {
localVarQueryParameters['userId'] = ObjectSerializer.serialize(userId, "string");
}
if (searchTerm !== undefined) {
localVarQueryParameters['searchTerm'] = ObjectSerializer.serialize(searchTerm, "string");
}
if (includeItemTypes !== undefined) {
localVarQueryParameters['includeItemTypes'] = ObjectSerializer.serialize(includeItemTypes, "Array<BaseItemKind>");
}
if (excludeItemTypes !== undefined) {
localVarQueryParameters['excludeItemTypes'] = ObjectSerializer.serialize(excludeItemTypes, "Array<BaseItemKind>");
}
if (mediaTypes !== undefined) {
localVarQueryParameters['mediaTypes'] = ObjectSerializer.serialize(mediaTypes, "Array<string>");
}
if (parentId !== undefined) {
localVarQueryParameters['parentId'] = ObjectSerializer.serialize(parentId, "string");
}
if (isMovie !== undefined) {
localVarQueryParameters['isMovie'] = ObjectSerializer.serialize(isMovie, "boolean");
}
if (isSeries !== undefined) {
localVarQueryParameters['isSeries'] = ObjectSerializer.serialize(isSeries, "boolean");
}
if (isNews !== undefined) {
localVarQueryParameters['isNews'] = ObjectSerializer.serialize(isNews, "boolean");
}
if (isKids !== undefined) {
localVarQueryParameters['isKids'] = ObjectSerializer.serialize(isKids, "boolean");
}
if (isSports !== undefined) {
localVarQueryParameters['isSports'] = ObjectSerializer.serialize(isSports, "boolean");
}
if (includePeople !== undefined) {
localVarQueryParameters['includePeople'] = ObjectSerializer.serialize(includePeople, "boolean");
}
if (includeMedia !== undefined) {
localVarQueryParameters['includeMedia'] = ObjectSerializer.serialize(includeMedia, "boolean");
}
if (includeGenres !== undefined) {
localVarQueryParameters['includeGenres'] = ObjectSerializer.serialize(includeGenres, "boolean");
}
if (includeStudios !== undefined) {
localVarQueryParameters['includeStudios'] = ObjectSerializer.serialize(includeStudios, "boolean");
}
if (includeArtists !== undefined) {
localVarQueryParameters['includeArtists'] = ObjectSerializer.serialize(includeArtists, "boolean");
}
(<any>Object).assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions: localVarRequest.Options = {
method: 'GET',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};
let authenticationPromise = Promise.resolve();
if (this.authentications.CustomAuthentication.apiKey) {
authenticationPromise = authenticationPromise.then(() => this.authentications.CustomAuthentication.applyToRequest(localVarRequestOptions));
}
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
(<any>localVarRequestOptions).formData = localVarFormParams;
} else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise<{ response: http.IncomingMessage; body: SearchHintResult; }>((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
} else {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
body = ObjectSerializer.deserialize(body, "SearchHintResult");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
}