summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@gmail.com>2019-03-18 16:13:46 -0300
committerMatias Linares <matiaslina@gmail.com>2019-03-18 16:13:46 -0300
commit401f3f80dca1cb16e51ab97b91d672ef895d9a0f (patch)
tree121602e775fde556ac34dec9f25a65eb2a30ff4b
parent0977a9f4148518686ac6e75c56542e7d8daca029 (diff)
parent24fa000eba9f778311b196e4df255952b6ac92bc (diff)
downloadperl6-matrix-client-401f3f80dca1cb16e51ab97b91d672ef895d9a0f.tar.gz
Merge remote-tracking branch 'github/master'
-rw-r--r--endpoints.md6
-rw-r--r--lib/Matrix/Client.pm618
-rw-r--r--lib/Matrix/Response.pm69
3 files changed, 30 insertions, 3 deletions
diff --git a/endpoints.md b/endpoints.md
index 8b0d3b7..2d7cb4e 100644
--- a/endpoints.md
+++ b/endpoints.md
@@ -152,9 +152,9 @@ from matrix.org. This will give you an overview about what's implemented in the
- [ ] GET - /_matrix/client/r0/account/3pid
- [ ] POST - /_matrix/client/r0/account/3pid
- [ ] PUT - /_matrix/client/r0/user/{userId}/account_data/{type}
-- [ ] PUT - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
-- [ ] DELETE - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
-- [ ] GET - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags
+- [X] PUT - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
+- [X] DELETE - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
+- [X] GET - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags
- [ ] POST - /_matrix/client/r0/account/deactivate
- [ ] POST - /_matrix/client/r0/account/3pid/delete
diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6
index 5f52779..bf3935c 100644
--- a/lib/Matrix/Client.pm6
+++ b/lib/Matrix/Client.pm6
@@ -117,6 +117,24 @@ method set-presence(Matrix::Client:D: Str $presence, Str :$status-message = "")
:$presence, :status_msg($status-message));
}
+#| PUT - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
+multi method tags(Str $room-id, Str:D $tag, $order) {
+ my $id = $.whoami;
+ from-json($.put("/user/$id/rooms/$room-id/tags/$tag", :$order).content)
+}
+
+#| GET - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags
+multi method tags(Str $room-id) {
+ my $id = $.whoami;
+ Matrix::Response::Tag.new(from-json($.get("/user/$id/rooms/$room-id/tags").content))
+}
+
+#| DELETE - /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}
+method remove-tag(Str $room-id, Str:D $tag) {
+ my $id = $.whoami;
+ $.delete("/user/$id/rooms/$room-id/tags/$tag")
+}
+
# Syncronization
multi method sync(Hash :$sync-filter is copy, :$since = "") {
diff --git a/lib/Matrix/Response.pm6 b/lib/Matrix/Response.pm6
index d8f68f0..edd4d51 100644
--- a/lib/Matrix/Response.pm6
+++ b/lib/Matrix/Response.pm6
@@ -113,3 +113,12 @@ class Presence {
:currently_active(:$!currently-active) = False
) { }
}
+
+class Tag {
+ has @.tags;
+
+ method new(%json) {
+ my @tags = %json<tags>.keys;
+ self.bless(:@tags)
+ }
+}