1
0
Fork 0
mirror of https://github.com/matrix-org/gomatrix synced 2025-05-12 10:41:44 +00:00

Add Client.StateEvent method with test and example. Move examples to different file

This commit is contained in:
Kegan Dougal 2016-12-02 15:36:09 +00:00
parent 1842392399
commit 8bd1c5a89b
3 changed files with 74 additions and 25 deletions

View file

@ -303,6 +303,15 @@ func (cli *Client) LeaveRoom(roomID string) (resp *RespLeaveRoom, err error) {
return
}
// StateEvent gets a single state event in a room. It will attempt to JSON unmarshal into the given "outContent" struct with
// the HTTP response body, or return an error.
// See http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype-statekey
func (cli *Client) StateEvent(roomID, eventType, stateKey string, outContent interface{}) (err error) {
u := cli.BuildURL("rooms", roomID, "state", eventType, stateKey)
_, err = cli.MakeRequest("GET", u, nil, outContent)
return
}
// UploadLink uploads an HTTP URL and then returns an MXC URI.
func (cli *Client) UploadLink(link string) (*RespMediaUpload, error) {
res, err := cli.Client.Get(link)