MailboxOrg.pm

filter: Statementstmt 98.1% 106 / 108 Branchbran 87.5% 14 / 16 Conditioncond 64.7% 11 / 17 MC/DCmcdc 54.5% 6 / 11 Subroutinesub 97.3% 36 / 37 Podpod 66.6% 2 / 3 totaltotal 91.1% 175 / 192 CC 15 SCAR 9.6
CC
15
Cov
93%
__ANON__
9.0
login
5.6
logout
2.0
CRAP 2.6
« MailboxOrg/API/Base.pm ↑ Summary MailboxOrg/Role/RPC.pm »
1 package WWW::MailboxOrg;
2  
3 # ABSTRACT: Perl client for Mailbox.org API
4  
5 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use WWW::MailboxOrg::API::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use WWW::MailboxOrg::API::Account;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use WWW::MailboxOrg::API::Domain;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use WWW::MailboxOrg::API::Mail;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use WWW::MailboxOrg::API::Mailinglist;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use WWW::MailboxOrg::API::Blacklist;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use WWW::MailboxOrg::API::Spamprotect;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use WWW::MailboxOrg::API::Videochat;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use WWW::MailboxOrg::API::Backup;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use WWW::MailboxOrg::API::Invoice;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use WWW::MailboxOrg::API::Passwordreset;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use WWW::MailboxOrg::API::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use WWW::MailboxOrg::API::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use WWW::MailboxOrg::API::System;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 5 our $VERSION = '0.100';
24  
25 5 has user => (
26 is => 'ro',
27 required => 1,
28 );
29  
30  
31 5 has password => (
32 is => 'ro',
33 required => 1,
34 );
35  
36  
37 5 has token => (
38 is => 'rwp',
39 clearer => 1,
40 );
41  
42  
43 5 has base_url => (
44 is => 'ro',
45 default => 'https://api.mailbox.org/v1',
46 );
47  
48  
49 25 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=9 SCAR=22.0
50 25 my ( $orig, $class, @args ) = @_;
51 25 my $args = $class->$orig( @args );
52  
53 25 ▶ $args->{user} = $ENV{WWW_MAILBOXORG_USER} if !defined $args->{user} && defined $ENV{WWW_MAILBOXORG_USER};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $args->{"user"} and defined $ENV{"WWW_MAILBOXORG_USER"} 3 22 25
Condition66%2/3
not defined $args->{"user"} and defined $ENV{"WWW_MAILBOXORG_USER"}
!ll&&!rl&&r
2203
MC/DC50%1/2
not defined $args->{"user"} and defined $ENV{"WWW_MAILBOXORG_USER"}
not defined $args->{"user"} defined $ENV{"WWW_MAILBOXORG_USER"}
Truth table66%2/3
not(A) and B
A= not defined $args->{"user"}B= defined $ENV{"WWW_MAILBOXORG_USER"}
ABresult
0X0
100
111
54 25 ▶ $args->{password} = $ENV{WWW_MAILBOXORG_PASSWORD} if !defined $args->{password} && defined $ENV{WWW_MAILBOXORG_PASSWORD};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $args->{"password"} and defined $ENV{"WWW_MAILBOXORG_PASSWORD"} 3 22 25
Condition66%2/3
not defined $args->{"password"} and defined $ENV{"WWW_MAILBOXORG_PASSWORD"}
!ll&&!rl&&r
2203
MC/DC50%1/2
not defined $args->{"password"} and defined $ENV{"WWW_MAILBOXORG_PASSWORD"}
not defined $args->{"password"} defined $ENV{"WWW_MAILBOXORG_PASSWORD"}
Truth table66%2/3
not(A) and B
A= not defined $args->{"password"}B= defined $ENV{"WWW_MAILBOXORG_PASSWORD"}
ABresult
0X0
100
111
55 25 ▶ $args->{base_url} = $ENV{WWW_MAILBOXORG_BASE_URL} if !defined $args->{base_url} && defined $ENV{WWW_MAILBOXORG_BASE_URL};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $args->{"base_url"} and defined $ENV{"WWW_MAILBOXORG_BASE_URL"} 1 24 25
Condition100%3/3
not defined $args->{"base_url"} and defined $ENV{"WWW_MAILBOXORG_BASE_URL"}
!ll&&!rl&&r
1231
MC/DC100%2/2
not defined $args->{"base_url"} and defined $ENV{"WWW_MAILBOXORG_BASE_URL"}
not defined $args->{"base_url"} defined $ENV{"WWW_MAILBOXORG_BASE_URL"}
Truth table100%3/3
not(A) and B
A= not defined $args->{"base_url"}B= defined $ENV{"WWW_MAILBOXORG_BASE_URL"}
ABresult
0X0
100
111
56 25 ▶ $args->{token} = $ENV{WWW_MAILBOXORG_TOKEN} if !defined $args->{token} && defined $ENV{WWW_MAILBOXORG_TOKEN};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $args->{"token"} and defined $ENV{"WWW_MAILBOXORG_TOKEN"} 1 24 25
Condition100%3/3
not defined $args->{"token"} and defined $ENV{"WWW_MAILBOXORG_TOKEN"}
!ll&&!rl&&r
1231
MC/DC100%2/2
not defined $args->{"token"} and defined $ENV{"WWW_MAILBOXORG_TOKEN"}
not defined $args->{"token"} defined $ENV{"WWW_MAILBOXORG_TOKEN"}
Truth table100%3/3
not(A) and B
A= not defined $args->{"token"}B= defined $ENV{"WWW_MAILBOXORG_TOKEN"}
ABresult
0X0
100
111
57  
58 25 return $args;
59 5 };
60  
61 5 with 'WWW::MailboxOrg::Role::HTTP';
62  
63 59 ▶sub _set_auth_header {
Subroutine _set_auth_header: called CC=2 SCAR=6.9
64 59 my ( $self, $headers ) = @_;
65 59 ▶ $headers->{'HPLS-AUTH'} = $self->token if $self->token;
Branch: 1 branch
BranchTrueFalseTotal
if $self->token 5 54 59
66 }
67  
68  
69 2 ▶sub login {
Subroutine login: called CC=4 SCAR=17.2
Pod documented
70 2 my ($self) = @_;
71  
72 2 my $result = $self->call( 'auth', {
73 user => $self->user,
74 pass => $self->password,
75 } );
76  
77 2 ▶ if ( ref $result && $result->{session} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result and $result->{"session"}) 2 0 2
Condition33%1/3
ref $result and $result->{"session"}
!ll&&!rl&&r
002
MC/DC0%0/2
ref $result and $result->{"session"}
ref $result $result->{"session"}
Truth table33%1/3
A and B
A= ref $resultB= $result->{"session"}
ABresult
0X0
100
111
78 2 $self->_set_token( $result->{session} );
79 2 return $result;
80 }
81  
82 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
83 }
84  
85  
86 4 ▶sub logout {
Subroutine logout: called CC=2 SCAR=7.1
Pod documented
87 4 my ($self) = @_;
88  
89 4 ▶ $self->call('deauth') if $self->token;
Branch: 1 branch
BranchTrueFalseTotal
if $self->token 4 0 4
90 4 $self->clear_token;
91 }
92  
93 25 ▶sub DEMOLISH {
Subroutine DEMOLISH: called CC=2 SCAR=6.9
Pod undocumented
94 25 my ($self) = @_;
95 25 ▶ $self->logout if $self->token;
Branch: 1 branch
BranchTrueFalseTotal
if $self->token 3 22 25
96 }
97  
98 # Resource accessors
99  
100 has base => (
101 is => 'lazy',
102 1 ▶ builder => sub { WWW::MailboxOrg::API::Base->new( client => shift ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine _build_base: called CC=1 SCAR=0.0
103 5 );
104  
105  
106 has account => (
107 is => 'lazy',
108 1 ▶ builder => sub { WWW::MailboxOrg::API::Account->new( client => shift ) },
Subroutine _build_account: called CC=1 SCAR=0.0
109 5 );
110  
111  
112 has domain => (
113 is => 'lazy',
114 1 ▶ builder => sub { WWW::MailboxOrg::API::Domain->new( client => shift ) },
Subroutine _build_domain: called CC=1 SCAR=0.0
115 5 );
116  
117  
118 has mail => (
119 is => 'lazy',
120 1 ▶ builder => sub { WWW::MailboxOrg::API::Mail->new( client => shift ) },
Subroutine _build_mail: called CC=1 SCAR=0.0
121 5 );
122  
123  
124 has mailinglist => (
125 is => 'lazy',
126 0 ▶ builder => sub { WWW::MailboxOrg::API::Mailinglist->new( client => shift ) },
Subroutine _build_mailinglist: not called CC=1 SCAR=6.9
127 5 );
128  
129  
130 has blacklist => (
131 is => 'lazy',
132 1 ▶ builder => sub { WWW::MailboxOrg::API::Blacklist->new( client => shift ) },
Subroutine _build_blacklist: called CC=1 SCAR=0.0
133 5 );
134  
135  
136 has spamprotect => (
137 is => 'lazy',
138 1 ▶ builder => sub { WWW::MailboxOrg::API::Spamprotect->new( client => shift ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
139 5 );
140  
141  
142 has videochat => (
143 is => 'lazy',
144 1 ▶ builder => sub { WWW::MailboxOrg::API::Videochat->new( client => shift ) },
Subroutine _build_videochat: called CC=1 SCAR=0.0
145 5 );
146  
147  
148 has backup => (
149 is => 'lazy',
150 1 ▶ builder => sub { WWW::MailboxOrg::API::Backup->new( client => shift ) },
Subroutine _build_backup: called CC=1 SCAR=0.0
151 5 );
152  
153  
154 has invoice => (
155 is => 'lazy',
156 1 ▶ builder => sub { WWW::MailboxOrg::API::Invoice->new( client => shift ) },
Subroutine _build_invoice: called CC=1 SCAR=0.0
157 5 );
158  
159  
160 has passwordreset => (
161 is => 'lazy',
162 1 ▶ builder => sub { WWW::MailboxOrg::API::Passwordreset->new( client => shift ) },
Subroutine _build_passwordreset: called CC=1 SCAR=0.0
163 5 );
164  
165  
166 has validate => (
167 is => 'lazy',
168 1 ▶ builder => sub { WWW::MailboxOrg::API::Validate->new( client => shift ) },
Subroutine _build_validate: called CC=1 SCAR=0.0
169 5 );
170  
171  
172 has utils => (
173 is => 'lazy',
174 1 ▶ builder => sub { WWW::MailboxOrg::API::Utils->new( client => shift ) },
Subroutine _build_utils: called CC=1 SCAR=0.0
175 5 );
176  
177  
178 has system => (
179 is => 'lazy',
180 1 ▶ builder => sub { WWW::MailboxOrg::API::System->new( client => shift ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
181 5 );
182  
183  
184 5 1;
185  
186 __END__
« MailboxOrg/API/Base.pm ↑ Summary MailboxOrg/Role/RPC.pm »