File Coverage

lib/API/DirectAdmin/Domain.pm
Criterion Covered Total %
statement 16 20 80.0
branch 2 6 33.3
condition n/a
subroutine 4 5 80.0
pod 0 2 0.0
total 22 33 66.6


line stmt bran cond sub pod time code
1             package API::DirectAdmin::Domain;
2              
3 1     1   1289 use Modern::Perl '2010';
  1         2  
  1         8  
4 1     1   138 use Data::Dumper;
  1         2  
  1         48  
5              
6 1     1   5 use base 'API::DirectAdmin::Component';
  1         1  
  1         344  
7              
8             our $VERSION = 0.05;
9              
10             # Return domains list
11             # INPUT
12             # connection data for USER, not admin
13             sub list {
14 0     0 0 0 my ($self ) = @_;
15              
16 0         0 my $responce = $self->directadmin->query(
17             command => 'CMD_API_SHOW_DOMAINS',
18             );
19            
20 0 0       0 return $responce->{list} if ref $responce eq 'HASH';
21 0         0 return [];
22             }
23              
24             # Add Domain to user account
25             # params: domain, php (ON|OFF), cgi (ON|OFF)
26             sub add {
27 2     2 0 3 my ($self, $params ) = @_;
28            
29 2         5 my %add_params = (
30             action => 'create',
31             );
32            
33 2         9 my %params = (%$params, %add_params);
34            
35             #warn 'params ' . Dumper(\%params) if $DEBUG;
36              
37 2         10 my $responce = $self->directadmin->query(
38             params => \%params,
39             command => 'CMD_API_DOMAIN',
40             method => 'POST',
41             allowed_fields =>
42             'action
43             domain
44             php
45             cgi',
46             );
47            
48 2 50       7 warn 'responce ' . Dumper(\$responce) if $self->{debug};
49              
50 2 50       6 warn "Creating domain: $responce->{text}, $responce->{details}" if $self->{debug};
51 2         8 return $responce;
52             }
53              
54             1;