defmodule MicrowavepropWeb.Api.V1.UserJSON do @moduledoc "Renders user representations for /api/v1." alias Microwaveprop.Accounts.User @doc "Public profile (no email)." @spec public(User.t()) :: map() def public(%User{} = user) do %{ data: %{ id: user.id, callsign: user.callsign, name: user.name, home_grid: user.home_grid, home_lat: user.home_lat, home_lon: user.home_lon } } end @doc "Authenticated /me view (includes email + admin flag)." @spec me(User.t()) :: map() def me(%User{} = user) do %{ data: %{ id: user.id, callsign: user.callsign, name: user.name, email: user.email, is_admin: user.is_admin, confirmed_at: user.confirmed_at, home_grid: user.home_grid, home_lat: user.home_lat, home_lon: user.home_lon, home_elevation_m: user.home_elevation_m } } end end