   use GenServer
   alias Farmbot.HTTP.{Adapter, Error, Response}
 
-  @adapter Application.get_env(:farmbot, :behaviour)[:http_adapter] || raise("No http adapter.")
+  @adapter Application.get_env(:farmbot, :behaviour)[:http_adapter]
+  @adapter || raise("No http adapter.")
 
   @typep method :: Adapter.method
   @typep url :: Adapter.url


  def request!(method, url, body, headers, opts) do
    case request(method, url, body, headers, opts) do
      {:ok, %Response{status_code: code} = resp} when code > 199 and code < 300 -> resp
      {:ok, %Response{} = resp} -> raise Error, resp

      {:error, reason} -> raise Error, reason

  end

  @doc "Download a file to the filesystem."
  def download_file(url,
                    path,
                    progress_callback \\ nil,
                    payload \\ "",
                    headers \\ [],
                    stream_fun \\ nil)

  def download_file(url, path, progress_callback, payload, hddrs, stream_fun) do
    opts = {url, path, progress_callback, payload, hddrs, stream_fun}
    call = {:download_file, opts}
    GenServer.call(__MODULE__, call, :infinity)
  end

  @doc "Upload a file to FB storage."
