upstox-js-sdk
Version:
The official Node Js client for communicating with the Upstox API
103 lines (92 loc) • 4.08 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.54
*
* Do not edit the class manually.
*
*/
import {ApiClient} from "../ApiClient";
import {ApiGatewayErrorResponse} from '../model/ApiGatewayErrorResponse';
import {TradeHistoryResponse} from '../model/TradeHistoryResponse';
/**
* PostTrade service.
* @module api/PostTradeApi
* @version v0
*/
export class PostTradeApi {
/**
* Constructs a new PostTradeApi.
* @alias module:api/PostTradeApi
* @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 getTradesByDateRange operation.
* @callback moduleapi/PostTradeApi~getTradesByDateRangeCallback
* @param {String} error Error message, if any.
* @param {module:model/TradeHistoryResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get historical trades
* This API retrieves the trade history for a specified time interval.
* @param {String} startDate Date from which trade history needs to be fetched. Date in YYYY-mm-dd format
* @param {String} endDate Date till which history needs needs to be fetched. Date in YYYY-mm-dd format
* @param {Number} pageNumber Page number for which you want to fetch trade history
* @param {Number} pageSize How many records you want for a page
* @param {Object} opts Optional parameters
* @param {String} opts.segment Segment for which data is requested can be from the following options EQ - Equity, FO - Futures and Options, COM - Commodity, CD - Currency Derivatives MF - Mutual Funds
* @param {module:api/PostTradeApi~getTradesByDateRangeCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getTradesByDateRange(startDate, endDate, pageNumber, pageSize, opts, callback) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'startDate' is set
if (startDate === undefined || startDate === null) {
throw new Error("Missing the required parameter 'startDate' when calling getTradesByDateRange");
}
// verify the required parameter 'endDate' is set
if (endDate === undefined || endDate === null) {
throw new Error("Missing the required parameter 'endDate' when calling getTradesByDateRange");
}
// verify the required parameter 'pageNumber' is set
if (pageNumber === undefined || pageNumber === null) {
throw new Error("Missing the required parameter 'pageNumber' when calling getTradesByDateRange");
}
// verify the required parameter 'pageSize' is set
if (pageSize === undefined || pageSize === null) {
throw new Error("Missing the required parameter 'pageSize' when calling getTradesByDateRange");
}
let pathParams = {
};
let queryParams = {
'segment': opts['segment'],'start_date': startDate,'end_date': endDate,'page_number': pageNumber,'page_size': pageSize
};
let headerParams = {
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*'];
let returnType = TradeHistoryResponse;
return this.apiClient.callApi(
'/v2/charges/historical-trades', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}