« lib/Webservice/OVH/Email/Domain/Domain/Task/Redirection.pm
↑ Summary
lib/Webservice/OVH/Me/Order.pm »
| 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 | use strict; | ||
| 26 | use warnings; | ||
| 27 | use Carp qw{ carp croak }; | ||
| 28 | |||
| 29 | our $VERSION = 0.47; | ||
| 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 | sub _new { | ||
| 49 | |||
| 50 | my ( $class, %params ) = @_; | ||
| 51 | |||
| 52 | die "Missing module" unless $params{module}; | ||
| 53 | die "Missing wrapper" unless $params{wrapper}; | ||
| 54 | |||
| 55 | my $module = $params{module}; | ||
| 56 | my $api_wrapper = $params{wrapper}; | ||
| 57 | |||
| 58 | my $self = bless { _module => $module, _api_wrapper => $api_wrapper}, $class; | ||
| 59 | |||
| 60 | 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 | sub available_services { | ||
| 78 | |||
| 79 | my ($self) = @_; | ||
| 80 | |||
| 81 | my $api = $self->{_api_wrapper}; | ||
| 82 | my $response = $api->rawCall( method => 'get', path => "/order/email/domain", noSignature => 0 ); | ||
| 83 | croak $response->error if $response->error; | ||
| 84 | |||
| 85 | 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 | sub allowed_durations { | ||
| 106 | |||
| 107 | my ($self, $domain, $offer) = @_; | ||
| 108 | |||
| 109 | croak "Missing offer" unless $offer; | ||
| 110 | croak "Missing domain" unless $domain; | ||
| 111 | |||
| 112 | my $filter = Webservice::OVH::Helper->construct_filter( "domain" => $domain, "offer" => $offer ); | ||
| 113 | |||
| 114 | my $api = $self->{_api_wrapper}; | ||
| 115 | my $response = $api->rawCall( method => 'get', path => "/order/email/domain/new$filter", noSignature => 0 ); | ||
| 116 | croak $response->error if $response->error; | ||
| 117 | |||
| 118 | 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 | sub info { | ||
| 139 | |||
| 140 | my ($self, $domain, $offer, $duration) = @_; | ||
| 141 | |||
| 142 | croak "Missing offer" unless $offer; | ||
| 143 | croak "Missing duration" unless $duration; | ||
| 144 | croak "Missing domain" unless $domain; | ||
| 145 | |||
| 146 | my $filter = Webservice::OVH::Helper->construct_filter( "domain" => $domain, "offer" => $offer ); | ||
| 147 | |||
| 148 | my $api = $self->{_api_wrapper}; | ||
| 149 | my $response = $api->rawCall( method => 'get', path => sprintf("/order/email/domain/new/%s%s", $duration, $filter), noSignature => 0 ); | ||
| 150 | croak $response->error if $response->error; | ||
| 151 | |||
| 152 | 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 | sub new { | ||
| 173 | |||
| 174 | my ($self, $domain, $offer, $duration) = @_; | ||
| 175 | |||
| 176 | croak "Missing offer" unless $offer; | ||
| 177 | croak "Missing duration" unless $duration; | ||
| 178 | croak "Missing domain" unless $domain; | ||
| 179 | |||
| 180 | my $api = $self->{_api_wrapper}; | ||
| 181 | my $module = $self->{_module}; | ||
| 182 | my $body = { offer => $offer, domain => $domain }; | ||
| 183 | my $response = $api->rawCall( method => 'post', path => "/order/email/domain/new/$duration", body => $body, noSignature => 0 ); | ||
| 184 | croak $response->error if $response->error; | ||
| 185 | |||
| 186 | my $order = $module->me->order($response->content->{orderId}); | ||
| 187 | |||
| 188 | return $order; | ||
| 189 | } | ||
| 190 | |||
| 191 | |||
| 192 | 1; |