analytics/lib/plausible_web/plugins/api/views/custom_props.ex
hq1 615b6aef7d
Plugins API exentsions (custom props, bulk goal delete, goal creation => ListResponse always) (#3593)
* End polymorphic response in goals create

Being part of the v3 spec, this isn't well
(or at all) supported by OpenAPI generators.

Always respond with `Goal.ListResponse`

* Implement `PUT /custom_props`

* Implement bulk `DELETE /goals`

* Expose API for (bulk-)disabling custom props

* Add controller typespecs

* Delegate list wrapping to `Plausible.API.*`
2023-12-06 12:33:33 +01:00

24 lines
468 B
Elixir

defmodule PlausibleWeb.Plugins.API.Views.CustomProp do
@moduledoc """
View for rendering Custom Props in the Plugins API
"""
use PlausibleWeb, :plugins_api_view
def render("index.json", %{props: props}) do
%{
custom_props: render_many(props, __MODULE__, "custom_prop.json")
}
end
def render("custom_prop.json", %{
custom_prop: custom_prop
}) do
%{
custom_prop: %{
key: custom_prop
}
}
end
end