defmodule LoopsEx.ContactProperties do @moduledoc """ Manage contact properties in your account. """ alias LoopsEx.Client @typedoc "Response type returned by Loops API calls" @type response :: LoopsEx.Client.response() @doc """ Create a contact property. ## Example iex> LoopsEx.ContactProperties.create(%{name: "planName", type: "string"}) {:ok, %{"success" => true}} """ @spec create(map()) :: response() def create(params) when is_map(params) do Client.request_api(:post, "/contacts/properties", params) |> Client.handle_response() end @doc """ List contact properties. ## Example iex> LoopsEx.ContactProperties.list() {:ok, [%{"key" => key, "label" => label, "type" => type}, ...]} """ @spec list(map()) :: response() def list(params \\ %{}) do Client.request_api(:get, "/contacts/properties", %{}, params) |> Client.handle_response() end end