From 3688e720e9afeac649dc505b35c520d3b9b8e372 Mon Sep 17 00:00:00 2001
From: David Mohl <git@d.sh>
Date: Sun, 29 Oct 2023 11:34:57 +0900
Subject: [PATCH] Fix endpoint getting fixed at compile-time

Endpoint was getting baked in at compile-time, so changing env at
runtime had no effect.

Fixes #44
---
 lib/binance/rest/http_client.ex | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/binance/rest/http_client.ex b/lib/binance/rest/http_client.ex
index 7a6a440..9a07bda 100644
--- a/lib/binance/rest/http_client.ex
+++ b/lib/binance/rest/http_client.ex
@@ -1,5 +1,7 @@
 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
     case validate_credentials(secret_key, api_key) do
@@ -32,7 +34,7 @@ defmodule Binance.Rest.HTTPClient do
   end
 
   defp request_binance(url, body, method) do
-    url = URI.parse("#{@endpoint}#{url}")
+    url = URI.parse("#{endpoint()}#{url}")
 
     encoded_url =
       if body != "" do