From ae68b25cc8c5888b5c1951b3f9a4bc6481a90a9e Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Thu, 2 Nov 2017 20:14:18 -0300 Subject: Make user-id and device-id public --- lib/Matrix/Client.pm6 | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'lib') 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; @@ -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); } -- cgit v1.2.3-54-g00ecf