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

929 lines
42 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 { BaseItemDto } from '../model/baseItemDto';
import { BaseItemDtoQueryResult } from '../model/baseItemDtoQueryResult';
import { BaseItemKind } from '../model/baseItemKind';
import { ImageType } from '../model/imageType';
import { ItemFields } from '../model/itemFields';
import { UserItemDataDto } from '../model/userItemDataDto';
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 UserLibraryApiApiKeys {
CustomAuthentication,
}
export class UserLibraryApi {
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: UserLibraryApiApiKeys, value: string) {
(this.authentications as any)[UserLibraryApiApiKeys[key]].apiKey = value;
}
public addInterceptor(interceptor: Interceptor) {
this.interceptors.push(interceptor);
}
/**
*
* @summary Deletes a user\'s saved personal rating for an item.
* @param userId User id.
* @param itemId Item id.
*/
public async deleteUserItemRating (userId: string, itemId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: UserItemDataDto; }> {
const localVarPath = this.basePath + '/Users/{userId}/Items/{itemId}/Rating'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)))
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling deleteUserItemRating.');
}
// 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 deleteUserItemRating.');
}
(<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: UserItemDataDto; }>((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, "UserItemDataDto");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
/**
*
* @summary Gets intros to play before the main media item plays.
* @param userId User id.
* @param itemId Item id.
*/
public async getIntros (userId: string, itemId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BaseItemDtoQueryResult; }> {
const localVarPath = this.basePath + '/Users/{userId}/Items/{itemId}/Intros'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)))
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling getIntros.');
}
// 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 getIntros.');
}
(<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 Gets an item from a user\'s library.
* @param userId User id.
* @param itemId Item id.
*/
public async getItem (userId: string, itemId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BaseItemDto; }> {
const localVarPath = this.basePath + '/Users/{userId}/Items/{itemId}'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)))
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling getItem.');
}
// 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 getItem.');
}
(<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: BaseItemDto; }>((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, "BaseItemDto");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
/**
*
* @summary Gets latest media.
* @param userId User id.
* @param parentId Specify this to localize the search to a specific item or folder. Omit to use the root.
* @param fields Optional. Specify additional fields of information to return in the output.
* @param includeItemTypes Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.
* @param isPlayed Filter by items that are played, or not.
* @param enableImages Optional. include image information in output.
* @param imageTypeLimit Optional. the max number of images to return, per image type.
* @param enableImageTypes Optional. The image types to include in the output.
* @param enableUserData Optional. include user data.
* @param limit Return item limit.
* @param groupItems Whether or not to group items into a parent container.
*/
public async getLatestMedia (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, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<BaseItemDto>; }> {
const localVarPath = this.basePath + '/Users/{userId}/Items/Latest'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling getLatestMedia.');
}
if (parentId !== undefined) {
localVarQueryParameters['parentId'] = ObjectSerializer.serialize(parentId, "string");
}
if (fields !== undefined) {
localVarQueryParameters['fields'] = ObjectSerializer.serialize(fields, "Array<ItemFields>");
}
if (includeItemTypes !== undefined) {
localVarQueryParameters['includeItemTypes'] = ObjectSerializer.serialize(includeItemTypes, "Array<BaseItemKind>");
}
if (isPlayed !== undefined) {
localVarQueryParameters['isPlayed'] = ObjectSerializer.serialize(isPlayed, "boolean");
}
if (enableImages !== undefined) {
localVarQueryParameters['enableImages'] = ObjectSerializer.serialize(enableImages, "boolean");
}
if (imageTypeLimit !== undefined) {
localVarQueryParameters['imageTypeLimit'] = ObjectSerializer.serialize(imageTypeLimit, "number");
}
if (enableImageTypes !== undefined) {
localVarQueryParameters['enableImageTypes'] = ObjectSerializer.serialize(enableImageTypes, "Array<ImageType>");
}
if (enableUserData !== undefined) {
localVarQueryParameters['enableUserData'] = ObjectSerializer.serialize(enableUserData, "boolean");
}
if (limit !== undefined) {
localVarQueryParameters['limit'] = ObjectSerializer.serialize(limit, "number");
}
if (groupItems !== undefined) {
localVarQueryParameters['groupItems'] = ObjectSerializer.serialize(groupItems, "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: Array<BaseItemDto>; }>((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, "Array<BaseItemDto>");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
/**
*
* @summary Gets local trailers for an item.
* @param userId User id.
* @param itemId Item id.
*/
public async getLocalTrailers (userId: string, itemId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<BaseItemDto>; }> {
const localVarPath = this.basePath + '/Users/{userId}/Items/{itemId}/LocalTrailers'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)))
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling getLocalTrailers.');
}
// 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 getLocalTrailers.');
}
(<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: Array<BaseItemDto>; }>((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, "Array<BaseItemDto>");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
/**
*
* @summary Gets the root folder from a user\'s library.
* @param userId User id.
*/
public async getRootFolder (userId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: BaseItemDto; }> {
const localVarPath = this.basePath + '/Users/{userId}/Items/Root'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling getRootFolder.');
}
(<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: BaseItemDto; }>((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, "BaseItemDto");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
/**
*
* @summary Gets special features for an item.
* @param userId User id.
* @param itemId Item id.
*/
public async getSpecialFeatures (userId: string, itemId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: Array<BaseItemDto>; }> {
const localVarPath = this.basePath + '/Users/{userId}/Items/{itemId}/SpecialFeatures'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)))
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling getSpecialFeatures.');
}
// 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 getSpecialFeatures.');
}
(<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: Array<BaseItemDto>; }>((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, "Array<BaseItemDto>");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
/**
*
* @summary Marks an item as a favorite.
* @param userId User id.
* @param itemId Item id.
*/
public async markFavoriteItem (userId: string, itemId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: UserItemDataDto; }> {
const localVarPath = this.basePath + '/Users/{userId}/FavoriteItems/{itemId}'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)))
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling markFavoriteItem.');
}
// 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 markFavoriteItem.');
}
(<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: UserItemDataDto; }>((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, "UserItemDataDto");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
/**
*
* @summary Unmarks item as a favorite.
* @param userId User id.
* @param itemId Item id.
*/
public async unmarkFavoriteItem (userId: string, itemId: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: UserItemDataDto; }> {
const localVarPath = this.basePath + '/Users/{userId}/FavoriteItems/{itemId}'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)))
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling unmarkFavoriteItem.');
}
// 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 unmarkFavoriteItem.');
}
(<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: UserItemDataDto; }>((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, "UserItemDataDto");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
/**
*
* @summary Updates a user\'s rating for an item.
* @param userId User id.
* @param itemId Item id.
* @param likes Whether this M:Jellyfin.Api.Controllers.UserLibraryController.UpdateUserItemRating(System.Guid,System.Guid,System.Nullable{System.Boolean}) is likes.
*/
public async updateUserItemRating (userId: string, itemId: string, likes?: boolean, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: UserItemDataDto; }> {
const localVarPath = this.basePath + '/Users/{userId}/Items/{itemId}/Rating'
.replace('{' + 'userId' + '}', encodeURIComponent(String(userId)))
.replace('{' + 'itemId' + '}', encodeURIComponent(String(itemId)));
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 'userId' is not null or undefined
if (userId === null || userId === undefined) {
throw new Error('Required parameter userId was null or undefined when calling updateUserItemRating.');
}
// 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 updateUserItemRating.');
}
if (likes !== undefined) {
localVarQueryParameters['likes'] = ObjectSerializer.serialize(likes, "boolean");
}
(<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: UserItemDataDto; }>((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, "UserItemDataDto");
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
}