/**
 * FinFeedAPI Stock REST API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: v1
 * Contact: support@apibricks.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 *
 */


import ApiClient from "../ApiClient";
import OHLCVExchangeTimeseriesItem from '../model/OHLCVExchangeTimeseriesItem';
import OHLCVTimeseriesItem from '../model/OHLCVTimeseriesItem';
import OHLCVTimeseriesPeriod from '../model/OHLCVTimeseriesPeriod';

/**
* Ohlcv service.
* @module api/OhlcvApi
* @version v1
*/
export default class OhlcvApi {

    /**
    * Constructs a new OhlcvApi. 
    * @alias module:api/OhlcvApi
    * @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.instance;
    }


    /**
     * Callback function to receive the result of the v1OhlcvExchangeExchangeIdHistoryGet operation.
     * @callback module:api/OhlcvApi~v1OhlcvExchangeExchangeIdHistoryGetCallback
     * @param {String} error Error message, if any.
     * @param {Array.<module:model/OHLCVExchangeTimeseriesItem>} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Historical data by exchange
     * Get OHLCV timeseries data returned in time ascending order. Data can be requested by the period and for the specific exchange.
     * @param {String} exchangeId Exchange identifier of requested timeseries (from the Metadata -> Exchanges)
     * @param {String} periodId Identifier of requested timeseries period (e.g. `5SEC` or `1DAY`)
     * @param {String} timeStart Timeseries starting time in ISO 8601
     * @param {String} timeEnd Timeseries ending time in ISO 8601
     * @param {module:api/OhlcvApi~v1OhlcvExchangeExchangeIdHistoryGetCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link Array.<module:model/OHLCVExchangeTimeseriesItem>}
     */
    v1OhlcvExchangeExchangeIdHistoryGet(exchangeId, periodId, timeStart, timeEnd, callback) {
      let postBody = null;
      // verify the required parameter 'exchangeId' is set
      if (exchangeId === undefined || exchangeId === null) {
        throw new Error("Missing the required parameter 'exchangeId' when calling v1OhlcvExchangeExchangeIdHistoryGet");
      }
      // verify the required parameter 'periodId' is set
      if (periodId === undefined || periodId === null) {
        throw new Error("Missing the required parameter 'periodId' when calling v1OhlcvExchangeExchangeIdHistoryGet");
      }
      // verify the required parameter 'timeStart' is set
      if (timeStart === undefined || timeStart === null) {
        throw new Error("Missing the required parameter 'timeStart' when calling v1OhlcvExchangeExchangeIdHistoryGet");
      }
      // verify the required parameter 'timeEnd' is set
      if (timeEnd === undefined || timeEnd === null) {
        throw new Error("Missing the required parameter 'timeEnd' when calling v1OhlcvExchangeExchangeIdHistoryGet");
      }

      let pathParams = {
        'exchange_id': exchangeId
      };
      let queryParams = {
        'period_id': periodId,
        'time_start': timeStart,
        'time_end': timeEnd
      };
      let headerParams = {
      };
      let formParams = {
      };

      let authNames = ['APIKey', 'JWT'];
      let contentTypes = [];
      let accepts = ['text/plain', 'application/json', 'text/json'];
      let returnType = [OHLCVExchangeTimeseriesItem];
      return this.apiClient.callApi(
        '/v1/ohlcv/exchange/{exchange_id}/history', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, null, callback
      );
    }

    /**
     * Callback function to receive the result of the v1OhlcvExchangeSymbolExchangeIdSymbolIdHistoryGet operation.
     * @callback module:api/OhlcvApi~v1OhlcvExchangeSymbolExchangeIdSymbolIdHistoryGetCallback
     * @param {String} error Error message, if any.
     * @param {Array.<module:model/OHLCVTimeseriesItem>} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Historical data
     * Get OHLCV timeseries data returned in time ascending order.
     * @param {String} exchangeId Exchange identifier of requested timeseries (from the Metadata -> Exchanges)
     * @param {String} symbolId Symbol identifier of requested timeseries (from the Metadata -> Symbols)
     * @param {String} periodId Identifier of requested timeseries period (e.g. `5SEC` or `2MTH`)
     * @param {Object} opts Optional parameters
     * @param {String} [timeStart] Timeseries starting time in ISO 8601
     * @param {String} [timeEnd] Timeseries ending time in ISO 8601
     * @param {Number} [limit = 100)] Amount of items to return (mininum is 1, maximum is 100000, default value is 100, if the parameter is used then every 100 output items are counted as one request)
     * @param {module:api/OhlcvApi~v1OhlcvExchangeSymbolExchangeIdSymbolIdHistoryGetCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link Array.<module:model/OHLCVTimeseriesItem>}
     */
    v1OhlcvExchangeSymbolExchangeIdSymbolIdHistoryGet(exchangeId, symbolId, periodId, opts, callback) {
      opts = opts || {};
      let postBody = null;
      // verify the required parameter 'exchangeId' is set
      if (exchangeId === undefined || exchangeId === null) {
        throw new Error("Missing the required parameter 'exchangeId' when calling v1OhlcvExchangeSymbolExchangeIdSymbolIdHistoryGet");
      }
      // verify the required parameter 'symbolId' is set
      if (symbolId === undefined || symbolId === null) {
        throw new Error("Missing the required parameter 'symbolId' when calling v1OhlcvExchangeSymbolExchangeIdSymbolIdHistoryGet");
      }
      // verify the required parameter 'periodId' is set
      if (periodId === undefined || periodId === null) {
        throw new Error("Missing the required parameter 'periodId' when calling v1OhlcvExchangeSymbolExchangeIdSymbolIdHistoryGet");
      }

      let pathParams = {
        'exchange_id': exchangeId,
        'symbol_id': symbolId
      };
      let queryParams = {
        'period_id': periodId,
        'time_start': opts['timeStart'],
        'time_end': opts['timeEnd'],
        'limit': opts['limit']
      };
      let headerParams = {
      };
      let formParams = {
      };

      let authNames = ['APIKey', 'JWT'];
      let contentTypes = [];
      let accepts = ['text/plain', 'application/json', 'text/json'];
      let returnType = [OHLCVTimeseriesItem];
      return this.apiClient.callApi(
        '/v1/ohlcv/exchange-symbol/{exchange_id}/{symbol_id}/history', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, null, callback
      );
    }

