Skip to content
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

Fix endpoint getting fixed at compile-time #106

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/binance/rest/http_client.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
defmodule Binance.Rest.HTTPClient do
@endpoint Application.get_env(:binance, :end_point, "https://api.binance.com")
defp endpoint() do
Application.get_env(:binance, :end_point, "https://api.binance.com")
end

defp prepare_request(url, params, secret_key, api_key) do

Check warning on line 6 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (24.3, 1.14.5)

function prepare_request/4 is unused

Check warning on line 6 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (25.3, 1.14.5)

function prepare_request/4 is unused

Check warning on line 6 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (26.1, 1.14.5)

function prepare_request/4 is unused

Check warning on line 6 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (24.3, 1.14.5)

function prepare_request/4 is unused

Check warning on line 6 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / testolder (23.3, 1.14)

function prepare_request/4 is unused

Check warning on line 6 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / testolder (23.3, 1.14)

function prepare_request/4 is unused

Check warning on line 6 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (26.1, 1.14.5)

function prepare_request/4 is unused

Check warning on line 6 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (25.3, 1.14.5)

function prepare_request/4 is unused
case validate_credentials(secret_key, api_key) do
{:error, _} = error ->
error
Expand Down Expand Up @@ -32,7 +34,7 @@
end

defp request_binance(url, body, method) do
url = URI.parse("#{@endpoint}#{url}")
url = URI.parse("#{endpoint()}#{url}")

encoded_url =
if body != "" do
Expand Down Expand Up @@ -111,7 +113,7 @@
request_binance(url, argument_string, method)
end

defp validate_credentials(nil, nil),

Check warning on line 116 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (24.3, 1.14.5)

function validate_credentials/2 is unused

Check warning on line 116 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (25.3, 1.14.5)

function validate_credentials/2 is unused

Check warning on line 116 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (26.1, 1.14.5)

function validate_credentials/2 is unused

Check warning on line 116 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (24.3, 1.14.5)

function validate_credentials/2 is unused

Check warning on line 116 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / testolder (23.3, 1.14)

function validate_credentials/2 is unused

Check warning on line 116 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / testolder (23.3, 1.14)

function validate_credentials/2 is unused

Check warning on line 116 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (26.1, 1.14.5)

function validate_credentials/2 is unused

Check warning on line 116 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (25.3, 1.14.5)

function validate_credentials/2 is unused
do: {:error, {:config_missing, "Secret and API key missing"}}

defp validate_credentials(nil, _api_key),
Expand All @@ -123,7 +125,7 @@
defp validate_credentials(_secret_key, _api_key),
do: :ok

defp parse_response({:ok, response}) do

Check warning on line 128 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (24.3, 1.14.5)

function parse_response/1 is unused

Check warning on line 128 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (25.3, 1.14.5)

function parse_response/1 is unused

Check warning on line 128 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (26.1, 1.14.5)

function parse_response/1 is unused

Check warning on line 128 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (24.3, 1.14.5)

function parse_response/1 is unused

Check warning on line 128 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / testolder (23.3, 1.14)

function parse_response/1 is unused

Check warning on line 128 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / testolder (23.3, 1.14)

function parse_response/1 is unused

Check warning on line 128 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (26.1, 1.14.5)

function parse_response/1 is unused

Check warning on line 128 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (25.3, 1.14.5)

function parse_response/1 is unused
response.body
|> Poison.decode()
|> parse_response_body
Expand All @@ -133,7 +135,7 @@
{:error, {:http_error, err}}
end

defp parse_response_body({:ok, data}) do

Check warning on line 138 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (24.3, 1.14.5)

function parse_response_body/1 is unused

Check warning on line 138 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (25.3, 1.14.5)

function parse_response_body/1 is unused

Check warning on line 138 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (26.1, 1.14.5)

function parse_response_body/1 is unused

Check warning on line 138 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (24.3, 1.14.5)

function parse_response_body/1 is unused

Check warning on line 138 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / testolder (23.3, 1.14)

function parse_response_body/1 is unused

Check warning on line 138 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / testolder (23.3, 1.14)

function parse_response_body/1 is unused

Check warning on line 138 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (26.1, 1.14.5)

function parse_response_body/1 is unused

Check warning on line 138 in lib/binance/rest/http_client.ex

View workflow job for this annotation

GitHub Actions / test (25.3, 1.14.5)

function parse_response_body/1 is unused
case data do
%{"code" => _c, "msg" => _m} = error -> {:error, error}
_ -> {:ok, data}
Expand Down
Loading