kalshi-typescript
Version:
OpenAPI client for kalshi-typescript
267 lines (240 loc) • 15.2 kB
text/typescript
/* 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 { GetMilestoneResponse } from '../models';
// @ts-ignore
import type { GetMilestonesResponse } from '../models';
/**
* MilestoneApi - axios parameter creator
*/
export const MilestoneApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
* Endpoint for getting data about a specific milestone by its ID.
* @summary Get Milestone
* @param {string} milestoneId Milestone ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMilestone: async (milestoneId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'milestoneId' is not null or undefined
assertParamExists('getMilestone', 'milestoneId', milestoneId)
const localVarPath = `/milestones/{milestone_id}`
.replace(`{${"milestone_id"}}`, encodeURIComponent(String(milestoneId)));
// 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;
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Minimum start date to filter milestones. Format: RFC3339 timestamp
* @summary Get Milestones
* @param {number} limit Number of milestones to return per page
* @param {string} [minimumStartDate] Minimum start date to filter milestones. Format RFC3339 timestamp
* @param {string} [category] Filter by milestone category. E.g. Sports, Elections, Esports, Crypto.
* @param {string} [competition] Filter by competition. E.g. Pro Football, Pro Basketball (M), Pro Baseball, Pro Hockey, College Football.
* @param {string} [sourceId] Filter by source id
* @param {string} [type] Filter by milestone type. E.g. football_game, basketball_game, soccer_tournament_multi_leg, baseball_game, hockey_match, political_race.
* @param {string} [relatedEventTicker] Filter by related event ticker
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results
* @param {number} [minUpdatedTs] Filter milestones with metadata updated after this Unix timestamp (in seconds). Use this to efficiently poll for changes.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMilestones: async (limit: number, minimumStartDate?: string, category?: string, competition?: string, sourceId?: string, type?: string, relatedEventTicker?: string, cursor?: string, minUpdatedTs?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'limit' is not null or undefined
assertParamExists('getMilestones', 'limit', limit)
const localVarPath = `/milestones`;
// 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;
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (minimumStartDate !== undefined) {
localVarQueryParameter['minimum_start_date'] = (minimumStartDate as any instanceof Date) ?
(minimumStartDate as any).toISOString() :
minimumStartDate;
}
if (category !== undefined) {
localVarQueryParameter['category'] = category;
}
if (competition !== undefined) {
localVarQueryParameter['competition'] = competition;
}
if (sourceId !== undefined) {
localVarQueryParameter['source_id'] = sourceId;
}
if (type !== undefined) {
localVarQueryParameter['type'] = type;
}
if (relatedEventTicker !== undefined) {
localVarQueryParameter['related_event_ticker'] = relatedEventTicker;
}
if (cursor !== undefined) {
localVarQueryParameter['cursor'] = cursor;
}
if (minUpdatedTs !== undefined) {
localVarQueryParameter['min_updated_ts'] = minUpdatedTs;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};
/**
* MilestoneApi - functional programming interface
*/
export const MilestoneApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = MilestoneApiAxiosParamCreator(configuration)
return {
/**
* Endpoint for getting data about a specific milestone by its ID.
* @summary Get Milestone
* @param {string} milestoneId Milestone ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getMilestone(milestoneId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetMilestoneResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getMilestone(milestoneId, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath: string | undefined = undefined;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* Minimum start date to filter milestones. Format: RFC3339 timestamp
* @summary Get Milestones
* @param {number} limit Number of milestones to return per page
* @param {string} [minimumStartDate] Minimum start date to filter milestones. Format RFC3339 timestamp
* @param {string} [category] Filter by milestone category. E.g. Sports, Elections, Esports, Crypto.
* @param {string} [competition] Filter by competition. E.g. Pro Football, Pro Basketball (M), Pro Baseball, Pro Hockey, College Football.
* @param {string} [sourceId] Filter by source id
* @param {string} [type] Filter by milestone type. E.g. football_game, basketball_game, soccer_tournament_multi_leg, baseball_game, hockey_match, political_race.
* @param {string} [relatedEventTicker] Filter by related event ticker
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results
* @param {number} [minUpdatedTs] Filter milestones with metadata updated after this Unix timestamp (in seconds). Use this to efficiently poll for changes.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getMilestones(limit: number, minimumStartDate?: string, category?: string, competition?: string, sourceId?: string, type?: string, relatedEventTicker?: string, cursor?: string, minUpdatedTs?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<GetMilestonesResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.getMilestones(limit, minimumStartDate, category, competition, sourceId, type, relatedEventTicker, cursor, minUpdatedTs, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath: string | undefined = undefined;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* MilestoneApi - factory interface
*/
export const MilestoneApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = MilestoneApiFp(configuration)
return {
/**
* Endpoint for getting data about a specific milestone by its ID.
* @summary Get Milestone
* @param {string} milestoneId Milestone ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMilestone(milestoneId: string, options?: RawAxiosRequestConfig): AxiosPromise<GetMilestoneResponse> {
return localVarFp.getMilestone(milestoneId, options).then((request) => request(axios, basePath));
},
/**
* Minimum start date to filter milestones. Format: RFC3339 timestamp
* @summary Get Milestones
* @param {number} limit Number of milestones to return per page
* @param {string} [minimumStartDate] Minimum start date to filter milestones. Format RFC3339 timestamp
* @param {string} [category] Filter by milestone category. E.g. Sports, Elections, Esports, Crypto.
* @param {string} [competition] Filter by competition. E.g. Pro Football, Pro Basketball (M), Pro Baseball, Pro Hockey, College Football.
* @param {string} [sourceId] Filter by source id
* @param {string} [type] Filter by milestone type. E.g. football_game, basketball_game, soccer_tournament_multi_leg, baseball_game, hockey_match, political_race.
* @param {string} [relatedEventTicker] Filter by related event ticker
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results
* @param {number} [minUpdatedTs] Filter milestones with metadata updated after this Unix timestamp (in seconds). Use this to efficiently poll for changes.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMilestones(limit: number, minimumStartDate?: string, category?: string, competition?: string, sourceId?: string, type?: string, relatedEventTicker?: string, cursor?: string, minUpdatedTs?: number, options?: RawAxiosRequestConfig): AxiosPromise<GetMilestonesResponse> {
return localVarFp.getMilestones(limit, minimumStartDate, category, competition, sourceId, type, relatedEventTicker, cursor, minUpdatedTs, options).then((request) => request(axios, basePath));
},
};
};
/**
* MilestoneApi - object-oriented interface
*/
export class MilestoneApi extends BaseAPI {
/**
* Endpoint for getting data about a specific milestone by its ID.
* @summary Get Milestone
* @param {string} milestoneId Milestone ID
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public getMilestone(milestoneId: string, options?: RawAxiosRequestConfig) {
return MilestoneApiFp(this.configuration).getMilestone(milestoneId, options).then((request) => request(this.axios, this.basePath));
}
/**
* Minimum start date to filter milestones. Format: RFC3339 timestamp
* @summary Get Milestones
* @param {number} limit Number of milestones to return per page
* @param {string} [minimumStartDate] Minimum start date to filter milestones. Format RFC3339 timestamp
* @param {string} [category] Filter by milestone category. E.g. Sports, Elections, Esports, Crypto.
* @param {string} [competition] Filter by competition. E.g. Pro Football, Pro Basketball (M), Pro Baseball, Pro Hockey, College Football.
* @param {string} [sourceId] Filter by source id
* @param {string} [type] Filter by milestone type. E.g. football_game, basketball_game, soccer_tournament_multi_leg, baseball_game, hockey_match, political_race.
* @param {string} [relatedEventTicker] Filter by related event ticker
* @param {string} [cursor] Pagination cursor. Use the cursor value returned from the previous response to get the next page of results
* @param {number} [minUpdatedTs] Filter milestones with metadata updated after this Unix timestamp (in seconds). Use this to efficiently poll for changes.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
public getMilestones(limit: number, minimumStartDate?: string, category?: string, competition?: string, sourceId?: string, type?: string, relatedEventTicker?: string, cursor?: string, minUpdatedTs?: number, options?: RawAxiosRequestConfig) {
return MilestoneApiFp(this.configuration).getMilestones(limit, minimumStartDate, category, competition, sourceId, type, relatedEventTicker, cursor, minUpdatedTs, options).then((request) => request(this.axios, this.basePath));
}
}