defmodule Ipstack do @moduledoc """ Ipstack library """ defmodule Result do @moduledoc false @type t :: %__MODULE__{ country_code: String.t(), region_code: String.t(), city: String.t() | nil, security: Ipstack.Result.Security.t() } defstruct country_code: nil, region_code: nil, city: nil, security: nil end defmodule Result.Security do @moduledoc false @type t :: %__MODULE__{ is_tor?: boolean, is_proxy?: boolean, is_crawler?: boolean, threat_level: :low | :medium | :high } defstruct [:is_tor?, :is_proxy?, :is_crawler?, :threat_level] end @callback resolve(String.t()) :: {:ok, map} | {:error | atom} def resolve(ip_address) do impl().resolve(ip_address) end defp impl, do: Application.fetch_env!(:ipstack, :impl) def reset_cache, do: Cachex.clear(:ipstack_lookup_cache) end