# `Ltix.Registerable`
[🔗](https://github.com/DecoyLex/ltix/blob/main/lib/ltix/registerable.ex#L1)

Protocol for converting your registration struct to an `Ltix.Registration`.

Implement it for your registration struct, and your storage adapter can
return that struct. Ltix passes your struct to the other
`Ltix.StorageAdapter` callbacks, and the `Ltix.LaunchContext` and
`Ltix.OAuth.Client` have it.

    defmodule MyApp.PlatformRegistration do
      defstruct [:id, :tenant_id, :issuer, :client_id,
                 :auth_endpoint, :jwks_uri, :token_endpoint]

      defimpl Ltix.Registerable do
        def to_registration(reg) do
          Ltix.Registration.new(%{
            issuer: reg.issuer,
            client_id: reg.client_id,
            auth_endpoint: reg.auth_endpoint,
            jwks_uri: reg.jwks_uri,
            token_endpoint: reg.token_endpoint
          })
        end
      end
    end

`Ltix.Registration` implements this protocol, so your storage adapter can
also return a `%Registration{}`. Login and launch return the same error as
`Ltix.Registration.new/1` for an invalid one.

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `to_registration`

```elixir
@spec to_registration(t()) :: {:ok, Ltix.Registration.t()} | {:error, Exception.t()}
```

Return the `Ltix.Registration` for the given struct.

Build it with `Ltix.Registration.new/1`, which validates the fields.

---

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