/**
 * Exchange Rates Historical 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 V1ExchangeRate from '../model/V1ExchangeRate';
import V1ExchangeRates from '../model/V1ExchangeRates';
import V1ExchangeRatesTimeseriesItem from '../model/V1ExchangeRatesTimeseriesItem';
import V1TimeseriesPeriod from '../model/V1TimeseriesPeriod';

/**
* ExchangeRates service.
* @module api/ExchangeRatesApi
* @version v1
*/
export default class ExchangeRatesApi {

    /**
    * Constructs a new ExchangeRatesApi. 
    * @alias module:api/ExchangeRatesApi
    * @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 getSpecificRate operation.
     * @callback module:api/ExchangeRatesApi~getSpecificRateCallback
     * @param {String} error Error message, if any.
     * @param {module:model/V1ExchangeRate} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Get specific rate
     * Retrieves the exchange rate for a specific base and quote asset at a given time or the current rate.              :::info If you are using an exchange rate for mission-critical operations, then for best reliability, you should measure the difference between current time and the time returned from the response to ensure that value of the difference between those meets your internal requirements. :::
     * @param {String} assetIdBase Requested exchange rate base asset identifier (from the Metadata -> Assets)
     * @param {String} assetIdQuote Requested exchange rate quote asset identifier (from the Metadata -> Assets)
     * @param {Object} opts Optional parameters
     * @param {String} [time] Time at which exchange rate is calculated (optional, if not supplied then current rate is returned)
     * @param {module:api/ExchangeRatesApi~getSpecificRateCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:model/V1ExchangeRate}
     */
    getSpecificRate(assetIdBase, assetIdQuote, opts, callback) {
      opts = opts || {};
      let postBody = null;
      // verify the required parameter 'assetIdBase' is set
      if (assetIdBase === undefined || assetIdBase === null) {
        throw new Error("Missing the required parameter 'assetIdBase' when calling getSpecificRate");
      }
      // verify the required parameter 'assetIdQuote' is set
      if (assetIdQuote === undefined || assetIdQuote === null) {
        throw new Error("Missing the required parameter 'assetIdQuote' when calling getSpecificRate");
      }

      let pathParams = {
        'asset_id_base': assetIdBase,
        'asset_id_quote': assetIdQuote
      };
      let queryParams = {
        'time': opts['time']
      };
      let headerParams = {
      };
      let formParams = {
      };

      let authNames = ['APIKey'];
      let contentTypes = [];
      let accepts = ['text/plain', 'application/json', 'text/json'];
      let returnType = V1ExchangeRate;
      return this.apiClient.callApi(
        '/v1/exchangerate/{asset_id_base}/{asset_id_quote}', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, null, callback
      );
    }

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

    /**
     * Timeseries data
     * Get the historical exchange rates between two assets in the form of the timeseries.
     * @param {String} assetIdBase Requested exchange rates base asset identifier (from the Metadata -> Assets)
     * @param {String} assetIdQuote Requested exchange rates base asset identifier (from the Metadata -> Assets)
     * @param {Object} opts Optional parameters
     * @param {String} [periodId] Identifier of requested timeseries period (required, e.g. `5SEC` or `1HRS`)
     * @param {String} [timeStart] Timeseries starting time in ISO 8601 (required)
     * @param {String} [timeEnd] Timeseries ending time in ISO 8601 (required)
     * @param {Number} [limit = 100)] Amount of items to return (optional, 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/ExchangeRatesApi~v1ExchangerateAssetIdBaseAssetIdQuoteHistoryGetCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link Array.<module:model/V1ExchangeRatesTimeseriesItem>}
     */
    v1ExchangerateAssetIdBaseAssetIdQuoteHistoryGet(assetIdBase, assetIdQuote, opts, callback) {
      opts = opts || {};
      let postBody = null;
      // verify the required parameter 'assetIdBase' is set
      if (assetIdBase === undefined || assetIdBase === null) {
        throw new Error("Missing the required parameter 'assetIdBase' when calling v1ExchangerateAssetIdBaseAssetIdQuoteHistoryGet");
      }
      // verify the required parameter 'assetIdQuote' is set
      if (assetIdQuote === undefined || assetIdQuote === null) {
        throw new Error("Missing the required parameter 'assetIdQuote' when calling v1ExchangerateAssetIdBaseAssetIdQuoteHistoryGet");
      }

      let pathParams = {
        'asset_id_base': assetIdBase,
        'asset_id_quote': assetIdQuote
      };
      let queryParams = {
        'period_id': opts['periodId'],
        'time_start': opts['timeStart'],
        'time_end': opts['timeEnd'],
        'limit': opts['limit']
      };
      let headerParams = {
      };
      let formParams = {
      };

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

    /**
     * Callback function to receive the result of the v1ExchangerateAssetIdBaseGet operation.
     * @callback module:api/ExchangeRatesApi~v1ExchangerateAssetIdBaseGetCallback
     * @param {String} error Error message, if any.
     * @param {module:model/V1ExchangeRates} data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Get all current rates
     * Get the current exchange rate between requested asset and all other assets.              :::info If you are using an exchange rate for mission-critical operations, then for best reliability, you should measure the difference between current time and the time returned from the response to ensure that value of the difference between those meets your internal requirements. :::              :::info You can invert the rates by using Y = 1 / X equation, for example BTC/USD = 1 / (USD/BTC); :::
     * @param {String} assetIdBase Requested exchange rates base asset identifier (from the Metadata -> Assets)
     * @param {Object} opts Optional parameters
     * @param {String} [filterAssetId] Comma or semicolon delimited asset identifiers used to filter response (optional)
     * @param {Boolean} [invert = false)] True will invert all the rates (optional, if true then rates will be calculated as `rate = 1 / actual_rate` eg. `USD/BTC` as `BTC/USD`)
     * @param {String} [time] Time for historical rates (optional)
     * @param {module:api/ExchangeRatesApi~v1ExchangerateAssetIdBaseGetCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link module:model/V1ExchangeRates}
     */
    v1ExchangerateAssetIdBaseGet(assetIdBase, opts, callback) {
      opts = opts || {};
      let postBody = null;
      // verify the required parameter 'assetIdBase' is set
      if (assetIdBase === undefined || assetIdBase === null) {
        throw new Error("Missing the required parameter 'assetIdBase' when calling v1ExchangerateAssetIdBaseGet");
      }

      let pathParams = {
        'asset_id_base': assetIdBase
      };
      let queryParams = {
        'filter_asset_id': opts['filterAssetId'],
        'invert': opts['invert'],
        'time': opts['time']
      };
      let headerParams = {
      };
      let formParams = {
      };

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

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

    /**
     * Timeseries periods
     * You can also obtain historical exchange rates of any asset pair, grouped into time periods. Get full list of supported time periods available for requesting exchange rates historical timeseries data.              ## Timeseries 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
     * @param {module:api/ExchangeRatesApi~v1ExchangerateHistoryPeriodsGetCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link Array.<module:model/V1TimeseriesPeriod>}
     */
    v1ExchangerateHistoryPeriodsGet(callback) {
      let postBody = null;

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

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


}
