# `Aker.Store`
[🔗](https://github.com/udin-io/aker/blob/v0.1.0/lib/aker/store.ex#L1)

Where a host keeps its licence. The gate reads and writes it only through
this behaviour, so the library takes no database dependency.

A record is any map or struct with `:envelope` (the licence file's
bytes), `:licence_id`, `:serial`, `:term_end` and `:last_seen_at`.
`store/3`'s attributes add `:customer_name`, `:seats`, `:features` and
`:term_start`.

The `actor` passes from the host's call to `store/3` untouched; the gate
never reads it. A renewal stores as `:system`. The store decides who may
write, and answers `{:error, :forbidden}` to anyone else.

Each callback gets the `opts` of the gate's `store: {module, opts}`.

# `record`

```elixir
@type record() :: map()
```

# `current`

```elixir
@callback current(opts :: keyword()) :: {:ok, record() | nil} | {:error, term()}
```

The newest licence by serial, `nil` when none is stored.

# `store`

```elixir
@callback store(attrs :: map(), actor :: term(), opts :: keyword()) ::
  {:ok, record()} | {:error, :forbidden} | {:error, :not_stored}
```

Stores a licence that passed every check.

# `touch`

```elixir
@callback touch(record(), last_seen_at :: DateTime.t(), opts :: keyword()) ::
  {:ok, record()} | {:error, term()}
```

Moves the latest time seen on `record`.

---

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