-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow defining API key/secret/passphrase/url dynamically #1
Comments
With the current approach of ex_gdax reading the api keys from system env vars or config.exs, I cannot think of a way off the top of my head to manage two different accounts inside the same application. I will put some thought into this but if you want to put together a PR I'd be happy to take a look! |
One idea I have to achieve this is by adding a I've partially implemented this approach in rylwin@08da55f. If you like the concept, I can finish implementing the change for the remaining Happy to go a different direction, too. Looking forward to your thoughts! |
@rylwin I've also been thinking about how to achieve this. I can't really think of another approach besides passing something into a function. One idea I had which is similar to yours was to pass around the app name instead of the config e.g. # config/config.exs
config :ex_gdax, app_one_api_key: "...", app_one_api_secret: "...", ...
config :ex_gdax, app_two_api_key: "...", app_two_api_secret: "...", ...
# lib/ex_gdax.ex
defdelegate list_accounts(app_name \\ nil), to: ExGdax.Private, as: :list_accounts
# lib/ex_gdax/config.ex
# ...
def api_key, do: from_env(:ex_gdax, :api_key)
def api_key(app_name), do: from_env(:ex_gdax, "#{app_name}_api_key" |> String.to_atom)
# Config usage
Config.api_key # default
Config.api_key(app_name) # For app |
I have a use-case where I want to manage multiple GDAX accounts at once. My understanding of how
Mix.Config
works and the wayex_gdax
uses it, that it would be difficult to achieve executing API calls for multiple accounts (but if I'm missing an easy way to do this, please let me know!).Would there be any interest in a PR that adds the ability to specify the config per request? If so, I'd be happy to work on this.
p.s. thanks for this project! It gave me a great jump start on my own project 👍
The text was updated successfully, but these errors were encountered: