=begin
#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
Generated by: https://openapi-generator.tech
Generator version: 7.14.0

=end

require 'cgi'

module OpenapiClient
  class OhlcvApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # 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 exchange_id [String] Exchange identifier of requested timeseries (from the Metadata -&gt; Exchanges)
    # @param period_id [String] Identifier of requested timeseries period (e.g. &#x60;5SEC&#x60; or &#x60;1DAY&#x60;)
    # @param time_start [String] Timeseries starting time in ISO 8601
    # @param time_end [String] Timeseries ending time in ISO 8601
    # @param [Hash] opts the optional parameters
    # @return [Array<OHLCVExchangeTimeseriesItem>]
    def v1_ohlcv_exchange_exchange_id_history_get(exchange_id, period_id, time_start, time_end, opts = {})
      data, _status_code, _headers = v1_ohlcv_exchange_exchange_id_history_get_with_http_info(exchange_id, period_id, time_start, time_end, opts)
      data
    end

    # 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 exchange_id [String] Exchange identifier of requested timeseries (from the Metadata -&gt; Exchanges)
    # @param period_id [String] Identifier of requested timeseries period (e.g. &#x60;5SEC&#x60; or &#x60;1DAY&#x60;)
    # @param time_start [String] Timeseries starting time in ISO 8601
    # @param time_end [String] Timeseries ending time in ISO 8601
    # @param [Hash] opts the optional parameters
    # @return [Array<(Array<OHLCVExchangeTimeseriesItem>, Integer, Hash)>] Array<OHLCVExchangeTimeseriesItem> data, response status code and response headers
    def v1_ohlcv_exchange_exchange_id_history_get_with_http_info(exchange_id, period_id, time_start, time_end, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OhlcvApi.v1_ohlcv_exchange_exchange_id_history_get ...'
      end
      # verify the required parameter 'exchange_id' is set
      if @api_client.config.client_side_validation && exchange_id.nil?
        fail ArgumentError, "Missing the required parameter 'exchange_id' when calling OhlcvApi.v1_ohlcv_exchange_exchange_id_history_get"
      end
      # verify the required parameter 'period_id' is set
      if @api_client.config.client_side_validation && period_id.nil?
        fail ArgumentError, "Missing the required parameter 'period_id' when calling OhlcvApi.v1_ohlcv_exchange_exchange_id_history_get"
      end
      # verify the required parameter 'time_start' is set
      if @api_client.config.client_side_validation && time_start.nil?
        fail ArgumentError, "Missing the required parameter 'time_start' when calling OhlcvApi.v1_ohlcv_exchange_exchange_id_history_get"
      end
      # verify the required parameter 'time_end' is set
      if @api_client.config.client_side_validation && time_end.nil?
        fail ArgumentError, "Missing the required parameter 'time_end' when calling OhlcvApi.v1_ohlcv_exchange_exchange_id_history_get"
      end
      # resource path
      local_var_path = '/v1/ohlcv/exchange/{exchange_id}/history'.sub('{' + 'exchange_id' + '}', CGI.escape(exchange_id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'period_id'] = period_id
      query_params[:'time_start'] = time_start
      query_params[:'time_end'] = time_end

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json', 'text/json']) unless header_params['Accept']

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'Array<OHLCVExchangeTimeseriesItem>'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['APIKey', 'JWT']

      new_options = opts.merge(
        :operation => :"OhlcvApi.v1_ohlcv_exchange_exchange_id_history_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OhlcvApi#v1_ohlcv_exchange_exchange_id_history_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Historical data
    # Get OHLCV timeseries data returned in time ascending order.
    # @param exchange_id [String] Exchange identifier of requested timeseries (from the Metadata -&gt; Exchanges)
    # @param symbol_id [String] Symbol identifier of requested timeseries (from the Metadata -&gt; Symbols)
    # @param period_id [String] Identifier of requested timeseries period (e.g. &#x60;5SEC&#x60; or &#x60;2MTH&#x60;)
    # @param [Hash] opts the optional parameters
    # @option opts [String] :time_start Timeseries starting time in ISO 8601
    # @option opts [String] :time_end Timeseries ending time in ISO 8601
    # @option opts [Integer] :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) (default to 100)
    # @return [Array<OHLCVTimeseriesItem>]
    def v1_ohlcv_exchange_symbol_exchange_id_symbol_id_history_get(exchange_id, symbol_id, period_id, opts = {})
      data, _status_code, _headers = v1_ohlcv_exchange_symbol_exchange_id_symbol_id_history_get_with_http_info(exchange_id, symbol_id, period_id, opts)
      data
    end

    # Historical data
    # Get OHLCV timeseries data returned in time ascending order.
    # @param exchange_id [String] Exchange identifier of requested timeseries (from the Metadata -&gt; Exchanges)
    # @param symbol_id [String] Symbol identifier of requested timeseries (from the Metadata -&gt; Symbols)
    # @param period_id [String] Identifier of requested timeseries period (e.g. &#x60;5SEC&#x60; or &#x60;2MTH&#x60;)
    # @param [Hash] opts the optional parameters
    # @option opts [String] :time_start Timeseries starting time in ISO 8601
    # @option opts [String] :time_end Timeseries ending time in ISO 8601
    # @option opts [Integer] :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) (default to 100)
    # @return [Array<(Array<OHLCVTimeseriesItem>, Integer, Hash)>] Array<OHLCVTimeseriesItem> data, response status code and response headers
    def v1_ohlcv_exchange_symbol_exchange_id_symbol_id_history_get_with_http_info(exchange_id, symbol_id, period_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_history_get ...'
      end
      # verify the required parameter 'exchange_id' is set
      if @api_client.config.client_side_validation && exchange_id.nil?
        fail ArgumentError, "Missing the required parameter 'exchange_id' when calling OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_history_get"
      end
      # verify the required parameter 'symbol_id' is set
      if @api_client.config.client_side_validation && symbol_id.nil?
        fail ArgumentError, "Missing the required parameter 'symbol_id' when calling OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_history_get"
      end
      # verify the required parameter 'period_id' is set
      if @api_client.config.client_side_validation && period_id.nil?
        fail ArgumentError, "Missing the required parameter 'period_id' when calling OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_history_get"
      end
      # resource path
      local_var_path = '/v1/ohlcv/exchange-symbol/{exchange_id}/{symbol_id}/history'.sub('{' + 'exchange_id' + '}', CGI.escape(exchange_id.to_s)).sub('{' + 'symbol_id' + '}', CGI.escape(symbol_id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'period_id'] = period_id
      query_params[:'time_start'] = opts[:'time_start'] if !opts[:'time_start'].nil?
      query_params[:'time_end'] = opts[:'time_end'] if !opts[:'time_end'].nil?
      query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json', 'text/json']) unless header_params['Accept']

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'Array<OHLCVTimeseriesItem>'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['APIKey', 'JWT']

      new_options = opts.merge(
        :operation => :"OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_history_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OhlcvApi#v1_ohlcv_exchange_symbol_exchange_id_symbol_id_history_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # 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 exchange_id [String] Exchange identifier of requested timeseries (from the Metadata -&gt; Exchanges)
    # @param symbol_id [String] Symbol identifier of requested timeseries (from the Metadata -&gt; Symbols)
    # @param period_id [String] Identifier of requested timeseries period (e.g. &#x60;5SEC&#x60; or &#x60;2MTH&#x60;)
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :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) (default to 100)
    # @return [Array<OHLCVTimeseriesItem>]
    def v1_ohlcv_exchange_symbol_exchange_id_symbol_id_latest_get(exchange_id, symbol_id, period_id, opts = {})
      data, _status_code, _headers = v1_ohlcv_exchange_symbol_exchange_id_symbol_id_latest_get_with_http_info(exchange_id, symbol_id, period_id, opts)
      data
    end

    # 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 exchange_id [String] Exchange identifier of requested timeseries (from the Metadata -&gt; Exchanges)
    # @param symbol_id [String] Symbol identifier of requested timeseries (from the Metadata -&gt; Symbols)
    # @param period_id [String] Identifier of requested timeseries period (e.g. &#x60;5SEC&#x60; or &#x60;2MTH&#x60;)
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :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) (default to 100)
    # @return [Array<(Array<OHLCVTimeseriesItem>, Integer, Hash)>] Array<OHLCVTimeseriesItem> data, response status code and response headers
    def v1_ohlcv_exchange_symbol_exchange_id_symbol_id_latest_get_with_http_info(exchange_id, symbol_id, period_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_latest_get ...'
      end
      # verify the required parameter 'exchange_id' is set
      if @api_client.config.client_side_validation && exchange_id.nil?
        fail ArgumentError, "Missing the required parameter 'exchange_id' when calling OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_latest_get"
      end
      # verify the required parameter 'symbol_id' is set
      if @api_client.config.client_side_validation && symbol_id.nil?
        fail ArgumentError, "Missing the required parameter 'symbol_id' when calling OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_latest_get"
      end
      # verify the required parameter 'period_id' is set
      if @api_client.config.client_side_validation && period_id.nil?
        fail ArgumentError, "Missing the required parameter 'period_id' when calling OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_latest_get"
      end
      # resource path
      local_var_path = '/v1/ohlcv/exchange-symbol/{exchange_id}/{symbol_id}/latest'.sub('{' + 'exchange_id' + '}', CGI.escape(exchange_id.to_s)).sub('{' + 'symbol_id' + '}', CGI.escape(symbol_id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'period_id'] = period_id
      query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json', 'text/json']) unless header_params['Accept']

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'Array<OHLCVTimeseriesItem>'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['APIKey', 'JWT']

      new_options = opts.merge(
        :operation => :"OhlcvApi.v1_ohlcv_exchange_symbol_exchange_id_symbol_id_latest_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OhlcvApi#v1_ohlcv_exchange_symbol_exchange_id_symbol_id_latest_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # 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 [Hash] opts the optional parameters
    # @return [Array<OHLCVTimeseriesPeriod>]
    def v1_ohlcv_periods_get(opts = {})
      data, _status_code, _headers = v1_ohlcv_periods_get_with_http_info(opts)
      data
    end

    # 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 [Hash] opts the optional parameters
    # @return [Array<(Array<OHLCVTimeseriesPeriod>, Integer, Hash)>] Array<OHLCVTimeseriesPeriod> data, response status code and response headers
    def v1_ohlcv_periods_get_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OhlcvApi.v1_ohlcv_periods_get ...'
      end
      # resource path
      local_var_path = '/v1/ohlcv/periods'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json', 'text/json']) unless header_params['Accept']

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'Array<OHLCVTimeseriesPeriod>'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['APIKey', 'JWT']

      new_options = opts.merge(
        :operation => :"OhlcvApi.v1_ohlcv_periods_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OhlcvApi#v1_ohlcv_periods_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
