| 1 | package Webservice::OVH::Email::Domain::Domain::Task::Mailinglist; | ||
| 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 $self = bless { _module => $module, _valid => 1, _wrapper => $api_wrapper, _id => $id, _properties => undef, _domain => $domain }, $class; | ||
| 25 | |||
| 26 | return $self; | ||
| 27 | } | ||
| 28 | |||
| 29 | sub is_valid { | ||
| 30 | |||
| 31 | my ($self) = @_; | ||
| 32 | |||
| 33 | $self->properties; | ||
| 34 | |||
| 35 | return $self->{_valid}; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub properties { | ||
| 39 | |||
| 40 | my ($self) = @_; | ||
| 41 | |||
| 42 | return unless $self->{_valid}; | ||
| 43 | |||
| 44 | my $domain_name = $self->{_domain}->name; | ||
| 45 | my $id = $self->{_id}; | ||
| 46 | my $api_wrapper = $self->{_wrapper}; | ||
| 47 | |||
| 48 | my $response = $api_wrapper->rawCall( method => 'get', path => "/email/domain/$domain_name/task/mailinglist/$id", noSignature => 0 ); | ||
| 49 | carp $response->error if $response->error; | ||
| 50 | |||
| 51 | if ( !$response->error ) { | ||
| 52 | |||
| 53 | my $properties = $response->content; | ||
| 54 | return $properties; | ||
| 55 | |||
| 56 | } else { | ||
| 57 | |||
| 58 | $self->{_valid} = 0; | ||
| 59 | } | ||
| 60 | |||
| 61 | } | ||
| 62 | |||
| 63 | sub account { | ||
| 64 | |||
| 65 | my ($self) = @_; | ||
| 66 | |||
| 67 | $self->properties unless $self->{_properties}; | ||
| 68 | return unless $self->{_valid}; | ||
| 69 | |||
| 70 | return $self->{_properties}{account}; | ||
| 71 | } | ||
| 72 | |||
| 73 | sub language { | ||
| 74 | |||
| 75 | my ($self) = @_; | ||
| 76 | |||
| 77 | $self->properties unless $self->{_properties}; | ||
| 78 | return unless $self->{_valid}; | ||
| 79 | |||
| 80 | return $self->{_properties}{language}; | ||
| 81 | } | ||
| 82 | |||
| 83 | sub id { | ||
| 84 | |||
| 85 | my ($self) = @_; | ||
| 86 | |||
| 87 | return $self->{_id}; | ||
| 88 | } | ||
| 89 | |||
| 90 | sub domain { | ||
| 91 | |||
| 92 | my ($self) = @_; | ||
| 93 | |||
| 94 | return $self->{_domain}; | ||
| 95 | } | ||
| 96 | |||
| 97 | sub date { | ||
| 98 | |||
| 99 | my ($self) = @_; | ||
| 100 | |||
| 101 | $self->properties unless $self->{_properties}; | ||
| 102 | return unless $self->{_valid}; | ||
| 103 | |||
| 104 | return $self->{_properties}{date}; | ||
| 105 | } | ||
| 106 | |||
| 107 | sub action { | ||
| 108 | |||
| 109 | my ($self) = @_; | ||
| 110 | |||
| 111 | $self->properties unless $self->{_properties}; | ||
| 112 | return unless $self->{_valid}; | ||
| 113 | |||
| 114 | return $self->{_properties}{action}; | ||
| 115 | } | ||
| 116 | |||
| 117 | 1; |