/* 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 {
  DeviceInfo,
  DeviceInfoQueryResult,
  DeviceOptions,
  ProblemDetails,
  UpdateDeviceOptionsRequest,
} from '../models';
import {
    DeviceInfoFromJSON,
    DeviceInfoToJSON,
    DeviceInfoQueryResultFromJSON,
    DeviceInfoQueryResultToJSON,
    DeviceOptionsFromJSON,
    DeviceOptionsToJSON,
    ProblemDetailsFromJSON,
    ProblemDetailsToJSON,
    UpdateDeviceOptionsRequestFromJSON,
    UpdateDeviceOptionsRequestToJSON,
} from '../models';

export interface DeleteDeviceRequest {
    id: string;
}

export interface GetDeviceInfoRequest {
    id: string;
}

export interface GetDeviceOptionsRequest {
    id: string;
}

export interface GetDevicesRequest {
    supportsSync?: boolean;
    userId?: string;
}

export interface UpdateDeviceOptionsOperationRequest {
    id: string;
    updateDeviceOptionsRequest: UpdateDeviceOptionsRequest;
}

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

    /**
     * Deletes a device.
     */
    async deleteDeviceRaw(requestParameters: DeleteDeviceRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling deleteDevice.');
        }

        const queryParameters: any = {};

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Deletes a device.
     */
    async deleteDevice(requestParameters: DeleteDeviceRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.deleteDeviceRaw(requestParameters, initOverrides);
    }

    /**
     * Get info for a device.
     */
    async getDeviceInfoRaw(requestParameters: GetDeviceInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<DeviceInfo>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling getDeviceInfo.');
        }

        const queryParameters: any = {};

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Get info for a device.
     */
    async getDeviceInfo(requestParameters: GetDeviceInfoRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DeviceInfo> {
        const response = await this.getDeviceInfoRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Get options for a device.
     */
    async getDeviceOptionsRaw(requestParameters: GetDeviceOptionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<DeviceOptions>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling getDeviceOptions.');
        }

        const queryParameters: any = {};

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

        const headerParameters: runtime.HTTPHeaders = {};

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

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

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

    /**
     * Get options for a device.
     */
    async getDeviceOptions(requestParameters: GetDeviceOptionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DeviceOptions> {
        const response = await this.getDeviceOptionsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Get Devices.
     */
    async getDevicesRaw(requestParameters: GetDevicesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<DeviceInfoQueryResult>> {
        const queryParameters: any = {};

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

        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: `/Devices`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * Get Devices.
     */
    async getDevices(requestParameters: GetDevicesRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DeviceInfoQueryResult> {
        const response = await this.getDevicesRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Update device options.
     */
    async updateDeviceOptionsRaw(requestParameters: UpdateDeviceOptionsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.id === null || requestParameters.id === undefined) {
            throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling updateDeviceOptions.');
        }

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

        const queryParameters: any = {};

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

        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: `/Devices/Options`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: UpdateDeviceOptionsRequestToJSON(requestParameters.updateDeviceOptionsRequest),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * Update device options.
     */
    async updateDeviceOptions(requestParameters: UpdateDeviceOptionsOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.updateDeviceOptionsRaw(requestParameters, initOverrides);
    }

}
