line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Webservice::OVH::Me; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Webservice::OVH::Me |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Webservice::OVH; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $ovh = Webservice::OVH->new_from_json("credentials.json"); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $contacts = $ovh->me->contacts; |
16
|
|
|
|
|
|
|
my $tasks_contact_change = $ovh->me->tasks_contact_change; |
17
|
|
|
|
|
|
|
my $orders = $ovh->me->orders(DateTime->now->sub(days => -1), DateTime->now); |
18
|
|
|
|
|
|
|
my $bills = $ovh->me->bills(DateTime->now->sub(days => -1), DateTime->now); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $bill_id = $bills->[0]->id; |
21
|
|
|
|
|
|
|
my $order_id = $orders->[0]->id; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $bill = $me->ovh->bill($bill_id); |
24
|
|
|
|
|
|
|
my $order = $me->ovh->bill($order_id); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
print $bill->pdf_url; |
27
|
|
|
|
|
|
|
print $order->url; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Module support for now only basic retrieval methods for contacs, tasks, orders and bills |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
36
|
|
|
36
|
|
282
|
use strict; |
|
36
|
|
|
|
|
84
|
|
|
36
|
|
|
|
|
1323
|
|
38
|
36
|
|
|
36
|
|
246
|
use warnings; |
|
36
|
|
|
|
|
122
|
|
|
36
|
|
|
|
|
1585
|
|
39
|
36
|
|
|
36
|
|
284
|
use Carp qw{ carp croak }; |
|
36
|
|
|
|
|
179
|
|
|
36
|
|
|
|
|
2653
|
|
40
|
36
|
|
|
36
|
|
308
|
use Webservice::OVH::Helper; |
|
36
|
|
|
|
|
99
|
|
|
36
|
|
|
|
|
1784
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our $VERSION = 0.46; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# sub modules |
45
|
36
|
|
|
36
|
|
277
|
use Webservice::OVH::Me::Contact; |
|
36
|
|
|
|
|
104
|
|
|
36
|
|
|
|
|
1056
|
|
46
|
36
|
|
|
36
|
|
17727
|
use Webservice::OVH::Me::Order; |
|
36
|
|
|
|
|
105
|
|
|
36
|
|
|
|
|
1476
|
|
47
|
36
|
|
|
36
|
|
18920
|
use Webservice::OVH::Me::Bill; |
|
36
|
|
|
|
|
109
|
|
|
36
|
|
|
|
|
1238
|
|
48
|
36
|
|
|
36
|
|
16957
|
use Webservice::OVH::Me::Task; |
|
36
|
|
|
|
|
97
|
|
|
36
|
|
|
|
|
41215
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 _new |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Internal Method to create the me object. |
53
|
|
|
|
|
|
|
This method is not ment to be called external. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Me> |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item * Synopsis: Webservice::OVH::Me->_new($ovh_api_wrapper, $self); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _new { |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
|
|
my ( $class, %params ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
die "Missing module" unless $params{module}; |
72
|
0
|
0
|
|
|
|
|
die "Missing wrapper" unless $params{wrapper}; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $module = $params{module}; |
75
|
0
|
|
|
|
|
|
my $api_wrapper = $params{wrapper}; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $self = bless { _module => $module, _api_wrapper => $api_wrapper, _contacts => {}, _tasks_contact_change => {}, _orders => {}, _bills => {} }, $class; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 contacts |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Produces an array of all available contacts that are stored for the used account. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * Return: ARRAY |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * Synopsis: my $contacts = $ovh->me->contacs(); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub contacts { |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
101
|
0
|
|
|
|
|
|
my $response = $api->rawCall( method => 'get', path => "/me/contact", noSignature => 0 ); |
102
|
0
|
0
|
|
|
|
|
croak $response->error if $response->error; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $contact_ids = $response->content; |
105
|
0
|
|
|
|
|
|
my $contacts = []; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
foreach my $contact_id (@$contact_ids) { |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
0
|
|
|
|
my $contact = $self->{_contacts}{$contact_id} = $self->{_contacts}{$contact_id} || Webservice::OVH::Me::Contact->_new_existing( wrapper => $api, id => $contact_id, module => $self->{_module} ); |
110
|
0
|
|
|
|
|
|
push @$contacts, $contact; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
return $contacts; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 contact |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns a single contact by id |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=over |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * Parameter: $contact_id - id |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Me::Contact> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * Synopsis: my $contact = $ovh->me->contact(1234567); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=back |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub contact { |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
0
|
1
|
|
my ( $self, $contact_id ) = @_; |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
137
|
0
|
|
0
|
|
|
|
my $contact = $self->{_contacts}{$contact_id} = $self->{_contacts}{$contact_id} || Webservice::OVH::Me::Contact->_new_existing( wrapper => $api, id => $contact_id, module => $self->{_module} ); |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
return $contact; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 tasks_contact_change |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Produces an array of all available contact change tasks. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=over |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * Return: ARRAY |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * Synopsis: my $tasks = $ovh->me->tasks_contact_change(); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub tasks_contact_change { |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
161
|
0
|
|
|
|
|
|
my $response = $api->rawCall( method => 'get', path => "/me/task/contactChange", noSignature => 0 ); |
162
|
0
|
0
|
|
|
|
|
croak $response->error if $response->error; |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
my $task_ids = $response->content; |
165
|
0
|
|
|
|
|
|
my $tasks = []; |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
foreach my $task_id (@$task_ids) { |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
0
|
|
|
|
my $task = $self->{_tasks_contact_change}{$task_id} = $self->{_tasks_contact_change}{$task_id} || Webservice::OVH::Me::Task->_new( wrapper => $api, type => "contact_change", id => $task_id, module => $self->{_module} ); |
170
|
0
|
|
|
|
|
|
push @$tasks, $task; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
return $tasks; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 task_contact_change |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Returns a single contact change task by id |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=over |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item * Parameter: $task_id - id |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Me::Task> |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * Synopsis: my $contact = $ovh->me->task_contact_change(1234567); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=back |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub task_contact_change { |
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
0
|
1
|
|
my ( $self, $task_id ) = @_; |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
197
|
0
|
|
0
|
|
|
|
my $task = $self->{_tasks_contact_change}{$task_id} = $self->{_tasks_contact_change}{$task_id} || Webservice::OVH::Me::Task->_new( wrapper => $api, type => "contact_change", id => $task_id, module => $self->{_module} ); |
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
return $task; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 orders |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Produces an array of all available orders. |
206
|
|
|
|
|
|
|
Orders can be optionally filtered by date. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=over |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item * Parameter: $date_from - optional filter DateTime, $date_to - optional filter DateTime |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item * Return: ARRAY |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item * Synopsis: my $orders = $ovh->me->orders(DateTime->new(), DateTime->new()); |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=back |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub orders { |
221
|
|
|
|
|
|
|
|
222
|
0
|
|
|
0
|
1
|
|
my ( $self, $date_from, $date_to ) = @_; |
223
|
|
|
|
|
|
|
|
224
|
0
|
0
|
|
|
|
|
my $str_date_from = $date_from ? $date_from->strftime("%Y-%m-%d") : ""; |
225
|
0
|
0
|
|
|
|
|
my $str_date_to = $date_to ? $date_to->strftime("%Y-%m-%d") : ""; |
226
|
0
|
|
|
|
|
|
my $filter = Webservice::OVH::Helper->construct_filter( "date.from" => $str_date_from, "date.to" => $str_date_to ); |
227
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
229
|
0
|
|
|
|
|
|
my $response = $api->rawCall( method => 'get', path => "/me/order$filter", noSignature => 0 ); |
230
|
0
|
0
|
|
|
|
|
croak $response->error if $response->error; |
231
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
|
my $order_ids = $response->content; |
233
|
0
|
|
|
|
|
|
my $orders = []; |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
foreach my $order_id (@$order_ids) { |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
0
|
|
|
|
my $order = $self->{_orders}{$order_id} = $self->{_orders}{$order_id} || Webservice::OVH::Me::Order->_new( wrapper => $api, id => $order_id, module => $self->{_module} ); |
238
|
0
|
|
|
|
|
|
push @$orders, $order; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
|
return $orders; |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 order |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Returns a single order by id |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=over |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item * Parameter: $order_id - id |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Me::Order> |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=item * Synopsis: my $order = $ovh->me->order(1234567); |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=back |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=cut |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
sub order { |
261
|
|
|
|
|
|
|
|
262
|
0
|
|
|
0
|
1
|
|
my ( $self, $order_id ) = @_; |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
265
|
0
|
|
0
|
|
|
|
my $order = $self->{_orders}{$order_id} = $self->{_orders}{$order_id} || Webservice::OVH::Me::Order->_new( wrapper => $api, id => $order_id, module => $self->{_module} ); |
266
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
|
return $order; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=head2 bill |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Returns a single bill by id |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=over |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=item * Parameter: $bill_id - id |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Me::Bill> |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=item * Synopsis: my $order = $ovh->me->bill(1234567); |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=back |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=cut |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
sub bill { |
287
|
|
|
|
|
|
|
|
288
|
0
|
|
|
0
|
1
|
|
my ( $self, $bill_id ) = @_; |
289
|
|
|
|
|
|
|
|
290
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
291
|
0
|
|
0
|
|
|
|
my $bill = $self->{_bills}{$bill_id} = $self->{_bills}{$bill_id} || Webservice::OVH::Me::Bill->_new( wrapper => $api, id => $bill_id, module => $self->{_module} ); |
292
|
|
|
|
|
|
|
|
293
|
0
|
|
|
|
|
|
return $bill; |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=head2 bills |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Produces an array of all available bills. |
299
|
|
|
|
|
|
|
Bills can be optionally filtered by date. |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=over |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=item * Parameter: $date_from - optional filter DateTime, $date_to - optional filter DateTime |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=item * Return: ARRAY |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=item * Synopsis: my $bills = $ovh->me->bills(DateTime->new(), DateTime->new()); |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=back |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=cut |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
sub bills { |
314
|
|
|
|
|
|
|
|
315
|
0
|
|
|
0
|
1
|
|
my ( $self, $date_from, $date_to ) = @_; |
316
|
|
|
|
|
|
|
|
317
|
0
|
0
|
|
|
|
|
my $str_date_from = $date_from ? $date_from->strftime("%Y-%m-%d") : ""; |
318
|
0
|
0
|
|
|
|
|
my $str_date_to = $date_to ? $date_to->strftime("%Y-%m-%d") : ""; |
319
|
0
|
|
|
|
|
|
my $filter = Webservice::OVH::Helper->construct_filter( "date.from" => $str_date_from, "date.to" => $str_date_to ); |
320
|
|
|
|
|
|
|
|
321
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
322
|
0
|
|
|
|
|
|
my $response = $api->rawCall( method => 'get', path => sprintf( "/me/bill%s", $filter ), noSignature => 0 ); |
323
|
0
|
0
|
|
|
|
|
croak $response->error if $response->error; |
324
|
|
|
|
|
|
|
|
325
|
0
|
|
|
|
|
|
my $bill_ids = $response->content; |
326
|
0
|
|
|
|
|
|
my $bills = []; |
327
|
|
|
|
|
|
|
|
328
|
0
|
|
|
|
|
|
foreach my $bill_id (@$bill_ids) { |
329
|
|
|
|
|
|
|
|
330
|
0
|
|
0
|
|
|
|
my $bill = $self->{_bills}{$bill_id} = $self->{_bills}{$bill_id} || Webservice::OVH::Me::Bill->_new( wrapper => $api, id => $bill_id, module => $self->{_module} ); |
331
|
0
|
|
|
|
|
|
push @$bills, $bill; |
332
|
|
|
|
|
|
|
} |
333
|
|
|
|
|
|
|
|
334
|
0
|
|
|
|
|
|
return $bills; |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
1; |