| 1 | package Webservice::OVH::Order::Email::Domain; | ||||||||||
| 2 | |||||||||||
| 3 | =encoding utf-8 | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Webservice::OVH::Order::Email::Domain | ||||||||||
| 8 | |||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||
| 10 | |||||||||||
| 11 | use Webservice::OVH; | ||||||||||
| 12 | |||||||||||
| 13 | my $ovh = Webservice::OVH->new_from_json("credentials.json"); | ||||||||||
| 14 | |||||||||||
| 15 | my $available_services = $ovh->order->email->domain->available_services; | ||||||||||
| 16 | |||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||
| 18 | |||||||||||
| 19 | Provides the possibility to order MX packaged. The api methods are deprecated, but no alternative is give at the moment. | ||||||||||
| 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 Domain 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::Email::Domain> | ||||||||||
| 41 | |||||||||||
| 42 | =item * Synopsis: Webservice::OVH::Order::Email::Domain->_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
| |||||||||||
| 53 | 0 | ▶ | die "Missing wrapper" unless $params{wrapper}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 _new | ||||||||||
| 64 | |||||||||||
| 65 | Returns an array of available services. | ||||||||||
| 66 | |||||||||||
| 67 | =over | ||||||||||
| 68 | |||||||||||
| 69 | =item * Return: L<ARRAY> | ||||||||||
| 70 | |||||||||||
| 71 | =item * Synopsis: Webservice::OVH::Order::Email::Domain->_new($ovh_api_wrapper, $module); | ||||||||||
| 72 | |||||||||||
| 73 | =back | ||||||||||
| 74 | |||||||||||
| 75 | =cut | ||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub available_services { | ||||||||
|
Subroutine
available_services: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 78 | |||||||||||
| 79 | 0 | my ($self) = @_; | |||||||||
| 80 | |||||||||||
| 81 | 0 | my $api = $self->{_api_wrapper}; | |||||||||
| 82 | 0 | my $response = $api->rawCall( method => 'get', path => "/order/email/domain", noSignature => 0 ); | |||||||||
| 83 | 0 | ▶ | croak $response->error if $response->error; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | |||||||||||
| 85 | 0 | return $response->content; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | =head2 allowed_durations | ||||||||||
| 89 | |||||||||||
| 90 | Returns an array of allowed durations. | ||||||||||
| 91 | DEPRECATED | ||||||||||
| 92 | |||||||||||
| 93 | =over | ||||||||||
| 94 | |||||||||||
| 95 | =item * Parameter: $domain - target domain for MX package, $offer - MX offer | ||||||||||
| 96 | |||||||||||
| 97 | =item * Return: L<ARRAY> | ||||||||||
| 98 | |||||||||||
| 99 | =item * Synopsis: $ovh->order->email->domain->allowed_durations('mydomain.de', '100'); | ||||||||||
| 100 | |||||||||||
| 101 | =back | ||||||||||
| 102 | |||||||||||
| 103 | =cut | ||||||||||
| 104 | |||||||||||
| 105 | 0 | ▶ | sub allowed_durations { | ||||||||
|
Subroutine
allowed_durations: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 106 | |||||||||||
| 107 | 0 | my ($self, $domain, $offer) = @_; | |||||||||
| 108 | |||||||||||
| 109 | 0 | ▶ | croak "Missing offer" unless $offer; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 110 | 0 | ▶ | croak "Missing domain" unless $domain; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 111 | |||||||||||
| 112 | 0 | my $filter = Webservice::OVH::Helper->construct_filter( "domain" => $domain, "offer" => $offer ); | |||||||||
| 113 | |||||||||||
| 114 | 0 | my $api = $self->{_api_wrapper}; | |||||||||
| 115 | 0 | my $response = $api->rawCall( method => 'get', path => "/order/email/domain/new$filter", noSignature => 0 ); | |||||||||
| 116 | 0 | ▶ | croak $response->error if $response->error; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 117 | |||||||||||
| 118 | 0 | return $response->content; | |||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | =head2 allowed_durations | ||||||||||
| 122 | |||||||||||
| 123 | Returns information for a desired MX package. | ||||||||||
| 124 | DEPRECATED | ||||||||||
| 125 | |||||||||||
| 126 | =over | ||||||||||
| 127 | |||||||||||
| 128 | =item * Parameter: $domain - target domain for MX package, $offer - MX offer, $duration - allowed duration | ||||||||||
| 129 | |||||||||||
| 130 | =item * Return: L<ARRAY> | ||||||||||
| 131 | |||||||||||
| 132 | =item * Synopsis: $ovh->order->email->domain->info('mydomain.de', '100', $allowed_durations->[0]); | ||||||||||
| 133 | |||||||||||
| 134 | =back | ||||||||||
| 135 | |||||||||||
| 136 | =cut | ||||||||||
| 137 | |||||||||||
| 138 | 0 | ▶ | sub info { | ||||||||
|
Subroutine
info: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 139 | |||||||||||
| 140 | 0 | my ($self, $domain, $offer, $duration) = @_; | |||||||||
| 141 | |||||||||||
| 142 | 0 | ▶ | croak "Missing offer" unless $offer; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 143 | 0 | ▶ | croak "Missing duration" unless $duration; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 144 | 0 | ▶ | croak "Missing domain" unless $domain; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 145 | |||||||||||
| 146 | 0 | my $filter = Webservice::OVH::Helper->construct_filter( "domain" => $domain, "offer" => $offer ); | |||||||||
| 147 | |||||||||||
| 148 | 0 | my $api = $self->{_api_wrapper}; | |||||||||
| 149 | 0 | my $response = $api->rawCall( method => 'get', path => sprintf("/order/email/domain/new/%s%s", $duration, $filter), noSignature => 0 ); | |||||||||
| 150 | 0 | ▶ | croak $response->error if $response->error; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 151 | |||||||||||
| 152 | 0 | return $response->content; | |||||||||
| 153 | } | ||||||||||
| 154 | |||||||||||
| 155 | =head2 new | ||||||||||
| 156 | |||||||||||
| 157 | Generates an order for the desired MX package. | ||||||||||
| 158 | DEPRECATED | ||||||||||
| 159 | |||||||||||
| 160 | =over | ||||||||||
| 161 | |||||||||||
| 162 | =item * Parameter: $domain - target domain for MX package, $offer - MX offer, $duration - allowed duration | ||||||||||
| 163 | |||||||||||
| 164 | =item * Return: L<ARRAY> | ||||||||||
| 165 | |||||||||||
| 166 | =item * Synopsis: $ovh->order->email->domain->new('mydomain.de', '100', $allowed_durations->[0]); | ||||||||||
| 167 | |||||||||||
| 168 | =back | ||||||||||
| 169 | |||||||||||
| 170 | =cut | ||||||||||
| 171 | |||||||||||
| 172 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 173 | |||||||||||
| 174 | 0 | my ($self, $domain, $offer, $duration) = @_; | |||||||||
| 175 | |||||||||||
| 176 | 0 | ▶ | croak "Missing offer" unless $offer; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 177 | 0 | ▶ | croak "Missing duration" unless $duration; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 178 | 0 | ▶ | croak "Missing domain" unless $domain; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 179 | |||||||||||
| 180 | 0 | my $api = $self->{_api_wrapper}; | |||||||||
| 181 | 0 | my $module = $self->{_module}; | |||||||||
| 182 | 0 | my $body = { offer => $offer, domain => $domain }; | |||||||||
| 183 | 0 | my $response = $api->rawCall( method => 'post', path => "/order/email/domain/new/$duration", body => $body, noSignature => 0 ); | |||||||||
| 184 | 0 | ▶ | croak $response->error if $response->error; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 185 | |||||||||||
| 186 | 0 | my $order = $module->me->order($response->content->{orderId}); | |||||||||
| 187 | |||||||||||
| 188 | 0 | return $order; | |||||||||
| 189 | } | ||||||||||
| 190 | |||||||||||
| 191 | |||||||||||
| 192 | 36 | 1; | |||||||||