UNPKG

upstox-js-sdk

Version:

The official Node Js client for communicating with the Upstox API

90 lines (79 loc) 3.09 kB
/* * 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 {GetNewsResponse} from '../model/GetNewsResponse'; /** * News service. * @module api/NewsApi * @version v0 */ export class NewsApi { /** * Constructs a new NewsApi. * @alias module:api/NewsApi * @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 getNews operation. * @callback moduleapi/NewsApi~getNewsCallback * @param {String} error Error message, if any. * @param {module:model/GetNewsResponse{ data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get News * Fetches news articles for the given instrument keys, or the user&#x27;s current positions or holdings. * @param {Object} category Category of news to fetch. Allowed values: instrument_keys, positions, holdings * @param {Object} opts Optional parameters * @param {Object} opts.instrumentKeys Comma-separated list of instrument keys. Required when category is instrument_keys. * @param {Object} opts.pageNumber Page number for pagination (default to <.>) * @param {Object} opts.pageSize Number of records per page (default to <.>) * @param {module:api/NewsApi~getNewsCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link <&vendorExtensions.x-jsdoc-type>} */ getNews(category, opts, callback) { opts = opts || {}; let postBody = null; // verify the required parameter 'category' is set if (category === undefined || category === null) { throw new Error("Missing the required parameter 'category' when calling getNews"); } let pathParams = { }; let queryParams = { 'category': category,'instrument_keys': opts['instrumentKeys'],'page_number': opts['pageNumber'],'page_size': opts['pageSize'] }; let headerParams = { }; let formParams = { }; let authNames = ['OAUTH2']; let contentTypes = []; let accepts = ['*/*', 'application/json']; let returnType = GetNewsResponse; return this.apiClient.callApi( '/v2/news', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } }