-
Notifications
You must be signed in to change notification settings - Fork 50
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
enables the use of per-request api-key/secret-key passing while keeping backward compatibility. #105
Conversation
gonna rewrite this again |
I think you can inject those as extra optional parameters into Then inside client, check if those params exist, and if they do use them for overwriting the APplication.get_env stuff Here's how I did it with a similar library (OpenAI): https://github.com/dvcrn/ex_openai/blob/main/lib/ex_openai/client.ex#L117-L118 |
thanks for the suggestion. currently running trials but iex -S mix looks good |
…ng backward compatibility.
this now is nice and working. sorry for the fuzz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I left some comments, mostly cosmetic
Also, I think we need a test for this. If you're unsure how to do it, I'm happy to help / take over as well.
@@ -33,7 +33,7 @@ defmodule Binance.Rest.HTTPClient do | |||
end | |||
end | |||
|
|||
defp request_binance(url, body, method) do | |||
defp request_binance(api_key, url, body, method) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature of this function is becoming a bit odd. API key should probably come after url, or in the end within optional args. Or even better - a pattern-matched function with different signature for apikey and no apikey
@@ -81,7 +81,7 @@ defmodule Binance.Rest.HTTPClient do | |||
end | |||
end | |||
|
|||
def signed_request_binance(url, params, method) do | |||
def signed_request_binance(api_key, secret_key, url, params, method) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
argument_string | ||
) | ||
|> Base.encode16() | ||
|
||
body = "#{argument_string}&signature=#{signature}" | ||
|
||
request_binance(url, body, method) | ||
request_binance(api_key, url, body, method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is a bit odd
Probably better to make it a function with different signature or optional arg
Since i really don't know how you like the functions to be, i'd appreciate it if you changed the 3 signatures to your liking :) I wouldn't be mad if you take over from here, i don't wanna screw around in your awesome code more than needed, but as for the test i suggest using get_account_summary to test this out. Also, big kudos for the code generator. I've used that part of the library to show off to clients how awesome Elixir can be. ;) |
actually trading (buy/sell) seems to be broken with this approach (worked with the other for some weird reason) |
I've changed the function signatures and shuffled things around, then added a test Could you give this branch a try? #107 |
Ping :) |
sorry i'm currently very busy with pre-christmas work -.- everyone needs stuff launched before christmas |
will try to get to it until the weekend |
hey dude, sorry for the delay. so with this branch i get the following when trying to buy or sell:
|
Thanks for the feedback hrrrm, which method did you use? Can you post the code? |
|
ah damn now i see it, one second, that's actually my error. i just saw it by rereading the two things close together doooooh Edit: nope this actually looks fine when dumping the params. had something else in my head apparently (sorry it's a saturday after having worked the past 3 weeks straight) I also remember having this issue when i tried your approach. i have no idea how it triggers this issue. |
I have used Application.set_env before, but this approach works a lot better.
feedback is welcome.