# NOTE: This file is auto generated by OpenAPI Generator 7.14.0 (https://openapi-generator.tech).
# Do not edit this file manually.

defmodule CoinAPIMarketDataRESTAPI.Api.MetricsV1 do
  @moduledoc """
  API calls for all endpoints tagged `MetricsV1`.
  """

  alias CoinAPIMarketDataRESTAPI.Connection
  import CoinAPIMarketDataRESTAPI.RequestBuilder

  @doc """
  Current metrics for given asset
  Get current asset metrics.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `opts` (keyword): Optional parameters
    - `:metric_id` (String.t): Metric identifier (from the Metrics -> Listing)
    - `:asset_id` (String.t): Asset identifier (from the Metadata -> Assets)
    - `:asset_id_external` (String.t): Exchange asset identifier
    - `:exchange_id` (String.t): Exchange identifier (from the Metadata -> Exchanges)

  ### Returns

  - `{:ok, [%V1GeneralData{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_asset_current_get(Tesla.Env.client, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1GeneralData.t]} | {:error, Tesla.Env.t}
  def v1_metrics_asset_current_get(connection, opts \\ []) do
    optional_params = %{
      :metric_id => :query,
      :asset_id => :query,
      :asset_id_external => :query,
      :exchange_id => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/asset/current")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1GeneralData}
    ])
  end

  @doc """
  Historical metrics for asset
  Get asset metrics history.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `metric_id` (String.t): Metric identifier (from the Metrics -> Listing)
  - `exchange_id` (String.t): Exchange identifier (from the Metadata -> Exchanges)
  - `opts` (keyword): Optional parameters
    - `:asset_id` (String.t): Asset identifier (from the Metadata -> Assets)
    - `:asset_id_external` (String.t): Exchange asset identifier
    - `:time_start` (DateTime.t): Starting time in ISO 8601
    - `:time_end` (DateTime.t): Ending time in ISO 8601
    - `:time_format` (String.t): If set, returned values will be in unix timestamp format (valid values: unix_sec, unix_millisec, unix_microsec, unix_nanosec)
    - `:period_id` (String.t): Identifier of requested timeseries period (e.g. `5SEC` or `2MTH`), default value is `1SEC`
    - `:limit` (integer()): 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)

  ### Returns

  - `{:ok, [%V1MetricData{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_asset_history_get(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1MetricData.t]} | {:error, Tesla.Env.t}
  def v1_metrics_asset_history_get(connection, metric_id, exchange_id, opts \\ []) do
    optional_params = %{
      :asset_id => :query,
      :asset_id_external => :query,
      :time_start => :query,
      :time_end => :query,
      :time_format => :query,
      :period_id => :query,
      :limit => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/asset/history")
      |> add_param(:query, :metric_id, metric_id)
      |> add_param(:query, :exchange_id, exchange_id)
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1MetricData}
    ])
  end

  @doc """
  Listing of all supported metrics for asset
  Get data metrics for asset.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `opts` (keyword): Optional parameters
    - `:metric_id` (String.t): Metric identifier (from the Metrics -> Listing)
    - `:exchange_id` (String.t): Exchange identifier (from the Metadata -> Exchanges)
    - `:chain_id` (String.t): Chain identifier
    - `:network_id` (String.t): Network identifier
    - `:asset_id` (String.t): Asset identifier (from the Metadata -> Assets)
    - `:asset_id_external` (String.t): The asset external identifier

  ### Returns

  - `{:ok, [%V1ListingItem{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_asset_listing_get(Tesla.Env.client, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1ListingItem.t]} | {:error, Tesla.Env.t}
  def v1_metrics_asset_listing_get(connection, opts \\ []) do
    optional_params = %{
      :metric_id => :query,
      :exchange_id => :query,
      :chain_id => :query,
      :network_id => :query,
      :asset_id => :query,
      :asset_id_external => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/asset/listing")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1ListingItem}
    ])
  end

  @doc """
  Current metrics for given exchange
  Get current exchange metrics values.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `exchange_id` (String.t): The exchange identifier (from the Metadata -> Exchanges)
  - `opts` (keyword): Optional parameters
    - `:metric_id` (String.t): The metric identifier (from the Metrics -> Listing)

  ### Returns

  - `{:ok, [%V1GeneralData{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_exchange_current_get(Tesla.Env.client, String.t, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1GeneralData.t]} | {:error, Tesla.Env.t}
  def v1_metrics_exchange_current_get(connection, exchange_id, opts \\ []) do
    optional_params = %{
      :metric_id => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/exchange/current")
      |> add_param(:query, :exchange_id, exchange_id)
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1GeneralData}
    ])
  end

  @doc """
  Historical metrics for the exchange
  Get exchange metrics history.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `metric_id` (String.t): Metric identifier (from the Metrics -> Listing)
  - `exchange_id` (String.t): Exchange identifier (from the Metadata -> Exchanges)
  - `opts` (keyword): Optional parameters
    - `:time_start` (DateTime.t): Starting time in ISO 8601
    - `:time_end` (DateTime.t): Ending time in ISO 8601
    - `:time_format` (String.t): If set, returned values will be in unix timestamp format (valid values: unix_sec, unix_millisec, unix_microsec, unix_nanosec)
    - `:period_id` (String.t): Identifier of requested timeseries period (e.g. `5SEC` or `2MTH`), default value is `1SEC`
    - `:limit` (integer()): 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)

  ### Returns

  - `{:ok, [%V1MetricData{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_exchange_history_get(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1MetricData.t]} | {:error, Tesla.Env.t}
  def v1_metrics_exchange_history_get(connection, metric_id, exchange_id, opts \\ []) do
    optional_params = %{
      :time_start => :query,
      :time_end => :query,
      :time_format => :query,
      :period_id => :query,
      :limit => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/exchange/history")
      |> add_param(:query, :metric_id, metric_id)
      |> add_param(:query, :exchange_id, exchange_id)
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1MetricData}
    ])
  end

  @doc """
  Listing of all supported exchange metrics
  Get data metrics for exchange.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `exchange_id` (String.t): The exchange identifier (from the Metadata -> Exchanges)
  - `opts` (keyword): Optional parameters
    - `:metric_id` (String.t): The metric identifier (from the Metrics -> Listing)

  ### Returns

  - `{:ok, [%V1ListingItem{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_exchange_listing_get(Tesla.Env.client, String.t, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1ListingItem.t]} | {:error, Tesla.Env.t}
  def v1_metrics_exchange_listing_get(connection, exchange_id, opts \\ []) do
    optional_params = %{
      :metric_id => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/exchange/listing")
      |> add_param(:query, :exchange_id, exchange_id)
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1ListingItem}
    ])
  end

  @doc """
  Listing of all supported metrics by CoinAPI
  Get all data metrics.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, [%V1Metric{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_listing_get(Tesla.Env.client, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1Metric.t]} | {:error, Tesla.Env.t}
  def v1_metrics_listing_get(connection, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/listing")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1Metric}
    ])
  end

  @doc """
  Current metrics for given symbol
  Get current symbol metrics.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `opts` (keyword): Optional parameters
    - `:metric_id` (String.t): Metric identifier (from the Metrics -> Listing)
    - `:symbol_id` (String.t): Symbol identifier (from the Metadata -> Symbols)
    - `:exchange_id` (String.t): Exchange id (from the Metadata -> Exchanges)

  ### Returns

  - `{:ok, [%V1GeneralData{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_symbol_current_get(Tesla.Env.client, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1GeneralData.t]} | {:error, Tesla.Env.t}
  def v1_metrics_symbol_current_get(connection, opts \\ []) do
    optional_params = %{
      :metric_id => :query,
      :symbol_id => :query,
      :exchange_id => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/symbol/current")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1GeneralData}
    ])
  end

  @doc """
  Historical metrics for symbol
  Get symbol metrics history.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `metric_id` (String.t): Metric identifier (from the Metrics -> Listing)
  - `symbol_id` (String.t): Symbol identifier (from the Metadata -> Symbols)
  - `opts` (keyword): Optional parameters
    - `:time_start` (DateTime.t): Starting time in ISO 8601
    - `:time_end` (DateTime.t): Ending time in ISO 8601
    - `:time_format` (String.t): If set, returned values will be in unix timestamp format (valid values: unix_sec, unix_millisec, unix_microsec, unix_nanosec)
    - `:period_id` (String.t): Identifier of requested timeseries period (e.g. `5SEC` or `2MTH`), default value is `1SEC`
    - `:limit` (integer()): 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)

  ### Returns

  - `{:ok, [%V1MetricData{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_symbol_history_get(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1MetricData.t]} | {:error, Tesla.Env.t}
  def v1_metrics_symbol_history_get(connection, metric_id, symbol_id, opts \\ []) do
    optional_params = %{
      :time_start => :query,
      :time_end => :query,
      :time_format => :query,
      :period_id => :query,
      :limit => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/symbol/history")
      |> add_param(:query, :metric_id, metric_id)
      |> add_param(:query, :symbol_id, symbol_id)
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1MetricData}
    ])
  end

  @doc """
  Listing of all supported metrics for symbol
  Get data metrics for symbol.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `opts` (keyword): Optional parameters
    - `:metric_id` (String.t): Metric identifier (from the Metrics -> Listing)
    - `:exchange_id` (String.t): Exchange identifier (from the Metadata -> Exchanges)
    - `:symbol_id` (String.t): Symbol identifier (from the Metadata -> Symbols)

  ### Returns

  - `{:ok, [%V1ListingItem{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_metrics_symbol_listing_get(Tesla.Env.client, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1ListingItem.t]} | {:error, Tesla.Env.t}
  def v1_metrics_symbol_listing_get(connection, opts \\ []) do
    optional_params = %{
      :metric_id => :query,
      :exchange_id => :query,
      :symbol_id => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/metrics/symbol/listing")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, CoinAPIMarketDataRESTAPI.Model.V1ListingItem}
    ])
  end
end
