| 1 | package Webservice::OVH::Email::Domain::Domain::Task::Redirection; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use Carp qw{ carp croak }; | ||
| 6 | |||
| 7 | our $VERSION = 0.47; | ||
| 8 | |||
| 9 | sub _new_existing { | ||
| 10 | |||
| 11 | my ( $class, %params ) = @_; | ||
| 12 | |||
| 13 | die "Missing module" unless $params{module}; | ||
| 14 | die "Missing wrapper" unless $params{wrapper}; | ||
| 15 | die "Missing id" unless $params{id}; | ||
| 16 | die "Missing domain" unless $params{domain}; | ||
| 17 | |||
| 18 | my $module = $params{module}; | ||
| 19 | my $api_wrapper = $params{wrapper}; | ||
| 20 | my $id = $params{id}; | ||
| 21 | my $domain = $params{domain}; | ||
| 22 | my $domain_name = $domain->name; | ||
| 23 | |||
| 24 | my $response = $api_wrapper->rawCall( method => 'get', path => "/email/domain/$domain_name/task/redirection/$id", noSignature => 0 ); | ||
| 25 | carp $response->error if $response->error; | ||
| 26 | |||
| 27 | if ( !$response->error ) { | ||
| 28 | |||
| 29 | my $porperties = $response->content; | ||
| 30 | my $self = bless { _module => $module, _valid => 1, _wrapper => $api_wrapper, _id => $id, _properties => $porperties, _domain => $domain }, $class; | ||
| 31 | |||
| 32 | return $self; | ||
| 33 | } else { | ||
| 34 | |||
| 35 | return undef; | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | sub is_valid { | ||
| 40 | |||
| 41 | my ($self) = @_; | ||
| 42 | |||
| 43 | $self->properties; | ||
| 44 | |||
| 45 | return $self->{_valid},; | ||
| 46 | } | ||
| 47 | |||
| 48 | sub properties { | ||
| 49 | |||
| 50 | my ($self) = @_; | ||
| 51 | |||
| 52 | croak "Invalid" unless $self->{_valid}; | ||
| 53 | |||
| 54 | my $domain_name = $self->{_domain}->name; | ||
| 55 | my $id = $self->{_id}; | ||
| 56 | my $api_wrapper = $self->{_wrapper}; | ||
| 57 | |||
| 58 | my $response = $api_wrapper->rawCall( method => 'get', path => "/email/domain/$domain_name/task/redirection/$id", noSignature => 0 ); | ||
| 59 | carp $response->error if $response->error; | ||
| 60 | |||
| 61 | if ( !$response->error ) { | ||
| 62 | |||
| 63 | my $porperties = $response->content; | ||
| 64 | |||
| 65 | } else { | ||
| 66 | |||
| 67 | $self->{_valid} = 0; | ||
| 68 | } | ||
| 69 | |||
| 70 | } | ||
| 71 | |||
| 72 | sub account { | ||
| 73 | |||
| 74 | my ($self) = @_; | ||
| 75 | |||
| 76 | $self->properties unless $self->{_properties}; | ||
| 77 | return unless $self->{_valid}; | ||
| 78 | |||
| 79 | return $self->{_properties}{account}; | ||
| 80 | } | ||
| 81 | |||
| 82 | sub type { | ||
| 83 | |||
| 84 | my ($self) = @_; | ||
| 85 | |||
| 86 | $self->properties unless $self->{_properties}; | ||
| 87 | return unless $self->{_valid}; | ||
| 88 | |||
| 89 | return $self->{_properties}{type}; | ||
| 90 | } | ||
| 91 | |||
| 92 | sub id { | ||
| 93 | |||
| 94 | my ($self) = @_; | ||
| 95 | |||
| 96 | return $self->{_id}; | ||
| 97 | } | ||
| 98 | |||
| 99 | sub domain { | ||
| 100 | |||
| 101 | my ($self) = @_; | ||
| 102 | |||
| 103 | return $self->{_domain}; | ||
| 104 | } | ||
| 105 | |||
| 106 | sub date { | ||
| 107 | |||
| 108 | my ($self) = @_; | ||
| 109 | |||
| 110 | $self->properties unless $self->{_properties}; | ||
| 111 | return unless $self->{_valid}; | ||
| 112 | |||
| 113 | return $self->{_properties}{date}; | ||
| 114 | } | ||
| 115 | |||
| 116 | sub action { | ||
| 117 | |||
| 118 | my ($self) = @_; | ||
| 119 | |||
| 120 | $self->properties unless $self->{_properties}; | ||
| 121 | return unless $self->{_valid}; | ||
| 122 | |||
| 123 | return $self->{_properties}{action}; | ||
| 124 | } | ||
| 125 | |||
| 126 | 1; |