    /**
     * Callback function to receive the result of the v1OhlcvExchangeSymbolExchangeIdSymbolIdLatestGet operation.
     * @callback module:api/OhlcvApi~v1OhlcvExchangeSymbolExchangeIdSymbolIdLatestGetCallback
     * @param {String} error Error message, if any.
     * @param {Array.<module:model/OHLCVTimeseriesItem>} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Latest data
     * Get OHLCV latest timeseries data returned in time descending order. Data can be requested by the period and for the specific symbol eg `BITSTAMP_SPOT_BTC_USD`, if you need to query timeseries by asset pairs eg. `BTC/USD`, then please reffer to the Exchange Rates Timeseries data              :::info OHLCV Latest endpoint is just the shortcut to the OHLCV Historical endpoint with substituted `time_start` and `time_end` parameters.  The OHLCV Historical endpoint data can be delayed a few seconds. Use OHLCV real-time data stream to get data without delay. :::
     * @param {String} exchangeId Exchange identifier of requested timeseries (from the Metadata -> Exchanges)
     * @param {String} symbolId Symbol identifier of requested timeseries (from the Metadata -> Symbols)
     * @param {String} periodId Identifier of requested timeseries period (e.g. `5SEC` or `2MTH`)
     * @param {Object} opts Optional parameters
     * @param {Number} [limit = 100)] Amount of items to return (mininum is 1, maximum is 100000, default value is 100, if the parameter is used then every 100 output items are counted as one request)
     * @param {module:api/OhlcvApi~v1OhlcvExchangeSymbolExchangeIdSymbolIdLatestGetCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link Array.<module:model/OHLCVTimeseriesItem>}
     */
    v1OhlcvExchangeSymbolExchangeIdSymbolIdLatestGet(exchangeId, symbolId, periodId, opts, callback) {
      opts = opts || {};
      let postBody = null;
      // verify the required parameter 'exchangeId' is set
      if (exchangeId === undefined || exchangeId === null) {
        throw new Error("Missing the required parameter 'exchangeId' when calling v1OhlcvExchangeSymbolExchangeIdSymbolIdLatestGet");
      }
      // verify the required parameter 'symbolId' is set
      if (symbolId === undefined || symbolId === null) {
        throw new Error("Missing the required parameter 'symbolId' when calling v1OhlcvExchangeSymbolExchangeIdSymbolIdLatestGet");
      }
      // verify the required parameter 'periodId' is set
      if (periodId === undefined || periodId === null) {
        throw new Error("Missing the required parameter 'periodId' when calling v1OhlcvExchangeSymbolExchangeIdSymbolIdLatestGet");
      }

      let pathParams = {
        'exchange_id': exchangeId,
        'symbol_id': symbolId
      };
      let queryParams = {
        'period_id': periodId,
        'limit': opts['limit']
      };
      let headerParams = {
      };
      let formParams = {
      };

      let authNames = ['APIKey', 'JWT'];
      let contentTypes = [];
      let accepts = ['text/plain', 'application/json', 'text/json'];
      let returnType = [OHLCVTimeseriesItem];
      return this.apiClient.callApi(
        '/v1/ohlcv/exchange-symbol/{exchange_id}/{symbol_id}/latest', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, null, callback
      );
    }

    /**
     * Callback function to receive the result of the v1OhlcvPeriodsGet operation.
     * @callback module:api/OhlcvApi~v1OhlcvPeriodsGetCallback
     * @param {String} error Error message, if any.
     * @param {Array.<module:model/OHLCVTimeseriesPeriod>} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * List all periods
     * Get full list of supported time periods available for requesting OHLCV timeseries data.              ### Available periods              Time unit | Period identifiers --------- | ----------- Second | 1SEC, 2SEC, 3SEC, 4SEC, 5SEC, 6SEC, 10SEC, 15SEC, 20SEC, 30SEC Minute | 1MIN, 2MIN, 3MIN, 4MIN, 5MIN, 6MIN, 10MIN, 15MIN, 20MIN, 30MIN Hour | 1HRS, 2HRS, 3HRS, 4HRS, 6HRS, 8HRS, 12HRS Day | 1DAY, 2DAY, 3DAY, 5DAY, 7DAY, 10DAY Month | 1MTH, 2MTH, 3MTH, 4MTH, 6MTH Year | 1YRS, 2YRS, 3YRS, 4YRS, 5YRS              :::tip You can assume that we will not remove any periods from this response, however, we may add new ones. :::
     * @param {module:api/OhlcvApi~v1OhlcvPeriodsGetCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link Array.<module:model/OHLCVTimeseriesPeriod>}
     */
    v1OhlcvPeriodsGet(callback) {
      let postBody = null;

      let pathParams = {
      };
      let queryParams = {
      };
      let headerParams = {
      };
      let formParams = {
      };

      let authNames = ['APIKey', 'JWT'];
      let contentTypes = [];
      let accepts = ['text/plain', 'application/json', 'text/json'];
      let returnType = [OHLCVTimeseriesPeriod];
      return this.apiClient.callApi(
        '/v1/ohlcv/periods', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, null, callback
      );
    }


}
