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

=end

require 'cgi'

module OpenapiClient
  class ExchangeRatesApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # 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 asset_id_base [String] Requested exchange rate base asset identifier (from the Metadata -&gt; Assets)
    # @param asset_id_quote [String] Requested exchange rate quote asset identifier (from the Metadata -&gt; Assets)
    # @param [Hash] opts the optional parameters
    # @option opts [String] :time Time at which exchange rate is calculated (optional, if not supplied then current rate is returned)
    # @return [V1ExchangeRate]
    def get_specific_rate(asset_id_base, asset_id_quote, opts = {})
      data, _status_code, _headers = get_specific_rate_with_http_info(asset_id_base, asset_id_quote, opts)
      data
    end

    # 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 asset_id_base [String] Requested exchange rate base asset identifier (from the Metadata -&gt; Assets)
    # @param asset_id_quote [String] Requested exchange rate quote asset identifier (from the Metadata -&gt; Assets)
    # @param [Hash] opts the optional parameters
    # @option opts [String] :time Time at which exchange rate is calculated (optional, if not supplied then current rate is returned)
    # @return [Array<(V1ExchangeRate, Integer, Hash)>] V1ExchangeRate data, response status code and response headers
    def get_specific_rate_with_http_info(asset_id_base, asset_id_quote, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ExchangeRatesApi.get_specific_rate ...'
      end
      # verify the required parameter 'asset_id_base' is set
      if @api_client.config.client_side_validation && asset_id_base.nil?
        fail ArgumentError, "Missing the required parameter 'asset_id_base' when calling ExchangeRatesApi.get_specific_rate"
      end
      # verify the required parameter 'asset_id_quote' is set
      if @api_client.config.client_side_validation && asset_id_quote.nil?
        fail ArgumentError, "Missing the required parameter 'asset_id_quote' when calling ExchangeRatesApi.get_specific_rate"
      end
      # resource path
      local_var_path = '/v1/exchangerate/{asset_id_base}/{asset_id_quote}'.sub('{' + 'asset_id_base' + '}', CGI.escape(asset_id_base.to_s)).sub('{' + 'asset_id_quote' + '}', CGI.escape(asset_id_quote.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'time'] = opts[:'time'] if !opts[:'time'].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] || 'V1ExchangeRate'

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

      new_options = opts.merge(
        :operation => :"ExchangeRatesApi.get_specific_rate",
        :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: ExchangeRatesApi#get_specific_rate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Timeseries data
    # Get the historical exchange rates between two assets in the form of the timeseries.
    # @param asset_id_base [String] Requested exchange rates base asset identifier (from the Metadata -&gt; Assets)
    # @param asset_id_quote [String] Requested exchange rates base asset identifier (from the Metadata -&gt; Assets)
    # @param [Hash] opts the optional parameters
    # @option opts [String] :period_id Identifier of requested timeseries period (required, e.g. &#x60;5SEC&#x60; or &#x60;1HRS&#x60;)
    # @option opts [String] :time_start Timeseries starting time in ISO 8601 (required)
    # @option opts [String] :time_end Timeseries ending time in ISO 8601 (required)
    # @option opts [Integer] :limit 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) (default to 100)
    # @return [Array<V1ExchangeRatesTimeseriesItem>]
    def v1_exchangerate_asset_id_base_asset_id_quote_history_get(asset_id_base, asset_id_quote, opts = {})
      data, _status_code, _headers = v1_exchangerate_asset_id_base_asset_id_quote_history_get_with_http_info(asset_id_base, asset_id_quote, opts)
      data
    end

    # Timeseries data
    # Get the historical exchange rates between two assets in the form of the timeseries.
    # @param asset_id_base [String] Requested exchange rates base asset identifier (from the Metadata -&gt; Assets)
    # @param asset_id_quote [String] Requested exchange rates base asset identifier (from the Metadata -&gt; Assets)
    # @param [Hash] opts the optional parameters
    # @option opts [String] :period_id Identifier of requested timeseries period (required, e.g. &#x60;5SEC&#x60; or &#x60;1HRS&#x60;)
    # @option opts [String] :time_start Timeseries starting time in ISO 8601 (required)
    # @option opts [String] :time_end Timeseries ending time in ISO 8601 (required)
    # @option opts [Integer] :limit 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) (default to 100)
    # @return [Array<(Array<V1ExchangeRatesTimeseriesItem>, Integer, Hash)>] Array<V1ExchangeRatesTimeseriesItem> data, response status code and response headers
    def v1_exchangerate_asset_id_base_asset_id_quote_history_get_with_http_info(asset_id_base, asset_id_quote, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ExchangeRatesApi.v1_exchangerate_asset_id_base_asset_id_quote_history_get ...'
      end
      # verify the required parameter 'asset_id_base' is set
      if @api_client.config.client_side_validation && asset_id_base.nil?
        fail ArgumentError, "Missing the required parameter 'asset_id_base' when calling ExchangeRatesApi.v1_exchangerate_asset_id_base_asset_id_quote_history_get"
      end
      # verify the required parameter 'asset_id_quote' is set
      if @api_client.config.client_side_validation && asset_id_quote.nil?
        fail ArgumentError, "Missing the required parameter 'asset_id_quote' when calling ExchangeRatesApi.v1_exchangerate_asset_id_base_asset_id_quote_history_get"
      end
      # resource path
      local_var_path = '/v1/exchangerate/{asset_id_base}/{asset_id_quote}/history'.sub('{' + 'asset_id_base' + '}', CGI.escape(asset_id_base.to_s)).sub('{' + 'asset_id_quote' + '}', CGI.escape(asset_id_quote.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'period_id'] = opts[:'period_id'] if !opts[:'period_id'].nil?
      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<V1ExchangeRatesTimeseriesItem>'

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

      new_options = opts.merge(
        :operation => :"ExchangeRatesApi.v1_exchangerate_asset_id_base_asset_id_quote_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: ExchangeRatesApi#v1_exchangerate_asset_id_base_asset_id_quote_history_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # 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 asset_id_base [String] Requested exchange rates base asset identifier (from the Metadata -&gt; Assets)
    # @param [Hash] opts the optional parameters
    # @option opts [String] :filter_asset_id Comma or semicolon delimited asset identifiers used to filter response (optional)
    # @option opts [Boolean] :invert True will invert all the rates (optional, if true then rates will be calculated as &#x60;rate &#x3D; 1 / actual_rate&#x60; eg. &#x60;USD/BTC&#x60; as &#x60;BTC/USD&#x60;) (default to false)
    # @option opts [String] :time Time for historical rates (optional)
    # @return [V1ExchangeRates]
    def v1_exchangerate_asset_id_base_get(asset_id_base, opts = {})
      data, _status_code, _headers = v1_exchangerate_asset_id_base_get_with_http_info(asset_id_base, opts)
      data
    end

    # 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 &#x3D; 1 / X equation, for example BTC/USD &#x3D; 1 / (USD/BTC); :::
    # @param asset_id_base [String] Requested exchange rates base asset identifier (from the Metadata -&gt; Assets)
    # @param [Hash] opts the optional parameters
    # @option opts [String] :filter_asset_id Comma or semicolon delimited asset identifiers used to filter response (optional)
    # @option opts [Boolean] :invert True will invert all the rates (optional, if true then rates will be calculated as &#x60;rate &#x3D; 1 / actual_rate&#x60; eg. &#x60;USD/BTC&#x60; as &#x60;BTC/USD&#x60;) (default to false)
    # @option opts [String] :time Time for historical rates (optional)
    # @return [Array<(V1ExchangeRates, Integer, Hash)>] V1ExchangeRates data, response status code and response headers
    def v1_exchangerate_asset_id_base_get_with_http_info(asset_id_base, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ExchangeRatesApi.v1_exchangerate_asset_id_base_get ...'
      end
      # verify the required parameter 'asset_id_base' is set
      if @api_client.config.client_side_validation && asset_id_base.nil?
        fail ArgumentError, "Missing the required parameter 'asset_id_base' when calling ExchangeRatesApi.v1_exchangerate_asset_id_base_get"
      end
      # resource path
      local_var_path = '/v1/exchangerate/{asset_id_base}'.sub('{' + 'asset_id_base' + '}', CGI.escape(asset_id_base.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'filter_asset_id'] = opts[:'filter_asset_id'] if !opts[:'filter_asset_id'].nil?
      query_params[:'invert'] = opts[:'invert'] if !opts[:'invert'].nil?
      query_params[:'time'] = opts[:'time'] if !opts[:'time'].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] || 'V1ExchangeRates'

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

      new_options = opts.merge(
        :operation => :"ExchangeRatesApi.v1_exchangerate_asset_id_base_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: ExchangeRatesApi#v1_exchangerate_asset_id_base_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

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

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

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

      new_options = opts.merge(
        :operation => :"ExchangeRatesApi.v1_exchangerate_history_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: ExchangeRatesApi#v1_exchangerate_history_periods_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
