MailboxOrg.pm

filter: Statementstmt 72.7% 72 / 99 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 48.5% 17 / 35 Podpod 66.6% 2 / 3 totaltotal 59.4% 91 / 153 CC 7 SCAR 13.7
CC
7
Cov
64%
login
20.0
_set_auth_header
6.0
logout
6.0
CRAP 3.9
« MailboxOrg/API/Utils.pm ↑ Summary MailboxOrg/API/Mail.pm »
1 package WWW::MailboxOrg;
2  
3 # ABSTRACT: Perl client for Mailbox.org API
4  
5 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use WWW::MailboxOrg::API::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use WWW::MailboxOrg::API::Account;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use WWW::MailboxOrg::API::Domain;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use WWW::MailboxOrg::API::Mail;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use WWW::MailboxOrg::API::Mailinglist;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use WWW::MailboxOrg::API::Blacklist;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use WWW::MailboxOrg::API::Spamprotect;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use WWW::MailboxOrg::API::Videochat;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use WWW::MailboxOrg::API::Backup;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use WWW::MailboxOrg::API::Invoice;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use WWW::MailboxOrg::API::Passwordreset;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use WWW::MailboxOrg::API::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use WWW::MailboxOrg::API::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use WWW::MailboxOrg::API::System;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 our $VERSION = '0.001';
24  
25  
26 1 has user => (
27 is => 'ro',
28 required => 1,
29 );
30  
31  
32 1 has password => (
33 is => 'ro',
34 required => 1,
35 );
36  
37  
38 1 has token => (
39 is => 'rwp',
40 clearer => 1,
41 );
42  
43  
44 1 has base_url => (
45 is => 'ro',
46 default => 'https://api.mailbox.org/v1',
47 );
48  
49  
50 1 with 'WWW::MailboxOrg::Role::HTTP';
51  
52 sub _set_auth_header {
53 0 ▶ my ($self, $headers) = @_;
Subroutine _set_auth_header: not called CC=2 SCAR=17.9
54 0 ▶ $headers->{'HPLS-AUTH'} = $self->token if $self->token;
Branch: 1 branch
BranchTrueFalseTotal
if $self->token 0 0 0
55 }
56  
57  
58 sub login {
59 0 ▶ my ($self) = @_;
Subroutine login: not called CC=4 SCAR=30.0
Pod documented
60  
61 0 my $result = $self->call('auth', {
62 user => $self->user,
63 pass => $self->password,
64 });
65  
66 0 ▶ if (ref $result && $result->{session}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result and $result->{"session"}) 0 0 0
Condition0%0/3
ref $result and $result->{"session"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $result and $result->{"session"}
ref $result $result->{"session"}
Truth table0%0/3
A and B
A= ref $resultB= $result->{"session"}
ABresult
0X0
100
111
67 0 $self->_set_token($result->{session});
68 0 return $result;
69 }
70  
71 0 ▶ croak "Login failed: " . ($result // 'no session returned');
Condition0%0/2
$result // "no session returned"
l!l
00
MC/DC0%0/1
$result // "no session returned"
$result
Truth table0%0/2
A
A= $result
Aresult
11
00
72 }
73  
74  
75 sub logout {
76 0 ▶ my ($self) = @_;
Subroutine logout: not called CC=2 SCAR=17.9
Pod documented
77  
78 0 ▶ $self->call('deauth') if $self->token;
Branch: 1 branch
BranchTrueFalseTotal
if $self->token 0 0 0
79 0 $self->_clear_token;
80 }
81  
82 sub DEMOLISH {
83 0 ▶ my ($self) = @_;
Subroutine DEMOLISH: not called CC=2 SCAR=17.9
Pod undocumented
84 0 ▶ $self->logout if $self->token;
Branch: 1 branch
BranchTrueFalseTotal
if $self->token 0 0 0
85 }
86  
87 # Resource accessors
88 has base => (
89 is => 'lazy',
90 0 ▶ builder => sub { WWW::MailboxOrg::API::Base->new(client => shift) },
Subroutine _build_base: not called CC=1 SCAR=6.9
91 1 );
92  
93  
94 has account => (
95 is => 'lazy',
96 0 ▶ builder => sub { WWW::MailboxOrg::API::Account->new(client => shift) },
Subroutine _build_account: not called CC=1 SCAR=6.9
97 1 );
98  
99  
100 has domain => (
101 is => 'lazy',
102 0 ▶ builder => sub { WWW::MailboxOrg::API::Domain->new(client => shift) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
103 1 );
104  
105  
106 has mail => (
107 is => 'lazy',
108 0 ▶ builder => sub { WWW::MailboxOrg::API::Mail->new(client => shift) },
Subroutine _build_mail: not called CC=1 SCAR=6.9
109 1 );
110  
111  
112 has mailinglist => (
113 is => 'lazy',
114 0 ▶ builder => sub { WWW::MailboxOrg::API::Mailinglist->new(client => shift) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
115 1 );
116  
117  
118 has blacklist => (
119 is => 'lazy',
120 0 ▶ builder => sub { WWW::MailboxOrg::API::Blacklist->new(client => shift) },
Subroutine _build_blacklist: not called CC=1 SCAR=6.9
121 1 );
122  
123  
124 has spamprotect => (
125 is => 'lazy',
126 0 ▶ builder => sub { WWW::MailboxOrg::API::Spamprotect->new(client => shift) },
Subroutine _build_spamprotect: not called CC=1 SCAR=6.9
127 1 );
128  
129  
130 has videochat => (
131 is => 'lazy',
132 0 ▶ builder => sub { WWW::MailboxOrg::API::Videochat->new(client => shift) },
Subroutine _build_videochat: not called CC=1 SCAR=6.9
133 1 );
134  
135  
136 has backup => (
137 is => 'lazy',
138 0 ▶ builder => sub { WWW::MailboxOrg::API::Backup->new(client => shift) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
139 1 );
140  
141  
142 has invoice => (
143 is => 'lazy',
144 0 ▶ builder => sub { WWW::MailboxOrg::API::Invoice->new(client => shift) },
Subroutine _build_invoice: not called CC=1 SCAR=6.9
145 1 );
146  
147  
148 has passwordreset => (
149 is => 'lazy',
150 0 ▶ builder => sub { WWW::MailboxOrg::API::Passwordreset->new(client => shift) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
151 1 );
152  
153  
154 has validate => (
155 is => 'lazy',
156 0 ▶ builder => sub { WWW::MailboxOrg::API::Validate->new(client => shift) },
Subroutine _build_validate: not called CC=1 SCAR=6.9
157 1 );
158  
159  
160 has utils => (
161 is => 'lazy',
162 0 ▶ builder => sub { WWW::MailboxOrg::API::Utils->new(client => shift) },
Subroutine _build_utils: not called CC=1 SCAR=6.9
163 1 );
164  
165  
166 has system => (
167 is => 'lazy',
168 0 ▶ builder => sub { WWW::MailboxOrg::API::System->new(client => shift) },
Subroutine _build_system: not called CC=1 SCAR=6.9
169 1 );
170  
171  
172 1 1;
173  
174 __END__
175  
176 =pod
177  
178 =encoding UTF-8
179  
180 =head1 NAME
181  
182 WWW::MailboxOrg - Perl client for Mailbox.org API
183  
184 =head1 VERSION
185  
186 version 0.001
187  
188 =head1 SYNOPSIS
189  
190 use WWW::MailboxOrg;
191  
192 my $api = WWW::MailboxOrg->new(
193 user => 'test@example.tld',
194 password => 'secret123',
195 );
196  
197 # Authenticate and get session
198 $api->login;
199  
200 # List accounts
201 my $accounts = $api->account->list;
202  
203 # Get domain info
204 my $domain = $api->domain->get(domain => 'example.com');
205  
206 =head1 DESCRIPTION
207  
208 WWW::MailboxOrg provides a Perl interface to the Mailbox.org API.
209 Uses JSON-RPC 2.0 over HTTPS with session-based authentication.
210  
211 =head2 user
212  
213 Mailbox.org username or email address.
214  
215 =head2 password
216  
217 Mailbox.org password.
218  
219 =head2 token
220  
221 Session token (HPLS-AUTH). Set after successful login.
222  
223 =head2 base_url
224  
225 Base URL for the API. Defaults to C<https://api.mailbox.org/v1>.
226  
227 =head2 login
228  
229 $api->login;
230  
231 Authenticate with username/password and store session token.
232  
233 =head2 logout
234  
235 $api->logout;
236  
237 End the current session.
238  
239 =head2 base
240  
241 Returns L<WWW::MailboxOrg::API::Base> for auth and search.
242  
243 =head2 account
244  
245 Returns L<WWW::MailboxOrg::API::Account> for account management.
246  
247 =head2 domain
248  
249 Returns L<WWW::MailboxOrg::API::Domain> for domain management.
250  
251 =head2 mail
252  
253 Returns L<WWW::MailboxOrg::API::Mail> for email operations.
254  
255 =head2 mailinglist
256  
257 Returns L<WWW::MailboxOrg::API::Mailinglist> for mailing list management.
258  
259 =head2 blacklist
260  
261 Returns L<WWW::MailboxOrg::API::Blacklist> for blacklist management.
262  
263 =head2 spamprotect
264  
265 Returns L<WWW::MailboxOrg::API::Spamprotect> for spam protection settings.
266  
267 =head2 videochat
268  
269 Returns L<WWW::MailboxOrg::API::Videochat> for video chat rooms.
270  
271 =head2 backup
272  
273 Returns L<WWW::MailboxOrg::API::Backup> for backup operations.
274  
275 =head2 invoice
276  
277 Returns L<WWW::MailboxOrg::API::Invoice> for invoice access.
278  
279 =head2 passwordreset
280  
281 Returns L<WWW::MailboxOrg::API::Passwordreset> for password reset.
282  
283 =head2 validate
284  
285 Returns L<WWW::MailboxOrg::API::Validate> for email validation.
286  
287 =head2 utils
288  
289 Returns L<WWW::MailboxOrg::API::Utils> for utility functions.
290  
291 =head2 system
292  
293 Returns L<WWW::MailboxOrg::API::System> for system info (hello, test).
294  
295 =head1 SEE ALSO
296  
297 L<https://api.mailbox.org/v1/doc/methods/index.html> - Mailbox.org API docs
298  
299 =cut
300  
301 =head1 SUPPORT
302  
303 =head2 Issues
304  
305 Please report bugs and feature requests on GitHub at
306 L<https://github.com/getty/p5-www-mailboxorg/issues>.
307  
308 =head2 IRC
309  
310 Join C<#perl-help> on C<irc.perl.org> or message Getty directly.
311  
312 =head1 CONTRIBUTING
313  
314 Contributions are welcome! Please fork the repository and submit a pull request.
315  
316 =head1 AUTHOR
317  
318 Torsten Raudssus <getty@cpan.org>
319  
320 =head1 COPYRIGHT AND LICENSE
321  
322 This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>.
323  
324 This is free software; you can redistribute it and/or modify it under
325 the same terms as the Perl 5 programming language system itself.
326  
327 =cut
« MailboxOrg/API/Utils.pm ↑ Summary MailboxOrg/API/Mail.pm »