   alias Vutuv.Repo
 
   def store_screenshot(url) do
-    job_id = job_id(url)
-    :timer.sleep(30000)
+    job_id = new_job_id(url)
+    :timer.sleep(45000)
     image_url = image_url(job_id)
     image_url
+    # TODO: Download the image from image_url and save it as
+    # a Screenshot to Url.
   end
 
-  def job_id(url) do
+  # Ask browserstack.com to generate a screenshot.
+  # WARNING: The generation of a screenshot takes time.
+  #          You have to wait at least 15 seconds after
+  #          new_job_id(url) to run image_url(url).
+  #
+  def new_job_id(url) do
     hackney = [basic_auth: {Application.fetch_env!(:vutuv, Vutuv.Endpoint)[:browserstack_user], Application.fetch_env!(:vutuv, Vutuv.Endpoint)[:browserstack_password]}]
     headers = ["Content-Type": "application/json", "Accept": "Application/json; Charset=utf-8"]
 

    end
  end

  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]}]


# 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
