/* 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 {
  ProblemDetails,
  QuickConnectResult,
} from '../models';
import {
    ProblemDetailsFromJSON,
    ProblemDetailsToJSON,
    QuickConnectResultFromJSON,
    QuickConnectResultToJSON,
} from '../models';

export interface AuthorizeRequest {
    code: string;
}

export interface ConnectRequest {
    secret: string;
}

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

    /**
     * Authorizes a pending quick connect request.
     */
    async authorizeRaw(requestParameters: AuthorizeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<boolean>> {
        if (requestParameters.code === null || requestParameters.code === undefined) {
            throw new runtime.RequiredError('code','Required parameter requestParameters.code was null or undefined when calling authorize.');
        }

        const queryParameters: any = {};

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<boolean>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Authorizes a pending quick connect request.
     */
    async authorize(requestParameters: AuthorizeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<boolean> {
        const response = await this.authorizeRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Attempts to retrieve authentication information.
     */
    async connectRaw(requestParameters: ConnectRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<QuickConnectResult>> {
        if (requestParameters.secret === null || requestParameters.secret === undefined) {
            throw new runtime.RequiredError('secret','Required parameter requestParameters.secret was null or undefined when calling connect.');
        }

        const queryParameters: any = {};

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

    /**
     * Attempts to retrieve authentication information.
     */
    async connect(requestParameters: ConnectRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<QuickConnectResult> {
        const response = await this.connectRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Gets the current quick connect state.
     */
    async getEnabledRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<boolean>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<boolean>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Gets the current quick connect state.
     */
    async getEnabled(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<boolean> {
        const response = await this.getEnabledRaw(initOverrides);
        return await response.value();
    }

    /**
     * Initiate a new quick connect request.
     */
    async initiateRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<QuickConnectResult>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

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

    /**
     * Initiate a new quick connect request.
     */
    async initiate(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<QuickConnectResult> {
        const response = await this.initiateRaw(initOverrides);
        return await response.value();
    }

}
