Webservice/OVH/Me/Task.pm

filter: Statementstmt 20.0% 11 / 55 Branchbran 0.0% 0 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 30.0% 3 / 10 Podpod 100% 6 / 6 totaltotal 20.6% 20 / 97 CC 14 SCAR 33.9
CC
14
Cov
14%
_new
72.0
accept
12.0
refuse
12.0
CRAP 29.5
« Webservice/OVH/Email/Domain/Domain/Redirection.pm ↑ Summary Webservice/OVH/Domain/Zone.pm »
1 package Webservice::OVH::Me::Task;
2  
3 =encoding utf-8
4  
5 =head1 NAME
6  
7 Webservice::OVH::Me::Task
8  
9 =head1 SYNOPSIS
10  
11 use Webservice::OVH;
12
13 my $ovh = Webservice::OVH->new_from_json("credentials.json");
14
15 my $task = $ovh->domain->service->change_contact(contact_billing => 'ovhaccount-ovh');
16
17 $task->resend_email;
18  
19 =head1 DESCRIPTION
20  
21 Module only provides basic functionality for contact_change tasks.
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  
31 36 our $VERSION = 0.48;
32  
33 =head2 _new
34  
35 Internal Method to create the Task object.
36 This method is not ment to be called directly.
37  
38 =over
39  
40 =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object, $type - intern type
41  
42 =item * Return: L<Webservice::OVH::Me::Task>
43  
44 =item * Synopsis: Webservice::OVH::Me::Task->_new($ovh_api_wrapper, $type, $module);
45  
46 =back
47  
48 =cut
49  
50 0 ▶sub _new {
Subroutine _new: not called CC=8 SCAR=42.8
51  
52 0 my ( $class, %params ) = @_;
53  
54 0 ▶ die "Missing module" unless $params{module};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"module"} 0 0 0
55 0 ▶ die "Missing wrapper" unless $params{wrapper};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"wrapper"} 0 0 0
56 0 ▶ die "Missing id" unless $params{id};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"id"} 0 0 0
57 0 ▶ die "Missing task type" unless $params{type};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"type"} 0 0 0
58  
59 0 my $module = $params{module};
60 0 my $api_wrapper = $params{wrapper};
61 0 my $task_id = $params{id};
62 0 my $type = $params{type};
63  
64 0 ▶ die "Missing contact_id" unless $task_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $task_id 0 0 0
65 0 ▶ die "Missing type" unless $type;
Branch: 1 branch
BranchTrueFalseTotal
unless $type 0 0 0
66  
67 0 my $response = $api_wrapper->rawCall( method => 'get', path => "/me/task/contactChange/$task_id", noSignature => 0 );
68 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
69  
70 0 my $porperties = $response->content;
71 0 my $self = bless { _module => $module, _api_wrapper => $api_wrapper, _id => $task_id, _type => $type, _properties => $porperties }, $class;
72  
73 0 return $self;
74 }
75  
76 =head2 type
77  
78 Returns intern type. At the moment only contact_change.
79  
80 =over
81  
82 =item * Return: VALUE
83  
84 =item * Synopsis: my $type = $task->type;
85  
86 =back
87  
88 =cut
89  
90 0 ▶sub type {
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
91  
92 0 my ($self) = @_;
93  
94 0 return $self->{_type};
95 }
96  
97 =head2 id
98  
99 Returns the api id.
100  
101 =over
102  
103 =item * Return: VALUE
104  
105 =item * Synopsis: my $id = $task->id;
106  
107 =back
108  
109 =cut
110  
111 0 ▶sub id {
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
112  
113 0 my ($self) = @_;
114  
115 0 return $self->{_id};
116 }
117  
118 =head2 properties
119  
120 Retrieves properties.
121 This method updates the intern property variable.
122  
123 =over
124  
125 =item * Return: HASH
126  
127 =item * Synopsis: my $properties = $task->properties;
128  
129 =back
130  
131 =cut
132  
133 0 ▶sub properties {
Subroutine properties: not called CC=2 SCAR=17.9
Pod documented
134  
135 0 my ($self) = @_;
136  
137 0 my $task_id = $self->id;
138 0 my $api = $self->{_api_wrapper};
139 0 my $response = $api->rawCall( method => 'get', path => "/me/task/contactChange/$task_id", noSignature => 0 );
140 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
141  
142 0 $self->{_properties} = $response->content;
143  
144 0 return $self->{_properties};
145 }
146  
147 =head2 accept
148  
149 Accepts a contact change.
150  
151 =over
152  
153 =item * Synopsis: $task->accept;
154  
155 =back
156  
157 =cut
158  
159 0 ▶sub accept {
Subroutine accept: not called CC=3 SCAR=24.8
Pod documented
160  
161 0 my ( $self, $token ) = @_;
162  
163 0 ▶ croak "Missing Token" unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
164  
165 0 my $task_id = $self->id;
166 0 my $api = $self->{_api_wrapper};
167 0 my $response = $api->rawCall( method => 'post', path => "/me/task/contactChange/$task_id/accept", body => { token => $token }, noSignature => 0 );
168 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
169 }
170  
171 =head2 refuse
172  
173 Refuses a contact change.
174  
175 =over
176  
177 =item * Synopsis: $task->accept;
178  
179 =back
180  
181 =cut
182  
183 0 ▶sub refuse {
Subroutine refuse: not called CC=3 SCAR=24.8
Pod documented
184  
185 0 my ( $self, $token ) = @_;
186  
187 0 ▶ croak "Missing Token" unless $token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
188  
189 0 my $task_id = $self->id;
190 0 my $api = $self->{_api_wrapper};
191 0 my $response = $api->rawCall( method => 'post', path => "/me/task/contactChange/$task_id/refuse", body => { token => $token }, noSignature => 0 );
192 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
193  
194 }
195  
196 =head2 resend_email
197  
198 Resends the contact change request.
199  
200 =over
201  
202 =item * Synopsis: $task->resend_email;
203  
204 =back
205  
206 =cut
207  
208 0 ▶sub resend_email {
Subroutine resend_email: not called CC=2 SCAR=17.9
Pod documented
209  
210 0 my ($self) = @_;
211  
212 0 my $task_id = $self->id;
213 0 my $api = $self->{_api_wrapper};
214 0 my $response = $api->rawCall( method => 'post', path => "/me/task/contactChange/$task_id/resendEmail", body => {}, noSignature => 0 );
215 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
216  
217 }
218  
219 36 1;
« Webservice/OVH/Email/Domain/Domain/Redirection.pm ↑ Summary Webservice/OVH/Domain/Zone.pm »