aboutsummaryrefslogtreecommitdiff
path: root/lib/Matrix/Client.rakumod
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@gmail.com>2021-07-08 17:20:37 -0300
committerMatias Linares <matiaslina@gmail.com>2021-07-08 17:20:37 -0300
commit6d93e48c2e9260a15746e96ec663c517d9ef26da (patch)
tree7506636606ade12732b78b0350eb7a1a07f2f1f8 /lib/Matrix/Client.rakumod
parente57b75a19a8f4a02bf93e99ac9dbf3c06575b219 (diff)
downloadperl6-matrix-client-6d93e48c2e9260a15746e96ec663c517d9ef26da.tar.gz
Add `room` helper method
Diffstat (limited to 'lib/Matrix/Client.rakumod')
-rw-r--r--lib/Matrix/Client.rakumod15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/Matrix/Client.rakumod b/lib/Matrix/Client.rakumod
index 01babe5..5c5751f 100644
--- a/lib/Matrix/Client.rakumod
+++ b/lib/Matrix/Client.rakumod
@@ -199,6 +199,15 @@ multi method sync(:$since = "") {
# Rooms
+#| Helper method to get a Matrix::Client::Room instance
+method room(Str $room-id --> Matrix::Client::Room) {
+ Matrix::Client::Room.new(
+ id => $room-id,
+ access-token => self.access-token,
+ home-server => self.home-server
+ )
+}
+
#| POST - /_matrix/client/r0/createRoom
method create-room(
Bool :$public = False,
@@ -216,11 +225,7 @@ method create-room(
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
- )
+ $.room($res<room_id>)
}
#| POST - /_matrix/client/r0/join/{roomIdOrAlias}