upstox-js-sdk
Version:
The official Node Js client for communicating with the Upstox API
532 lines (470 loc) • 21.3 kB
JavaScript
/*
* Upstox Developer API
* Build your App on the Upstox platform  # Introduction Upstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection. All requests are over HTTPS and the requests are sent with the content-type ‘application/json’. Developers have the option of choosing the response type as JSON or CSV for a few API calls. To be able to use these APIs you need to create an App in the Developer Console and generate your **apiKey** and **apiSecret**. You can use a redirect URL which will be called after the login flow. If you are a **trader**, you can directly create apps from Upstox mobile app or the desktop platform itself from **Apps** sections inside the **Account** Tab. Head over to <a href=\"http://account.upstox.com/developer/apps\" target=\"_blank\">account.upstox.com/developer/apps</a>.</br> If you are a **business** looking to integrate Upstox APIs, reach out to us and we will get a custom app created for you in no time. It is highly recommended that you do not embed the **apiSecret** in your frontend app. Create a remote backend which does the handshake on behalf of the frontend app. Marking the apiSecret in the frontend app will make your app vulnerable to threats and potential issues.
*
* OpenAPI spec version: v2
*
* 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.46
*
* Do not edit the class manually.
*
*/
import {ApiClient} from "../ApiClient";
import {ApiGatewayErrorResponse} from '../model/ApiGatewayErrorResponse';
import {InitiatePayoutRequest} from '../model/InitiatePayoutRequest';
import {ModifyPayoutRequest} from '../model/ModifyPayoutRequest';
import {PayoutDetailsResponse} from '../model/PayoutDetailsResponse';
import {PayoutModesResponse} from '../model/PayoutModesResponse';
import {GetProfileResponse} from '../model/GetProfileResponse';
import {GetUserFundMarginResponse} from '../model/GetUserFundMarginResponse';
import {GetUserFundMarginV3Response} from '../model/GetUserFundMarginV3Response';
import {KillSwitchResponse} from '../model/KillSwitchResponse';
import {PaymentHistoryResponse} from '../model/PaymentHistoryResponse';
import {UpdateUserIpRequest} from '../model/UpdateUserIpRequest';
import {UserIpResponse} from '../model/UserIpResponse';
/**
* User service.
* @module api/UserApi
* @version v2
*/
export class UserApi {
/**
* Constructs a new UserApi.
* @alias module:api/UserApi
* @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 getProfile operation.
* @callback moduleapi/UserApi~getProfileCallback
* @param {String} error Error message, if any.
* @param {module:model/GetProfileResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get profile
* This API allows to fetch the complete information of the user who is logged in including the products, order types and exchanges enabled for the user
* @param {String} apiVersion API Version Header
* @param {module:api/UserApi~getProfileCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getProfile(apiVersion, callback) {
let postBody = null;
// verify the required parameter 'apiVersion' is set
if (apiVersion === undefined || apiVersion === null) {
throw new Error("Missing the required parameter 'apiVersion' when calling getProfile");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
'Api-Version': apiVersion
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = GetProfileResponse;
return this.apiClient.callApi(
'/v2/user/profile', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getUserFundMargin operation.
* @callback moduleapi/UserApi~getUserFundMarginCallback
* @param {String} error Error message, if any.
* @param {module:model/GetUserFundMarginResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get User Fund And Margin
* Shows the balance of the user in equity and commodity market.
* @param {String} apiVersion API Version Header
* @param {Object} opts Optional parameters
* @param {module:model/String} opts.segment
* @param {module:api/UserApi~getUserFundMarginCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getUserFundMargin(apiVersion, opts, callback) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'apiVersion' is set
if (apiVersion === undefined || apiVersion === null) {
throw new Error("Missing the required parameter 'apiVersion' when calling getUserFundMargin");
}
let pathParams = {
};
let queryParams = {
'segment': opts['segment']
};
let headerParams = {
'Api-Version': apiVersion
};
let formParams = {
};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['application/json', '*/*'];
let returnType = GetUserFundMarginResponse;
return this.apiClient.callApi(
'/v2/user/get-funds-and-margin', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getKillSwitch operation.
* @callback moduleapi/UserApi~getKillSwitchCallback
* @param {String} error Error message, if any.
* @param {module:model/KillSwitchResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get kill switch status
* Returns the disable/enable status of all trading segments for the user.
* @param {module:api/UserApi~getKillSwitchCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/KillSwitchResponse}
*/
getKillSwitch(callback) {
let postBody = null;
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = KillSwitchResponse;
return this.apiClient.callApi(
'/v2/user/kill-switch', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getPayinHistory operation.
* @callback moduleapi/UserApi~getPayinHistoryCallback
* @param {String} error Error message, if any.
* @param {module:model/PaymentHistoryResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* @param {module:api/UserApi~getPayinHistoryCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getPayinHistory(callback) {
let postBody = null;
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*'];
let returnType = PaymentHistoryResponse;
return this.apiClient.callApi(
'/v2/user/payments/payin', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getPayoutHistory operation.
* @callback moduleapi/UserApi~getPayoutHistoryCallback
* @param {String} error Error message, if any.
* @param {module:model/PaymentHistoryResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* @param {module:api/UserApi~getPayoutHistoryCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getPayoutHistory(callback) {
let postBody = null;
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*'];
let returnType = PaymentHistoryResponse;
return this.apiClient.callApi(
'/v2/user/payments/payout', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the initiatePayout operation.
* @callback moduleapi/UserApi~initiatePayoutCallback
* @param {String} error Error message, if any.
* @param {module:model/PayoutDetailsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Initiate a payout request.
* @param {module:model/InitiatePayoutRequest} body
* @param {module:api/UserApi~initiatePayoutCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
initiatePayout(body, callback) {
let postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling initiatePayout");
}
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = ['application/json'];
let accepts = ['*/*'];
let returnType = PayoutDetailsResponse;
return this.apiClient.callApi(
'/v2/user/payments/payout', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getPayoutModes operation.
* @callback moduleapi/UserApi~getPayoutModesCallback
* @param {String} error Error message, if any.
* @param {module:model/PayoutModesResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get the available payout modes for the user.
* @param {module:api/UserApi~getPayoutModesCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getPayoutModes(callback) {
let postBody = null;
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*'];
let returnType = PayoutModesResponse;
return this.apiClient.callApi(
'/v2/user/payments/payout/modes', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the modifyPayout operation.
* @callback moduleapi/UserApi~modifyPayoutCallback
* @param {String} error Error message, if any.
* @param {module:model/PayoutDetailsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Modify an existing payout request.
* @param {module:model/ModifyPayoutRequest} body
* @param {Object} transactionId Payout transaction id
* @param {module:api/UserApi~modifyPayoutCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
modifyPayout(body, transactionId, callback) {
let postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling modifyPayout");
}
// verify the required parameter 'transactionId' is set
if (transactionId === undefined || transactionId === null) {
throw new Error("Missing the required parameter 'transactionId' when calling modifyPayout");
}
let pathParams = {
'transaction_id': transactionId
};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = ['application/json'];
let accepts = ['*/*'];
let returnType = PayoutDetailsResponse;
return this.apiClient.callApi(
'/v2/user/payments/payout/{transaction_id}', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the cancelPayout operation.
* @callback moduleapi/UserApi~cancelPayoutCallback
* @param {String} error Error message, if any.
* @param {module:model/PayoutDetailsResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Cancel an existing payout request.
* @param {Object} transactionId Payout transaction id
* @param {module:api/UserApi~cancelPayoutCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
cancelPayout(transactionId, callback) {
let postBody = null;
// verify the required parameter 'transactionId' is set
if (transactionId === undefined || transactionId === null) {
throw new Error("Missing the required parameter 'transactionId' when calling cancelPayout");
}
let pathParams = {
'transaction_id': transactionId
};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*'];
let returnType = PayoutDetailsResponse;
return this.apiClient.callApi(
'/v2/user/payments/payout/{transaction_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getUserFundMarginV3 operation.
* @callback moduleapi/UserApi~getUserFundMarginV3Callback
* @param {String} error Error message, if any.
* @param {module:model/GetUserFundMarginV3Response} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get User Fund And Margin (v3)
* Shows the detailed balance breakdown of the user including cash, pledged margin, available-to-trade, and unavailable-to-trade components.
* @param {module:api/UserApi~getUserFundMarginV3Callback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/GetUserFundMarginV3Response}
*/
getUserFundMarginV3(callback) {
let postBody = null;
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = GetUserFundMarginV3Response;
return this.apiClient.callApi(
'/v3/user/get-funds-and-margin', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getUserIps operation.
* @callback moduleapi/UserApi~getUserIpsCallback
* @param {String} error Error message, if any.
* @param {module:model/UserIpResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get whitelisted IPs for the user.
* @param {module:api/UserApi~getUserIpsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/UserIpResponse}
*/
getUserIps(callback) {
let postBody = null;
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*'];
let returnType = UserIpResponse;
return this.apiClient.callApi(
'/v2/user/ip', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the updateKillSwitch operation.
* @callback moduleapi/UserApi~updateKillSwitchCallback
* @param {String} error Error message, if any.
* @param {module:model/KillSwitchResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Update kill switch
* Enable or disable specific trading segments.
* @param {Object} body
* @param {module:api/UserApi~updateKillSwitchCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/KillSwitchResponse}
*/
updateKillSwitch(body, callback) {
let postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling updateKillSwitch");
}
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = ['application/json'];
let accepts = ['*/*', 'application/json'];
let returnType = KillSwitchResponse;
return this.apiClient.callApi(
'/v2/user/kill-switch', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the updateUserIp operation.
* @callback moduleapi/UserApi~updateUserIpCallback
* @param {String} error Error message, if any.
* @param {module:model/UserIpResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Update whitelisted IPs for the user.
* @param {module:model/UpdateUserIpRequest} body
* @param {module:api/UserApi~updateUserIpCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/UserIpResponse}
*/
updateUserIp(body, callback) {
let postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling updateUserIp");
}
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = ['application/json'];
let accepts = ['*/*'];
let returnType = UserIpResponse;
return this.apiClient.callApi(
'/v2/user/ip', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}