Skip to content

Commit

Permalink
uses a better approach than before to dynamically pick the api key an…
Browse files Browse the repository at this point in the history
…d secret key.
  • Loading branch information
fbettag committed Oct 31, 2023
1 parent 2585d8f commit 446fe82
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/binance.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down

0 comments on commit 446fe82

Please sign in to comment.