Entity/Account.pm

filter: Statementstmt 82.1% 46 / 56 Branchbran 0.0% 0 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 70.0% 7 / 10 Podpod 100% 2 / 2 totaltotal 72.1% 57 / 79 CC 4 SCAR 11.1
CC
4
Cov
74%
remote_follow
6.0
report
6.0
__ANON__
4.3
CRAP 3.0
« Role/UserAgent.pm ↑ Summary Entity/Status.pm »
1 package Mastodon::Entity::Account;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.018'; # TRIAL
7  
8 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 with 'Mastodon::Role::Entity';
10  
11 3 ▶use Types::Standard qw( Int Str Bool );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Mastodon::Types qw( Acct URI DateTime );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶use Log::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 my $log = Log::Any->get_logger( category => 'Mastodon' );
16  
17 3 has acct => ( is => 'ro', isa => Acct, required => 1, );
18 3 has avatar => ( is => 'ro', isa => URI, coerce => 1, required => 1, );
19 3 has avatar_static => ( is => 'ro', isa => URI, coerce => 1, );
20 3 has created_at => ( is => 'ro', isa => DateTime, coerce => 1, );
21 3 has display_name => ( is => 'ro', isa => Str, );
22 3 has followers_count => ( is => 'ro', isa => Int, );
23 3 has following_count => ( is => 'ro', isa => Int, );
24 3 has header => ( is => 'ro', isa => URI, coerce => 1, );
25 3 has header_static => ( is => 'ro', isa => URI, coerce => 1, );
26 3 has id => ( is => 'ro', isa => Int, );
27 3 has locked => ( is => 'ro', isa => Bool, coerce => 1, );
28 3 has note => ( is => 'ro', isa => Str, );
29 3 has statuses_count => ( is => 'ro', isa => Int, );
30 3 has url => ( is => 'ro', isa => URI, coerce => 1, );
31 3 has username => ( is => 'ro', isa => Str, );
32  
33 3 foreach my $pair (
34 [ fetch => 'get_account' ],
35 [ followers => undef ],
36 [ following => undef ],
37 [ statuses => undef ],
38 [ follow => undef ],
39 [ unfollow => undef ],
40 [ block => undef ],
41 [ unblock => undef ],
42 [ mute => undef ],
43 [ unmute => undef ],
44 [ relationship => 'relationships' ],
45 [ authorize => 'authorize_follow' ],
46 [ reject => 'reject_follow' ],
47 ) {
48  
49 39 my ($name, $method) = @{$pair};
50 39 ▶ $method //= $name;
Condition66%2/3
$method //= $name
l!l&&r!l&&!r
12270
MC/DC0%0/2
$method //= $name
$method $name
Truth table66%2/3
A //= B
A= $methodB= $name
ABresult
1X1
011
000
51  
52 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
53 39 ▶ *{ __PACKAGE__ . '::' . $name } = sub {
Subroutine __ANON__: not called CC=2 SCAR=14.6
54 0 my $self = shift;
55 0 ▶ croak $log->fatal(qq{Cannot call '$name' without client})
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_client 0 0 0
56 unless $self->_client;
57 0 $self->_client->$method($self->id, @_);
58 39 };
59 }
60  
61 0 ▶sub remote_follow {
Subroutine remote_follow: not called CC=2 SCAR=17.9
Pod documented
62 0 my $self = shift;
63 0 ▶ croak $log->fatal(q{Cannot call 'remote_follow' without client})
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_client 0 0 0
64 unless $self->_client;
65 0 $self->_client->remote_follow($self->acct, @_);
66 }
67  
68 0 ▶sub report {
Subroutine report: not called CC=2 SCAR=17.9
Pod documented
69 0 my ($self, $params) = @_;
70 0 ▶ croak $log->fatal(q{Cannot call 'report' without client})
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_client 0 0 0
71 unless $self->_client;
72 $self->_client->report({
73 0 %{$params},
74 account_id => $self->id,
75 });
76 }
77  
78 3 1;
79  
80 =encoding utf8
81  
82 =head1 NAME
83  
84 Mastodon::Entity::Account - A Mastodon user account
85  
86 =head1 DESCRIPTION
87  
88 This object should not be manually created. It is intended to be generated
89 from the data received from a Mastodon server using the coercions in
90 L<Mastodon::Types>.
91  
92 For current information, see the
93 L<Mastodon API documentation|https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#account>
94  
95 =head1 ATTRIBUTES
96  
97 =over 4
98  
99 =item B<id>
100  
101 The ID of the account
102  
103 =item B<username>
104  
105 The username of the account
106  
107 =item B<acct>
108  
109 Equals C<username> for local users, includes C<@domain> for remote ones
110  
111 =item B<display_name>
112  
113 The account's display name
114  
115 =item B<locked>
116  
117 Boolean for when the account cannot be followed without waiting for approval
118 first
119  
120 =item B<created_at>
121  
122 The time the account was created
123  
124 =item B<followers_count>
125  
126 The number of followers for the account
127  
128 =item B<following_count>
129  
130 The number of accounts the given account is following
131  
132 =item B<statuses_count>
133  
134 The number of statuses the account has made
135  
136 =item B<note>
137  
138 Biography of user
139  
140 =item B<url>
141  
142 URL of the user's profile page (can be remote)
143  
144 =item B<avatar>
145  
146 URL to the avatar image
147  
148 =item B<avatar_static>
149  
150 URL to the avatar static image (gif)
151  
152 =item B<header>
153  
154 URL to the header image
155  
156 =item B<header_static>
157  
158 URL to the header static image (gif)
159  
160 =back
161  
162 =head1 METHODS
163  
164 This class provides the following convenience methods. They act as a shortcut,
165 passing the appropriate identifier of the current object as the first argument
166 to the corresponding methods in L<Mastodon::Client>.
167  
168 =over 4
169  
170 =item B<fetch>
171  
172 A shortcut to C<get_account>.
173  
174 =item B<followers>
175  
176 A shortcut to C<followers>.
177  
178 =item B<following>
179  
180 A shortcut to C<following>.
181  
182 =item B<statuses>
183  
184 A shortcut to C<statuses>.
185  
186 =item B<follow>
187  
188 A shortcut to C<follow>.
189  
190 =item B<unfollow>
191  
192 A shortcut to C<unfollow>.
193  
194 =item B<remote_follow>
195  
196 A shortcut to C<remote_follow>.
197  
198 =item B<report>
199  
200 A shortcut to C<report>.
201  
202 =item B<block>
203  
204 A shortcut to C<block>.
205  
206 =item B<unblock>
207  
208 A shortcut to C<unblock>.
209  
210 =item B<mute>
211  
212 A shortcut to C<mute>.
213  
214 =item B<unmute>
215  
216 A shortcut to C<unmute>.
217  
218 =item B<relationship>
219  
220 A shortcut to C<relationships>.
221  
222 =item B<authorize>
223  
224 A shortcut to C<authorize_follow>.
225  
226 =item B<reject>
227  
228 A shortcut to C<reject_follow>.
229  
230 =back
231  
232 =head1 AUTHOR
233  
234 =over 4
235  
236 =item *
237  
238 José Joaquín Atria <jjatria@cpan.org>
239  
240 =back
241  
242 =head1 COPYRIGHT AND LICENSE
243  
244 This software is copyright (c) 2017 by José Joaquín Atria.
245  
246 This is free software; you can redistribute it and/or modify it under
247 the same terms as the Perl 5 programming language system itself.
248  
249 =cut
« Role/UserAgent.pm ↑ Summary Entity/Status.pm »