/* tslint:disable */
/* eslint-disable */
/**
 * Commander Spellbook API
 * API for Commander Spellbook, the combo database engine for Magic: The Gathering
 *
 * The version of the OpenAPI document: 5.4.10
 * 
 *
 * 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.js';
import {
    type PaginatedWebsitePropertyList,
    PaginatedWebsitePropertyListFromJSON,
    PaginatedWebsitePropertyListToJSON,
} from '../models/PaginatedWebsitePropertyList.js';
import {
    type WebsiteProperty,
    WebsitePropertyFromJSON,
    WebsitePropertyToJSON,
} from '../models/WebsiteProperty.js';

export interface PropertiesListRequest {
    count?: boolean;
    limit?: number;
    offset?: number;
}

export interface PropertiesRetrieveRequest {
    key: string;
}

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

    /**
     * Creates request options for propertiesList without sending the request
     */
    async propertiesListRequestOpts(requestParameters: PropertiesListRequest): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        if (requestParameters['count'] != null) {
            queryParameters['count'] = requestParameters['count'];
        }

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

        if (requestParameters['offset'] != null) {
            queryParameters['offset'] = requestParameters['offset'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("jwtAuth", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/properties/`;

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     */
    async propertiesListRaw(requestParameters: PropertiesListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PaginatedWebsitePropertyList>> {
        const requestOptions = await this.propertiesListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     */
    async propertiesList(requestParameters: PropertiesListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PaginatedWebsitePropertyList> {
        const response = await this.propertiesListRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for propertiesRetrieve without sending the request
     */
    async propertiesRetrieveRequestOpts(requestParameters: PropertiesRetrieveRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['key'] == null) {
            throw new runtime.RequiredError(
                'key',
                'Required parameter "key" was null or undefined when calling propertiesRetrieve().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
            headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
        }
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("jwtAuth", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/properties/{key}/`;
        urlPath = urlPath.replace('{key}', encodeURIComponent(String(requestParameters['key'])));

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     */
    async propertiesRetrieveRaw(requestParameters: PropertiesRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<WebsiteProperty>> {
        const requestOptions = await this.propertiesRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     */
    async propertiesRetrieve(requestParameters: PropertiesRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<WebsiteProperty> {
        const response = await this.propertiesRetrieveRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
