     {:stop, :normal, :ok, state}
   end
 
-  defp refresh_login(login) do
+  defp refresh_login(login, attempts) do
     body = """
       { "data": { "fetch_type": "recent" }}
     """

    Logger.info("Refreshed login #{login.saltedge_login_id} with result => #{inspect(result)}")

    case result["data"]["refreshed"] do
      false -> Process.send_after(self(), {:refresh, login}, 5000) # FIXME endless loop
      true -> :ok
    end
  end



    case Timex.Date.diff(last_refreshed_at, Timex.Date.now, :secs) do
      secs when secs >= 3600 ->
        refresh_login(login, 5)
      secs when secs < 3600 ->
        next_run = 3600 - secs

