diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Matrix/Client.pm6 | 25 | ||||
-rw-r--r-- | lib/Matrix/Response.pm6 | 15 |
2 files changed, 40 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; 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)? + ) { } +} |