upstox-js-sdk
Version:
The official Node Js client for communicating with the Upstox API
94 lines (83 loc) • 3.52 kB
JavaScript
/*
* 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.
*
*/
import { ApiClient } from "../ApiClient";
import { ApiGatewayErrorResponse } from '../model/ApiGatewayErrorResponse';
import { SearchInstrumentResponse } from '../model/SearchInstrumentResponse';
/**
* Instruments service.
* @module api/InstrumentsApi
* @version v0
*/
export 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.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;
return this.apiClient.callApi(
'/v2/instruments/search', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}