| 1 | package WWW::MailboxOrg::API::Mailinglist; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Mailing list 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); | ||||||||
|
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
| |||||||||||
| 22 | 0 | return $client->call($method, @params); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 1 | my %validators = ( | |||||||||
| 26 | add => validation_for( | ||||||||||
| 27 | params => { | ||||||||||
| 28 | account => { type => Str, optional => 0 }, | ||||||||||
| 29 | list => { type => Str, optional => 0 }, | ||||||||||
| 30 | password => { type => Str, optional => 0 }, | ||||||||||
| 31 | memo => { type => Str, optional => 1 }, | ||||||||||
| 32 | }, | ||||||||||
| 33 | ), | ||||||||||
| 34 | del => validation_for( | ||||||||||
| 35 | params => { | ||||||||||
| 36 | account => { type => Str, optional => 0 }, | ||||||||||
| 37 | list => { type => Str, optional => 0 }, | ||||||||||
| 38 | }, | ||||||||||
| 39 | ), | ||||||||||
| 40 | get => validation_for( | ||||||||||
| 41 | params => { | ||||||||||
| 42 | account => { type => Str, optional => 0 }, | ||||||||||
| 43 | list => { type => Str, optional => 0 }, | ||||||||||
| 44 | }, | ||||||||||
| 45 | ), | ||||||||||
| 46 | list => validation_for( | ||||||||||
| 47 | params => { | ||||||||||
| 48 | account => { type => Str, optional => 1 }, | ||||||||||
| 49 | }, | ||||||||||
| 50 | ), | ||||||||||
| 51 | set => validation_for( | ||||||||||
| 52 | params => { | ||||||||||
| 53 | account => { type => Str, optional => 0 }, | ||||||||||
| 54 | list => { type => Str, optional => 0 }, | ||||||||||
| 55 | password => { type => Str, optional => 1 }, | ||||||||||
| 56 | memo => { type => Str, optional => 1 }, | ||||||||||
| 57 | }, | ||||||||||
| 58 | ), | ||||||||||
| 59 | add_member => validation_for( | ||||||||||
| 60 | params => { | ||||||||||
| 61 | account => { type => Str, optional => 0 }, | ||||||||||
| 62 | list => { type => Str, optional => 0 }, | ||||||||||
| 63 | email => { type => Str, optional => 0 }, | ||||||||||
| 64 | }, | ||||||||||
| 65 | ), | ||||||||||
| 66 | del_member => validation_for( | ||||||||||
| 67 | params => { | ||||||||||
| 68 | account => { type => Str, optional => 0 }, | ||||||||||
| 69 | list => { type => Str, optional => 0 }, | ||||||||||
| 70 | email => { type => Str, optional => 0 }, | ||||||||||
| 71 | }, | ||||||||||
| 72 | ), | ||||||||||
| 73 | list_members => validation_for( | ||||||||||
| 74 | params => { | ||||||||||
| 75 | account => { type => Str, optional => 0 }, | ||||||||||
| 76 | list => { type => Str, optional => 0 }, | ||||||||||
| 77 | }, | ||||||||||
| 78 | ), | ||||||||||
| 79 | ); | ||||||||||
| 80 | |||||||||||
| 81 | sub add { | ||||||||||
| 82 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
add: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 83 | 0 | my $v = $validators{'add'}; | |||||||||
| 84 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | 0 | return $self->_rpc('mailinglist.add', \%params); | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | sub del { | ||||||||||
| 89 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
del: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 90 | 0 | my $v = $validators{'del'}; | |||||||||
| 91 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 0 | return $self->_rpc('mailinglist.del', \%params); | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | sub get { | ||||||||||
| 96 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 97 | 0 | my $v = $validators{'get'}; | |||||||||
| 98 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | 0 | return $self->_rpc('mailinglist.get', \%params); | |||||||||
| 100 | } | ||||||||||
| 101 | |||||||||||
| 102 | sub list { | ||||||||||
| 103 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
list: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 104 | 0 | my $v = $validators{'list'}; | |||||||||
| 105 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 106 | 0 | return $self->_rpc('mailinglist.list', \%params); | |||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | sub set { | ||||||||||
| 110 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
set: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 111 | 0 | my $v = $validators{'set'}; | |||||||||
| 112 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | 0 | return $self->_rpc('mailinglist.set', \%params); | |||||||||
| 114 | } | ||||||||||
| 115 | |||||||||||
| 116 | sub add_member { | ||||||||||
| 117 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
add_member: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 118 | 0 | my $v = $validators{'add_member'}; | |||||||||
| 119 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 120 | 0 | return $self->_rpc('mailinglist.add_member', \%params); | |||||||||
| 121 | } | ||||||||||
| 122 | |||||||||||
| 123 | sub del_member { | ||||||||||
| 124 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
del_member: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 125 | 0 | my $v = $validators{'del_member'}; | |||||||||
| 126 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 127 | 0 | return $self->_rpc('mailinglist.del_member', \%params); | |||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | sub list_members { | ||||||||||
| 131 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
list_members: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 132 | 0 | my $v = $validators{'list_members'}; | |||||||||
| 133 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 134 | 0 | return $self->_rpc('mailinglist.list_members', \%params); | |||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | 1 | 1; | |||||||||
| 138 | |||||||||||
| 139 | __END__ | ||||||||||
| 140 | |||||||||||
| 141 | =pod | ||||||||||
| 142 | |||||||||||
| 143 | =encoding UTF-8 | ||||||||||
| 144 | |||||||||||
| 145 | =head1 NAME | ||||||||||
| 146 | |||||||||||
| 147 | WWW::MailboxOrg::API::Mailinglist - Mailing list API | ||||||||||
| 148 | |||||||||||
| 149 | =head1 VERSION | ||||||||||
| 150 | |||||||||||
| 151 | version 0.001 | ||||||||||
| 152 | |||||||||||
| 153 | =head1 NAME | ||||||||||
| 154 | |||||||||||
| 155 | WWW::MailboxOrg::API::Mailinglist - Mailing list API | ||||||||||
| 156 | |||||||||||
| 157 | =head2 add | ||||||||||
| 158 | |||||||||||
| 159 | $api->mailinglist->add( | ||||||||||
| 160 | account => 'admin@example.com', | ||||||||||
| 161 | list => 'list@example.com', | ||||||||||
| 162 | password => 'secret', | ||||||||||
| 163 | memo => 'Optional note', | ||||||||||
| 164 | ); | ||||||||||
| 165 | |||||||||||
| 166 | Add a new mailing list. Required: C<account>, C<list>, C<password>. | ||||||||||
| 167 | |||||||||||
| 168 | =head2 del | ||||||||||
| 169 | |||||||||||
| 170 | $api->mailinglist->del( | ||||||||||
| 171 | account => 'admin@example.com', | ||||||||||
| 172 | list => 'list@example.com', | ||||||||||
| 173 | ); | ||||||||||
| 174 | |||||||||||
| 175 | Delete a mailing list. | ||||||||||
| 176 | |||||||||||
| 177 | =head2 get | ||||||||||
| 178 | |||||||||||
| 179 | $api->mailinglist->get( | ||||||||||
| 180 | account => 'admin@example.com', | ||||||||||
| 181 | list => 'list@example.com', | ||||||||||
| 182 | ); | ||||||||||
| 183 | |||||||||||
| 184 | Get mailing list details. | ||||||||||
| 185 | |||||||||||
| 186 | =head2 list | ||||||||||
| 187 | |||||||||||
| 188 | $api->mailinglist->list; | ||||||||||
| 189 | $api->mailinglist->list(account => 'admin@example.com'); | ||||||||||
| 190 | |||||||||||
| 191 | List mailing lists. Optional C<account> filter. | ||||||||||
| 192 | |||||||||||
| 193 | =head2 set | ||||||||||
| 194 | |||||||||||
| 195 | $api->mailinglist->set( | ||||||||||
| 196 | account => 'admin@example.com', | ||||||||||
| 197 | list => 'list@example.com', | ||||||||||
| 198 | password => 'newsecret', | ||||||||||
| 199 | memo => 'Updated note', | ||||||||||
| 200 | ); | ||||||||||
| 201 | |||||||||||
| 202 | Update mailing list settings. At least C<account> and C<list> required. | ||||||||||
| 203 | |||||||||||
| 204 | =head2 add_member | ||||||||||
| 205 | |||||||||||
| 206 | $api->mailinglist->add_member( | ||||||||||
| 207 | account => 'admin@example.com', | ||||||||||
| 208 | list => 'list@example.com', | ||||||||||
| 209 | email => 'member@example.com', | ||||||||||
| 210 | ); | ||||||||||
| 211 | |||||||||||
| 212 | Add a member to a mailing list. | ||||||||||
| 213 | |||||||||||
| 214 | =head2 del_member | ||||||||||
| 215 | |||||||||||
| 216 | $api->mailinglist->del_member( | ||||||||||
| 217 | account => 'admin@example.com', | ||||||||||
| 218 | list => 'list@example.com', | ||||||||||
| 219 | email => 'member@example.com', | ||||||||||
| 220 | ); | ||||||||||
| 221 | |||||||||||
| 222 | Remove a member from a mailing list. | ||||||||||
| 223 | |||||||||||
| 224 | =head2 list_members | ||||||||||
| 225 | |||||||||||
| 226 | $api->mailinglist->list_members( | ||||||||||
| 227 | account => 'admin@example.com', | ||||||||||
| 228 | list => 'list@example.com', | ||||||||||
| 229 | ); | ||||||||||
| 230 | |||||||||||
| 231 | List all members of a mailing list. | ||||||||||
| 232 | |||||||||||
| 233 | =cut | ||||||||||
| 234 | |||||||||||
| 235 | =head1 SUPPORT | ||||||||||
| 236 | |||||||||||
| 237 | =head2 Issues | ||||||||||
| 238 | |||||||||||
| 239 | Please report bugs and feature requests on GitHub at | ||||||||||
| 240 | L<https://github.com/getty/p5-www-mailboxorg/issues>. | ||||||||||
| 241 | |||||||||||
| 242 | =head2 IRC | ||||||||||
| 243 | |||||||||||
| 244 | Join C<#perl-help> on C<irc.perl.org> or message Getty directly. | ||||||||||
| 245 | |||||||||||
| 246 | =head1 CONTRIBUTING | ||||||||||
| 247 | |||||||||||
| 248 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||
| 249 | |||||||||||
| 250 | =head1 AUTHOR | ||||||||||
| 251 | |||||||||||
| 252 | Torsten Raudssus <getty@cpan.org> | ||||||||||
| 253 | |||||||||||
| 254 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 255 | |||||||||||
| 256 | This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>. | ||||||||||
| 257 | |||||||||||
| 258 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 259 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 260 | |||||||||||
| 261 | =cut | ||||||||||