defmodule TehamaClient.Site do
@moduledoc """
A tehama site.
Note that `name` is trimmed to remove whitespace.
"""
use TypedStruct
typedstruct do
@typedoc "A typed Site struct"
field(:access_code, String.t())
field(:parent_node_id, String.t())
field(:node_id, String.t())
field(:node_type, String.t())
field(:name, String.t())
field(:property_id, String.t())
field(:address, String.t())
field(:city, String.t())
field(:state, String.t())
field(:zipcode, String.t())
field(:sql_user_name, String.t())
field(:dcap_ip_adrs, String.t())
field(:get_port_num, String.t())
field(:knocker_dly, String.t())
field(:knocker_dly_enbld, String.t())
field(:note, String.t())
end
def new(data) when is_map(data) do
%__MODULE__{
access_code: data["access_code"],
property_id: data["property_id"],
name: (data["name"] || "") |> String.trim(),
node_type: data["nodeType"],
node_id: data["nodeId"]
}
end
def new(_) do
nil
end
end