From de4faaf9211308bd7f0fce524dbe1718b2dd88e9 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Mon, 4 Jun 2018 23:16:32 -0300 Subject: Add create-room endpoint --- lib/Matrix/Client.pm6 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib') diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index 73ed923..e380e95 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -125,6 +125,29 @@ multi method sync(Hash :$sync-filter is copy, :$since = "") { # Rooms +method create-room( + Bool :$public = False, + *%args --> Matrix::Client::Room +) { + my %params; + + for %args.kv -> $key, $value { + %params{$key.subst('-', '_')} = $value; + } + + if 'visibility' ~~ %params { + %params = $public; + } + + my $res = from-json($.post('/createRoom', |%params).content); + + Matrix::Client::Room.new( + id => $res, + access-token => self.access-token, + home-server => self.home-server + ) +} + method join-room($room-id!) { $.post("/rooms/$room-id/join") } -- cgit v1.2.3-70-g09d2