@factset/sdk-factsetglobalprices
Version:
FactSet Global Prices client library for JavaScript
280 lines (266 loc) • 12.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.GetSecurityPricesForListMarketValResponseWrapper = exports.GetGPDMarketValResponseWrapper = void 0;
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
var _BatchStatusResponse = _interopRequireDefault(require("../model/BatchStatusResponse"));
var _ErrorResponse = _interopRequireDefault(require("../model/ErrorResponse"));
var _MarketValueRequest = _interopRequireDefault(require("../model/MarketValueRequest"));
var _MarketValueResponse = _interopRequireDefault(require("../model/MarketValueResponse"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* FactSet Global Prices API
* The FactSet Global Prices API provides end of day market pricing content using cloud and microservices technology, encompassing both pricing as well as corporate actions and events data.</p>
*
* The version of the OpenAPI document: 1.11.0
* Contact: api@factset.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
*/
/**
* MarketValue service.
* @module api/MarketValueApi
*/
class MarketValueApi {
/**
* Constructs a new MarketValueApi.
* @alias module:api/MarketValueApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
constructor(apiClient) {
this.apiClient = apiClient || _ApiClient.default.instance;
}
/**
* Provides the current market value for a list of specified securities.
* Provides the current market value (in USD millions) for a list of specified securities.
* @param {Array.<String>} ids The requested list of security identifiers. Accepted ID types include Market Tickers, SEDOL, ISINs, CUSIPs, or FactSet Permanent IDs.<p>***IDs limit** = 50 per non-batch request and 400 per batch request*</p> *<p>Make note, GET Method URL request lines are also limited to a total length of 8192 bytes (8KB). In cases where the service allows for thousands of IDs, which may lead to exceeding this request line limit of 8KB, it's advised for any requests with large request lines to be requested through the respective \"POST\" method.</p>*
* @param {Object} opts Optional parameters
* @param {module:model/String} opts.batch Enables the ability to asynchronously \"batch\" the request, supporting a long-running request for up to 20 minutes. Upon requesting batch=Y, the service will respond with an HTTP Status Code of 202. Once a batch request is submitted, use batch status to see if the job has been completed. Once completed, retrieve the results of the request via batch-result. For single-day requests, the IDs limit is 500 for non-batch and 2000 for batch. For multi-day requests, the limit is 50 IDs for both batch and non-batch. Limits on query string via GET method still apply. It's advised to submit large lists of IDs via POST method. <B>Please note that the number of unique currencies present in the requested IDs is limited to 50 per request.</B> (default to 'N')
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/MarketValueResponse} and HTTP response
*/
getGPDMarketValWithHttpInfo(ids, opts) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'ids' is set
if (ids === undefined || ids === null) {
throw new Error("Missing the required parameter 'ids' when calling getGPDMarketVal");
}
let pathParams = {};
let queryParams = {
'ids': this.apiClient.buildCollectionParam(ids, 'csv'),
'batch': opts['batch']
};
let headerParams = {};
let formParams = {};
let authNames = ['FactSetApiKey', 'FactSetOAuth2'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = GetGPDMarketValResponseWrapperTypeMap;
return this.apiClient.callApi('/factset-global-prices/v1/market-value', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Provides the current market value for a list of specified securities.
* Provides the current market value (in USD millions) for a list of specified securities.
* @param {Array.<String>} ids The requested list of security identifiers. Accepted ID types include Market Tickers, SEDOL, ISINs, CUSIPs, or FactSet Permanent IDs.<p>***IDs limit** = 50 per non-batch request and 400 per batch request*</p> *<p>Make note, GET Method URL request lines are also limited to a total length of 8192 bytes (8KB). In cases where the service allows for thousands of IDs, which may lead to exceeding this request line limit of 8KB, it's advised for any requests with large request lines to be requested through the respective \"POST\" method.</p>*
* @param {Object} opts Optional parameters
* @param {module:model/String} opts.batch Enables the ability to asynchronously \"batch\" the request, supporting a long-running request for up to 20 minutes. Upon requesting batch=Y, the service will respond with an HTTP Status Code of 202. Once a batch request is submitted, use batch status to see if the job has been completed. Once completed, retrieve the results of the request via batch-result. For single-day requests, the IDs limit is 500 for non-batch and 2000 for batch. For multi-day requests, the limit is 50 IDs for both batch and non-batch. Limits on query string via GET method still apply. It's advised to submit large lists of IDs via POST method. <B>Please note that the number of unique currencies present in the requested IDs is limited to 50 per request.</B> (default to 'N')
* @return { Promise.< GetGPDMarketValResponseWrapper > } a Promise, with data of type {@link GetGPDMarketValResponseWrapper }
*/
getGPDMarketVal(ids, opts) {
return this.getGPDMarketValWithHttpInfo(ids, opts).then(function (response_and_data) {
return response_and_data.data;
});
}
/**
* Requests the current market value for a list of specified securities.
* Provides the current market value (in USD millions) for a list of specified securities.
* @param {module:model/MarketValueRequest} marketValueRequest Request object for `Market Value`.
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/MarketValueResponse} and HTTP response
*/
getSecurityPricesForListMarketValWithHttpInfo(marketValueRequest) {
let postBody = marketValueRequest;
// verify the required parameter 'marketValueRequest' is set
if (marketValueRequest === undefined || marketValueRequest === null) {
throw new Error("Missing the required parameter 'marketValueRequest' when calling getSecurityPricesForListMarketVal");
}
let pathParams = {};
let queryParams = {};
let headerParams = {};
let formParams = {};
let authNames = ['FactSetApiKey', 'FactSetOAuth2'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = GetSecurityPricesForListMarketValResponseWrapperTypeMap;
return this.apiClient.callApi('/factset-global-prices/v1/market-value', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null);
}
/**
* Requests the current market value for a list of specified securities.
* Provides the current market value (in USD millions) for a list of specified securities.
* @param {module:model/MarketValueRequest} marketValueRequest Request object for `Market Value`.
* @return { Promise.< GetSecurityPricesForListMarketValResponseWrapper > } a Promise, with data of type {@link GetSecurityPricesForListMarketValResponseWrapper }
*/
getSecurityPricesForListMarketVal(marketValueRequest) {
return this.getSecurityPricesForListMarketValWithHttpInfo(marketValueRequest).then(function (response_and_data) {
return response_and_data.data;
});
}
}
exports.default = MarketValueApi;
const GetGPDMarketValResponseWrapperTypeMap = {
200: _MarketValueResponse.default,
202: _BatchStatusResponse.default,
400: _ErrorResponse.default,
401: _ErrorResponse.default,
403: _ErrorResponse.default,
415: _ErrorResponse.default,
500: _ErrorResponse.default,
_createResponseWrapper(statusCode, response) {
return new GetGPDMarketValResponseWrapper(statusCode, response);
}
};
const GetSecurityPricesForListMarketValResponseWrapperTypeMap = {
200: _MarketValueResponse.default,
202: _BatchStatusResponse.default,
400: _ErrorResponse.default,
401: _ErrorResponse.default,
403: _ErrorResponse.default,
415: _ErrorResponse.default,
500: _ErrorResponse.default,
_createResponseWrapper(statusCode, response) {
return new GetSecurityPricesForListMarketValResponseWrapper(statusCode, response);
}
};
/**
* Wrapper to support GET /factset-global-prices/v1/market-value returning different types
* per status code.
*
* <p>
* Responses:
* <ul>
* <li>200 : {@code MarketValueResponse }<br>Array of Price Objects</li>
*
* <li>202 : {@code BatchStatusResponse }<br>Batch request has been accepted.</li>
* </ul>
*
* </p>
* Example:
* <pre>{@code
* const response = ...;
* switch (response.statusCode) {
* case 200:
* MarketValueResponse data200 = response.getResponse200();
* break;
* case 202:
* BatchStatusResponse data202 = response.getResponse202();
* break;
* }
* }</pre>
*
* @alias module:GetGPDMarketValResponseWrapper
* @class
*/
class GetGPDMarketValResponseWrapper {
/**
* @param {number} statusCode
* @param {*} response
*/
constructor(statusCode, response) {
/**
* @type {number}
*/
this.statusCode = statusCode;
/**
* @type {*}
*/
this.response = response;
}
/**
* @returns { MarketValueResponse }
*/
getResponse200() {
if (this.statusCode !== 200) {
throw new Error("Invalid response getter called. getResponse200 can't return a " + this.statusCode + " response");
}
return this.response;
}
/**
* @returns { BatchStatusResponse }
*/
getResponse202() {
if (this.statusCode !== 202) {
throw new Error("Invalid response getter called. getResponse202 can't return a " + this.statusCode + " response");
}
return this.response;
}
}
/**
* Wrapper to support POST /factset-global-prices/v1/market-value returning different types
* per status code.
*
* <p>
* Responses:
* <ul>
* <li>200 : {@code MarketValueResponse }<br>Market Value Response</li>
*
* <li>202 : {@code BatchStatusResponse }<br>Batch request has been accepted.</li>
* </ul>
*
* </p>
* Example:
* <pre>{@code
* const response = ...;
* switch (response.statusCode) {
* case 200:
* MarketValueResponse data200 = response.getResponse200();
* break;
* case 202:
* BatchStatusResponse data202 = response.getResponse202();
* break;
* }
* }</pre>
*
* @alias module:GetSecurityPricesForListMarketValResponseWrapper
* @class
*/
exports.GetGPDMarketValResponseWrapper = GetGPDMarketValResponseWrapper;
class GetSecurityPricesForListMarketValResponseWrapper {
/**
* @param {number} statusCode
* @param {*} response
*/
constructor(statusCode, response) {
/**
* @type {number}
*/
this.statusCode = statusCode;
/**
* @type {*}
*/
this.response = response;
}
/**
* @returns { MarketValueResponse }
*/
getResponse200() {
if (this.statusCode !== 200) {
throw new Error("Invalid response getter called. getResponse200 can't return a " + this.statusCode + " response");
}
return this.response;
}
/**
* @returns { BatchStatusResponse }
*/
getResponse202() {
if (this.statusCode !== 202) {
throw new Error("Invalid response getter called. getResponse202 can't return a " + this.statusCode + " response");
}
return this.response;
}
}
exports.GetSecurityPricesForListMarketValResponseWrapper = GetSecurityPricesForListMarketValResponseWrapper;