   end
 
   def update_lead(lead_id, payload, opts \\ [])
+  def update_lead(@not_found_id, _payload, _opts) do
+    {:error, :mock_not_found}
+  end
   def update_lead(lead_id, payload, opts) do
     lead = load("lead.json")
     |> Map.merge(payload)
-    |> Map.merge({"id" => lead_id})
+    |> Map.merge(%{"id" => lead_id})
 
     lead = parse_dates_to_strings(lead)
     send self(), {:closex_mock_client, :update_lead, [lead_id, payload, opts]}
     {:ok, lead}
-  end
-  def update_lead(@not_found_id, _payload, _opts) do
-    {:error, :mock_not_found}
   end
 
   def create_opportunity(payload, opts \\ []) do

    {:error, :mock_not_found}
  """
  def get_lead(id, opts \\ [])
  def get_lead(id, opts) do
    lead = load("lead.json")
           |> Map.merge({"id" => id})
    send self(), {:closex_mock_client, :get_lead, [id, opts]}
    {:ok, lead}
  end
  def get_lead(id = @not_found_id, opts) do
    send self(), {:closex_mock_client, :get_lead, [id, opts]}
    {:error, :mock_not_found}
  end

  @doc """
  Gets an opportunity from CloseIO.

    {:error, :mock_not_found}
  """
  def get_organization(id, opts \\ [])
  def get_organization(id = @not_found_id, opts) do
    send self(), {:closex_mock_client, :get_organization, [id, opts]}
    {:error, :mock_not_found}
  end
  def get_organization(id, opts) do
    organization = load("organization.json")
                   |> Map.merge(%{"id" => id})
    send self(), {:closex_mock_client, :get_organization, [id, opts]}
    {:ok, organization}
  end

  @doc """
