defmodule UrbitEx.Group do alias UrbitEx.Resource # "/ship/~mirtyl-wacdec/apitest2" => %{ # "hidden" => false, # "members" => ["havsem-mirtyl-wacdec", "timlet-barlep-docteg-mothep", # "mirtyl-wacdec"], # "policy" => %{"open" => %{"banRanks" => [], "banned" => []}}, # "tags" => %{"admin" => ["mirtyl-wacdec"]} # } defstruct hidden: false, members: ["mirtyl-wacdec", "zod"], policy: %{}, tags: %{}, # also the index on the graph url: "/ship/~mirtyl-wacdec/apitest2" def to_list(%{}), do: nil def to_list(graph) do hashes = Map.keys(graph) |> Enum.map(&new(graph, &1)) end def new(graph, index) do node = graph[index] %__MODULE__{ hidden: node["hidden"], members: node["members"], policy: node["policy"], tags: node["tags"], url: index } end end