summaryrefslogtreecommitdiff
path: root/lib/Matrix/Client.pm6
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@gmail.com>2019-06-29 19:04:10 -0300
committerMatias Linares <matiaslina@gmail.com>2019-06-29 19:04:10 -0300
commit82a19be633aafd305fab93c7e3ea660656ae441a (patch)
tree321f18e9311b8f45cb986130c8d2c2b068ab3506 /lib/Matrix/Client.pm6
parent4f9159b228cb2533eccab11f82690171a1484ee5 (diff)
downloadperl6-matrix-client-82a19be633aafd305fab93c7e3ea660656ae441a.tar.gz
Add device management endpoints
Missing delete methods only
Diffstat (limited to 'lib/Matrix/Client.pm6')
-rw-r--r--lib/Matrix/Client.pm625
1 files changed, 25 insertions, 0 deletions
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<devices>.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;