diff options
Diffstat (limited to 'lib/polyjuice/client/room.ex')
-rw-r--r-- | lib/polyjuice/client/room.ex | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/polyjuice/client/room.ex b/lib/polyjuice/client/room.ex index f640861..886a38e 100644 --- a/lib/polyjuice/client/room.ex +++ b/lib/polyjuice/client/room.ex @@ -265,4 +265,29 @@ defmodule Polyjuice.Client.Room do fn _ -> nil end ) end + + @doc """ + Get a room state. + If `event_type` is not provided, returns a list of events. + If `event_type` and `state_key` are provided, returns an event content. + `state_key` can be omitted but this will return events that have a blank state key, not events that have "any state key". + """ + @spec get_state( + client_api :: Polyjuice.Client.API.t(), + room :: String.t(), + event_type :: String.t(), + state_key :: String.t() + ) :: {:ok, String.t()} | Any + def get_state(client_api, room, event_type \\ nil, state_key \\ "") + when (is_nil(event_type) or is_binary(event_type)) and is_binary(state_key) and + is_binary(room) do + Polyjuice.Client.API.call( + client_api, + %Polyjuice.Client.Endpoint.GetRoomsState{ + room: room, + event_type: event_type, + state_key: state_key + } + ) + end end |