upstox-js-sdk
Version:
The official Node Js client for communicating with the Upstox API
121 lines (116 loc) • 4.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.OptionsApi = void 0;
var _ApiClient = require("../ApiClient");
var _ApiGatewayErrorResponse = require("../model/ApiGatewayErrorResponse");
var _GetOptionChainResponse = require("../model/GetOptionChainResponse");
var _GetOptionContractResponse = require("../model/GetOptionContractResponse");
/*
* 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.
*
*/
/**
* Options service.
* @module api/OptionsApi
* @version v0
*/
class OptionsApi {
/**
* Constructs a new OptionsApi.
* @alias module:api/OptionsApi
* @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 getOptionContracts operation.
* @callback moduleapi/OptionsApi~getOptionContractsCallback
* @param {String} error Error message, if any.
* @param {module:model/GetOptionContractResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get option contracts
* This API provides the functionality to retrieve the option contracts
* @param {String} instrumentKey Instrument key for an underlying symbol
* @param {Object} opts Optional parameters
* @param {String} opts.expiryDate Expiry date in format: YYYY-mm-dd
* @param {module:api/OptionsApi~getOptionContractsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getOptionContracts(instrumentKey, opts, callback) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'instrumentKey' is set
if (instrumentKey === undefined || instrumentKey === null) {
throw new Error("Missing the required parameter 'instrumentKey' when calling getOptionContracts");
}
let pathParams = {};
let queryParams = {
'instrument_key': instrumentKey,
'expiry_date': opts['expiryDate']
};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['application/json', '*/*'];
let returnType = _GetOptionContractResponse.GetOptionContractResponse;
return this.apiClient.callApi('/v2/option/contract', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback);
}
/**
* Callback function to receive the result of the getPutCallOptionChain operation.
* @callback moduleapi/OptionsApi~getPutCallOptionChainCallback
* @param {String} error Error message, if any.
* @param {module:model/GetOptionChainResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get option chain
* This API provides the functionality to retrieve the option chain
* @param {String} instrumentKey Instrument key for an underlying symbol
* @param {String} expiryDate Expiry date in format: YYYY-mm-dd
* @param {module:api/OptionsApi~getPutCallOptionChainCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getPutCallOptionChain(instrumentKey, expiryDate, callback) {
let postBody = null;
// verify the required parameter 'instrumentKey' is set
if (instrumentKey === undefined || instrumentKey === null) {
throw new Error("Missing the required parameter 'instrumentKey' when calling getPutCallOptionChain");
}
// verify the required parameter 'expiryDate' is set
if (expiryDate === undefined || expiryDate === null) {
throw new Error("Missing the required parameter 'expiryDate' when calling getPutCallOptionChain");
}
let pathParams = {};
let queryParams = {
'instrument_key': instrumentKey,
'expiry_date': expiryDate
};
let headerParams = {};
let formParams = {};
let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['application/json', '*/*'];
let returnType = _GetOptionChainResponse.GetOptionChainResponse;
return this.apiClient.callApi('/v2/option/chain', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback);
}
}
exports.OptionsApi = OptionsApi;