     end
   end
 
+  # Fetch the image_url of a given job_id
+  #
   def image_url(job_id) do
     hackney = [basic_auth: {Application.fetch_env!(:vutuv, Vutuv.Endpoint)[:browserstack_user], Application.fetch_env!(:vutuv, Vutuv.Endpoint)[:browserstack_password]}]
 

      _ -> nil
    end
  end

  # def store_gravatar(user) do
  #   case HTTPoison.get("https://www.gravatar.com/avatar/#{hd(user.emails).md5sum}?s=130&d=404", [], [timeout: 1000, recv_timeout: 1000])  do
  #     {:ok, %HTTPoison.Response{status_code: 404}} -> nil
  #     {:ok, %HTTPoison.Response{body: body, headers: headers}} ->
  #       content_type = find_content_type(headers)
  #       filename = "/#{user.active_slug}.#{String.replace(content_type,"image/", "")}"
  #       path = System.tmp_dir
  #       upload = #create the upload struct that arc-ecto will use to store the file and update the database
  #         %Plug.Upload{content_type: content_type,
  #         filename: filename,
  #         path: path<>filename}
  #       File.write(path<>filename, body) #Write the file temporarily to the disk
  #       user
  #       |> Repo.preload([:slugs, :oauth_providers, :emails])
  #       |> User.changeset(%{avatar: upload}) #update the user with the upload struct
  #       |> Repo.update
  #     _ -> nil
  #   end
  # end

end

# The idea of this module is to generate screenshots
# of Urls and save them in Screenshot.
# We use browserstack.com for this and are greatful
# that they give us a free account because we are
# an open-source project.
#
defmodule Vutuv.Browserstack do
  import Ecto.Query
  alias Vutuv.Screenshot
