/* 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 {
  MetadataEditorInfo,
  ProblemDetails,
  UpdateItemRequest,
} from '../models';
import {
    MetadataEditorInfoFromJSON,
    MetadataEditorInfoToJSON,
    ProblemDetailsFromJSON,
    ProblemDetailsToJSON,
    UpdateItemRequestFromJSON,
    UpdateItemRequestToJSON,
} from '../models';

export interface GetMetadataEditorInfoRequest {
    itemId: string;
}

export interface UpdateItemOperationRequest {
    itemId: string;
    updateItemRequest: UpdateItemRequest;
}

export interface UpdateItemContentTypeRequest {
    itemId: string;
    contentType?: string;
}

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

    /**
     * Gets metadata editor info for an item.
     */
    async getMetadataEditorInfoRaw(requestParameters: GetMetadataEditorInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MetadataEditorInfo>> {
        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling getMetadataEditorInfo.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Gets metadata editor info for an item.
     */
    async getMetadataEditorInfo(requestParameters: GetMetadataEditorInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MetadataEditorInfo> {
        const response = await this.getMetadataEditorInfoRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Updates an item.
     */
    async updateItemRaw(requestParameters: UpdateItemOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling updateItem.');
        }

        if (requestParameters.updateItemRequest === null || requestParameters.updateItemRequest === undefined) {
            throw new runtime.RequiredError('updateItemRequest','Required parameter requestParameters.updateItemRequest was null or undefined when calling updateItem.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

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

        const response = await this.request({
            path: `/Items/{itemId}`.replace(`{${"itemId"}}`, encodeURIComponent(String(requestParameters.itemId))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: UpdateItemRequestToJSON(requestParameters.updateItemRequest),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Updates an item.
     */
    async updateItem(requestParameters: UpdateItemOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.updateItemRaw(requestParameters, initOverrides);
    }

    /**
     * Updates an item\'s content type.
     */
    async updateItemContentTypeRaw(requestParameters: UpdateItemContentTypeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.itemId === null || requestParameters.itemId === undefined) {
            throw new runtime.RequiredError('itemId','Required parameter requestParameters.itemId was null or undefined when calling updateItemContentType.');
        }

        const queryParameters: any = {};

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Updates an item\'s content type.
     */
    async updateItemContentType(requestParameters: UpdateItemContentTypeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.updateItemContentTypeRaw(requestParameters, initOverrides);
    }

}
