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

defmodule FXRealtimeRESTAPI.Api.ExchangeRates do
  @moduledoc """
  API calls for all endpoints tagged `ExchangeRates`.
  """

  alias FXRealtimeRESTAPI.Connection
  import FXRealtimeRESTAPI.RequestBuilder

  @doc """
  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. :::

  ### Parameters

  - `connection` (FXRealtimeRESTAPI.Connection): Connection to server
  - `asset_id_base` (String.t): Requested exchange rate base asset identifier (from the Metadata -> Assets)
  - `asset_id_quote` (String.t): Requested exchange rate quote asset identifier (from the Metadata -> Assets)
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, FXRealtimeRESTAPI.Model.V1ExchangeRate.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec get_specific_rate(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, FXRealtimeRESTAPI.Model.V1ExchangeRate.t} | {:error, Tesla.Env.t}
  def get_specific_rate(connection, asset_id_base, asset_id_quote, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/exchangerate/#{asset_id_base}/#{asset_id_quote}")
      |> Enum.into([])

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

  @doc """
  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); :::

  ### Parameters

  - `connection` (FXRealtimeRESTAPI.Connection): Connection to server
  - `asset_id_base` (String.t): Requested exchange rates base asset identifier (from the Metadata -> Assets)
  - `opts` (keyword): Optional parameters
    - `:filter_asset_id` (String.t): Comma or semicolon delimited asset identifiers used to filter response (optional)
    - `:invert` (boolean()): True will invert all the rates (optional, if true then rates will be calculated as `rate = 1 / actual_rate` eg. `USD/BTC` as `BTC/USD`)

  ### Returns

  - `{:ok, FXRealtimeRESTAPI.Model.V1ExchangeRates.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_exchangerate_asset_id_base_get(Tesla.Env.client, String.t, keyword()) :: {:ok, FXRealtimeRESTAPI.Model.V1ExchangeRates.t} | {:error, Tesla.Env.t}
  def v1_exchangerate_asset_id_base_get(connection, asset_id_base, opts \\ []) do
    optional_params = %{
      :filter_asset_id => :query,
      :invert => :query
    }

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

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