defmodule MicrowavepropWeb.Api.V1.BeaconJSON do @moduledoc "Renders beacon representations." alias Microwaveprop.Beacons.Beacon @spec index(map()) :: map() def index(%{beacons: beacons}), do: %{data: Enum.map(beacons, &data/1)} @spec show(map()) :: map() def show(%{beacon: beacon}), do: %{data: data(beacon)} defp data(%Beacon{} = b) do %{ id: b.id, callsign: b.callsign, frequency_mhz: b.frequency_mhz, lat: b.lat, lon: b.lon, grid: b.grid, power_mw: b.power_mw, height_ft: b.height_ft, on_the_air: b.on_the_air, approved: b.approved, keying: b.keying, bearing: b.bearing, beamwidth_deg: b.beamwidth_deg, notes: b.notes, inserted_at: b.inserted_at } end end