| 1 | package Webservice::OVH::Order::Domain::Zone; | ||
| 2 | |||
| 3 | =encoding utf-8 | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Webservice::OVH::Order::Domain::Zone | ||
| 8 | |||
| 9 | =head1 SYNOPSIS | ||
| 10 | |||
| 11 | use Webservice::OVH; | ||
| 12 | |||
| 13 | my $ovh = Webservice::OVH->new_from_json("credentials.json"); | ||
| 14 | |||
| 15 | my $existing_zones = $ovh->order->domain->zone->existing; | ||
| 16 | |||
| 17 | =head1 DESCRIPTION | ||
| 18 | |||
| 19 | Provides the possibility to order domain zones only. | ||
| 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 | use Webservice::OVH::Me::Order; | ||
| 32 | |||
| 33 | =head2 _new | ||
| 34 | |||
| 35 | Internal Method to create the Zone object. | ||
| 36 | This method is not ment to be called directly. | ||
| 37 | |||
| 38 | =over | ||
| 39 | |||
| 40 | =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object | ||
| 41 | |||
| 42 | =item * Return: L<Webservice::OVH::Order::Domain::Zone> | ||
| 43 | |||
| 44 | =item * Synopsis: Webservice::OVH::Order::Domain::Zone->_new($ovh_api_wrapper, $module); | ||
| 45 | |||
| 46 | =back | ||
| 47 | |||
| 48 | =cut | ||
| 49 | |||
| 50 | sub _new { | ||
| 51 | |||
| 52 | my ( $class, %params ) = @_; | ||
| 53 | |||
| 54 | die "Missing module" unless $params{module}; | ||
| 55 | die "Missing wrapper" unless $params{wrapper}; | ||
| 56 | |||
| 57 | my $module = $params{module}; | ||
| 58 | my $api_wrapper = $params{wrapper}; | ||
| 59 | |||
| 60 | my $self = bless { _module => $module, _api_wrapper => $api_wrapper }, $class; | ||
| 61 | |||
| 62 | return $self; | ||
| 63 | } | ||
| 64 | |||
| 65 | =head2 _new | ||
| 66 | |||
| 67 | Returns an array with all available zones connected to the active account. | ||
| 68 | |||
| 69 | =over | ||
| 70 | |||
| 71 | =item * Return: L<ARRAY> | ||
| 72 | |||
| 73 | =item * Synopsis: my $existing_zones = $ovh->order->domain->zone->existing; | ||
| 74 | |||
| 75 | =back | ||
| 76 | |||
| 77 | =cut | ||
| 78 | |||
| 79 | sub existing { | ||
| 80 | |||
| 81 | my ($self) = @_; | ||
| 82 | |||
| 83 | my $api = $self->{_api_wrapper}; | ||
| 84 | |||
| 85 | my $response = $api->rawCall( method => 'get', path => "/order/domain/zone", noSignature => 0 ); | ||
| 86 | croak $response->error if $response->error; | ||
| 87 | |||
| 88 | return $response->content; | ||
| 89 | } | ||
| 90 | |||
| 91 | =head2 _new | ||
| 92 | |||
| 93 | Gets information about a requested zone order. | ||
| 94 | |||
| 95 | =over | ||
| 96 | |||
| 97 | =item * Return: HASH | ||
| 98 | |||
| 99 | =item * Synopsis: my $existing_zones = $ovh->order->domain->zone->existing; | ||
| 100 | |||
| 101 | =back | ||
| 102 | |||
| 103 | =cut | ||
| 104 | |||
| 105 | sub info_order { | ||
| 106 | |||
| 107 | my ($self) = @_; | ||
| 108 | |||
| 109 | my $api = $self->{_api_wrapper}; | ||
| 110 | |||
| 111 | my $response = $api->rawCall( method => 'get', path => "/order/domain/zone/new", noSignature => 0 ); | ||
| 112 | croak $response->error if $response->error; | ||
| 113 | |||
| 114 | return $response->content; | ||
| 115 | } | ||
| 116 | |||
| 117 | =head2 _new | ||
| 118 | |||
| 119 | Gets information about a requested zone order. | ||
| 120 | |||
| 121 | =over | ||
| 122 | |||
| 123 | =item * Parameter: $zone_name - desired zone, $minimized - only mandatory record entries | ||
| 124 | |||
| 125 | =item * Return: L<Webservice::OVH::Me::Order> | ||
| 126 | |||
| 127 | =item * Synopsis: my $oder = $ovh->order->domain->zone->order('mydomain.de', 'true'); | ||
| 128 | |||
| 129 | =back | ||
| 130 | |||
| 131 | =cut | ||
| 132 | |||
| 133 | sub order { | ||
| 134 | |||
| 135 | my ( $self, $zone_name, $minimized ) = @_; | ||
| 136 | |||
| 137 | $minimized ||= 'false'; | ||
| 138 | |||
| 139 | my $api = $self->{_api_wrapper}; | ||
| 140 | my $module = $self->{_module}; | ||
| 141 | |||
| 142 | my $response = $api->rawCall( method => 'post', path => "/order/domain/zone/new", body => { zoneName => $zone_name, minimized => $minimized }, noSignature => 0 ); | ||
| 143 | croak $response->error if $response->error; | ||
| 144 | |||
| 145 | my $order = $module->me->order( $response->content->{orderId} ); | ||
| 146 | |||
| 147 | return $order; | ||
| 148 | } | ||
| 149 | |||
| 150 | =head2 _new | ||
| 151 | |||
| 152 | Gets available options for the desired zone order. | ||
| 153 | |||
| 154 | =over | ||
| 155 | |||
| 156 | =item * Parameter: $zone_name - desired zone | ||
| 157 | |||
| 158 | =item * Return: HASH | ||
| 159 | |||
| 160 | =item * Synopsis: my $options = $ovh->order->domain->zone->options('mydomain.de'); | ||
| 161 | |||
| 162 | =back | ||
| 163 | |||
| 164 | =cut | ||
| 165 | |||
| 166 | sub options { | ||
| 167 | |||
| 168 | my ( $self, $zone_name ) = @_; | ||
| 169 | |||
| 170 | my $api = $self->{_api_wrapper}; | ||
| 171 | |||
| 172 | my $response = $api->rawCall( method => 'get', path => "/order/domain/zone/$zone_name", noSignature => 0 ); | ||
| 173 | croak $response->error if $response->error; | ||
| 174 | |||
| 175 | return $response->content; | ||
| 176 | } | ||
| 177 | |||
| 178 | 1; |