From 6d93e48c2e9260a15746e96ec663c517d9ef26da Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Thu, 8 Jul 2021 17:20:37 -0300 Subject: Add `room` helper method --- lib/Matrix/Client.rakumod | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'lib/Matrix/Client.rakumod') 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, - access-token => self.access-token, - home-server => self.home-server - ) + $.room($res) } #| POST - /_matrix/client/r0/join/{roomIdOrAlias} -- cgit v1.2.3-70-g09d2