/**
 * @fileoverview AUTOMATICALLY GENERATED service for API.Client.OhlcvApi.
 * Do not edit this file by hand or your changes will be lost next time it is
 * generated.
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 * Version: v1
* Generator version: 7.14.0
 * Generated by: org.openapitools.codegen.languages.JavascriptClosureAngularClientCodegen
 */
/**
 * @license MIT License
 * https://github.com/api-bricks/api-bricks-sdk/blob/master/LICENSE
 */

goog.provide('API.Client.OhlcvApi');

goog.require('API.Client.Models.ExchangeTimeseriesItem');
goog.require('API.Client.v1.TimeseriesItem');
goog.require('API.Client.v1.TimeseriesPeriod');

/**
 * @constructor
 * @param {!angular.$http} $http
 * @param {!Object} $httpParamSerializer
 * @param {!angular.$injector} $injector
 * @struct
 */
API.Client.OhlcvApi = function($http, $httpParamSerializer, $injector) {
  /** @private {!string} */
  this.basePath_ = $injector.has('OhlcvApiBasePath') ?
                   /** @type {!string} */ ($injector.get('OhlcvApiBasePath')) :
                   'https://rest.coinapi.io';

  /** @private {!Object<string, string>} */
  this.defaultHeaders_ = $injector.has('OhlcvApiDefaultHeaders') ?
                   /** @type {!Object<string, string>} */ (
                       $injector.get('OhlcvApiDefaultHeaders')) :
                   {};

  /** @private {!angular.$http} */
  this.http_ = $http;

  /** @package {!Object} */
  this.httpParamSerializer = $injector.get('$httpParamSerializer');
}
API.Client.OhlcvApi.$inject = ['$http', '$httpParamSerializer', '$injector'];

/**
 * 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 eg &#x60;BITSTAMP&#x60;              :::info The OHLCV Historical endpoint data can be delayed a few seconds. Use OHLCV real-time data stream to get data without delay. The difference between &#x60;time_end&#x60; and &#x60;time_start&#x60; cannot be higher than 1 day. The &#x60;period_id&#x60; cannot be higher than &#x60;1DAY&#x60;. :::
 * @param {!string} exchangeId Exchange identifier of requested timeseries (from the Metadata -&gt; Exchanges)
 * @param {!string} periodId Identifier of requested timeseries period (e.g. &#x60;5SEC&#x60; or &#x60;1DAY&#x60;)
 * @param {!string} timeStart Timeseries starting time in ISO 8601
 * @param {!string} timeEnd Timeseries ending time in ISO 8601
 * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send.
 * @return {!angular.$q.Promise<!Array<!API.Client.Models.ExchangeTimeseriesItem>>}
 */
API.Client.OhlcvApi.prototype.v1OhlcvExchangesExchangeIdHistoryGet = function(exchangeId, periodId, timeStart, timeEnd, opt_extraHttpRequestParams) {
  /** @const {string} */
  var path = this.basePath_ + '/v1/ohlcv/exchanges/{exchange_id}/history'
      .replace('{' + 'exchange_id' + '}', String(exchangeId));

  /** @type {!Object} */
  var queryParameters = {};

  /** @type {!Object} */
  var headerParams = angular.extend({}, this.defaultHeaders_);
  // verify required parameter 'exchangeId' is set
  if (!exchangeId) {
    throw new Error('Missing required parameter exchangeId when calling v1OhlcvExchangesExchangeIdHistoryGet');
  }
  // verify required parameter 'periodId' is set
  if (!periodId) {
    throw new Error('Missing required parameter periodId when calling v1OhlcvExchangesExchangeIdHistoryGet');
  }
  // verify required parameter 'timeStart' is set
  if (!timeStart) {
    throw new Error('Missing required parameter timeStart when calling v1OhlcvExchangesExchangeIdHistoryGet');
  }
  // verify required parameter 'timeEnd' is set
  if (!timeEnd) {
    throw new Error('Missing required parameter timeEnd when calling v1OhlcvExchangesExchangeIdHistoryGet');
  }
  if (periodId !== undefined) {
    queryParameters['period_id'] = periodId;
  }

  if (timeStart !== undefined) {
    queryParameters['time_start'] = timeStart;
  }

  if (timeEnd !== undefined) {
    queryParameters['time_end'] = timeEnd;
  }

  /** @type {!Object} */
  var httpRequestParams = {
    method: 'GET',
    url: path,
    json: true,
            params: queryParameters,
    headers: headerParams
  };

  if (opt_extraHttpRequestParams) {
    httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
  }

  return (/** @type {?} */ (this.http_))(httpRequestParams);
}

/**
 * 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 {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send.
 * @return {!angular.$q.Promise<!Array<!API.Client.v1.TimeseriesPeriod>>}
 */
API.Client.OhlcvApi.prototype.v1OhlcvPeriodsGet = function(opt_extraHttpRequestParams) {
  /** @const {string} */
  var path = this.basePath_ + '/v1/ohlcv/periods';

  /** @type {!Object} */
  var queryParameters = {};

  /** @type {!Object} */
  var headerParams = angular.extend({}, this.defaultHeaders_);
  /** @type {!Object} */
  var httpRequestParams = {
    method: 'GET',
    url: path,
    json: true,
            params: queryParameters,
    headers: headerParams
  };

  if (opt_extraHttpRequestParams) {
    httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
  }

  return (/** @type {?} */ (this.http_))(httpRequestParams);
}

