# `Smee.Fetch`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/fetch.ex#L1)

Downloads or loads the metadata specified in a `%Smee.Source{}` struct and returns a `%Smee.Metadata{}` struct.

The `fetch!/2` and `fetch/2` functions can handle both remote and local sources, but sometimes it can be
  reassuring to prevent unexpected behaviour (perhaps if using a source defined by a user) so `Smee.Fetch` also
contains `local!/2` and `remote!/2` which will each only accept certain types of sources.

This module will do the work of creating suitable Metadata structs for you, so you should not normally need to
  create Metadata structs directly yourself.

# `fetch`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/fetch.ex#L45)

```elixir
@spec fetch(source :: Smee.Source.t(), options :: keyword()) ::
  {:ok, Smee.Metadata.t()} | {:error, any()}
```

Uses the passed Source struct to load or download the requested metadata XML, and returns a Metadata struct containing the XML
inside an :ok tuple.

Works with all types of Source, even MDQ services.

# `fetch!`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/fetch.ex#L27)

```elixir
@spec fetch!(source :: Smee.Source.t(), options :: keyword()) :: Smee.Metadata.t()
```

Uses the passed Source struct to load or download the requested metadata XML, and returns a Metadata struct containing the XML.

Works with all types of Source, even MDQ services.

Will raise an exception on any errors.

# `local`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/fetch.ex#L128)

```elixir
@spec local(source :: Smee.Source.t(), options :: keyword()) ::
  {:ok, Smee.Metadata.t()} | {:error, any()}
```

Uses the passed Source struct to load the requested metadata XML, and returns a Metadata struct containing
 the XML in an :ok tuple

 Works with local Sources including MDQ services but will not accept metadata at a remote URL.

# `local!`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/fetch.ex#L110)

```elixir
@spec local!(source :: Smee.Source.t(), options :: keyword()) :: Smee.Metadata.t()
```

Uses the passed Source struct to load the requested metadata XML, and returns a Metadata struct containing
 the XML

 Works with local Sources including MDQ services but will not accept metadata at a remote URL.

 Will raise an exception on any errors.

# `probe`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/fetch.ex#L174)

```elixir
@spec probe(sources :: Smee.Source.t()) :: {:ok, map()} | {:error, any()}
```

Connects to a remote Source and uses HEAD HTTP method, with no caching, to fetch version/change information from headers.

An :ok tuple containing a map of etag (string) and changed_at (DateTime) will be returned if successful.

# `remote`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/fetch.ex#L64)

```elixir
@spec remote(source :: Smee.Source.t(), options :: keyword()) ::
  {:ok, Smee.Metadata.t()} | {:error, any()}
```

Uses the passed Source struct to download the requested metadata XML, and returns a Metadata struct containing
 the XML in an :ok/:error tuple.

   Works with remote Sources including MDQ services but will not accept metadata in a local file.

# `remote!`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/fetch.ex#L85)

```elixir
@spec remote!(source :: Smee.Source.t(), options :: keyword()) :: Smee.Metadata.t()
```

Uses the passed Source struct to download the requested metadata XML, and returns a Metadata struct containing
 the XML

 Works with remote Sources including MDQ services but will not accept metadata in a local file.

 Will raise an exception on any errors.

# `warm`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/fetch.ex#L157)

```elixir
@spec warm(sources :: Smee.Source.t() | list(), options :: keyword()) :: map()
```

Downloads one or more Sources in parallel and caches the result in the HTTP cache.

A map of source URLs and status codes are returned. A status code of 0 indicates a client error of some sort.

This function is useful for downloading source metadata in advance so that processing can happen immediately.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
