Webservice/OVH/Order/Hosting/Web.pm

filter: Statementstmt 23.9% 11 / 46 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod 100% 2 / 2 totaltotal 22.8% 16 / 70 CC 9 SCAR 26.5
CC
9
Cov
18%
free_email_info
20.0
activate_free_email
20.0
_new
12.0
CRAP 14.2
« Webservice/OVH/Email/Domain/Domain/Task/Mailinglist.pm ↑ Summary OVH/OvhApi/Answer.pm »
1 package Webservice::OVH::Order::Hosting::Web;
2  
3 =encoding utf-8
4  
5 =head1 NAME
6  
7 Webservice::OVH::Order::Hosting::Web
8  
9 =head1 SYNOPSIS
10  
11 use Webservice::OVH;
12
13 my $ovh = Webservice::OVH->new_from_json("credentials.json");
14
15 my $free_email_info = $ovh->order->hosting->web->free_email_info;
16  
17 =head1 DESCRIPTION
18  
19 Provides the possibility to activate the free hostig package.
20  
21 =head1 METHODS
22  
23 =cut
24  
25 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 36 ▶use Carp qw{ carp croak };
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 36 our $VERSION = 0.48;
30  
31 =head2 _new
32  
33 Internal Method to create the Web object.
34 This method is not ment to be called directly.
35  
36 =over
37  
38 =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object
39  
40 =item * Return: L<Webservice::OVH::Order::Hosting::Web>
41  
42 =item * Synopsis: Webservice::OVH::Order::Hosting::Web->_new($ovh_api_wrapper, $module);
43  
44 =back
45  
46 =cut
47  
48 0 ▶sub _new {
Subroutine _new: not called CC=3 SCAR=24.8
49  
50 0 my ( $class, %params ) = @_;
51  
52 0 ▶ die "Missing module" unless $params{module};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"module"} 0 0 0
53 0 ▶ die "Missing wrapper" unless $params{wrapper};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"wrapper"} 0 0 0
54  
55 0 my $module = $params{module};
56 0 my $api_wrapper = $params{wrapper};
57  
58 0 my $self = bless { _module => $module, _api_wrapper => $api_wrapper }, $class;
59  
60 0 return $self;
61 }
62  
63 =head2 free_email_info
64  
65 Gets information if free webhosting is available.
66  
67 =over
68  
69 =item * Parameter: $domain - target domain for free webhosting
70  
71 =item * Return: HASH
72  
73 =item * Synopsis: Webservice::OVH::Order::Hosting::Web->_new('mydomain.de');
74  
75 =back
76  
77 =cut
78  
79 0 ▶sub free_email_info {
Subroutine free_email_info: not called CC=4 SCAR=30.0
Pod documented
80  
81 0 my ( $self, $domain ) = @_;
82  
83 0 ▶ croak "Missing domain" unless $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain 0 0 0
84 0 my $offer = "START";
85  
86 0 my $filter = Webservice::OVH::Helper->construct_filter( "domain" => $domain, "offer" => $offer );
87 0 my $api = $self->{_api_wrapper};
88 0 my $response_duration = $api->rawCall( method => 'get', path => "/order/hosting/web/new$filter", noSignature => 0 );
89 0 ▶ croak $response_duration->error if $response_duration->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_duration->error 0 0 0
90 0 my $duration = $response_duration->content->[0];
91  
92 0 my $filter2 = Webservice::OVH::Helper->construct_filter( "domain" => $domain, "offer" => $offer );
93 0 my $response = $api->rawCall( method => 'get', path => sprintf( "/order/hosting/web/new/%s%s", $duration, $filter2 ), noSignature => 0 );
94 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
95  
96 0 return $response->content;
97 }
98  
99 =head2 activate_free_email
100  
101 Generates an order and pays the order for free webhosting.
102  
103 =over
104  
105 =item * Parameter: $domain - target domain for free webhosting, $params - zusätzliche Parameter beim hosting erlauben
106  
107 =item * Return: L<Webservice::Me::Order>
108  
109 =item * Synopsis: my $order = Webservice::OVH::Order::Hosting::Web->activate_free_email('mydomain.de');
110  
111 =back
112  
113 =cut
114  
115 0 ▶sub activate_free_email {
Subroutine activate_free_email: not called CC=4 SCAR=30.0
Pod documented
116  
117 0 my ( $self, $domain, $params ) = @_;
118  
119 0 my $module = $self->{_module};
120  
121 0 ▶ croak "Missing domain" unless $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless $domain 0 0 0
122 0 my $offer = 'START';
123 0 my $dns_zone = 'NO_CHANGE';
124  
125 0 my $filter = Webservice::OVH::Helper->construct_filter( "domain" => $domain, "offer" => $offer );
126 0 my $api = $self->{_api_wrapper};
127 0 my $response_duration = $api->rawCall( method => 'get', path => sprintf( "/order/hosting/web/new%s", $filter ), noSignature => 0 );
128 0 ▶ croak $response_duration->error if $response_duration->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response_duration->error 0 0 0
129 0 my $duration = $response_duration->content->[0];
130  
131 0 my $body = { domain => $domain, offer => 'START', dnsZone => $dns_zone, %$params };
132 0 my $response = $api->rawCall( method => 'post', path => "/order/hosting/web/new/$duration", body => $body, noSignature => 0 );
133 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
134  
135 0 my $order = $module->me->order( $response->content->{orderId} );
136  
137 0 $order->pay_with_registered_payment_mean('fidelityAccount');
138  
139 0 return $order;
140 }
141  
142 36 1;
« Webservice/OVH/Email/Domain/Domain/Task/Mailinglist.pm ↑ Summary OVH/OvhApi/Answer.pm »