/**
 * Historical data
 * Get OHLCV timeseries data returned in time ascending order. Data can be requested by the period and for the specific symbol eg &#x60;BITSTAMP_SPOT_BTC_USD&#x60;, if you need to query timeseries by asset pairs eg. &#x60;BTC/USD&#x60;, then please reffer to the Exchange Rates Timeseries data              :::info The OHLCV Historical endpoint data can be delayed a few seconds. Use OHLCV real-time data stream to get data without delay. :::
 * @param {!string} symbolId Symbol identifier of requested timeseries (from the Metadata -&gt; Symbols)
 * @param {!string} periodId Identifier of requested timeseries period (e.g. &#x60;5SEC&#x60; or &#x60;2MTH&#x60;)
 * @param {!string=} opt_timeStart Timeseries starting time in ISO 8601
 * @param {!string=} opt_timeEnd Timeseries ending time in ISO 8601
 * @param {!number=} opt_limit 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 {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send.
 * @return {!angular.$q.Promise<!Array<!API.Client.v1.TimeseriesItem>>}
 */
API.Client.OhlcvApi.prototype.v1OhlcvSymbolIdHistoryGet = function(symbolId, periodId, opt_timeStart, opt_timeEnd, opt_limit, opt_extraHttpRequestParams) {
  /** @const {string} */
  var path = this.basePath_ + '/v1/ohlcv/{symbol_id}/history'
      .replace('{' + 'symbol_id' + '}', String(symbolId));

  /** @type {!Object} */
  var queryParameters = {};

  /** @type {!Object} */
  var headerParams = angular.extend({}, this.defaultHeaders_);
  // verify required parameter 'symbolId' is set
  if (!symbolId) {
    throw new Error('Missing required parameter symbolId when calling v1OhlcvSymbolIdHistoryGet');
  }
  // verify required parameter 'periodId' is set
  if (!periodId) {
    throw new Error('Missing required parameter periodId when calling v1OhlcvSymbolIdHistoryGet');
  }
  if (periodId !== undefined) {
    queryParameters['period_id'] = periodId;
  }

  if (opt_timeStart !== undefined) {
    queryParameters['time_start'] = opt_timeStart;
  }

  if (opt_timeEnd !== undefined) {
    queryParameters['time_end'] = opt_timeEnd;
  }

  if (opt_limit !== undefined) {
    queryParameters['limit'] = opt_limit;
  }

  /** @type {!Object} */
  var httpRequestParams = {
    method: 'GET',
    url: path,
    json: true,
            params: queryParameters,
    headers: headerParams
  };

  if (opt_extraHttpRequestParams) {
    httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
  }

  return (/** @type {?} */ (this.http_))(httpRequestParams);
}

/**
 * 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 &#x60;BITSTAMP_SPOT_BTC_USD&#x60;, if you need to query timeseries by asset pairs eg. &#x60;BTC/USD&#x60;, then please reffer to the Exchange Rates Timeseries data              :::info OHLCV Latest endpoint is just the shortcut to the OHLCV Historical endpoint with substituted &#x60;time_start&#x60; and &#x60;time_end&#x60; 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} symbolId Symbol identifier of requested timeseries (from the Metadata -&gt; Symbols)
 * @param {!string} periodId Identifier of requested timeseries period (e.g. &#x60;5SEC&#x60; or &#x60;2MTH&#x60;)
 * @param {!number=} opt_limit 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 {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send.
 * @return {!angular.$q.Promise<!Array<!API.Client.v1.TimeseriesItem>>}
 */
API.Client.OhlcvApi.prototype.v1OhlcvSymbolIdLatestGet = function(symbolId, periodId, opt_limit, opt_extraHttpRequestParams) {
  /** @const {string} */
  var path = this.basePath_ + '/v1/ohlcv/{symbol_id}/latest'
      .replace('{' + 'symbol_id' + '}', String(symbolId));

  /** @type {!Object} */
  var queryParameters = {};

  /** @type {!Object} */
  var headerParams = angular.extend({}, this.defaultHeaders_);
  // verify required parameter 'symbolId' is set
  if (!symbolId) {
    throw new Error('Missing required parameter symbolId when calling v1OhlcvSymbolIdLatestGet');
  }
  // verify required parameter 'periodId' is set
  if (!periodId) {
    throw new Error('Missing required parameter periodId when calling v1OhlcvSymbolIdLatestGet');
  }
  if (periodId !== undefined) {
    queryParameters['period_id'] = periodId;
  }

  if (opt_limit !== undefined) {
    queryParameters['limit'] = opt_limit;
  }

  /** @type {!Object} */
  var httpRequestParams = {
    method: 'GET',
    url: path,
    json: true,
            params: queryParameters,
    headers: headerParams
  };

  if (opt_extraHttpRequestParams) {
    httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
  }

  return (/** @type {?} */ (this.http_))(httpRequestParams);
}
