Webservice/OVH/Order/Cart.pm

filter: Statementstmt 5.0% 14 / 279 Branchbran 0.0% 0 / 196 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 14.2% 4 / 28 Podpod 95.2% 20 / 21 totaltotal 7.1% 38 / 534 CC 103 SCAR 51.9
CC
103
Cov
3%
add_transfer
420.0
add_transfer_new
420.0
add_domain
272.0
CRAP 179.1
↑ Summary Webservice/OVH/Hosting/Web/Service.pm »
1 package Webservice::OVH::Order::Cart;
2  
3 =encoding utf-8
4  
5 =head1 NAME
6  
7 Webservice::OVH::Order::Cart
8  
9 =head1 SYNOPSIS
10  
11 use Webservice::OVH;
12
13 my $ovh = Webservice::OVH->new_from_json("credentials.json");
14
15 my $cart = $ovh->order->new_cart(ovh_subsidiary => 'DE');
16
17 $cart->add_domain('www.domain.com');
18
19 $cart->delete;
20  
21 =head1 DESCRIPTION
22  
23 Provides methods to manage shopping carts.
24  
25 =head1 METHODS
26  
27 =cut
28  
29 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 36 ▶use Carp qw{ carp croak };
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 36 our $VERSION = 0.48;
34  
35 36 ▶use Webservice::OVH::Order::Cart::Item;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 =head2 _new_existing
38  
39 Internal Method to create the Cart object.
40 This method is not ment to be called directly.
41  
42 =over
43  
44 =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object, $cart_id - api id
45  
46 =item * Return: L<Webservice::OVH::Order::Cart>
47  
48 =item * Synopsis: Webservice::OVH::Order::Cart->_new($ovh_api_wrapper, $cart_id, $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  
62 0 my $module = $params{module};
63 0 my $api_wrapper = $params{wrapper};
64 0 my $cart_id = $params{id};
65  
66 0 my $response = $api_wrapper->rawCall( method => 'get', path => "/order/cart/$cart_id", noSignature => 0 );
67 0 ▶ carp $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
68  
69 0 ▶ if ( !$response->error ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $response->error) { } 0 0 0
70  
71 0 my $properties = $response->content;
72 0 my $self = bless { _module => $module, _valid => 1, _api_wrapper => $api_wrapper, _id => $cart_id, _properties => $properties, _items => {} }, $class;
73  
74 0 return $self;
75  
76 } else {
77  
78 0 return undef;
79 }
80 }
81  
82 =head2 _new_existing
83  
84 Internal Method to create the Cart object.
85 This method is not ment to be called directly.
86  
87 =over
88  
89 =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object - api id
90  
91 =item * Return: L<Webservice::OVH::Order::Cart>
92  
93 =item * Synopsis: Webservice::OVH::Order::Cart->_new($ovh_api_wrapper, $module, ovhSubsidiary => 'DE', decription => 'Shopping');
94  
95 =back
96  
97 =cut
98  
99 0 ▶sub _new {
Subroutine _new: not called CC=8 SCAR=42.8
100  
101 0 my ( $class, %params ) = @_;
102  
103 0 ▶ die "Missing module" unless $params{module};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"module"} 0 0 0
104 0 ▶ die "Missing wrapper" unless $params{wrapper};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"wrapper"} 0 0 0
105  
106 0 my $module = $params{module};
107 0 my $api_wrapper = $params{wrapper};
108  
109 0 ▶ croak "Missing ovh_subsidiary" unless exists $params{ovh_subsidiary};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"ovh_subsidiary"} 0 0 0
110 0 my $body = {};
111 0 ▶ $body->{description} = $params{description} if exists $params{description};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"description"} 0 0 0
112 0 ▶ $body->{expire} = $params{expire} if exists $params{expire};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"expire"} 0 0 0
113 0 $body->{ovhSubsidiary} = $params{ovh_subsidiary};
114 0 my $response = $api_wrapper->rawCall( method => 'post', path => "/order/cart", body => $body, noSignature => 0 );
115 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
116  
117 0 my $cart_id = $response->content->{cartId};
118 0 my $properties = $response->content;
119  
120 0 my $response_assign = $api_wrapper->rawCall( method => 'post', path => "/order/cart/$cart_id/assign", body => {}, noSignature => 0 );
121 0 ▶ croak $response_assign->error if $response_assign->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_assign->error 0 0 0
122  
123 0 my $self = bless { _module => $module, _valid => 1, _api_wrapper => $api_wrapper, _id => $cart_id, _properties => $properties, _items => {} }, $class;
124  
125 0 return $self;
126 }
127  
128 =head2 properties
129  
130 Retrieves properties.
131 This method updates the intern property variable.
132  
133 =over
134  
135 =item * Return: HASH
136  
137 =item * Synopsis: my $properties = $cart->properties;
138  
139 =back
140  
141 =cut
142  
143 0 ▶sub properties {
Subroutine properties: not called CC=2 SCAR=17.9
Pod documented
144  
145 0 my ($self) = @_;
146  
147 0 my $api = $self->{_api_wrapper};
148 0 my $cart_id = $self->id;
149 0 my $response = $api->rawCall( method => 'get', path => "/order/cart/$cart_id", noSignature => 0 );
150 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
151  
152 0 $self->{_properties} = $response->content;
153 0 return $self->{_properties};
154 }
155  
156 =head2 description
157  
158 Exposed property value.
159  
160 =over
161  
162 =item * Return: VALUE
163  
164 =item * Synopsis: my $description = $cart->description;
165  
166 =back
167  
168 =cut
169  
170 0 ▶sub description {
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
171  
172 0 my ($self) = @_;
173  
174 0 return $self->{_properties}->{description};
175 }
176  
177 =head2 expire
178  
179 Exposed property value.
180  
181 =over
182  
183 =item * Return: VALUE
184  
185 =item * Synopsis: my $expire = $cart->expire;
186  
187 =back
188  
189 =cut
190  
191 0 ▶sub expire {
Subroutine expire: not called CC=1 SCAR=6.9
Pod documented
192  
193 0 my ($self) = @_;
194  
195 0 return $self->{_properties}->{expire};
196 }
197  
198 =head2 read_only
199  
200 Exposed property value.
201  
202 =over
203  
204 =item * Return: VALUE
205  
206 =item * Synopsis: my $read_only = $cart->read_only;
207  
208 =back
209  
210 =cut
211  
212 0 ▶sub read_only {
Subroutine read_only: not called CC=2 SCAR=17.9
Pod documented
213  
214 0 my ($self) = @_;
215  
216 0 ▶ return $self->{_properties}->{readOnly} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_properties'}{'readOnly'} ? : 0 0 0
217 }
218  
219 =head2 change
220  
221 Exposed property value.
222  
223 =over
224  
225 =item * Parameter: %params - key => value description expire
226  
227 =item * Synopsis: my $change = $cart->change(description => 'Shopping!');
228  
229 =back
230  
231 =cut
232  
233 0 ▶sub change {
Subroutine change: not called CC=7 SCAR=40.3
Pod documented
234  
235 0 my ( $self, %params ) = @_;
236  
237 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
238  
239 0 my $api = $self->{_api_wrapper};
240 0 my $cart_id = $self->id;
241  
242 0 ▶ croak "Missing Parameter description" unless exists $params{description};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"description"} 0 0 0
243 0 ▶ croak "Missing Parameter description" unless exists $params{expire};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"expire"} 0 0 0
244  
245 0 my $body = {};
246 0 ▶ $body->{description} = $params{description} if $params{description};
Branch: 1 branch
BranchTrueFalseTotal
if $params{"description"} 0 0 0
247 0 ▶ $body->{expire} = $params{expire} if $params{expire};
Branch: 1 branch
BranchTrueFalseTotal
if $params{"expire"} 0 0 0
248  
249 0 my $response = $api->rawCall( method => 'put', path => "/order/cart/$cart_id", body => $body, noSignature => 0 );
250 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
251  
252 0 $self->properties;
253 }
254  
255 =head2 is_valid
256  
257 When this cart is deleted on the api side, this method returns 0.
258  
259 =over
260  
261 =item * Return: VALUE
262  
263 =item * Synopsis: print "Valid" if $cart->is_valid;
264  
265 =back
266  
267 =cut
268  
269 0 ▶sub is_valid {
Subroutine is_valid: not called CC=1 SCAR=6.9
Pod documented
270  
271 0 my ($self) = @_;
272  
273 0 return $self->{_valid};
274 }
275  
276 =head2 _is_valid
277  
278 Intern method to check validity.
279 Difference is that this method carps an error.
280  
281 =over
282  
283 =item * Return: VALUE
284  
285 =item * Synopsis: $cart->_is_valid;
286  
287 =back
288  
289 =cut
290  
291 0 ▶sub _is_valid {
Subroutine _is_valid: not called CC=2 SCAR=17.9
292  
293 0 my ($self) = @_;
294  
295 0 my $cart_id = $self->id;
296 0 ▶ carp "Cart $cart_id is not valid anymore" unless $self->is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_valid 0 0 0
297 0 return $self->is_valid;
298 }
299  
300 =head2 delete
301  
302 Deletes the cart api sided and sets this object invalid.
303  
304 =over
305  
306 =item * Synopsis: $cart->delete;
307  
308 =back
309  
310 =cut
311  
312 0 ▶sub delete {
Subroutine delete: not called CC=3 SCAR=24.8
Pod documented
313  
314 0 my ($self) = @_;
315  
316 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
317  
318 0 my $api = $self->{_api_wrapper};
319 0 my $cart_id = $self->id;
320  
321 0 my $response = $api->rawCall( method => 'delete', path => "/order/cart/$cart_id", noSignature => 0 );
322 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
323  
324 0 $self->{_valid} = 0;
325 }
326  
327 =head2 id
328  
329 Returns the api id.
330  
331 =over
332  
333 =item * Return: VALUE
334  
335 =item * Synopsis: my $id = $cart->id;
336  
337 =back
338  
339 =cut
340  
341 0 ▶sub id {
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
342  
343 0 my ($self) = @_;
344  
345 0 return $self->{_id},;
346 }
347  
348 =head2 offers_domain
349  
350 Returns an Array of hashs with offers.
351  
352 =over
353  
354 =item * Parameter: $domain - domain name
355  
356 =item * Return: L<ARRAY>
357  
358 =item * Synopsis: my $offers = $cart->offers_domain('mydomain.de');
359  
360 =back
361  
362 =cut
363  
364 0 ▶sub offers_domain {
Subroutine offers_domain: not called CC=3 SCAR=24.8
Pod documented
365  
366 0 my ( $self, $domain ) = @_;
367  
368 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
369  
370 0 my $api = $self->{_api_wrapper};
371 0 my $cart_id = $self->id;
372  
373 0 my $response = $api->rawCall( method => 'get', path => sprintf( "/order/cart/%s/domain?domain=%s", $cart_id, $domain ), noSignature => 0 );
374 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
375  
376 0 return $response->content;
377 }
378  
379 =head2 add_domain
380  
381 Adds a domain request to a cart.
382  
383 =over
384  
385 =item * Parameter: $domain - domain name, %params - key => value duration offer_id quantity
386  
387 =item * Return: L<Webservice::OVH::Order::Cart::Item>
388  
389 =item * Synopsis: my $item = $cart->add_domain('mydomain.de');
390  
391 =back
392  
393 =cut
394  
395 0 ▶sub add_domain {
Subroutine add_domain: not called CC=16 SCAR=56.1
Pod documented
396  
397 0 my ( $self, $domain, %params ) = @_;
398  
399 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
400  
401 0 my $api = $self->{_api_wrapper};
402 0 my $cart_id = $self->id;
403  
404 0 ▶ croak "Missing domain parameter" unless $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain 0 0 0
405  
406 0 my $body = {};
407 0 ▶ $body->{duration} = $params{duration} if exists $params{duration};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"duration"} 0 0 0
408 0 ▶ $body->{offerId} = $params{offer_id} if exists $params{offer_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"offer_id"} 0 0 0
409 0 ▶ $body->{quantity} = $params{quantity} if exists $params{quantity};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"quantity"} 0 0 0
410 0 $body->{domain} = $domain;
411  
412 0 my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/domain", body => $body, noSignature => 0 );
413 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
414  
415 0 my $item_id = $response->content->{itemId};
416 0 my $item = Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} );
417  
418 0 my $owner = $params{owner_contact};
419 0 my $admin = $params{admin_account};
420 0 my $tech = $params{tech_account};
421  
422 0 ▶ if ($owner) {
Branch: 1 branch
BranchTrueFalseTotal
if ($owner) 0 0 0
423 0 my $config_preset_owner = { label => "OWNER_CONTACT", value => $owner };
424 0 my $response_product_set_config_owner = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_owner, noSignature => 0 );
425 0 ▶ my $config2 = $response_product_set_config_owner->content unless $response_product_set_config_owner->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config_owner->error 0 0 0
426 0 ▶ croak $response_product_set_config_owner->error if $response_product_set_config_owner->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config_owner->error 0 0 0
427 }
428  
429 0 ▶ if ($admin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($admin) 0 0 0
430  
431 0 my $config_preset_admin = { label => "ADMIN_ACCOUNT", value => $admin };
432 0 my $response_product_set_config_admin = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_admin, noSignature => 0 );
433 0 ▶ my $config3 = $response_product_set_config_admin->content unless $response_product_set_config_admin->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config_admin->error 0 0 0
434 0 ▶ croak $response_product_set_config_admin->error if $response_product_set_config_admin->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config_admin->error 0 0 0
435 }
436  
437 0 ▶ if ($tech) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tech) 0 0 0
438  
439 0 my $config_preset_tech = { label => "TECH_ACCOUNT", value => $tech };
440 0 my $response_product_set_config_tech = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_tech, noSignature => 0 );
441 0 ▶ my $config4 = $response_product_set_config_tech->content unless $response_product_set_config_tech->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config_tech->error 0 0 0
442 0 ▶ croak $response_product_set_config_tech->error if $response_product_set_config_tech->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config_tech->error 0 0 0
443 }
444  
445 0 return $item;
446 }
447  
448 =head2 offer_dns
449  
450 Returns an Hash with information for dns Zone pricing
451 A Domain must be added before requestion info
452  
453 =over
454  
455 =item * Parameter: $dns - domain name
456  
457 =item * Return: L<HASHREF>
458  
459 =item * Synopsis: my $offer = $cart->offers_dns;
460  
461 =back
462  
463 =cut
464  
465 0 ▶sub offer_dns {
Subroutine offer_dns: not called CC=3 SCAR=24.8
Pod documented
466  
467 0 my ( $self, $domain ) = @_;
468  
469 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
470  
471 0 my $api = $self->{_api_wrapper};
472 0 my $cart_id = $self->id;
473  
474 0 my $response = $api->rawCall( method => 'get', path => sprintf( "/order/cart/%s/dns?domain=%s", $cart_id, $domain ), noSignature => 0 );
475 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
476  
477 0 return $response->content;
478 }
479  
480 =head2 add_dns
481  
482 Adds a dns Zone to a cart.
483  
484 =over
485  
486 =item * Return: L<Webservice::OVH::Order::Cart::Item>
487  
488 =item * Synopsis: my $item = $cart->add_dns;
489  
490 =back
491  
492 =cut
493  
494 0 ▶sub add_dns {
Subroutine add_dns: not called CC=7 SCAR=40.3
Pod documented
495  
496 0 my ( $self, $domain, %params ) = @_;
497  
498 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
499  
500 0 my $api = $self->{_api_wrapper};
501 0 my $cart_id = $self->id;
502  
503 0 my $body = {};
504 0 ▶ $body->{duration} = $params{duration} if exists $params{duration};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"duration"} 0 0 0
505 0 ▶ $body->{planCode} = $params{plan_code} if exists $params{plan_code};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"plan_code"} 0 0 0
506 0 ▶ $body->{pricingMode} = $params{pricing_mode} if exists $params{pricing_mode};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"pricing_mode"} 0 0 0
507 0 ▶ $body->{quantity} = $params{quantity} if exists $params{quantity};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"quantity"} 0 0 0
508 0 $body->{domain} = $domain;
509  
510 0 my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/dns", body => $body, noSignature => 0 );
511 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
512  
513 0 my $item_id = $response->content->{itemId};
514 0 my $item = Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} );
515  
516 0 return $item;
517 }
518  
519  
520 =head2 offers_domain_transfer
521  
522 Returns an Array of hashes with offers.
523  
524 =over
525  
526 =item * Parameter: $domain - domain name
527  
528 =item * Return: L<ARRAY>
529  
530 =item * Synopsis: my $offers = $cart->offers_domain_transfer('mydomain.de');
531  
532 =back
533  
534 =cut
535  
536 0 ▶sub offers_domain_transfer {
Subroutine offers_domain_transfer: not called CC=3 SCAR=24.8
Pod documented
537  
538 0 my ( $self, $domain ) = @_;
539  
540 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
541  
542 0 my $api = $self->{_api_wrapper};
543 0 my $cart_id = $self->id;
544  
545 0 my $response = $api->rawCall( method => 'get', path => sprintf( "/order/cart/%s/domainTransfer?domain=%s", $cart_id, $domain ), noSignature => 0 );
546 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
547  
548 0 return $response->content;
549 }
550  
551 =head2 offers_domain
552  
553 Adds a domain transfer request to a cart.
554  
555 =over
556  
557 =item * Parameter: $domain - domain name, %params - key => value duration offer_id quantity
558  
559 =item * Return: L<Webservice::OVH::Order::Cart::Item>
560  
561 =item * Synopsis: my $item = $cart->add_transfer('mydomain.de');
562  
563 =back
564  
565 =cut
566  
567 0 ▶sub add_transfer {
Subroutine add_transfer: not called CC=20 SCAR=60.4
Pod documented
568  
569 0 my ( $self, $domain, %params ) = @_;
570  
571 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
572  
573 0 my $api = $self->{_api_wrapper};
574 0 my $cart_id = $self->id;
575  
576 0 ▶ croak "Missing domain parameter" unless $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain 0 0 0
577 0 ▶ croak "Missing auth_info" unless exists $params{auth_info};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"auth_info"} 0 0 0
578  
579 0 my $body = {};
580 0 ▶ $body->{duration} = $params{duration} if exists $params{duration};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"duration"} 0 0 0
581 0 ▶ $body->{offerId} = $params{offer_id} if exists $params{offer_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"offer_id"} 0 0 0
582 0 ▶ $body->{quantity} = $params{quantity} if exists $params{quantity};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"quantity"} 0 0 0
583 0 $body->{domain} = $domain;
584  
585 0 my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/domainTransfer", body => $body, noSignature => 0 );
586 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
587  
588 0 my $item_id = $response->content->{itemId};
589 0 my $item = Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} );
590  
591 0 ▶ return unless $item;
Branch: 1 branch
BranchTrueFalseTotal
unless $item 0 0 0
592  
593 0 my $auth_info = $params{auth_info};
594 0 my $owner = $params{owner_contact};
595 0 my $admin = $params{admin_account};
596 0 my $tech = $params{tech_account};
597  
598 0 my $config_preset = { label => "AUTH_INFO", value => $auth_info };
599 0 my $response_product_set_config = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset, noSignature => 0 );
600 0 ▶ my $config1 = $response_product_set_config->content unless $response_product_set_config->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config->error 0 0 0
601 0 ▶ croak $response_product_set_config->error if $response_product_set_config->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config->error 0 0 0
602  
603 0 ▶ if ($owner) {
Branch: 1 branch
BranchTrueFalseTotal
if ($owner) 0 0 0
604 0 my $config_preset_owner = { label => "OWNER_CONTACT", value => $owner };
605 0 my $response_product_set_config_owner = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_owner, noSignature => 0 );
606 0 ▶ my $config2 = $response_product_set_config_owner->content unless $response_product_set_config_owner->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config_owner->error 0 0 0
607 0 ▶ croak $response_product_set_config_owner->error if $response_product_set_config_owner->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config_owner->error 0 0 0
608 }
609  
610 0 ▶ if ($admin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($admin) 0 0 0
611 0 my $config_preset_admin = { label => "ADMIN_ACCOUNT", value => $admin };
612 0 my $response_product_set_config_admin = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_admin, noSignature => 0 );
613 0 ▶ my $config3 = $response_product_set_config_admin->content unless $response_product_set_config_admin->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config_admin->error 0 0 0
614 0 ▶ croak $response_product_set_config_admin->error if $response_product_set_config_admin->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config_admin->error 0 0 0
615 }
616  
617 0 ▶ if ($tech) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tech) 0 0 0
618 0 my $config_preset_tech = { label => "TECH_ACCOUNT", value => $tech };
619 0 my $response_product_set_config_tech = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_tech, noSignature => 0 );
620 0 ▶ my $config4 = $response_product_set_config_tech->content unless $response_product_set_config_tech->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config_tech->error 0 0 0
621 0 ▶ croak $response_product_set_config_tech->error if $response_product_set_config_tech->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config_tech->error 0 0 0
622 }
623  
624 0 return $item;
625 }
626  
627 0 ▶sub add_transfer_new {
Subroutine add_transfer_new: not called CC=20 SCAR=60.4
Pod undocumented
628  
629 0 my ( $self, $domain, %params ) = @_;
630  
631 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
632  
633 0 my $api = $self->{_api_wrapper};
634 0 my $cart_id = $self->id;
635  
636 0 ▶ croak "Missing domain parameter" unless $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain 0 0 0
637 0 ▶ croak "Missing auth_info" unless exists $params{auth_info};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"auth_info"} 0 0 0
638  
639 0 my $body = {};
640 0 ▶ $body->{duration} = $params{duration} if exists $params{duration};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"duration"} 0 0 0
641 0 ▶ $body->{offerId} = $params{offer_id} if exists $params{offer_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"offer_id"} 0 0 0
642 0 ▶ $body->{quantity} = $params{quantity} if exists $params{quantity};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params{"quantity"} 0 0 0
643 0 $body->{domain} = $domain;
644  
645 0 my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/domain", body => $body, noSignature => 0 );
646 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
647  
648 0 my $item_id = $response->content->{itemId};
649 0 my $item = Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} );
650  
651 0 ▶ return unless $item;
Branch: 1 branch
BranchTrueFalseTotal
unless $item 0 0 0
652  
653 0 my $auth_info = $params{auth_info};
654 0 my $owner = $params{owner_contact};
655 0 my $admin = $params{admin_account};
656 0 my $tech = $params{tech_account};
657  
658 0 my $config_preset = { label => "AUTH_INFO", value => $auth_info };
659 0 my $response_product_set_config = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset, noSignature => 0 );
660 0 ▶ my $config1 = $response_product_set_config->content unless $response_product_set_config->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config->error 0 0 0
661 0 ▶ croak $response_product_set_config->error if $response_product_set_config->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config->error 0 0 0
662  
663 0 ▶ if ($owner) {
Branch: 1 branch
BranchTrueFalseTotal
if ($owner) 0 0 0
664 0 my $config_preset_owner = { label => "OWNER_CONTACT", value => $owner };
665 0 my $response_product_set_config_owner = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_owner, noSignature => 0 );
666 0 ▶ my $config2 = $response_product_set_config_owner->content unless $response_product_set_config_owner->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config_owner->error 0 0 0
667 0 ▶ croak $response_product_set_config_owner->error if $response_product_set_config_owner->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config_owner->error 0 0 0
668 }
669  
670 0 ▶ if ($admin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($admin) 0 0 0
671 0 my $config_preset_admin = { label => "ADMIN_ACCOUNT", value => $admin };
672 0 my $response_product_set_config_admin = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_admin, noSignature => 0 );
673 0 ▶ my $config3 = $response_product_set_config_admin->content unless $response_product_set_config_admin->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config_admin->error 0 0 0
674 0 ▶ croak $response_product_set_config_admin->error if $response_product_set_config_admin->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config_admin->error 0 0 0
675 }
676  
677 0 ▶ if ($tech) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tech) 0 0 0
678 0 my $config_preset_tech = { label => "TECH_ACCOUNT", value => $tech };
679 0 my $response_product_set_config_tech = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_tech, noSignature => 0 );
680 0 ▶ my $config4 = $response_product_set_config_tech->content unless $response_product_set_config_tech->error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response_product_set_config_tech->error 0 0 0
681 0 ▶ croak $response_product_set_config_tech->error if $response_product_set_config_tech->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_product_set_config_tech->error 0 0 0
682 }
683  
684 0 return $item;
685 }
686  
687 =head2 info_checkout
688  
689 Returns checkout without generating an order.
690  
691 =over
692  
693 =item * Return: HASH
694  
695 =item * Synopsis: my $checkout = $cart->info_checkout;
696  
697 =back
698  
699 =cut
700  
701 0 ▶sub info_checkout {
Subroutine info_checkout: not called CC=3 SCAR=24.8
Pod documented
702  
703 0 my ($self) = @_;
704  
705 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
706  
707 0 my $api = $self->{_api_wrapper};
708 0 my $cart_id = $self->id;
709  
710 0 my $response = $api->rawCall( method => 'get', path => "/order/cart/$cart_id/checkout", noSignature => 0 );
711 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
712  
713 0 return $response->content;
714 }
715  
716 =head2 checkout
717  
718 Generates an order. Makes the cart invalid. Returns the order.
719  
720 =over
721  
722 =item * Return: L<Webservice::OVH::Me::Order>
723  
724 =item * Synopsis: my $order = $cart->checkout;
725  
726 =back
727  
728 =cut
729  
730 0 ▶sub checkout {
Subroutine checkout: not called CC=3 SCAR=24.8
Pod documented
731  
732 0 my ($self) = @_;
733  
734 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
735  
736 0 my $api = $self->{_api_wrapper};
737 0 my $cart_id = $self->id;
738  
739 0 my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/checkout", body => {}, noSignature => 0 );
740 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
741  
742 0 my $order_id = $response->content->{orderId};
743 0 my $order = Webservice::OVH::Me::Order->_new( wrapper => $api, id => $order_id, module => $self->{_module} );
744  
745 0 return $order;
746 }
747  
748 =head2 items
749  
750 Produces an Array of Item Objects.
751  
752 =over
753  
754 =item * Return: L<ARRAY>
755  
756 =item * Synopsis: my $items = $cart->items;
757  
758 =back
759  
760 =cut
761  
762 0 ▶sub items {
Subroutine items: not called CC=5 SCAR=34.0
Pod documented
763  
764 0 my ($self) = @_;
765  
766 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
767  
768 0 my $api = $self->{_api_wrapper};
769 0 my $cart_id = $self->id;
770 0 my $response = $api->rawCall( method => 'get', path => "/order/cart/$cart_id/item", noSignature => 0 );
771 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
772  
773 0 my $item_ids = $response->content;
774 0 my $items = [];
775  
776 0 foreach my $item_id (@$item_ids) {
777  
778 0 ▶ my $item = $self->{_items}{$item_id} = $self->{_items}{$item_id} || Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} );
Condition0%0/3
$self->{'_items'}{$item_id} || 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'_items'}{$item_id} || 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
$self->{'_items'}{$item_id} 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
Truth table0%0/3
A || B
A= $self->{'_items'}{$item_id}B= 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
ABresult
1X1
011
000
779 0 push @$items, $item;
780 }
781  
782 0 return $items;
783 }
784  
785 =head2 item
786  
787 Returns a single item by id
788  
789 =over
790  
791 =item * Parameter: $item_id - api id
792  
793 =item * Return: L<Webservice::OVH::Order::Cart::Item>
794  
795 =item * Synopsis: my $item = $ovh->order->cart->item(123456);
796  
797 =back
798  
799 =cut
800  
801 0 ▶sub item {
Subroutine item: not called CC=3 SCAR=24.8
Pod documented
802  
803 0 my ( $self, $item_id ) = @_;
804  
805 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
806  
807 0 my $api = $self->{_api_wrapper};
808 0 ▶ my $item = $self->{_items}{$item_id} = $self->{_items}{$item_id} || Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} );
Condition0%0/3
$self->{'_items'}{$item_id} || 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'_items'}{$item_id} || 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
$self->{'_items'}{$item_id} 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
Truth table0%0/3
A || B
A= $self->{'_items'}{$item_id}B= 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
ABresult
1X1
011
000
809 0 return $item;
810 }
811  
812 =head2 item
813  
814 Deletes all items from the cart.
815  
816 =over
817  
818 =item * Synopsis: $cart->clear;
819  
820 =back
821  
822 =cut
823  
824 0 ▶sub clear {
Subroutine clear: not called CC=3 SCAR=24.8
Pod documented
825  
826 0 my ($self) = @_;
827  
828 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
829  
830 0 my $items = $self->items;
831  
832 0 foreach my $item (@$items) {
833  
834 0 $item->delete;
835 }
836 }
837  
838 =head2 assign
839  
840 Assign a shopping cart to an loggedin client
841  
842 =over
843  
844 =item * Synopsis: $cart->assign;
845  
846 =back
847  
848 =cut
849  
850 0 ▶sub assign {
Subroutine assign: not called CC=3 SCAR=24.8
Pod documented
851  
852 0 my ($self) = @_;
853  
854 0 ▶ return unless $self->_is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_valid 0 0 0
855  
856 0 my $api = $self->{_api_wrapper};
857 0 my $cart_id = $self->id;
858 0 my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/assign", noSignature => 0 );
859 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
860 }
861  
862  
863  
864  
865  
866  
867 36 1;
868  
↑ Summary Webservice/OVH/Hosting/Web/Service.pm »