/* tslint:disable */
/* eslint-disable */
/**
 * Kalshi Trade API Manual Endpoints
 * Manually defined OpenAPI spec for endpoints being migrated to spec-first approach
 *
 * The version of the OpenAPI document: 3.11.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// URLSearchParams not necessarily used
// @ts-ignore
import { URL, URLSearchParams } from 'url';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError } from '../base';
// @ts-ignore
import type { GetOrdersResponse } from '../models';
// @ts-ignore
import type { GetPositionsResponse } from '../models';
/**
 * FcmApi - axios parameter creator
 */
export const FcmApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Endpoint for FCM members to get orders filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering orders by subtrader ID. 
         * @summary Get FCM Orders
         * @param {string} subtraderId Restricts the response to orders for a specific subtrader (FCM members only)
         * @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
         * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported.
         * @param {string} [ticker] Filter by market ticker
         * @param {number} [minTs] Restricts the response to orders after a timestamp, formatted as a Unix Timestamp
         * @param {number} [maxTs] Restricts the response to orders before a timestamp, formatted as a Unix Timestamp
         * @param {GetFCMOrdersStatusEnum} [status] Restricts the response to orders that have a certain status
         * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getFCMOrders: async (subtraderId: string, cursor?: string, eventTicker?: string, ticker?: string, minTs?: number, maxTs?: number, status?: GetFCMOrdersStatusEnum, limit?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'subtraderId' is not null or undefined
            assertParamExists('getFCMOrders', 'subtraderId', subtraderId)
            const localVarPath = `/fcm/orders`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication kalshiAccessSignature required
            await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration)

            // authentication kalshiAccessKey required
            await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration)

            // authentication kalshiAccessTimestamp required
            await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration)

            if (subtraderId !== undefined) {
                localVarQueryParameter['subtrader_id'] = subtraderId;
            }

            if (cursor !== undefined) {
                localVarQueryParameter['cursor'] = cursor;
            }

            if (eventTicker !== undefined) {
                localVarQueryParameter['event_ticker'] = eventTicker;
            }

            if (ticker !== undefined) {
                localVarQueryParameter['ticker'] = ticker;
            }

            if (minTs !== undefined) {
                localVarQueryParameter['min_ts'] = minTs;
            }

            if (maxTs !== undefined) {
                localVarQueryParameter['max_ts'] = maxTs;
            }

            if (status !== undefined) {
                localVarQueryParameter['status'] = status;
            }

            if (limit !== undefined) {
                localVarQueryParameter['limit'] = limit;
            }


    
            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Endpoint for FCM members to get market positions filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering positions by subtrader ID. 
         * @summary Get FCM Positions
         * @param {string} subtraderId Restricts the response to positions for a specific subtrader (FCM members only)
         * @param {string} [ticker] Ticker of desired positions
         * @param {string} [eventTicker] Event ticker of desired positions
         * @param {string} [countFilter] Restricts the positions to those with any of following fields with non-zero values, as a comma separated list
         * @param {GetFCMPositionsSettlementStatusEnum} [settlementStatus] Settlement status of the markets to return. Defaults to unsettled
         * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100
         * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getFCMPositions: async (subtraderId: string, ticker?: string, eventTicker?: string, countFilter?: string, settlementStatus?: GetFCMPositionsSettlementStatusEnum, limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'subtraderId' is not null or undefined
            assertParamExists('getFCMPositions', 'subtraderId', subtraderId)
            const localVarPath = `/fcm/positions`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication kalshiAccessSignature required
            await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-SIGNATURE", configuration)

            // authentication kalshiAccessKey required
            await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-KEY", configuration)

            // authentication kalshiAccessTimestamp required
            await setApiKeyToObject(localVarHeaderParameter, "KALSHI-ACCESS-TIMESTAMP", configuration)

            if (subtraderId !== undefined) {
                localVarQueryParameter['subtrader_id'] = subtraderId;
            }

            if (ticker !== undefined) {
                localVarQueryParameter['ticker'] = ticker;
            }

            if (eventTicker !== undefined) {
                localVarQueryParameter['event_ticker'] = eventTicker;
            }

            if (countFilter !== undefined) {
                localVarQueryParameter['count_filter'] = countFilter;
            }

            if (settlementStatus !== undefined) {
                localVarQueryParameter['settlement_status'] = settlementStatus;
            }

            if (limit !== undefined) {
                localVarQueryParameter['limit'] = limit;
            }

            if (cursor !== undefined) {
                localVarQueryParameter['cursor'] = cursor;
            }


    
            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * FcmApi - functional programming interface
 */
export const FcmApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = FcmApiAxiosParamCreator(configuration)
    return {
        /**
         * Endpoint for FCM members to get orders filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering orders by subtrader ID. 
         * @summary Get FCM Orders
         * @param {string} subtraderId Restricts the response to orders for a specific subtrader (FCM members only)
         * @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
         * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported.
         * @param {string} [ticker] Filter by market ticker
         * @param {number} [minTs] Restricts the response to orders after a timestamp, formatted as a Unix Timestamp
         * @param {number} [maxTs] Restricts the response to orders before a timestamp, formatted as a Unix Timestamp
         * @param {GetFCMOrdersStatusEnum} [status] Restricts the response to orders that have a certain status
         * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getFCMOrders(subtraderId: string, cursor?: string, eventTicker?: string, ticker?: string, minTs?: number, maxTs?: number, status?: GetFCMOrdersStatusEnum, limit?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetOrdersResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getFCMOrders(subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath: string | undefined = undefined;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Endpoint for FCM members to get market positions filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering positions by subtrader ID. 
         * @summary Get FCM Positions
         * @param {string} subtraderId Restricts the response to positions for a specific subtrader (FCM members only)
         * @param {string} [ticker] Ticker of desired positions
         * @param {string} [eventTicker] Event ticker of desired positions
         * @param {string} [countFilter] Restricts the positions to those with any of following fields with non-zero values, as a comma separated list
         * @param {GetFCMPositionsSettlementStatusEnum} [settlementStatus] Settlement status of the markets to return. Defaults to unsettled
         * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100
         * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getFCMPositions(subtraderId: string, ticker?: string, eventTicker?: string, countFilter?: string, settlementStatus?: GetFCMPositionsSettlementStatusEnum, limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetPositionsResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getFCMPositions(subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath: string | undefined = undefined;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * FcmApi - factory interface
 */
export const FcmApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = FcmApiFp(configuration)
    return {
        /**
         * Endpoint for FCM members to get orders filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering orders by subtrader ID. 
         * @summary Get FCM Orders
         * @param {string} subtraderId Restricts the response to orders for a specific subtrader (FCM members only)
         * @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
         * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported.
         * @param {string} [ticker] Filter by market ticker
         * @param {number} [minTs] Restricts the response to orders after a timestamp, formatted as a Unix Timestamp
         * @param {number} [maxTs] Restricts the response to orders before a timestamp, formatted as a Unix Timestamp
         * @param {GetFCMOrdersStatusEnum} [status] Restricts the response to orders that have a certain status
         * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getFCMOrders(subtraderId: string, cursor?: string, eventTicker?: string, ticker?: string, minTs?: number, maxTs?: number, status?: GetFCMOrdersStatusEnum, limit?: number, options?: RawAxiosRequestConfig): AxiosPromise<GetOrdersResponse> {
            return localVarFp.getFCMOrders(subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options).then((request) => request(axios, basePath));
        },
        /**
         * Endpoint for FCM members to get market positions filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering positions by subtrader ID. 
         * @summary Get FCM Positions
         * @param {string} subtraderId Restricts the response to positions for a specific subtrader (FCM members only)
         * @param {string} [ticker] Ticker of desired positions
         * @param {string} [eventTicker] Event ticker of desired positions
         * @param {string} [countFilter] Restricts the positions to those with any of following fields with non-zero values, as a comma separated list
         * @param {GetFCMPositionsSettlementStatusEnum} [settlementStatus] Settlement status of the markets to return. Defaults to unsettled
         * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100
         * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getFCMPositions(subtraderId: string, ticker?: string, eventTicker?: string, countFilter?: string, settlementStatus?: GetFCMPositionsSettlementStatusEnum, limit?: number, cursor?: string, options?: RawAxiosRequestConfig): AxiosPromise<GetPositionsResponse> {
            return localVarFp.getFCMPositions(subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * FcmApi - object-oriented interface
 */
export class FcmApi extends BaseAPI {
    /**
     * Endpoint for FCM members to get orders filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering orders by subtrader ID. 
     * @summary Get FCM Orders
     * @param {string} subtraderId Restricts the response to orders for a specific subtrader (FCM members only)
     * @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results. Leave empty for the first page.
     * @param {string} [eventTicker] Event ticker to filter by. Only a single event ticker is supported.
     * @param {string} [ticker] Filter by market ticker
     * @param {number} [minTs] Restricts the response to orders after a timestamp, formatted as a Unix Timestamp
     * @param {number} [maxTs] Restricts the response to orders before a timestamp, formatted as a Unix Timestamp
     * @param {GetFCMOrdersStatusEnum} [status] Restricts the response to orders that have a certain status
     * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getFCMOrders(subtraderId: string, cursor?: string, eventTicker?: string, ticker?: string, minTs?: number, maxTs?: number, status?: GetFCMOrdersStatusEnum, limit?: number, options?: RawAxiosRequestConfig) {
        return FcmApiFp(this.configuration).getFCMOrders(subtraderId, cursor, eventTicker, ticker, minTs, maxTs, status, limit, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Endpoint for FCM members to get market positions filtered by subtrader ID. This endpoint requires FCM member access level and allows filtering positions by subtrader ID. 
     * @summary Get FCM Positions
     * @param {string} subtraderId Restricts the response to positions for a specific subtrader (FCM members only)
     * @param {string} [ticker] Ticker of desired positions
     * @param {string} [eventTicker] Event ticker of desired positions
     * @param {string} [countFilter] Restricts the positions to those with any of following fields with non-zero values, as a comma separated list
     * @param {GetFCMPositionsSettlementStatusEnum} [settlementStatus] Settlement status of the markets to return. Defaults to unsettled
     * @param {number} [limit] Parameter to specify the number of results per page. Defaults to 100
     * @param {string} [cursor] The Cursor represents a pointer to the next page of records in the pagination
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getFCMPositions(subtraderId: string, ticker?: string, eventTicker?: string, countFilter?: string, settlementStatus?: GetFCMPositionsSettlementStatusEnum, limit?: number, cursor?: string, options?: RawAxiosRequestConfig) {
        return FcmApiFp(this.configuration).getFCMPositions(subtraderId, ticker, eventTicker, countFilter, settlementStatus, limit, cursor, options).then((request) => request(this.axios, this.basePath));
    }
}

export const GetFCMOrdersStatusEnum = {
    Resting: 'resting',
    Canceled: 'canceled',
    Executed: 'executed'
} as const;
export type GetFCMOrdersStatusEnum = typeof GetFCMOrdersStatusEnum[keyof typeof GetFCMOrdersStatusEnum];
export const GetFCMPositionsSettlementStatusEnum = {
    All: 'all',
    Unsettled: 'unsettled',
    Settled: 'settled'
} as const;
export type GetFCMPositionsSettlementStatusEnum = typeof GetFCMPositionsSettlementStatusEnum[keyof typeof GetFCMPositionsSettlementStatusEnum];
