522 lines
23 KiB
TypeScript
522 lines
23 KiB
TypeScript
/**
|
|
* 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 { BaseItemDtoQueryResult } from '../model/baseItemDtoQueryResult';
|
|
import { CreatePlaylistRequest } from '../model/createPlaylistRequest';
|
|
import { ImageType } from '../model/imageType';
|
|
import { ItemFields } from '../model/itemFields';
|
|
import { PlaylistCreationResult } from '../model/playlistCreationResult';
|
|
|
|
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 PlaylistsApiApiKeys {
|
|
CustomAuthentication,
|
|
}
|
|
|
|
export class PlaylistsApi {
|
|
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: PlaylistsApiApiKeys, value: string) {
|
|
(this.authentications as any)[PlaylistsApiApiKeys[key]].apiKey = value;
|
|
}
|
|
|
|
public addInterceptor(interceptor: Interceptor) {
|
|
this.interceptors.push(interceptor);
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @summary Adds items to a playlist.
|
|
* @param playlistId The playlist id.
|
|
* @param ids Item id, comma delimited.
|
|
* @param userId The userId.
|
|
*/
|
|
public async addToPlaylist (playlistId: string, ids?: Array<string>, userId?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
|
|
const localVarPath = this.basePath + '/Playlists/{playlistId}/Items'
|
|
.replace('{' + 'playlistId' + '}', encodeURIComponent(String(playlistId)));
|
|
let localVarQueryParameters: any = {};
|
|
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
|
|
let localVarFormParams: any = {};
|
|
|
|
// verify required parameter 'playlistId' is not null or undefined
|
|
if (playlistId === null || playlistId === undefined) {
|
|
throw new Error('Required parameter playlistId was null or undefined when calling addToPlaylist.');
|
|
}
|
|
|
|
if (ids !== undefined) {
|
|
localVarQueryParameters['ids'] = ObjectSerializer.serialize(ids, "Array<string>");
|
|
}
|
|
|
|
if (userId !== undefined) {
|
|
localVarQueryParameters['userId'] = ObjectSerializer.serialize(userId, "string");
|
|
}
|
|
|
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|
|
|
let localVarUseFormData = false;
|
|
|
|
let localVarRequestOptions: localVarRequest.Options = {
|
|
method: 'POST',
|
|
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?: any; }>((resolve, reject) => {
|
|
localVarRequest(localVarRequestOptions, (error, response, body) => {
|
|
if (error) {
|
|
reject(error);
|
|
} else {
|
|
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
|
|
resolve({ response: response, body: body });
|
|
} else {
|
|
reject(new HttpError(response, body, response.statusCode));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
/**
|
|
* For backwards compatibility parameters can be sent via Query or Body, with Query having higher precedence. Query parameters are obsolete.
|
|
* @summary Creates a new playlist.
|
|
* @param name The playlist name.
|
|
* @param ids The item ids.
|
|
* @param userId The user id.
|
|
* @param mediaType The media type.
|
|
* @param createPlaylistRequest The create playlist payload.
|
|
*/
|
|
public async createPlaylist (name?: string, ids?: Array<string>, userId?: string, mediaType?: string, createPlaylistRequest?: CreatePlaylistRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: PlaylistCreationResult; }> {
|
|
const localVarPath = this.basePath + '/Playlists';
|
|
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 = {};
|
|
|
|
if (name !== undefined) {
|
|
localVarQueryParameters['name'] = ObjectSerializer.serialize(name, "string");
|
|
}
|
|
|
|
if (ids !== undefined) {
|
|
localVarQueryParameters['ids'] = ObjectSerializer.serialize(ids, "Array<string>");
|
|
}
|
|
|
|
if (userId !== undefined) {
|
|
localVarQueryParameters['userId'] = ObjectSerializer.serialize(userId, "string");
|
|
}
|
|
|
|
if (mediaType !== undefined) {
|
|
localVarQueryParameters['mediaType'] = ObjectSerializer.serialize(mediaType, "string");
|
|
}
|
|
|
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|
|
|
let localVarUseFormData = false;
|
|
|
|
let localVarRequestOptions: localVarRequest.Options = {
|
|
method: 'POST',
|
|
qs: localVarQueryParameters,
|
|
headers: localVarHeaderParams,
|
|
uri: localVarPath,
|
|
useQuerystring: this._useQuerystring,
|
|
json: true,
|
|
body: ObjectSerializer.serialize(createPlaylistRequest, "CreatePlaylistRequest")
|
|
};
|
|
|
|
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: PlaylistCreationResult; }>((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, "PlaylistCreationResult");
|
|
resolve({ response: response, body: body });
|
|
} else {
|
|
reject(new HttpError(response, body, response.statusCode));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
/**
|
|
*
|
|
* @summary Gets the original items of a playlist.
|
|
* @param playlistId The playlist id.
|
|
* @param userId User id.
|
|
* @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 fields Optional. Specify additional fields of information to return in the output.
|
|
* @param enableImages Optional. Include image information in output.
|
|
* @param enableUserData Optional. Include user data.
|
|
* @param imageTypeLimit Optional. The max number of images to return, per image type.
|
|
* @param enableImageTypes Optional. The image types to include in the output.
|
|
*/
|
|
public async getPlaylistItems (playlistId: string, userId: string, startIndex?: number, limit?: number, fields?: Array<ItemFields>, enableImages?: boolean, enableUserData?: boolean, imageTypeLimit?: number, enableImageTypes?: Array<ImageType>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BaseItemDtoQueryResult; }> {
|
|
const localVarPath = this.basePath + '/Playlists/{playlistId}/Items'
|
|
.replace('{' + 'playlistId' + '}', encodeURIComponent(String(playlistId)));
|
|
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 'playlistId' is not null or undefined
|
|
if (playlistId === null || playlistId === undefined) {
|
|
throw new Error('Required parameter playlistId was null or undefined when calling getPlaylistItems.');
|
|
}
|
|
|
|
// verify required parameter 'userId' is not null or undefined
|
|
if (userId === null || userId === undefined) {
|
|
throw new Error('Required parameter userId was null or undefined when calling getPlaylistItems.');
|
|
}
|
|
|
|
if (userId !== undefined) {
|
|
localVarQueryParameters['userId'] = ObjectSerializer.serialize(userId, "string");
|
|
}
|
|
|
|
if (startIndex !== undefined) {
|
|
localVarQueryParameters['startIndex'] = ObjectSerializer.serialize(startIndex, "number");
|
|
}
|
|
|
|
if (limit !== undefined) {
|
|
localVarQueryParameters['limit'] = ObjectSerializer.serialize(limit, "number");
|
|
}
|
|
|
|
if (fields !== undefined) {
|
|
localVarQueryParameters['fields'] = ObjectSerializer.serialize(fields, "Array<ItemFields>");
|
|
}
|
|
|
|
if (enableImages !== undefined) {
|
|
localVarQueryParameters['enableImages'] = ObjectSerializer.serialize(enableImages, "boolean");
|
|
}
|
|
|
|
if (enableUserData !== undefined) {
|
|
localVarQueryParameters['enableUserData'] = ObjectSerializer.serialize(enableUserData, "boolean");
|
|
}
|
|
|
|
if (imageTypeLimit !== undefined) {
|
|
localVarQueryParameters['imageTypeLimit'] = ObjectSerializer.serialize(imageTypeLimit, "number");
|
|
}
|
|
|
|
if (enableImageTypes !== undefined) {
|
|
localVarQueryParameters['enableImageTypes'] = ObjectSerializer.serialize(enableImageTypes, "Array<ImageType>");
|
|
}
|
|
|
|
(<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: BaseItemDtoQueryResult; }>((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, "BaseItemDtoQueryResult");
|
|
resolve({ response: response, body: body });
|
|
} else {
|
|
reject(new HttpError(response, body, response.statusCode));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
/**
|
|
*
|
|
* @summary Moves a playlist item.
|
|
* @param playlistId The playlist id.
|
|
* @param itemId The item id.
|
|
* @param newIndex The new index.
|
|
*/
|
|
public async moveItem (playlistId: string, itemId: string, newIndex: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
|
|
const localVarPath = this.basePath + '/Playlists/{playlistId}/Items/{itemId}/Move/{newIndex}'
|
|
.replace('{' + 'playlistId' + '}', encodeURIComponent(String(playlistId)))
|
|
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)))
|
|
.replace('{' + 'newIndex' + '}', encodeURIComponent(String(newIndex)));
|
|
let localVarQueryParameters: any = {};
|
|
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
|
|
let localVarFormParams: any = {};
|
|
|
|
// verify required parameter 'playlistId' is not null or undefined
|
|
if (playlistId === null || playlistId === undefined) {
|
|
throw new Error('Required parameter playlistId was null or undefined when calling moveItem.');
|
|
}
|
|
|
|
// verify required parameter 'itemId' is not null or undefined
|
|
if (itemId === null || itemId === undefined) {
|
|
throw new Error('Required parameter itemId was null or undefined when calling moveItem.');
|
|
}
|
|
|
|
// verify required parameter 'newIndex' is not null or undefined
|
|
if (newIndex === null || newIndex === undefined) {
|
|
throw new Error('Required parameter newIndex was null or undefined when calling moveItem.');
|
|
}
|
|
|
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|
|
|
let localVarUseFormData = false;
|
|
|
|
let localVarRequestOptions: localVarRequest.Options = {
|
|
method: 'POST',
|
|
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?: any; }>((resolve, reject) => {
|
|
localVarRequest(localVarRequestOptions, (error, response, body) => {
|
|
if (error) {
|
|
reject(error);
|
|
} else {
|
|
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
|
|
resolve({ response: response, body: body });
|
|
} else {
|
|
reject(new HttpError(response, body, response.statusCode));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
/**
|
|
*
|
|
* @summary Removes items from a playlist.
|
|
* @param playlistId The playlist id.
|
|
* @param entryIds The item ids, comma delimited.
|
|
*/
|
|
public async removeFromPlaylist (playlistId: string, entryIds?: Array<string>, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
|
|
const localVarPath = this.basePath + '/Playlists/{playlistId}/Items'
|
|
.replace('{' + 'playlistId' + '}', encodeURIComponent(String(playlistId)));
|
|
let localVarQueryParameters: any = {};
|
|
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
|
|
let localVarFormParams: any = {};
|
|
|
|
// verify required parameter 'playlistId' is not null or undefined
|
|
if (playlistId === null || playlistId === undefined) {
|
|
throw new Error('Required parameter playlistId was null or undefined when calling removeFromPlaylist.');
|
|
}
|
|
|
|
if (entryIds !== undefined) {
|
|
localVarQueryParameters['entryIds'] = ObjectSerializer.serialize(entryIds, "Array<string>");
|
|
}
|
|
|
|
(<any>Object).assign(localVarHeaderParams, options.headers);
|
|
|
|
let localVarUseFormData = false;
|
|
|
|
let localVarRequestOptions: localVarRequest.Options = {
|
|
method: 'DELETE',
|
|
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?: any; }>((resolve, reject) => {
|
|
localVarRequest(localVarRequestOptions, (error, response, body) => {
|
|
if (error) {
|
|
reject(error);
|
|
} else {
|
|
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
|
|
resolve({ response: response, body: body });
|
|
} else {
|
|
reject(new HttpError(response, body, response.statusCode));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|