| line | stmt | bran | cond | sub | pod | time | code | 
| 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 |  |  | 36 |  | 256 | use strict; | 
|  | 36 |  |  |  |  | 99 |  | 
|  | 36 |  |  |  |  | 1097 |  | 
| 28 | 36 |  |  | 36 |  | 186 | use warnings; | 
|  | 36 |  |  |  |  | 88 |  | 
|  | 36 |  |  |  |  | 1203 |  | 
| 29 | 36 |  |  | 36 |  | 230 | use Carp qw{ carp croak }; | 
|  | 36 |  |  |  |  | 130 |  | 
|  | 36 |  |  |  |  | 25995 |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | 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 |  |  |  |  |  |  | sub _new { | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 0 |  |  | 0 |  |  | my ( $class, %params ) = @_; | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 0 | 0 |  |  |  |  | die "Missing module"    unless $params{module}; | 
| 55 | 0 | 0 |  |  |  |  | die "Missing wrapper"   unless $params{wrapper}; | 
| 56 | 0 | 0 |  |  |  |  | die "Missing id"        unless $params{id}; | 
| 57 | 0 | 0 |  |  |  |  | die "Missing task type" unless $params{type}; | 
| 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 | 0 |  |  |  |  | die "Missing contact_id" unless $task_id; | 
| 65 | 0 | 0 |  |  |  |  | die "Missing type" unless $type; | 
| 66 |  |  |  |  |  |  |  | 
| 67 | 0 |  |  |  |  |  | my $response = $api_wrapper->rawCall( method => 'get', path => "/me/task/contactChange/$task_id", noSignature => 0 ); | 
| 68 | 0 | 0 |  |  |  |  | croak $response->error if $response->error; | 
| 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 |  |  |  |  |  |  | sub type { | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub id { | 
| 112 |  |  |  |  |  |  |  | 
| 113 | 0 |  |  | 0 | 1 |  | 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 |  |  |  |  |  |  | sub properties { | 
| 134 |  |  |  |  |  |  |  | 
| 135 | 0 |  |  | 0 | 1 |  | 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 | 0 |  |  |  |  | croak $response->error if $response->error; | 
| 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 |  |  |  |  |  |  | sub accept { | 
| 160 |  |  |  |  |  |  |  | 
| 161 | 0 |  |  | 0 | 1 |  | my ( $self, $token ) = @_; | 
| 162 |  |  |  |  |  |  |  | 
| 163 | 0 | 0 |  |  |  |  | croak "Missing Token" unless $token; | 
| 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 | 0 |  |  |  |  | croak $response->error if $response->error; | 
| 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 |  |  |  |  |  |  | sub refuse { | 
| 184 |  |  |  |  |  |  |  | 
| 185 | 0 |  |  | 0 | 1 |  | my ( $self, $token ) = @_; | 
| 186 |  |  |  |  |  |  |  | 
| 187 | 0 | 0 |  |  |  |  | croak "Missing Token" unless $token; | 
| 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 | 0 |  |  |  |  | croak $response->error if $response->error; | 
| 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 |  |  |  |  |  |  | sub resend_email { | 
| 209 |  |  |  |  |  |  |  | 
| 210 | 0 |  |  | 0 | 1 |  | 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 | 0 |  |  |  |  | croak $response->error if $response->error; | 
| 216 |  |  |  |  |  |  |  | 
| 217 |  |  |  |  |  |  | } | 
| 218 |  |  |  |  |  |  |  | 
| 219 |  |  |  |  |  |  | 1; |