UNPKG

upstox-js-sdk

Version:

The official Node Js client for communicating with the Upstox API

93 lines (89 loc) 3.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InstrumentsApi = void 0; var _ApiClient = require("../ApiClient"); var _ApiGatewayErrorResponse = require("../model/ApiGatewayErrorResponse"); var _SearchInstrumentResponse = require("../model/SearchInstrumentResponse"); /* * OpenAPI definition * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * OpenAPI spec version: v0 * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * * Swagger Codegen version: 3.0.66 * * Do not edit the class manually. * */ /** * Instruments service. * @module api/InstrumentsApi * @version v0 */ class InstrumentsApi { /** * Constructs a new InstrumentsApi. * @alias module:api/InstrumentsApi * @class * @param {module:ApiClient} [apiClient] Optional API client implementation to use, * default to {@link module:ApiClient#instanc e} if unspecified. */ constructor(apiClient) { this.apiClient = apiClient || _ApiClient.ApiClient.instance; } /** * Callback function to receive the result of the searchInstrument operation. * @callback moduleapi/InstrumentsApi~searchInstrumentCallback * @param {String} error Error message, if any. * @param {module:model/SearchInstrumentResponse{ data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Search instruments * This API provides the functionality to retrieve the instrument details for searched query * @param {Object} query natural language query * @param {Object} opts Optional parameters * @param {Object} opts.exchanges Comma separated exchanges * @param {Object} opts.segments Comma separated segments * @param {Object} opts.instrumentTypes Comma separated instrument types * @param {Object} opts.expiry expiry in format: yyyy-MM-dd * @param {Object} opts.atmOffset page number greater than or equal to 1 * @param {Object} opts.pageNumber ATM offset number for queries like ATM, ATM+1, ATM-1, etc. (default to <.>) * @param {Object} opts.records no of records in a single page (default to <.>) * @param {module:api/InstrumentsApi~searchInstrumentCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link <&vendorExtensions.x-jsdoc-type>} */ searchInstrument(query, opts, callback) { opts = opts || {}; let postBody = null; // verify the required parameter 'query' is set if (query === undefined || query === null) { throw new Error("Missing the required parameter 'query' when calling searchInstrument"); } let pathParams = {}; let queryParams = { 'query': query, 'exchanges': opts['exchanges'], 'segments': opts['segments'], 'instrument_types': opts['instrumentTypes'], 'expiry': opts['expiry'], 'atm_offset': opts['atmOffset'], 'page_number': opts['pageNumber'], 'records': opts['records'] }; let headerParams = {}; let formParams = {}; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['*/*', 'application/json']; let returnType = _SearchInstrumentResponse.SearchInstrumentResponse; return this.apiClient.callApi('/v2/instruments/search', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } } exports.InstrumentsApi = InstrumentsApi;