@jellyfin/sdk
Version:
A TypeScript SDK for Jellyfin.
250 lines (247 loc) • 14.1 kB
JavaScript
import globalAxios from 'axios';
import { assertParamExists, DUMMY_BASE_URL, setApiKeyToObject, setSearchParams, toPathString, createRequestFunction } from '../common.js';
import { operationServerMap, BaseAPI, BASE_PATH } from '../base.js';
/* tslint:disable */
/* eslint-disable */
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit the class manually.
*
* Jellyfin API
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* PersonsApi - axios parameter creator
* @export
*/
const PersonsApiAxiosParamCreator = function (configuration) {
return {
/**
*
* @summary Get person by name.
* @param {string} name Person name.
* @param {string} [userId] Optional. Filter by user id, and attach user data.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getPerson: async (name, userId, options = {}) => {
// verify required parameter 'name' is not null or undefined
assertParamExists('getPerson', 'name', name);
const localVarPath = `/Persons/{name}`
.replace(`{${"name"}}`, encodeURIComponent(String(name)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication CustomAuthentication required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
if (userId !== undefined) {
localVarQueryParameter['userId'] = userId;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Gets all persons.
* @param {number} [limit] Optional. The maximum number of records to return.
* @param {string} [searchTerm] The search term.
* @param {Array<ItemFields>} [fields] Optional. Specify additional fields of information to return in the output.
* @param {Array<ItemFilter>} [filters] Optional. Specify additional filters to apply.
* @param {boolean} [isFavorite] Optional filter by items that are marked as favorite, or not. userId is required.
* @param {boolean} [enableUserData] Optional, include user data.
* @param {number} [imageTypeLimit] Optional, the max number of images to return, per image type.
* @param {Array<ImageType>} [enableImageTypes] Optional. The image types to include in the output.
* @param {Array<string>} [excludePersonTypes] Optional. If specified results will be filtered to exclude those containing the specified PersonType. Allows multiple, comma-delimited.
* @param {Array<string>} [personTypes] Optional. If specified results will be filtered to include only those containing the specified PersonType. Allows multiple, comma-delimited.
* @param {string} [appearsInItemId] Optional. If specified, person results will be filtered on items related to said persons.
* @param {string} [userId] User id.
* @param {boolean} [enableImages] Optional, include image information in output.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getPersons: async (limit, searchTerm, fields, filters, isFavorite, enableUserData, imageTypeLimit, enableImageTypes, excludePersonTypes, personTypes, appearsInItemId, userId, enableImages, options = {}) => {
const localVarPath = `/Persons`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication CustomAuthentication required
await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (searchTerm !== undefined) {
localVarQueryParameter['searchTerm'] = searchTerm;
}
if (fields) {
localVarQueryParameter['fields'] = fields;
}
if (filters) {
localVarQueryParameter['filters'] = filters;
}
if (isFavorite !== undefined) {
localVarQueryParameter['isFavorite'] = isFavorite;
}
if (enableUserData !== undefined) {
localVarQueryParameter['enableUserData'] = enableUserData;
}
if (imageTypeLimit !== undefined) {
localVarQueryParameter['imageTypeLimit'] = imageTypeLimit;
}
if (enableImageTypes) {
localVarQueryParameter['enableImageTypes'] = enableImageTypes;
}
if (excludePersonTypes) {
localVarQueryParameter['excludePersonTypes'] = excludePersonTypes;
}
if (personTypes) {
localVarQueryParameter['personTypes'] = personTypes;
}
if (appearsInItemId !== undefined) {
localVarQueryParameter['appearsInItemId'] = appearsInItemId;
}
if (userId !== undefined) {
localVarQueryParameter['userId'] = userId;
}
if (enableImages !== undefined) {
localVarQueryParameter['enableImages'] = enableImages;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
};
};
/**
* PersonsApi - functional programming interface
* @export
*/
const PersonsApiFp = function (configuration) {
const localVarAxiosParamCreator = PersonsApiAxiosParamCreator(configuration);
return {
/**
*
* @summary Get person by name.
* @param {string} name Person name.
* @param {string} [userId] Optional. Filter by user id, and attach user data.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getPerson(name, userId, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.getPerson(name, userId, options);
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
const localVarOperationServerBasePath = (_c = (_b = operationServerMap['PersonsApi.getPerson']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @summary Gets all persons.
* @param {number} [limit] Optional. The maximum number of records to return.
* @param {string} [searchTerm] The search term.
* @param {Array<ItemFields>} [fields] Optional. Specify additional fields of information to return in the output.
* @param {Array<ItemFilter>} [filters] Optional. Specify additional filters to apply.
* @param {boolean} [isFavorite] Optional filter by items that are marked as favorite, or not. userId is required.
* @param {boolean} [enableUserData] Optional, include user data.
* @param {number} [imageTypeLimit] Optional, the max number of images to return, per image type.
* @param {Array<ImageType>} [enableImageTypes] Optional. The image types to include in the output.
* @param {Array<string>} [excludePersonTypes] Optional. If specified results will be filtered to exclude those containing the specified PersonType. Allows multiple, comma-delimited.
* @param {Array<string>} [personTypes] Optional. If specified results will be filtered to include only those containing the specified PersonType. Allows multiple, comma-delimited.
* @param {string} [appearsInItemId] Optional. If specified, person results will be filtered on items related to said persons.
* @param {string} [userId] User id.
* @param {boolean} [enableImages] Optional, include image information in output.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getPersons(limit, searchTerm, fields, filters, isFavorite, enableUserData, imageTypeLimit, enableImageTypes, excludePersonTypes, personTypes, appearsInItemId, userId, enableImages, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.getPersons(limit, searchTerm, fields, filters, isFavorite, enableUserData, imageTypeLimit, enableImageTypes, excludePersonTypes, personTypes, appearsInItemId, userId, enableImages, options);
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
const localVarOperationServerBasePath = (_c = (_b = operationServerMap['PersonsApi.getPersons']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
};
};
/**
* PersonsApi - factory interface
* @export
*/
const PersonsApiFactory = function (configuration, basePath, axios) {
const localVarFp = PersonsApiFp(configuration);
return {
/**
*
* @summary Get person by name.
* @param {PersonsApiGetPersonRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getPerson(requestParameters, options) {
return localVarFp.getPerson(requestParameters.name, requestParameters.userId, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Gets all persons.
* @param {PersonsApiGetPersonsRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getPersons(requestParameters = {}, options) {
return localVarFp.getPersons(requestParameters.limit, requestParameters.searchTerm, requestParameters.fields, requestParameters.filters, requestParameters.isFavorite, requestParameters.enableUserData, requestParameters.imageTypeLimit, requestParameters.enableImageTypes, requestParameters.excludePersonTypes, requestParameters.personTypes, requestParameters.appearsInItemId, requestParameters.userId, requestParameters.enableImages, options).then((request) => request(axios, basePath));
},
};
};
/**
* PersonsApi - object-oriented interface
* @export
* @class PersonsApi
* @extends {BaseAPI}
*/
class PersonsApi extends BaseAPI {
/**
*
* @summary Get person by name.
* @param {PersonsApiGetPersonRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersonsApi
*/
getPerson(requestParameters, options) {
return PersonsApiFp(this.configuration).getPerson(requestParameters.name, requestParameters.userId, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary Gets all persons.
* @param {PersonsApiGetPersonsRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersonsApi
*/
getPersons(requestParameters = {}, options) {
return PersonsApiFp(this.configuration).getPersons(requestParameters.limit, requestParameters.searchTerm, requestParameters.fields, requestParameters.filters, requestParameters.isFavorite, requestParameters.enableUserData, requestParameters.imageTypeLimit, requestParameters.enableImageTypes, requestParameters.excludePersonTypes, requestParameters.personTypes, requestParameters.appearsInItemId, requestParameters.userId, requestParameters.enableImages, options).then((request) => request(this.axios, this.basePath));
}
}
export { PersonsApi, PersonsApiAxiosParamCreator, PersonsApiFactory, PersonsApiFp };