summaryrefslogtreecommitdiff
path: root/lib/Matrix
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2018-06-04 23:16:32 -0300
committerMatias Linares <matiaslina@openmailbox.org>2018-06-04 23:16:32 -0300
commitde4faaf9211308bd7f0fce524dbe1718b2dd88e9 (patch)
tree38b5d7060f60ee6a0d722c4713fe933f6836c909 /lib/Matrix
parent0bbd2b29349e0aa99c13e93ee12dba50b6ee06c5 (diff)
downloadperl6-matrix-client-de4faaf9211308bd7f0fce524dbe1718b2dd88e9.tar.gz
Add create-room endpoint
Diffstat (limited to 'lib/Matrix')
-rw-r--r--lib/Matrix/Client.pm623
1 files changed, 23 insertions, 0 deletions
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<visibility> = $public;
+ }
+
+ my $res = from-json($.post('/createRoom', |%params).content);
+
+ Matrix::Client::Room.new(
+ id => $res<room_id>,
+ access-token => self.access-token,
+ home-server => self.home-server
+ )
+}
+
method join-room($room-id!) {
$.post("/rooms/$room-id/join")
}