# 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.Quotes do
  @moduledoc """
  API calls for all endpoints tagged `Quotes`.
  """

  alias CoinAPIMarketDataRESTAPI.Connection
  import CoinAPIMarketDataRESTAPI.RequestBuilder

  @doc """
  Current data
  Get current quotes for all symbols or for a specific symbol.              :::info When requesting current data for a specific symbol, output is not encapsulated into JSON array as only one item is returned. :::

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `opts` (keyword): Optional parameters
    - `:filter_symbol_id` (String.t): Comma or semicolon delimited parts of symbol identifier used to filter response. (optional)

  ### Returns

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

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

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

  @doc """
  Latest data
  Get latest updates of the quotes up to 1 minute ago. Latest data is always returned in time descending order.

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `opts` (keyword): Optional parameters
    - `:filter_symbol_id` (String.t): Comma or semicolon delimited parts of symbol identifier used to filter response. (optional)
    - `: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, [%V1Quote{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_quotes_latest_get(Tesla.Env.client, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1Quote.t]} | {:error, Tesla.Env.t}
  def v1_quotes_latest_get(connection, opts \\ []) do
    optional_params = %{
      :filter_symbol_id => :query,
      :limit => :query
    }

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

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

  @doc """
  Current quotes for a specific symbol

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `symbol_id` (String.t): The symbol identifier (from the Metadata -> Symbols)
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, CoinAPIMarketDataRESTAPI.Model.V1QuoteTrade.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_quotes_symbol_id_current_get(Tesla.Env.client, String.t, keyword()) :: {:ok, CoinAPIMarketDataRESTAPI.Model.V1QuoteTrade.t} | {:error, Tesla.Env.t}
  def v1_quotes_symbol_id_current_get(connection, symbol_id, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/quotes/#{symbol_id}/current")
      |> Enum.into([])

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

  @doc """
  Historical data
  Get historical quote updates within requested time range, returned in time ascending order.  :::warning The 'time_start' and 'time_end' parameters must be from the same day as this endpoint provides intraday data only for specific day. Please use the 'date' parameter instead for querying data for a specific day without filter. :::

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `symbol_id` (String.t): Symbol identifier for requested timeseries (from the Metadata -> Symbols)
  - `opts` (keyword): Optional parameters
    - `:date` (String.t): Date in ISO 8601, returned data is for the whole given day (preferred method, required if 'time_start' is not provided)
    - `:time_start` (String.t): Starting time in ISO 8601
    - `:time_end` (String.t): Timeseries ending time in ISO 8601
    - `:limit` (integer()): Amount of items to return (optional, minimum 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, [%V1Quote{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_quotes_symbol_id_history_get(Tesla.Env.client, String.t, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1Quote.t]} | {:error, Tesla.Env.t}
  def v1_quotes_symbol_id_history_get(connection, symbol_id, opts \\ []) do
    optional_params = %{
      :date => :query,
      :time_start => :query,
      :time_end => :query,
      :limit => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/quotes/#{symbol_id}/history")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

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

  @doc """
  Latest quote updates for a specific symbol

  ### Parameters

  - `connection` (CoinAPIMarketDataRESTAPI.Connection): Connection to server
  - `symbol_id` (String.t): Symbol identifier of requested timeseries (from the Metadata -> Symbols)
  - `opts` (keyword): Optional parameters
    - `: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, [%V1Quote{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_quotes_symbol_id_latest_get(Tesla.Env.client, String.t, keyword()) :: {:ok, [CoinAPIMarketDataRESTAPI.Model.V1Quote.t]} | {:error, Tesla.Env.t}
  def v1_quotes_symbol_id_latest_get(connection, symbol_id, opts \\ []) do
    optional_params = %{
      :limit => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/quotes/#{symbol_id}/latest")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

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