Webservice/OVH/Email/Domain/Domain/MailingList.pm

filter: Statementstmt 7.6% 20 / 260 Branchbran 0.0% 0 / 148 Conditioncond 0.0% 0 / 29 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 18.7% 6 / 32 Podpod 100% 24 / 24 totaltotal 9.8% 50 / 509 CC 85 SCAR 45.1
CC
85
Cov
5%
_new
420.0
change_options
56.0
_new_existing
42.0
CRAP 90.5
« Webservice/OVH/Cloud/Project/Network/Private/Subnet.pm ↑ Summary Webservice/OVH/Domain/Zone/Record.pm »
1 package Webservice::OVH::Email::Domain::Domain::MailingList;
2  
3 =encoding utf-8
4  
5 =head1 NAME
6  
7 Webservice::OVH::Email::Domain::Domain::MailingList
8  
9 =head1 SYNOPSIS
10  
11 use Webservice::OVH;
12
13 my $ovh = Webservice::OVH->new_from_json("credentials.json");
14
15 my $email_domain = $ovh->email->domain->domain('testdomain.de');
16
17 my $mailing_list = $email_domain->new_redirection(language 'de', name => 'infos', options => {moderatorMessage => 'true', subscribeByModerator => 'true', usersPostOnly => 'false'}, owner_email => 'owner@test.de' );
18  
19 =head1 DESCRIPTION
20  
21 Provides ability to create, delete, change and manage mailinglists.
22  
23 =head1 METHODS
24  
25 =cut
26  
27 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 36 ▶use Carp qw{ carp croak };
Subroutine BEGIN: called CC=1 SCAR=0.0
30 36 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 36 our $VERSION = 0.48;
33  
34 36 ▶use Webservice::OVH::Helper;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 36 ▶use Webservice::OVH::Email::Domain::Domain::Task;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 =head2 _new_existing
38  
39 Internal Method to create a MailingList object.
40 This method should never be called directly.
41  
42 =over
43  
44 =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object, $domain - parent domain Objekt, $mailing_list_name => unique name
45  
46 =item * Return: L<Webservice::OVH::Email::Domain::Domain::MailingList>
47  
48 =item * Synopsis: Webservice::OVH::Email::Domain::Domain::MailingList->_new_existing($ovh_api_wrapper, $domain, $mailing_list_name, $module);
49  
50 =back
51  
52 =cut
53  
54 0 ▶sub _new_existing {
Subroutine _new_existing: not called CC=6 SCAR=37.4
55  
56 0 my ( $class, %params ) = @_;
57  
58 0 ▶ die "Missing module" unless $params{module};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"module"} 0 0 0
59 0 ▶ die "Missing wrapper" unless $params{wrapper};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"wrapper"} 0 0 0
60 0 ▶ die "Missing id" unless $params{id};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"id"} 0 0 0
61 0 ▶ die "Missing domain" unless $params{domain};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"domain"} 0 0 0
62  
63 0 my $module = $params{module};
64 0 my $api_wrapper = $params{wrapper};
65 0 my $mailing_list_name = $params{id};
66 0 my $domain = $params{domain};
67  
68 0 ▶ die "Missing mailing_list_name" unless $mailing_list_name;
Branch: 1 branch
BranchTrueFalseTotal
unless $mailing_list_name 0 0 0
69  
70 0 my $self = bless { _valid => 1, _api_wrapper => $api_wrapper, _name => $mailing_list_name, _properties => undef, _domain => $domain, _module => $module }, $class;
71  
72 0 return $self;
73 }
74  
75 =head2 _new
76  
77 Internal Method to create the MailingList object.
78 This method should never be called directly.
79  
80 =over
81  
82 =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object, $domain - parent domain, %params - key => value
83  
84 =item * Return: L<Webservice::OVH::Email::Domain::Domain::MailingList>
85  
86 =item * Synopsis: Webservice::OVH::Email::Domain::Domain::MailingList->_new($ovh_api_wrapper, $domain, $module, language 'DE', name => 'infos', options => {}, owner_email => 'owner@test.de', reply_to => 'test@test.de' );
87  
88 =back
89  
90 =cut
91  
92 0 ▶sub _new {
Subroutine _new: not called CC=20 SCAR=60.4
93  
94 0 my ( $class, %params ) = @_;
95  
96 0 ▶ die "Missing module" unless $params{module};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"module"} 0 0 0
97 0 ▶ die "Missing wrapper" unless $params{wrapper};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"wrapper"} 0 0 0
98 0 ▶ die "Missing domain" unless $params{domain};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"domain"} 0 0 0
99  
100 0 my $module = $params{module};
101 0 my $api_wrapper = $params{wrapper};
102 0 my $domain = $params{domain};
103  
104 0 my @keys_needed = qw{ language name options owner_email };
105  
106 0 ▶ die "Missing domain" unless $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain 0 0 0
107  
108 0 ▶ if ( my @missing_parameters = grep { not exists $params{$_} } @keys_needed ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@missing_parameters) = grep({not exists $params{$_};} @keys_needed)) 0 0 0
109  
110 0 croak "Missing parameter: @missing_parameters";
111 }
112  
113 0 ▶ my $moderator_message = $params{options}{moderator_message} || $params{options}{moderatorMessage};
Condition0%0/3
$params{'options'}{'moderator_message'} || $params{'options'}{'moderatorMessage'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$params{'options'}{'moderator_message'} || $params{'options'}{'moderatorMessage'}
$params{'options'}{'moderator_message'} $params{'options'}{'moderatorMessage'}
Truth table0%0/3
A || B
A= $params{'options'}{'moderator_message'}B= $params{'options'}{'moderatorMessage'}
ABresult
1X1
011
000
114 0 ▶ my $subscribe_by_moderator = $params{options}{subscribe_by_moderator} || $params{options}{subscribeByModerator};
Condition0%0/3
$params{'options'}{'subscribe_by_moderator'} || $params{'options'}{'subscribeByModerator'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$params{'options'}{'subscribe_by_moderator'} || $params{'options'}{'subscribeByModerator'}
$params{'options'}{'subscribe_by_moderator'} $params{'options'}{'subscribeByModerator'}
Truth table0%0/3
A || B
A= $params{'options'}{'subscribe_by_moderator'}B= $params{'options'}{'subscribeByModerator'}
ABresult
1X1
011
000
115 0 ▶ my $users_post_only = $params{options}{users_post_only} || $params{options}{usersPostOnly};
Condition0%0/3
$params{'options'}{'users_post_only'} || $params{'options'}{'usersPostOnly'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$params{'options'}{'users_post_only'} || $params{'options'}{'usersPostOnly'}
$params{'options'}{'users_post_only'} $params{'options'}{'usersPostOnly'}
Truth table0%0/3
A || B
A= $params{'options'}{'users_post_only'}B= $params{'options'}{'usersPostOnly'}
ABresult
1X1
011
000
116  
117 0 my $options = {};
118 0 ▶ $options->{moderatorMessage} = $moderator_message eq 'true' || $moderator_message eq 'yes' || $moderator_message eq '1' ? JSON::true : JSON::false;
Branch: 1 branch
BranchTrueFalseTotal
$moderator_message eq 'true' || $moderator_message eq 'yes' || $moderator_message eq '1' ? : 0 0 0
Condition0%0/6
$moderator_message eq "true" or $moderator_message eq "yes" or $moderator_message eq 1
l!l&&r!l&&!r
000
$moderator_message eq "true" or $moderator_message eq "yes"
l!l&&r!l&&!r
000
MC/DC0%0/3
$moderator_message eq "true" or $moderator_message eq "yes" or $moderator_message eq 1
$moderator_message eq "true" $moderator_message eq "yes" $moderator_message eq 1
Truth table0%0/4
A or B or C
A= $moderator_message eq "true"B= $moderator_message eq "yes"C= $moderator_message eq 1
ABCresult
1XX1
01X1
0011
0000
119 0 ▶ $options->{subscribeByModerator} = $subscribe_by_moderator eq 'true' || $subscribe_by_moderator eq 'yes' || $subscribe_by_moderator eq '1' ? JSON::true : JSON::false;
Branch: 1 branch
BranchTrueFalseTotal
$subscribe_by_moderator eq 'true' || $subscribe_by_moderator eq 'yes' || $subscribe_by_moderator eq '1' ? : 0 0 0
Condition0%0/6
$subscribe_by_moderator eq "true" or $subscribe_by_moderator eq "yes" or $subscribe_by_moderator eq 1
l!l&&r!l&&!r
000
$subscribe_by_moderator eq "true" or $subscribe_by_moderator eq "yes"
l!l&&r!l&&!r
000
MC/DC0%0/3
$subscribe_by_moderator eq "true" or $subscribe_by_moderator eq "yes" or $subscribe_by_moderator eq 1
$subscribe_by_moderator eq "true" $subscribe_by_moderator eq "yes" $subscribe_by_moderator eq 1
Truth table0%0/4
A or B or C
A= $subscribe_by_moderator eq "true"B= $subscribe_by_moderator eq "yes"C= $subscribe_by_moderator eq 1
ABCresult
1XX1
01X1
0011
0000
120 0 ▶ $options->{usersPostOnly} = $users_post_only eq 'true' || $users_post_only eq 'yes' || $users_post_only eq '1' ? JSON::true : JSON::false;
Branch: 1 branch
BranchTrueFalseTotal
$users_post_only eq 'true' || $users_post_only eq 'yes' || $users_post_only eq '1' ? : 0 0 0
Condition0%0/6
$users_post_only eq "true" or $users_post_only eq "yes" or $users_post_only eq 1
l!l&&r!l&&!r
000
$users_post_only eq "true" or $users_post_only eq "yes"
l!l&&r!l&&!r
000
MC/DC0%0/3
$users_post_only eq "true" or $users_post_only eq "yes" or $users_post_only eq 1
$users_post_only eq "true" $users_post_only eq "yes" $users_post_only eq 1
Truth table0%0/4
A or B or C
A= $users_post_only eq "true"B= $users_post_only eq "yes"C= $users_post_only eq 1
ABCresult
1XX1
01X1
0011
0000
121  
122 0 my $domain_name = $domain->name;
123 0 my $body = {};
124 0 $body->{language} = $params{language};
125 0 $body->{name} = Webservice::OVH::Helper->trim($params{name});
126 0 $body->{options} = $options;
127 0 $body->{ownerEmail} = Webservice::OVH::Helper->trim($params{owner_email});
128 0 ▶ $body->{replyTo} = Webservice::OVH::Helper->trim($params{reply_to}) if exists $params{reply_to};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"reply_to"} 0 0 0
129 0 my $response = $api_wrapper->rawCall( method => 'post', path => "/email/domain/$domain_name/mailingList", body => $body, noSignature => 0 );
130 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
131  
132 0 my $task_id = $response->content->{id};
133 0 my $task = Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api_wrapper, domain => $domain, id => $task_id, module => $module );
134  
135 0 my $self = bless { _valid => 1, _api_wrapper => $api_wrapper, _properties => undef, _name => $params{name}, _domain => $domain, _module => $module }, $class;
136  
137 0 return ( $self, $task );
138 }
139  
140 =head2 is_valid
141  
142 When this mailinglist is deleted on the api side, this method returns 0.
143  
144 =over
145  
146 =item * Return: VALUE
147  
148 =item * Synopsis: print "Valid" if $mailing_list->is_valid;
149  
150 =back
151  
152 =cut
153  
154 0 ▶sub is_valid {
Subroutine is_valid: not called CC=1 SCAR=6.9
Pod documented
155  
156 0 my ($self) = @_;
157  
158 0 $self->properties;
159  
160 0 return $self->{_valid};
161 }
162  
163 =head2 name
164  
165 Unique identifier.
166  
167 =over
168  
169 =item * Return: VALUE
170  
171 =item * Synopsis: my $name = $redirection->name;
172  
173 =back
174  
175 =cut
176  
177 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
178  
179 0 my ($self) = @_;
180  
181 0 return $self->{_name};
182 }
183  
184 =head2 id
185  
186 Secondary unique identifier.
187  
188 =over
189  
190 =item * Return: VALUE
191  
192 =item * Synopsis: my $id = $mailing_list->id;
193  
194 =back
195  
196 =cut
197  
198 0 ▶sub id {
Subroutine id: not called CC=3 SCAR=24.8
Pod documented
199  
200 0 my ($self) = @_;
201  
202 0 ▶ $self->properties unless $self->{_properties};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_properties"} 0 0 0
203 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
204  
205 0 return $self->{properties}{id};
206 }
207  
208 =head2 domain
209  
210 Returns the email-domain this redirection is attached to.
211  
212 =over
213  
214 =item * Return: L<Webservice::Email::Domain::Domain>
215  
216 =item * Synopsis: my $email_domain = $mailing_list->domain;
217  
218 =back
219  
220 =cut
221  
222 0 ▶sub domain {
Subroutine domain: not called CC=1 SCAR=6.9
Pod documented
223  
224 0 my ($self) = @_;
225  
226 0 return $self->{_domain};
227 }
228  
229 =head2 properties
230  
231 Returns the raw properties as a hash.
232 This is the original return value of the web-api.
233  
234 =over
235  
236 =item * Return: HASH
237  
238 =item * Synopsis: my $properties = $mailing_list->properties;
239  
240 =back
241  
242 =cut
243  
244 0 ▶sub properties {
Subroutine properties: not called CC=4 SCAR=30.0
Pod documented
245  
246 0 my ($self) = @_;
247  
248 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
249  
250 0 my $api = $self->{_api_wrapper};
251 0 my $domain_name = $self->domain->name;
252 0 my $mailing_list_name = $self->name;
253 0 my $response = $api->rawCall( method => 'get', path => "/email/domain/$domain_name/mailingList/$mailing_list_name", noSignature => 0 );
254 0 ▶ carp $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
255  
256 0 ▶ if ( $response->error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response->error) { } 0 0 0
257  
258 0 $self->{_valid} = 0;
259 0 $self->{_properties} = undef;
260 0 return undef;
261  
262 } else {
263  
264 0 $self->{_properties} = $response->content;
265 0 return $self->{_properties};
266 }
267 }
268  
269 =head2 language
270  
271 Exposed property value.
272  
273 =over
274  
275 =item * Return: VALUE
276  
277 =item * Synopsis: my $language = $mailing_list->language;
278  
279 =back
280  
281 =cut
282  
283 0 ▶sub language {
Subroutine language: not called CC=3 SCAR=24.8
Pod documented
284  
285 0 my ($self) = @_;
286  
287 0 ▶ $self->properties unless $self->{_properties};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_properties"} 0 0 0
288 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
289  
290 0 return $self->{_properties}->{language};
291 }
292  
293 =head2 options
294  
295 Exposed property value.
296  
297 =over
298  
299 =item * Return: HASH
300  
301 =item * Synopsis: my $options = $mailing_list->options;
302  
303 =back
304  
305 =cut
306  
307 0 ▶sub options {
Subroutine options: not called CC=3 SCAR=24.8
Pod documented
308  
309 0 my ($self) = @_;
310  
311 0 ▶ $self->properties unless $self->{_properties};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_properties"} 0 0 0
312 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
313  
314 0 return $self->{_properties}->{options};
315 }
316  
317 =head2 owner_email
318  
319 Exposed property value.
320  
321 =over
322  
323 =item * Return: VALUE
324  
325 =item * Synopsis: my $owner_email = $mailing_list->owner_email;
326  
327 =back
328  
329 =cut
330  
331 0 ▶sub owner_email {
Subroutine owner_email: not called CC=3 SCAR=24.8
Pod documented
332  
333 0 my ($self) = @_;
334  
335 0 ▶ $self->properties unless $self->{_properties};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_properties"} 0 0 0
336 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
337  
338 0 return $self->{_properties}->{ownerEmail};
339 }
340  
341 =head2 reply_to
342  
343 Exposed property value.
344  
345 =over
346  
347 =item * Return: VALUE
348  
349 =item * Synopsis: my $reply_to = $mailing_list->reply_to;
350  
351 =back
352  
353 =cut
354  
355 0 ▶sub reply_to {
Subroutine reply_to: not called CC=3 SCAR=24.8
Pod documented
356  
357 0 my ($self) = @_;
358  
359 0 ▶ $self->properties unless $self->{_properties};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_properties"} 0 0 0
360 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
361  
362 0 return $self->{_properties}->{replyTo};
363 }
364  
365 =head2 nb_subscribers_update_date
366  
367 Exposed property value.
368  
369 =over
370  
371 =item * Return: VALUE
372  
373 =item * Synopsis: my $nb_subscribers_update_date = $mailing_list->nb_subscribers_update_date;
374  
375 =back
376  
377 =cut
378  
379 0 ▶sub nb_subscribers_update_date {
Subroutine nb_subscribers_update_date: not called CC=3 SCAR=24.8
Pod documented
380  
381 0 my ($self) = @_;
382  
383 0 ▶ $self->properties unless $self->{_properties};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_properties"} 0 0 0
384 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
385  
386 0 my $str_datetime = $self->{_properties}->{nbSubscribersUpdateDate};
387 0 my $datetime = Webservice::OVH::Helper->parse_datetime($str_datetime);
388  
389 0 return $datetime;
390 }
391  
392 =head2 nb_subscribers
393  
394 Exposed property value.
395  
396 =over
397  
398 =item * Return: VALUE
399  
400 =item * Synopsis: my $nb_subscribers = $mailing_list->nb_subscribers;
401  
402 =back
403  
404 =cut
405  
406 0 ▶sub nb_subscribers {
Subroutine nb_subscribers: not called CC=3 SCAR=24.8
Pod documented
407  
408 0 my ($self) = @_;
409  
410 0 ▶ $self->properties unless $self->{_properties};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_properties"} 0 0 0
411 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
412  
413 0 return $self->{_properties}->{nbSubscribers};
414 }
415  
416 =head2 change
417  
418 Changes the objcet.
419  
420 =over
421  
422 =item * Parameter: %params - key => value language owner_email reply_to
423  
424 =item * Synopsis: $mailing_list->change( language => 'en', owner_email => 'other@test.de', reply_to => 'reply@test.de');
425  
426 =back
427  
428 =cut
429  
430 0 ▶sub change {
Subroutine change: not called CC=6 SCAR=37.4
Pod documented
431  
432 0 my ( $self, %params ) = @_;
433  
434 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
435  
436 0 my $api = $self->{_api_wrapper};
437 0 my $domain_name = $self->domain->name;
438 0 my $mailing_list_name = $self->name;
439 0 my $body = {};
440 0 ▶ $body->{language} = $params{language} if exists $params{language};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"language"} 0 0 0
441 0 ▶ $body->{ownerEmail} = Webservice::OVH::Helper->trim($params{owner_email}) if exists $params{owner_email};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"owner_email"} 0 0 0
442 0 ▶ $body->{replyTo} = Webservice::OVH::Helper->trim($params{reply_to}) if exists $params{reply_to};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"reply_to"} 0 0 0
443 0 my $response = $api->rawCall( method => 'put', path => "/email/domain/$domain_name/mailingList/$mailing_list_name", body => $body, noSignature => 0 );
444 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
445  
446 0 $self->properties;
447 }
448  
449 =head2 delete
450  
451 Deletes the mailinglist api sided and sets this object invalid.
452  
453 =over
454  
455 =item * Synopsis: $mailing_list->delete;
456  
457 =back
458  
459 =cut
460  
461 0 ▶sub delete {
Subroutine delete: not called CC=3 SCAR=24.8
Pod documented
462  
463 0 my ($self) = @_;
464  
465 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
466  
467 0 my $api = $self->{_api_wrapper};
468 0 my $domain_name = $self->domain->name;
469 0 my $mailing_list_name = $self->name;
470 0 my $response = $api->rawCall( method => 'delete', path => "/email/domain/$domain_name/mailingList/$mailing_list_name", noSignature => 0 );
471 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
472  
473 0 my $task_id = $response->content->{id};
474 0 my $task = Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $task_id, module => $self->{_module} );
475  
476 0 $self->{_valid} = 0;
477  
478 0 return $task;
479 }
480  
481 =head2 change_options
482  
483 Changes additional options.
484  
485 =over
486  
487 =item * Parameter: %params - key => value moderator_message subscribe_by_moderator users_post_only
488  
489 =item * Synopsis: $mailing_list->change_options( moderator_message => 'false', subscribe_by_moderator => 'false', users_post_only => 'true' );
490  
491 =back
492  
493 =cut
494  
495 0 ▶sub change_options {
Subroutine change_options: not called CC=7 SCAR=40.3
Pod documented
496  
497 0 my ( $self, %params ) = @_;
498  
499 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
500  
501 0 my @keys_needed = qw{ moderator_message subscribe_by_moderator users_post_only };
502  
503 0 ▶ if ( my @missing_parameters = grep { not exists $params{$_} } @keys_needed ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@missing_parameters) = grep({not exists $params{$_};} @keys_needed)) 0 0 0
504  
505 0 croak "Missing parameter: @missing_parameters";
506 }
507  
508 0 my $api = $self->{_api_wrapper};
509 0 my $domain_name = $self->domain->name;
510 0 my $mailing_list_name = $self->name;
511 0 my $body = { options => {} };
512 0 ▶ $body->{options}->{moderatorMessage} = $params{moderator_message} if exists $params{moderator_message};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"moderator_message"} 0 0 0
513 0 ▶ $body->{options}->{subscribeByModerator} = $params{subscribe_by_moderator} if exists $params{subscribe_by_moderator};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"subscribe_by_moderator"} 0 0 0
514 0 ▶ $body->{options}->{usersPostOnly} = $params{users_post_only} if exists $params{users_post_only};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"users_post_only"} 0 0 0
515 0 my $response = $api->rawCall( method => 'post', path => "/email/domain/$domain_name/mailingList/$mailing_list_name/changeOptions", body => $body, noSignature => 0 );
516 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
517  
518 0 my $task_id = $response->content->{id};
519 0 my $task = Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $task_id, module => $self->{_module} );
520  
521 0 $self->properties;
522  
523 0 return $task;
524 }
525  
526 =head2 moderators
527  
528 Returns an array of all moderators of this mailinglist.
529  
530 =over
531  
532 =item * Return: L<ARRAY>
533  
534 =item * Synopsis: my $moderators = $mailing_list->moderators();
535  
536 =back
537  
538 =cut
539  
540 0 ▶sub moderators {
Subroutine moderators: not called CC=3 SCAR=24.8
Pod documented
541  
542 0 my ($self) = @_;
543  
544 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
545  
546 0 my $api = $self->{_api_wrapper};
547 0 my $domain_name = $self->domain->name;
548 0 my $mailing_list_name = $self->name;
549 0 my $response = $api->rawCall( method => 'get', path => "/email/domain/$domain_name/mailingList/$mailing_list_name/moderator", noSignature => 0 );
550 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
551  
552 0 return $response->content;
553 }
554  
555 =head2 moderators
556  
557 Returns properties for a specified moderator E-Mail
558  
559 =over
560  
561 =item * Parameter: $email - email address
562  
563 =item * Return: HASH
564  
565 =item * Synopsis: my $properties = $mailing_list->moderator('moderator@test.de');
566  
567 =back
568  
569 =cut
570  
571 0 ▶sub moderator {
Subroutine moderator: not called CC=4 SCAR=30.0
Pod documented
572  
573 0 my ( $self, $email ) = @_;
574  
575 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
576  
577 0 ▶ croak "Missing email" unless $email;
Branch: 1 branch
BranchTrueFalseTotal
unless $email 0 0 0
578  
579 0 my $api = $self->{_api_wrapper};
580 0 my $domain_name = $self->domain->name;
581 0 my $mailing_list_name = $self->name;
582 0 my $response = $api->rawCall( method => 'get', path => "/email/domain/$domain_name/mailingList/$mailing_list_name/moderator/$email", noSignature => 0 );
583 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
584  
585 0 return $response->content;
586 }
587  
588 =head2 add_moderator
589  
590 Adds a moderator via E-Mail address.
591  
592 =over
593  
594 =item * Parameter: $email - email address
595  
596 =item * Synopsis: my $properties = $mailing_list->add_moderator('moderator@test.de');
597  
598 =back
599  
600 =cut
601  
602 0 ▶sub add_moderator {
Subroutine add_moderator: not called CC=4 SCAR=30.0
Pod documented
603  
604 0 my ( $self, $email ) = @_;
605  
606 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
607  
608 0 ▶ croak "Missing email" unless $email;
Branch: 1 branch
BranchTrueFalseTotal
unless $email 0 0 0
609  
610 0 my $api = $self->{_api_wrapper};
611 0 my $domain_name = $self->domain->name;
612 0 my $mailing_list_name = $self->name;
613 0 my $body = { email => Webservice::OVH::Helper->trim($email) };
614 0 my $response = $api->rawCall( method => 'post', path => "/email/domain/$domain_name/mailingList/$mailing_list_name/moderator", body => $body, noSignature => 0 );
615 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
616  
617 0 my $task_id = $response->content->{id};
618 0 my $task = Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $task_id, module => $self->{_module} );
619  
620 0 return $task;
621  
622 }
623  
624 =head2 delete_moderator
625  
626 Deletes a moderator via E-Mail address.
627  
628 =over
629  
630 =item * Parameter: $email - email address
631  
632 =item * Synopsis: my $properties = $mailing_list->delete_moderator('moderator@test.de');
633  
634 =back
635  
636 =cut
637  
638 0 ▶sub delete_moderator {
Subroutine delete_moderator: not called CC=4 SCAR=30.0
Pod documented
639  
640 0 my ( $self, $email ) = @_;
641  
642 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
643  
644 0 ▶ croak "Missing email" unless $email;
Branch: 1 branch
BranchTrueFalseTotal
unless $email 0 0 0
645  
646 0 my $api = $self->{_api_wrapper};
647 0 my $domain_name = $self->domain->name;
648 0 my $mailing_list_name = $self->name;
649 0 my $response = $api->rawCall( method => 'delete', path => "/email/domain/$domain_name/mailingList/$mailing_list_name/moderator/$email", noSignature => 0 );
650 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
651  
652 0 my $task_id = $response->content->{id};
653 0 my $task = Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $task_id, module => $self->{_module} );
654  
655 0 return $task;
656  
657 }
658  
659 =head2 delete_moderator
660  
661 Sends the subscriber and moderator list to a specified E-Mail address.
662  
663 =over
664  
665 =item * Parameter: $email - email address
666  
667 =item * Synopsis: my $properties = $mailing_list->send_list_by_email('moderator@test.de');
668  
669 =back
670  
671 =cut
672  
673 0 ▶sub send_list_by_email {
Subroutine send_list_by_email: not called CC=4 SCAR=30.0
Pod documented
674  
675 0 my ( $self, $email ) = @_;
676  
677 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
678  
679 0 ▶ croak "Missing email" unless $email;
Branch: 1 branch
BranchTrueFalseTotal
unless $email 0 0 0
680  
681 0 my $api = $self->{_api_wrapper};
682 0 my $domain_name = $self->domain->name;
683 0 my $mailing_list_name = $self->name;
684 0 my $body = { email => Webservice::OVH::Helper->trim($email) };
685 0 my $response = $api->rawCall( method => 'post', path => "/email/domain/$domain_name/mailingList/$mailing_list_name/sendListByEmail", body => $body, noSignature => 0 );
686 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
687  
688 0 my $task_id = $response->content->{id};
689 0 my $task = Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $task_id, module => $self->{_module} );
690  
691 0 return $task;
692 }
693  
694 =head2 subscribers
695  
696 Returns an array of all subscribers or a filtered list.
697  
698 =over
699  
700 =item * $email - filter for specified E-Mail address
701  
702 =item * Return: L<ARRAY>
703  
704 =item * Synopsis: my $subscribers = $mailing_list->subscribers();
705  
706 =back
707  
708 =cut
709  
710 0 ▶sub subscribers {
Subroutine subscribers: not called CC=4 SCAR=30.0
Pod documented
711  
712 0 my ( $self, $email ) = @_;
713  
714 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
715  
716 0 ▶ my $filter_email = $email ? $email : "";
Branch: 1 branch
BranchTrueFalseTotal
$email ? : 0 0 0
717 0 my $filter = Webservice::OVH::Helper->construct_filter( "email" => $filter_email );
718  
719 0 my $api = $self->{_api_wrapper};
720 0 my $domain_name = $self->domain->name;
721 0 my $mailing_list_name = $self->name;
722  
723 0 my $response = $api->rawCall( method => 'get', path => sprintf( "/email/domain/$domain_name/mailingList/$mailing_list_name/subscriber%s", $filter ), noSignature => 0 );
724 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
725  
726 0 return $response->content;
727 }
728  
729 =head2 subscriber
730  
731 Returns the properties of a single subscriber.
732  
733 =over
734  
735 =item * Parameter: $email - E-Mail address
736  
737 =item * Return: HASH
738  
739 =item * Synopsis: my $subscriber = $mailing_list->subscriber('sub@test.de');
740  
741 =back
742  
743 =cut
744  
745 0 ▶sub subscriber {
Subroutine subscriber: not called CC=4 SCAR=30.0
Pod documented
746  
747 0 my ( $self, $email ) = @_;
748  
749 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
750  
751 0 ▶ croak "Missing email" unless $email;
Branch: 1 branch
BranchTrueFalseTotal
unless $email 0 0 0
752  
753 0 my $api = $self->{_api_wrapper};
754 0 my $domain_name = $self->domain->name;
755 0 my $mailing_list_name = $self->name;
756  
757 0 my $response = $api->rawCall( method => 'get', path => "/email/domain/$domain_name/mailingList/$mailing_list_name/subscriber/$email", noSignature => 0 );
758 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
759  
760 0 return $response->content;
761 }
762  
763 =head2 add_subscriber
764  
765 Adds an subscriber to the mailinglist.
766  
767 =over
768  
769 =item * Parameter: $email - E-Mail address
770  
771 =item * Synopsis: $mailing_list->add_subscriber('sub@test.de');
772  
773 =back
774  
775 =cut
776  
777 0 ▶sub add_subscriber {
Subroutine add_subscriber: not called CC=4 SCAR=30.0
Pod documented
778  
779 0 my ( $self, $email ) = @_;
780  
781 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
782  
783 0 ▶ croak "Missing email" unless $email;
Branch: 1 branch
BranchTrueFalseTotal
unless $email 0 0 0
784  
785 0 my $api = $self->{_api_wrapper};
786 0 my $domain_name = $self->domain->name;
787 0 my $mailing_list_name = $self->name;
788 0 my $body = { email => Webservice::OVH::Helper->trim($email) };
789 0 my $response = $api->rawCall( method => 'post', path => "/email/domain/$domain_name/mailingList/$mailing_list_name/subscriber", body => $body, noSignature => 0 );
790 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
791  
792 0 my $task_id = $response->content->{id};
793 0 my $task = Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $task_id, module => $self->{_module} );
794  
795 0 return $task;
796  
797 }
798  
799 =head2 delete_subscriber
800  
801 Deletes an subscriber to the mailinglist.
802  
803 =over
804  
805 =item * Parameter: $email - E-Mail address
806  
807 =item * Synopsis: $mailing_list->delete_subscriber('sub@test.de');
808  
809 =back
810  
811 =cut
812  
813 0 ▶sub delete_subscriber {
Subroutine delete_subscriber: not called CC=4 SCAR=30.0
Pod documented
814  
815 0 my ( $self, $email ) = @_;
816  
817 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
818  
819 0 ▶ croak "Missing email" unless $email;
Branch: 1 branch
BranchTrueFalseTotal
unless $email 0 0 0
820  
821 0 my $api = $self->{_api_wrapper};
822 0 my $domain_name = $self->domain->name;
823 0 my $mailing_list_name = $self->name;
824 0 my $response = $api->rawCall( method => 'delete', path => "/email/domain/$domain_name/mailingList/$mailing_list_name/subscriber/$email", noSignature => 0 );
825 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
826  
827 0 my $task_id = $response->content->{id};
828 0 my $task = Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $task_id, module => $self->{_module} );
829  
830 0 return $task;
831 }
832  
833 =head2 tasks
834  
835 Get all associated tasks
836  
837 =over
838  
839 =item * Return: HASH
840  
841 =item * Synopsis: $mailinglist->tasks;
842  
843 =back
844  
845 =cut
846  
847 0 ▶sub tasks {
Subroutine tasks: not called CC=5 SCAR=34.0
Pod documented
848  
849 0 my ($self) = @_;
850  
851 0 ▶ return unless $self->{_valid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_valid"} 0 0 0
852  
853 0 my $domain_name = $self->domain->name;
854 0 my $api = $self->{_api_wrapper};
855 0 my $name = $self->name;
856  
857 0 my $response = $api->rawCall( method => 'get', path => sprintf( "/email/domain/$domain_name/task/mailinglist?account=%s", $name ), noSignature => 0 );
858 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
859  
860 0 ▶ my $taks = $response->content || [];
Condition0%0/2
$response->content || []
l!l
00
MC/DC0%0/1
$response->content || []
$response->content
Truth table0%0/2
A
A= $response->content
Aresult
11
00
861  
862 0 ▶ return unless scalar @$taks;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$taks 0 0 0
863  
864 0 return $taks;
865  
866 }
867  
868 36 1;
« Webservice/OVH/Cloud/Project/Network/Private/Subnet.pm ↑ Summary Webservice/OVH/Domain/Zone/Record.pm »