MailboxOrg/API/Account.pm

filter: Statementstmt 48.8% 22 / 45 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 6 / 12 Podpod 100% 5 / 5 totaltotal 44.5% 33 / 74 CC 7 SCAR 14.7
CC
7
Cov
39%
_rpc
6.0
add
6.0
del
6.0
CRAP 4.3
« MailboxOrg/API/Mailinglist.pm ↑ Summary MailboxOrg/API/Domain.pm »
1 package WWW::MailboxOrg::API::Account;
2  
3 # ABSTRACT: Account management API
4  
5 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use MooX::Singleton;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Params::ValidationCompiler qw(validation_for);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Types::Standard qw(Str Enum HashRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use WWW::MailboxOrg::Types qw(EmailAddress);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $VERSION = '0.001';
13  
14 1 has client => (
15 is => 'ro',
16 required => 1,
17 weak_ref => 1,
18 );
19  
20 sub _rpc {
21 0 ▶ my ($self, $method, @params) = @_;
Subroutine _rpc: not called CC=2 SCAR=17.9
22 0 ▶ my $client = $self->client or croak "No client set";
Branch: 1 branch
BranchTrueFalseTotal
my $client = $self->client or croak("No client set") 0 0 0
23 0 return $client->call($method, @params);
24 }
25  
26 1 my %validators = (
27 add => validation_for(
28 params => {
29 account => { type => EmailAddress, optional => 0 },
30 password => { type => Str, optional => 0 },
31 plan => { type => Enum[qw(basic profi profixl reseller)], optional => 0 },
32 tarifflimits => { type => HashRef, optional => 1 },
33 memo => { type => Str, optional => 1 },
34 },
35 ),
36 del => validation_for(
37 params => {
38 account => { type => EmailAddress, optional => 0 },
39 },
40 ),
41 get => validation_for(
42 params => {
43 account => { type => EmailAddress, optional => 0 },
44 },
45 ),
46 list => validation_for(
47 params => {
48 account => { type => EmailAddress, optional => 1 },
49 },
50 ),
51 set => validation_for(
52 params => {
53 account => { type => EmailAddress, optional => 0 },
54 password => { type => Str, optional => 1 },
55 plan => { type => Enum[qw(basic profi profixl reseller)], optional => 1 },
56 memo => { type => Str, optional => 1 },
57 address_payment_first_name => { type => Str, optional => 1 },
58 address_payment_last_name => { type => Str, optional => 1 },
59 address_payment_street => { type => Str, optional => 1 },
60 address_payment_zipcode => { type => Str, optional => 1 },
61 address_payment_town => { type => Str, optional => 1 },
62 av_contract_accept_name => { type => Str, optional => 1 },
63 tarifflimits => { type => HashRef, optional => 1 },
64 },
65 ),
66 );
67  
68 sub add {
69 0 ▶ my ($self, %params) = @_;
Subroutine add: not called CC=2 SCAR=17.9
Pod documented
70 0 my $v = $validators{'add'};
71 0 ▶ %params = $v->(%params) if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
72 0 return $self->_rpc('account.add', \%params);
73 }
74  
75 sub del {
76 0 ▶ my ($self, %params) = @_;
Subroutine del: not called CC=2 SCAR=17.9
Pod documented
77 0 my $v = $validators{'del'};
78 0 ▶ %params = $v->(%params) if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
79 0 return $self->_rpc('account.del', \%params);
80 }
81  
82 sub get {
83 0 ▶ my ($self, %params) = @_;
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
84 0 my $v = $validators{'get'};
85 0 ▶ %params = $v->(%params) if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
86 0 return $self->_rpc('account.get', \%params);
87 }
88  
89 sub list {
90 0 ▶ my ($self, %params) = @_;
Subroutine list: not called CC=2 SCAR=17.9
Pod documented
91 0 my $v = $validators{'list'};
92 0 ▶ %params = $v->(%params) if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
93 0 return $self->_rpc('account.list', \%params);
94 }
95  
96 sub set {
97 0 ▶ my ($self, %params) = @_;
Subroutine set: not called CC=2 SCAR=17.9
Pod documented
98 0 my $v = $validators{'set'};
99 0 ▶ %params = $v->(%params) if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
100 0 return $self->_rpc('account.set', \%params);
101 }
102  
103 1 1;
104  
105 __END__
106  
107 =pod
108  
109 =encoding UTF-8
110  
111 =head1 NAME
112  
113 WWW::MailboxOrg::API::Account - Account management API
114  
115 =head1 VERSION
116  
117 version 0.001
118  
119 =head1 NAME
120  
121 WWW::MailboxOrg::API::Account - Account management API
122  
123 =head2 add
124  
125 $api->account->add(
126 account => 'user@example.com',
127 password => 'secret123',
128 plan => 'basic',
129 tarifflimits => { ... },
130 memo => 'Optional note',
131 );
132  
133 Add a new account. Required: C<account>, C<password>, C<plan>.
134  
135 =head2 del
136  
137 $api->account->del(account => 'user@example.com');
138  
139 Delete an account.
140  
141 =head2 get
142  
143 $api->account->get(account => 'user@example.com');
144  
145 Get account details.
146  
147 =head2 list
148  
149 $api->account->list;
150 $api->account->list(account => 'admin@example.com');
151  
152 List accounts. Optional C<account> filter.
153  
154 =head2 set
155  
156 $api->account->set(
157 account => 'user@example.com',
158 plan => 'profi',
159 memo => 'Updated note',
160 );
161  
162 Update account settings. At least C<account> required.
163  
164 =cut
165  
166 =head1 SUPPORT
167  
168 =head2 Issues
169  
170 Please report bugs and feature requests on GitHub at
171 L<https://github.com/getty/p5-www-mailboxorg/issues>.
172  
173 =head2 IRC
174  
175 Join C<#perl-help> on C<irc.perl.org> or message Getty directly.
176  
177 =head1 CONTRIBUTING
178  
179 Contributions are welcome! Please fork the repository and submit a pull request.
180  
181 =head1 AUTHOR
182  
183 Torsten Raudssus <getty@cpan.org>
184  
185 =head1 COPYRIGHT AND LICENSE
186  
187 This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>.
188  
189 This is free software; you can redistribute it and/or modify it under
190 the same terms as the Perl 5 programming language system itself.
191  
192 =cut
« MailboxOrg/API/Mailinglist.pm ↑ Summary MailboxOrg/API/Domain.pm »