From 52bfdcb6fa3b4946f1dd8b5f8aea32bcc4265c7e Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 5 Jan 2017 14:25:05 +0000 Subject: [PATCH] Add PUT /room/roomId/state/type/key endpoint --- client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client.go b/client.go index c3a4d4e..acf8804 100644 --- a/client.go +++ b/client.go @@ -386,6 +386,14 @@ func (cli *Client) SendMessageEvent(roomID string, eventType string, contentJSON return } +// SendStateEvent sends a state event into a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey +// contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal. +func (cli *Client) SendStateEvent(roomID, eventType, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error) { + urlPath := cli.BuildURL("rooms", roomID, "state", eventType, stateKey) + _, err = cli.MakeRequest("PUT", urlPath, contentJSON, &resp) + return +} + // SendText sends an m.room.message event into the given room with a msgtype of m.text // See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-text func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error) {