UNPKG

kalshi-typescript

Version:
250 lines (249 loc) 15.3 kB
/* 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. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import globalAxios from 'axios'; // URLSearchParams not necessarily used // @ts-ignore import { URL } from 'url'; // Some imports not used depending on template conditions // @ts-ignore import { DUMMY_BASE_URL, assertParamExists, setSearchParams, toPathString, createRequestFunction } from '../common'; // @ts-ignore import { BASE_PATH, BaseAPI } from '../base'; /** * MilestoneApi - axios parameter creator */ export const MilestoneApiAxiosParamCreator = function (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_1, ...args_1) => __awaiter(this, [milestoneId_1, ...args_1], void 0, function* (milestoneId, options = {}) { // 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 = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); const localVarHeaderParameter = {}; const localVarQueryParameter = {}; setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, 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: (limit_1, minimumStartDate_1, category_1, competition_1, sourceId_1, type_1, relatedEventTicker_1, cursor_1, minUpdatedTs_1, ...args_1) => __awaiter(this, [limit_1, minimumStartDate_1, category_1, competition_1, sourceId_1, type_1, relatedEventTicker_1, cursor_1, minUpdatedTs_1, ...args_1], void 0, function* (limit, minimumStartDate, category, competition, sourceId, type, relatedEventTicker, cursor, minUpdatedTs, options = {}) { // 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 = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options); const localVarHeaderParameter = {}; const localVarQueryParameter = {}; if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } if (minimumStartDate !== undefined) { localVarQueryParameter['minimum_start_date'] = (minimumStartDate instanceof Date) ? minimumStartDate.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 = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers); return { url: toPathString(localVarUrlObj), options: localVarRequestOptions, }; }), }; }; /** * MilestoneApi - functional programming interface */ export const MilestoneApiFp = function (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} */ getMilestone(milestoneId, options) { return __awaiter(this, void 0, void 0, function* () { var _a; const localVarAxiosArgs = yield localVarAxiosParamCreator.getMilestone(milestoneId, options); const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0; const localVarOperationServerBasePath = 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} */ getMilestones(limit, minimumStartDate, category, competition, sourceId, type, relatedEventTicker, cursor, minUpdatedTs, options) { return __awaiter(this, void 0, void 0, function* () { var _a; const localVarAxiosArgs = yield localVarAxiosParamCreator.getMilestones(limit, minimumStartDate, category, competition, sourceId, type, relatedEventTicker, cursor, minUpdatedTs, options); const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0; const localVarOperationServerBasePath = undefined; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }); }, }; }; /** * MilestoneApi - factory interface */ export const MilestoneApiFactory = function (configuration, basePath, axios) { 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, options) { 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, minimumStartDate, category, competition, sourceId, type, relatedEventTicker, cursor, minUpdatedTs, options) { 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} */ getMilestone(milestoneId, options) { 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} */ getMilestones(limit, minimumStartDate, category, competition, sourceId, type, relatedEventTicker, cursor, minUpdatedTs, options) { return MilestoneApiFp(this.configuration).getMilestones(limit, minimumStartDate, category, competition, sourceId, type, relatedEventTicker, cursor, minUpdatedTs, options).then((request) => request(this.axios, this.basePath)); } }