From ecf602241f38552132e16d44a8871232b23f2b1e Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Wed, 5 Jun 2019 00:30:56 -0300 Subject: Add POD declarators --- lib/Matrix/Client.pm6 | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'lib/Matrix/Client.pm6') diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index bf3935c..2fdbf4b 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -17,11 +17,12 @@ submethod TWEAK { $Matrix::Client::Common::TXN-ID = now.Int; } - +#| POST - /_matrix/client/r0/login multi method login(Str $username, Str $password) { $.login(:$username, :$password); } +#| POST - /_matrix/client/r0/login multi method login(Str :$username, Str :$password) { my $post-data = { type => "m.login.password", @@ -41,10 +42,12 @@ multi method login(Str :$username, Str :$password) { $!device-id = $data; } +#| POST - /_matrix/client/r0/logout method logout() { $.post("/logout") } +#| POST - /_matrix/client/r0/register method register($username, $password, Bool :$bind-email? = False) { my $res = $.post("/register", username => $username, password => $password, @@ -59,11 +62,13 @@ method register($username, $password, Bool :$bind-email? = False) { # User Data +#| GET - /_matrix/client/r0/profile/{userId} method profile(Str :$user-id?) { my $id = $user-id // $.whoami; from-json($.get("/profile/" ~ $id).content); } +#| GET - /_matrix/client/r0/profile/{userId}/displayname method display-name(Str :$user-id?) { my $id = $user-id // $.whoami; my $res = $.get("/profile/" ~ $id ~ "/displayname"); @@ -73,11 +78,13 @@ method display-name(Str :$user-id?) { $data // "" } +#| PUT - /_matrix/client/r0/profile/{userId}/displayname method change-display-name(Str:D $display-name!) { so $.put("/profile/" ~ $.whoami ~ "/displayname", displayname => $display-name) } +#| GET - /_matrix/client/r0/profile/{userId}/avatar_url method avatar-url(Str :$user-id?) { my $id = $user-id // $.whoami; my $res = $.get("/profile/" ~ $id ~ "/avatar_url"); @@ -86,16 +93,19 @@ method avatar-url(Str :$user-id?) { $data // "" } +#| PUT - /_matrix/client/r0/profile/{userId}/avatar_url multi method change-avatar(IO::Path $avatar) { my $mxc-url = $.upload($avatar.IO); samewith($mxc-url); } +#| PUT - /_matrix/client/r0/profile/{userId}/avatar_url multi method change-avatar(Str:D $mxc-url!) { $.put("/profile/" ~ $.whoami ~ "/avatar_url", avatar_url => $mxc-url); } +#| GET - /_matrix/client/r0/account/whoami method whoami { unless $!user-id { my $res = $.get('/account/whoami'); @@ -106,12 +116,14 @@ method whoami { $!user-id } +#| GET - /_matrix/client/r0/presence/{userId}/status method presence(Matrix::Client:D: $user-id? --> Matrix::Response::Presence) { my $id = $user-id // $.whoami; my $data = from-json($.get("/presence/$id/status").content); Matrix::Response::Presence.new(|$data) } +#| PUT - /_matrix/client/r0/presence/{userId}/status method set-presence(Matrix::Client:D: Str $presence, Str :$status-message = "") { $.put("/presence/$.whoami/status", :$presence, :status_msg($status-message)); @@ -137,10 +149,12 @@ method remove-tag(Str $room-id, Str:D $tag) { # Syncronization +#| GET - /_matrix/client/r0/sync multi method sync(Hash :$sync-filter is copy, :$since = "") { $.sync(sync-filter => to-json($sync-filter), since => $since) } +#| GET - /_matrix/client/r0/sync multi method sync(Str:D :$sync-filter, Str :$since = "") { my $res = $.get("/sync", timeout => 30000, @@ -151,6 +165,7 @@ multi method sync(Str:D :$sync-filter, Str :$since = "") { Matrix::Response::Sync.new($res.content) } +#| GET - /_matrix/client/r0/sync multi method sync(:$since = "") { my $res = $.get("/sync", timeout => 30000, since => $since); Matrix::Response::Sync.new($res.content) @@ -158,6 +173,7 @@ multi method sync(:$since = "") { # Rooms +#| POST - /_matrix/client/r0/createRoom method create-room( Bool :$public = False, *%args --> Matrix::Client::Room @@ -181,14 +197,17 @@ method create-room( ) } +#| POST - /_matrix/client/r0/join/{roomIdOrAlias} method join-room($room-id!) { $.post("/join/$room-id") } +#| POST - /_matrix/client/r0/rooms/{roomId}/leave method leave-room($room-id) { $.post("/rooms/$room-id/leave"); } +#| GET - /_matrix/client/r0/joined_rooms method joined-rooms(--> Seq) { my $res = $.get('/joined_rooms'); my $data = from-json($res.content); @@ -201,10 +220,12 @@ method joined-rooms(--> Seq) { }); } +#| GET - /_matrix/client/r0/publicRooms method public-rooms() { $.get('/publicRooms') } +#| PUT - /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId} method send(Str $room-id, Str $body, :$type? = "m.text") { $Matrix::Client::Common::TXN-ID++; my $res = $.put( @@ -215,23 +236,27 @@ method send(Str $room-id, Str $body, :$type? = "m.text") { from-json($res.content) } +#| GET - /_matrix/client/r0/directory/room/{roomAlias} method get-room-id($room-alias) { my $res = $.get("/directory/room/$room-alias"); from-json($res.content) } +#| PUT - /_matrix/client/r0/directory/room/{roomAlias} method add-room-alias($room-id, $room-alias) { $.put("/directory/room/$room-alias", room_id => $room-id); } +#| DELETE - /_matrix/client/r0/directory/room/{roomAlias} method remove-room-alias($room-alias) { $.delete("/directory/room/$room-alias"); } # Media +#| POST - /_matrix/media/r0/upload method upload(IO::Path $path, Str $filename?) { my $buf = slurp $path, :bin; my $fn = $filename ?? $filename !! $path.basename; -- cgit v1.2.3-54-g00ecf