MailboxOrg/API/Mail.pm

filter: Statementstmt 63.3% 19 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 5 / 8 Podpod 100% 2 / 2 totaltotal 56.5% 26 / 46 CC 4 SCAR 13.2
CC
4
Cov
53%
_rpc
6.0
find
6.0
list
6.0
CRAP 3.7
« MailboxOrg.pm ↑ Summary MailboxOrg/API/Passwordreset.pm »
1 package WWW::MailboxOrg::API::Mail;
2  
3 # ABSTRACT: Mail operations 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 ArrayRef HashRef Bool Int);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = '0.001';
12  
13 1 has client => (
14 is => 'ro',
15 required => 1,
16 weak_ref => 1,
17 );
18  
19 sub _rpc {
20 0 ▶ my ($self, $method, @params) = @_;
Subroutine _rpc: not called CC=2 SCAR=17.9
21 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
22 0 return $client->call($method, @params);
23 }
24  
25 1 my %validators = (
26 find => validation_for(
27 params => {
28 query => { type => Str, optional => 0 },
29 },
30 ),
31 list => validation_for(
32 params => {
33 account => { type => Str, optional => 1 },
34 folder => { type => Str, optional => 1 },
35 order_by => { type => Str, optional => 1 },
36 page => { type => Int, optional => 1 },
37 per_page => { type => Int, optional => 1 },
38 result_mode => { type => Str, optional => 1 },
39 unseen_only => { type => Bool, optional => 1 },
40 },
41 ),
42 );
43  
44 sub find {
45 0 ▶ my ($self, %params) = @_;
Subroutine find: not called CC=2 SCAR=17.9
Pod documented
46 0 my $v = $validators{'find'};
47 0 ▶ %params = $v->(%params) if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
48 0 return $self->_rpc('mail.find', \%params);
49 }
50  
51 sub list {
52 0 ▶ my ($self, %params) = @_;
Subroutine list: not called CC=2 SCAR=17.9
Pod documented
53 0 my $v = $validators{'list'};
54 0 ▶ %params = $v->(%params) if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
55 0 return $self->_rpc('mail.list', \%params);
56 }
57  
58 1 1;
59  
60 __END__
61  
62 =pod
63  
64 =encoding UTF-8
65  
66 =head1 NAME
67  
68 WWW::MailboxOrg::API::Mail - Mail operations API
69  
70 =head1 VERSION
71  
72 version 0.001
73  
74 =head1 NAME
75  
76 WWW::MailboxOrg::API::Mail - Mail operations API
77  
78 =head2 find
79  
80 my $results = $api->mail->find(query => 'from:user@example.com');
81 my $results = $api->mail->find(query => 'subject:"hello world"');
82  
83 Search emails. Required: C<query> string.
84  
85 =head2 list
86  
87 $api->mail->list(folder => 'INBOX', unseen_only => 1);
88 $api->mail->list(account => 'user@example.com', page => 1, per_page => 50);
89  
90 List emails in a folder. Optional params:
91 - C<account> - Filter by account
92 - C<folder> - Folder name (default: INBOX)
93 - C<order_by> - Sort order
94 - C<page> - Page number
95 - C<per_page> - Results per page
96 - C<result_mode> - Result mode
97 - C<unseen_only> - Only unseen emails
98  
99 =cut
100  
101 =head1 SUPPORT
102  
103 =head2 Issues
104  
105 Please report bugs and feature requests on GitHub at
106 L<https://github.com/getty/p5-www-mailboxorg/issues>.
107  
108 =head2 IRC
109  
110 Join C<#perl-help> on C<irc.perl.org> or message Getty directly.
111  
112 =head1 CONTRIBUTING
113  
114 Contributions are welcome! Please fork the repository and submit a pull request.
115  
116 =head1 AUTHOR
117  
118 Torsten Raudssus <getty@cpan.org>
119  
120 =head1 COPYRIGHT AND LICENSE
121  
122 This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>.
123  
124 This is free software; you can redistribute it and/or modify it under
125 the same terms as the Perl 5 programming language system itself.
126  
127 =cut
« MailboxOrg.pm ↑ Summary MailboxOrg/API/Passwordreset.pm »