diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2017-11-02 20:14:18 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2017-11-02 20:14:18 -0300 |
commit | ae68b25cc8c5888b5c1951b3f9a4bc6481a90a9e (patch) | |
tree | 58cf1ee97f7faa11fe9ab4b7d76948f68a6229ba | |
parent | ee4db344a8604852bfa4f863ea132b8e1ab63ab7 (diff) | |
download | perl6-matrix-client-ae68b25cc8c5888b5c1951b3f9a4bc6481a90a9e.tar.gz |
Make user-id and device-id public
-rw-r--r-- | lib/Matrix/Client.pm6 | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index 1708407..47610a1 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -7,14 +7,14 @@ use Matrix::Client::Requester; unit class Matrix::Client does Matrix::Client::Requester; -has Str $!user-id; -has Str $!device-id; +has Str $.user-id; +has Str $.device-id; has Str $!auth-file; has $!logged = False; has @!rooms; has @!users; -submethod BUILD(:$!home-server, :$!auth-file = 'auth') { +submethod BUILD(:$!home-server!, :$!auth-file = 'auth') { if $!auth-file.IO.e { my $data = from-json(slurp $!auth-file); $!access-token = $data<access_token>; @@ -25,14 +25,6 @@ submethod BUILD(:$!home-server, :$!auth-file = 'auth') { } } -method user-id() { - $!user-id -} - -method device-id() { - $!device-id -} - method login(Str $username, Str $pass) returns Bool { return True if $!logged; @@ -59,8 +51,8 @@ method login(Str $username, Str $pass) returns Bool { method save-auth-data() { my %data = access_token => $!access-token, - user_id => $!user-id, - device_id => $!device-id, + user_id => $.user-id, + device_id => $.device-id, txn_id => $Matrix::Client::Common::TXN-ID; spurt $!auth-file, to-json(%data); @@ -100,14 +92,14 @@ method check-res($res) { # User Data method profile(Str :$user-id?) { - my $id = $user-id // $!user-id; + my $id = $user-id // $.user-id; my $res = $.get("/profile/" ~ $id); $.check-res($res); $res } method display-name(Str :$user-id?) { - my $id = $user-id // $!user-id; + my $id = $user-id // $.user-id; my $res = $.get("/profile/" ~ $id ~ "/displayname"); $.check-res($res); @@ -117,13 +109,13 @@ method display-name(Str :$user-id?) { } method change-display-name(Str:D $display-name!) { - my $res = $.put("/profile/" ~ $!user-id ~ "/displayname", + my $res = $.put("/profile/" ~ $.user-id ~ "/displayname", displayname => $display-name); return $.check-res($res); } method avatar-url(Str :$user-id?) { - my $id = $user-id // $!user-id; + my $id = $user-id // $.user-id; my $res = $.get("/profile/" ~ $id ~ "/avatar_url"); $.check-res($res); my $data = from-json($res.content); @@ -139,7 +131,7 @@ method change-avatar(Str:D $avatar!, Bool :$upload) { $mxc-url = $avatar; } - my $res = $.put("/profile/" ~ $!user-id ~ "/avatar_url", + my $res = $.put("/profile/" ~ $.user-id ~ "/avatar_url", avatar_url => $mxc-url); return $.check-res($res); } |