File Coverage

lib/Webservice/OVH/Email/Domain/Domain/Task.pm
Criterion Covered Total %
statement 18 119 15.1
branch 0 42 0.0
condition 0 33 0.0
subroutine 6 17 35.2
pod 0 10 0.0
total 24 221 10.8


line stmt bran cond sub pod time code
1              
2             use strict;
3 36     36   217 use warnings;
  36         72  
  36         877  
4 36     36   153 use Carp qw{ carp croak };
  36         63  
  36         824  
5 36     36   157  
  36         72  
  36         1857  
6             our $VERSION = 0.47;
7              
8             use Webservice::OVH::Email::Domain::Domain::Task::Account;
9 36     36   13847 use Webservice::OVH::Email::Domain::Domain::Task::Mailinglist;
  36         95  
  36         1065  
10 36     36   13351 use Webservice::OVH::Email::Domain::Domain::Task::Redirection;
  36         94  
  36         1023  
11 36     36   13502  
  36         92  
  36         46677  
12              
13             my ( $class, %params ) = @_;
14              
15 0     0     die "Missing module" unless $params{module};
16             die "Missing wrapper" unless $params{wrapper};
17 0 0         die "Missing domain" unless $params{domain};
18 0 0          
19 0 0         my $module = $params{module};
20             my $api_wrapper = $params{wrapper};
21 0           my $domain = $params{domain};
22 0            
23 0           my $self = bless {
24             _module => $module,
25 0           _wrapper => $api_wrapper,
26             _tasks_account => {},
27             _tasks_mailinglist => {},
28             _tasks_redirection => {},
29             _domain => $domain,
30             }, $class;
31              
32             return $self;
33             }
34 0            
35              
36             my ($self) = @_;
37              
38             return $self->{_domain};
39 0     0 0   }
40              
41 0            
42             my ($self) = @_;
43             my $api = $self->{_wrapper};
44             my $domain_name = $self->domain->name;
45              
46 0     0 0   my $response = $api->rawCall( method => 'get', path => "/email/domain/$domain_name/task/mailinglist", noSignature => 0 );
47 0           croak $response->error if $response->error;
48 0            
49             my $ids = $response->content;
50 0           my $objects = [];
51 0 0          
52             foreach my $id (@$ids) {
53 0            
54 0           my $object = $self->{_tasks_mailinglist}{$id} = $self->{_tasks_mailinglist}{$id} || Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $id, module => $self->{_module} );
55             push @$objects, $object;
56 0           }
57              
58 0   0       return $objects;
59 0           }
60              
61              
62 0           my ( $self, $id ) = @_;
63              
64             croak "Missing id" unless $id;
65              
66             my $api = $self->{_wrapper};
67 0     0 0   my $from_object_array = $self->{_tasks_mailinglist}{$id} if $self->{_tasks_mailinglist}{$id} && $self->{_tasks_mailinglist}{$id}->is_valid;
68             my $account = $self->{_tasks_mailinglist}{$id} = $from_object_array || Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $id, module => $self->{_module} );
69 0 0          
70             return $account;
71 0           }
72 0 0 0        
73 0   0        
74             my ( $self, $mailinglist_name ) = @_;
75 0            
76             croak "Missing mailinglist_name" unless $mailinglist_name;
77              
78             my $domain_name = $self->domain->name;
79             my $api = $self->{_wrapper};
80 0     0 0    
81             my $response = $api->rawCall( method => 'get', path => sprintf( "/email/domain/$domain_name/task/mailinglist?account=%s", $mailinglist_name ), noSignature => 0 );
82 0 0         croak $response->error if $response->error;
83              
84 0           my $ids = $response->content;
85 0           my $objects = [];
86              
87 0           foreach my $id (@$ids) {
88 0 0          
89             my $object = $self->{_tasks_mailinglist}{$id} = $self->{_tasks_mailinglist}{$id} || Webservice::OVH::Email::Domain::Domain::Task::Mailinglist->_new_existing( wrapper => $api, domain => $self->domain, id => $id, module => $self->{_module} );
90 0           push @$objects, $object;
91 0           }
92              
93 0           return unless scalar @$objects;
94              
95 0   0       return $objects;
96 0           }
97              
98              
99 0 0         my ($self) = @_;
100              
101 0           my $api = $self->{_wrapper};
102             my $domain_name = $self->domain->name;
103              
104             my $response = $api->rawCall( method => 'get', path => "/email/domain/$domain_name/task/account", noSignature => 0 );
105             croak $response->error if $response->error;
106 0     0 0    
107             my $ids = $response->content;
108 0           my $objects = [];
109 0            
110             foreach my $id (@$ids) {
111 0            
112 0 0         my $object = $self->{_tasks_account}{$id} = $self->{_tasks_account}{$id} || Webservice::OVH::Email::Domain::Domain::Task::Account->_new_existing( wrapper => $api, domain => $self->domain, id => $id, module => $self->{_module} );
113             push @$objects, $object;
114 0           }
115 0            
116             return $objects;
117 0           }
118              
119 0   0        
120 0           my ( $self, $id ) = @_;
121              
122             croak "Missing id" unless $id;
123 0            
124             my $api = $self->{_wrapper};
125             my $from_object_array = $self->{_tasks_account}{$id} if $self->{_tasks_account}{$id};
126             my $account = $self->{_tasks_account}{$id} = $from_object_array || Webservice::OVH::Email::Domain::Domain::Task::Account->_new_existing( wrapper => $api, domain => $self->domain, id => $id, module => $self->{_module} );
127              
128 0     0 0   return $account;
129             }
130 0 0          
131              
132 0           my ( $self, $account_name ) = @_;
133 0 0          
134 0   0       croak "Missing mailinglist_name" unless $account_name;
135              
136 0           my $domain_name = $self->domain->name;
137             my $api = $self->{_wrapper};
138              
139             my $response = $api->rawCall( method => 'get', path => sprintf( "/email/domain/$domain_name/task/account?name=%s", $account_name ), noSignature => 0 );
140             croak $response->error if $response->error;
141 0     0 0    
142             my $ids = $response->content;
143 0 0         my $objects = [];
144              
145 0           foreach my $id (@$ids) {
146 0            
147             my $object = $self->{_tasks_account}{$id} = $self->{_tasks_account}{$id} || Webservice::OVH::Email::Domain::Domain::Task::Account->_new_existing( wrapper => $api, domain => $self->domain, id => $id, module => $self->{_module} );
148 0           push @$objects, $object;
149 0 0         }
150              
151 0           return unless scalar @$objects;
152 0            
153             return $objects;
154 0           }
155              
156 0   0        
157 0           my ($self) = @_;
158              
159             my $api = $self->{_wrapper};
160 0 0         my $domain_name = $self->domain->name;
161              
162 0           my $response = $api->rawCall( method => 'get', path => "/email/domain/$domain_name/task/redirection", noSignature => 0 );
163             croak $response->error if $response->error;
164              
165             my $ids = $response->content;
166             my $objects = [];
167 0     0 0    
168             foreach my $id (@$ids) {
169 0            
170 0           my $object = $self->{_tasks_redirection}{$id} = $self->{_tasks_redirection}{$id} || Webservice::OVH::Email::Domain::Domain::Task::Redirection->_new_existing( wrapper => $api, domain => $self->domain, id => $id, module => $self->{_module} );
171             push @$objects, $object;
172 0           }
173 0 0          
174             return $objects;
175 0           }
176 0            
177              
178 0           my ( $self, $id ) = @_;
179              
180 0   0       croak "Missing id" unless $id;
181 0            
182             my $api = $self->{_wrapper};
183             my $from_object_array = $self->{_tasks_redirection}{$id} if $self->{_tasks_redirection}{$id} && $self->{_tasks_redirection}{$id}->is_valid;
184 0           my $account = $self->{_tasks_redirection}{$id} = $from_object_array || Webservice::OVH::Email::Domain::Domain::Task::Redirection->_new_existing( wrapper => $api, domain => $self->domain, id => $id, module => $self->{_module} );
185              
186             return $account;
187             }
188              
189 0     0 0    
190             my ( $self, $redirection_id ) = @_;
191 0 0          
192             croak "Missing mailinglist_name" unless $redirection_id;
193 0            
194 0 0 0       my $domain_name = $self->domain->name;
195 0   0       my $api = $self->{_wrapper};
196              
197 0           my $response = $api->rawCall( method => 'get', path => sprintf( "/email/domain/$domain_name/task/redirection?account=%s", $redirection_id ), noSignature => 0 );
198             croak $response->error if $response->error;
199              
200             my $ids = $response->content;
201             my $objects = [];
202 0     0 0    
203             foreach my $id (@$ids) {
204 0 0          
205             my $object = $self->{_tasks_redirection}{$id} = $self->{_tasks_redirection}{$id} || Webservice::OVH::Email::Domain::Domain::Task::Redirection->_new_existing( wrapper => $api, domain => $self->domain, id => $id, module => $self->{_module} );
206 0           push @$objects, $object;
207 0           }
208              
209 0           return unless scalar @$objects;
210 0 0          
211             return $objects;
212 0           }
213 0            
214             1;