From 989e6afb0b9c4b43cac48918ee08d0e24c606c80 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Mon, 17 Jun 2019 23:58:29 -0300 Subject: Add ban and unban endpoints --- endpoints.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'endpoints.md') diff --git a/endpoints.md b/endpoints.md index 9abcf1a..2ee313e 100644 --- a/endpoints.md +++ b/endpoints.md @@ -82,14 +82,14 @@ from matrix.org. This will give you an overview about what's implemented in the - [X] GET - /_matrix/client/r0/joined_rooms - [X] POST - /_matrix/client/r0/join/{roomIdOrAlias} -- [ ] POST - /_matrix/client/r0/rooms/{roomId}/ban +- [X] POST - /_matrix/client/r0/rooms/{roomId}/ban - [ ] POST - /_matrix/client/r0/rooms/{roomId}/forget - [ ] POST - /_matrix/client/r0/rooms/{roomId}/invite - [ ] POST - /_matrix/client/r0/rooms/{roomId}/invite - [ ] POST - /_matrix/client/r0/rooms/{roomId}/join - [ ] POST - /_matrix/client/r0/rooms/{roomId}/kick - [X] POST - /_matrix/client/r0/rooms/{roomId}/leave -- [ ] POST - /_matrix/client/r0/rooms/{roomId}/unban +- [X] POST - /_matrix/client/r0/rooms/{roomId}/unban ## Room participation -- cgit v1.2.3-70-g09d2 From a090293f1fb64375f5ba16b6a5e53c829eb41add Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Tue, 18 Jun 2019 00:02:08 -0300 Subject: Add invite endpoint --- endpoints.md | 2 +- lib/Matrix/Client.pm6 | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'endpoints.md') diff --git a/endpoints.md b/endpoints.md index 2ee313e..5fbb63c 100644 --- a/endpoints.md +++ b/endpoints.md @@ -84,7 +84,7 @@ from matrix.org. This will give you an overview about what's implemented in the - [X] POST - /_matrix/client/r0/join/{roomIdOrAlias} - [X] POST - /_matrix/client/r0/rooms/{roomId}/ban - [ ] POST - /_matrix/client/r0/rooms/{roomId}/forget -- [ ] POST - /_matrix/client/r0/rooms/{roomId}/invite +- [X] POST - /_matrix/client/r0/rooms/{roomId}/invite - [ ] POST - /_matrix/client/r0/rooms/{roomId}/invite - [ ] POST - /_matrix/client/r0/rooms/{roomId}/join - [ ] POST - /_matrix/client/r0/rooms/{roomId}/kick diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index a19918b..86de2e8 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -219,6 +219,14 @@ method unban(Str $room-id, Str $user-id) { ); } +#| POST - /_matrix/client/r0/rooms/{roomId}/invite +method invite(Str $room-id, Str $user-id) { + $.post( + "/rooms/$room-id/invite", + :$user-id + ) +} + #| POST - /_matrix/client/r0/rooms/{roomId}/leave method leave-room($room-id) { $.post("/rooms/$room-id/leave"); -- cgit v1.2.3-70-g09d2 From 86d4f5b939010f716e6e0e4768e6a0da3700adfd Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Tue, 18 Jun 2019 00:06:07 -0300 Subject: Add kick and forget endpoints --- endpoints.md | 4 ++-- lib/Matrix/Client.pm6 | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'endpoints.md') diff --git a/endpoints.md b/endpoints.md index 5fbb63c..8b22289 100644 --- a/endpoints.md +++ b/endpoints.md @@ -83,11 +83,11 @@ from matrix.org. This will give you an overview about what's implemented in the - [X] GET - /_matrix/client/r0/joined_rooms - [X] POST - /_matrix/client/r0/join/{roomIdOrAlias} - [X] POST - /_matrix/client/r0/rooms/{roomId}/ban -- [ ] POST - /_matrix/client/r0/rooms/{roomId}/forget +- [X] POST - /_matrix/client/r0/rooms/{roomId}/forget - [X] POST - /_matrix/client/r0/rooms/{roomId}/invite - [ ] POST - /_matrix/client/r0/rooms/{roomId}/invite - [ ] POST - /_matrix/client/r0/rooms/{roomId}/join -- [ ] POST - /_matrix/client/r0/rooms/{roomId}/kick +- [X] POST - /_matrix/client/r0/rooms/{roomId}/kick - [X] POST - /_matrix/client/r0/rooms/{roomId}/leave - [X] POST - /_matrix/client/r0/rooms/{roomId}/unban diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index 86de2e8..6d60660 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -227,6 +227,20 @@ method invite(Str $room-id, Str $user-id) { ) } +#| POST - /_matrix/client/r0/rooms/{roomId}/forget +method forget(Str $room-id) { + $.post("/rooms/$room-id/forget") +} + +#| POST - /_matrix/client/r0/rooms/{roomId}/kick +method kick(Str $room-id, Str $user-id, $reason = "") { + $.post( + "/rooms/$room-id/kick", + :$user-id, + :$reason + ); +} + #| POST - /_matrix/client/r0/rooms/{roomId}/leave method leave-room($room-id) { $.post("/rooms/$room-id/leave"); -- cgit v1.2.3-70-g09d2 From 82a19be633aafd305fab93c7e3ea660656ae441a Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sat, 29 Jun 2019 19:04:10 -0300 Subject: Add device management endpoints Missing delete methods only --- endpoints.md | 20 +++++++++++++------- lib/Matrix/Client.pm6 | 25 +++++++++++++++++++++++++ lib/Matrix/Response.pm6 | 15 +++++++++++++++ 3 files changed, 53 insertions(+), 7 deletions(-) (limited to 'endpoints.md') diff --git a/endpoints.md b/endpoints.md index 8b22289..2ddf2c3 100644 --- a/endpoints.md +++ b/endpoints.md @@ -8,13 +8,17 @@ from matrix.org. This will give you an overview about what's implemented in the - [ ] PUT - /_matrix/client/r0/directory/list/appservice/{networkId}/{roomId} +## Capabilities + +- [ ] GET - /_matrix/client/r0/capabilities + ## Device management - [ ] DELETE - /_matrix/client/r0/devices/{deviceId} -- [ ] GET - /_matrix/client/r0/devices -- [ ] GET - /_matrix/client/r0/devices/{deviceId} +- [X] GET - /_matrix/client/r0/devices +- [X] GET - /_matrix/client/r0/devices/{deviceId} - [ ] POST - /_matrix/client/r0/delete_devices -- [ ] PUT - /_matrix/client/r0/devices/{deviceId} +- [X] PUT - /_matrix/client/r0/devices/{deviceId} ## End-to-end encryption @@ -38,9 +42,7 @@ from matrix.org. This will give you an overview about what's implemented in the ## Presence -- [ ] GET - /_matrix/client/r0/presence/list/{userId} - [X] GET - /_matrix/client/r0/presence/{userId}/status -- [ ] POST - /_matrix/client/r0/presence/list/{userId} - [X] PUT - /_matrix/client/r0/presence/{userId}/status ## Push notifications @@ -103,7 +105,6 @@ from matrix.org. This will give you an overview about what's implemented in the - [ ] GET - /_matrix/client/r0/rooms/{roomId}/members - [X] GET - /_matrix/client/r0/rooms/{roomId}/messages - [ ] GET - /_matrix/client/r0/rooms/{roomId}/state -- [ ] GET - /_matrix/client/r0/rooms/{roomId}/state/{eventType} - [ ] GET - /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey} - [ ] GET - /_matrix/client/r0/sync - [ ] GET - /_matrix/client/r0/user/{userId}/filter/{filterId} @@ -111,10 +112,13 @@ from matrix.org. This will give you an overview about what's implemented in the - [ ] POST - /_matrix/client/r0/user/{userId}/filter - [ ] PUT - /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId} - [X] PUT - /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId} -- [ ] PUT - /_matrix/client/r0/rooms/{roomId}/state/{eventType} - [X] PUT - /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey} - [ ] PUT - /_matrix/client/r0/rooms/{roomId}/typing/{userId} +## Room ugprades + +- [ ] POST - /_matrix/client/r0/rooms/{roomId}/upgrade + ## Search - [ ] POST - /_matrix/client/r0/search @@ -145,6 +149,8 @@ from matrix.org. This will give you an overview about what's implemented in the - [X] GET - /_matrix/client/r0/profile/{userId}/avatar_url - [X] GET - /_matrix/client/r0/profile/{userId}/displayname - [ ] GET - /_matrix/client/r0/register/available +- [ ] GET - /_matrix/client/r0/user/{userId}/account_data/{type} +- [ ] GET - /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type} - [ ] GET - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags - [ ] POST - /_matrix/client/r0/account/3pid - [ ] POST - /_matrix/client/r0/account/3pid/delete diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index 1a24790..d7206b0 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -116,6 +116,31 @@ method whoami { $!user-id } +## Device management + +#| GET - /_matrix/client/r0/devices +method devices(Matrix::Client:D: --> Seq) { + my $data = from-json($.get("/devices").content); + $data.map(-> $device-data { + Matrix::Response::Device.new(|$device-data) + }) +} + +#| GET - /_matrix/client/r0/devices/{deviceId} +method device(Matrix::Client:D: Str $device-id where *.chars > 0 --> Matrix::Response::Device) { + my $device-data = from-json($.get("/devices/$device-id").content); + Matrix::Response::Device.new(|$device-data) +} + +#| PUT - /_matrix/client/r0/devices/{deviceId} +method update-device(Matrix::Client:D: + Str $device-id where *.chars > 0, + Str $display-name) { + $.put("/devices/$device-id", :display_name($display-name)); +} + +## Presence + #| GET - /_matrix/client/r0/presence/{userId}/status method presence(Matrix::Client:D: $user-id? --> Matrix::Response::Presence) { my $id = $user-id // $.whoami; diff --git a/lib/Matrix/Response.pm6 b/lib/Matrix/Response.pm6 index edd4d51..14e2b21 100644 --- a/lib/Matrix/Response.pm6 +++ b/lib/Matrix/Response.pm6 @@ -122,3 +122,18 @@ class Tag { self.bless(:@tags) } } + + +class Matrix::Response::Device { + has Str $.device-id; + has $.display-name; + has $.last-seen-ip; + has $.last-seen-ts; + + submethod BUILD( + Str :device_id(:$!device-id), + :display_name(:$!display-name)?, + :last_seen_ip(:$!last-seen-ip)?, + :last_seen_ts(:$!last-seen-ts)? + ) { } +} -- cgit v1.2.3-70-g09d2