/* 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 {
  BaseItemDto,
  BaseItemDtoQueryResult,
  ImageType,
  ItemFields,
  ItemFilter,
  ProblemDetails,
} from '../models';
import {
    BaseItemDtoFromJSON,
    BaseItemDtoToJSON,
    BaseItemDtoQueryResultFromJSON,
    BaseItemDtoQueryResultToJSON,
    ImageTypeFromJSON,
    ImageTypeToJSON,
    ItemFieldsFromJSON,
    ItemFieldsToJSON,
    ItemFilterFromJSON,
    ItemFilterToJSON,
    ProblemDetailsFromJSON,
    ProblemDetailsToJSON,
} from '../models';

export interface GetPersonRequest {
    name: string;
    userId?: string;
}

export interface GetPersonsRequest {
    limit?: number;
    searchTerm?: string;
    fields?: Array<ItemFields>;
    filters?: Array<ItemFilter>;
    isFavorite?: boolean;
    enableUserData?: boolean;
    imageTypeLimit?: number;
    enableImageTypes?: Array<ImageType>;
    excludePersonTypes?: Array<string>;
    personTypes?: Array<string>;
    appearsInItemId?: string;
    userId?: string;
    enableImages?: boolean;
}

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

    /**
     * Get person by name.
     */
    async getPersonRaw(requestParameters: GetPersonRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDto>> {
        if (requestParameters.name === null || requestParameters.name === undefined) {
            throw new runtime.RequiredError('name','Required parameter requestParameters.name was null or undefined when calling getPerson.');
        }

        const queryParameters: any = {};

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Get person by name.
     */
    async getPerson(requestParameters: GetPersonRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDto> {
        const response = await this.getPersonRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets all persons.
     */
    async getPersonsRaw(requestParameters: GetPersonsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseItemDtoQueryResult>> {
        const queryParameters: any = {};

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

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

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

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

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

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

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

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

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

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

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

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

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Gets all persons.
     */
    async getPersons(requestParameters: GetPersonsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseItemDtoQueryResult> {
        const response = await this.getPersonsRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
