From 446fe824f40eb8e6fcc375fc13ece86de505b644 Mon Sep 17 00:00:00 2001 From: Franz Bettag Date: Tue, 31 Oct 2023 18:08:40 +0100 Subject: [PATCH] uses a better approach than before to dynamically pick the api key and secret key. --- lib/binance.ex | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/binance.ex b/lib/binance.ex index 1df2f04..15ca01c 100644 --- a/lib/binance.ex +++ b/lib/binance.ex @@ -137,21 +137,17 @@ docs """ # fx without opts - @spec unquote(fx_name)(String.t() | nil, String.t() | nil, unquote_splicing(spec)) :: + @spec unquote(fx_name)(unquote_splicing(spec)) :: {:ok, any()} | {:error, any()} # fx with opts @spec unquote(fx_name)( - String.t() | nil, - String.t() | nil, unquote_splicing(spec), unquote(optional_args) ) :: {:ok, any()} | {:error, any()} def unquote(fx_name)( - api_key \\ unquote(Application.get_env(:binance, :api_key)), - secret_key \\ unquote(Application.get_env(:binance, :secret_key)), unquote_splicing(arg_names), opts \\ [] ) do @@ -160,6 +156,8 @@ docs # merge all passed args together, so opts + passed all_passed_args = Keyword.merge(binding, opts) |> Keyword.drop([:opts, :api_key, :secret_key]) + api_key = Keyword.get(opts, :api_key) || Application.get_env(:binance, :api_key) || "" + secret_key = Keyword.get(opts, :secret_key) || Application.get_env(:binance, :secret_key) || "" # if the call requires a timestamp, we add it adjusted_args =