File Coverage

blib/lib/WWW/DNSMadeEasy/Domain/Record.pm
Criterion Covered Total %
statement 14 29 48.2
branch 0 2 0.0
condition n/a
subroutine 8 19 42.1
pod 13 15 86.6
total 35 65 53.8


line stmt bran cond sub pod time code
1             package WWW::DNSMadeEasy::Domain::Record;
2             our $VERSION = '0.100';
3             our $AUTHORITY = 'cpan:GETTY';
4             # ABSTRACT: A domain record in the DNSMadeEasy API
5              
6 8     8   63 use Moo;
  8         30  
  8         50  
7 8     8   2991 use Carp;
  8         15  
  8         4084  
8              
9             has id => (
10             is => 'ro',
11             required => 1,
12             );
13              
14             has domain => (
15             is => 'ro',
16             required => 1,
17             );
18              
19             has response_index => (
20             is => 'rw',
21             predicate => 'has_response_index',
22             );
23              
24             has as_hashref => (is => 'rw', builder => 1, lazy => 1);
25             has response => (is => 'rw', builder => 1, lazy => 1);
26              
27 0     0   0 sub _build_as_hashref { shift->response->as_hashref }
28 0     0   0 sub _build_response { $_[0]->domain->dme->request(GET => $_[0]->path) }
29              
30 1     1 1 349 sub ttl { shift->as_hashref->{ttl} }
31 0     0 1 0 sub gtd_location { shift->as_hashref->{gtdLocation} }
32 1     1 1 983 sub name { shift->as_hashref->{name} }
33 1     1 1 273 sub data { shift->as_hashref->{data} }
34 1     1 1 278 sub type { shift->as_hashref->{type} }
35 0     0 1 0 sub password { shift->as_hashref->{password} }
36 0     0 1 0 sub description { shift->as_hashref->{description} }
37 0     0 1 0 sub keywords { shift->as_hashref->{keywords} }
38 0     0 1 0 sub title { shift->as_hashref->{title} }
39 0     0 1 0 sub redirect_type { shift->as_hashref->{redirectType} }
40 0     0 1 0 sub hard_link { shift->as_hashref->{hardLink} }
41              
42             sub path {
43 1     1 0 1 my ( $self ) = @_;
44 1         5 $self->domain->path_records.'/'.$self->id;
45             }
46              
47             sub delete {
48 1     1 1 727 my ( $self ) = @_;
49 1         7 $self->domain->dme->request('DELETE',$self->path);
50             }
51              
52 0     0 0   sub put { shift->update(@_) }
53              
54             sub update {
55 0     0 1   my $self = shift;
56 0 0         my %data = ( @_ % 2 == 1 ) ? %{ $_[0] } : @_;
  0            
57 0           my $put_response = $self->domain->dme->request('PUT', $self->path, \%data);
58             return WWW::DNSMadeEasy::Domain::Record->new({
59             domain => $self->domain,
60             id => $put_response->data->{id},
61 0           response => $put_response,
62             });
63             }
64              
65             1;
66              
67             __END__
68              
69             =pod
70              
71             =encoding UTF-8
72              
73             =head1 NAME
74              
75             WWW::DNSMadeEasy::Domain::Record - A domain record in the DNSMadeEasy API
76              
77             =head1 VERSION
78              
79             version 0.100
80              
81             =head1 ATTRIBUTES
82              
83             =head2 id
84              
85             =head2 domain
86              
87             =head2 obj
88              
89             =head1 METHODS
90              
91             =head2 $obj->delete
92              
93             =head2 $obj->ttl
94              
95             =head2 $obj->gtd_location
96              
97             =head2 $obj->name
98              
99             =head2 $obj->data
100              
101             =head2 $obj->type
102              
103             =head2 $obj->password
104              
105             =head2 $obj->description
106              
107             =head2 $obj->keywords
108              
109             =head2 $obj->title
110              
111             =head2 $obj->redirect_type
112              
113             =head2 $obj->hard_link
114              
115             =head2 $obj->update
116              
117             $record->put( {
118             name => $name,
119             type => $type,
120             data => $data,
121             gtdLocation => $gtdLocation,
122             ttl => $ttl
123             } );
124              
125             to update the record
126              
127             =head1 ATTRIBUTES
128              
129             =head1 SUPPORT
130              
131             IRC
132              
133             Join #duckduckgo on irc.freenode.net and highlight Getty or /msg me.
134              
135             Repository
136              
137             http://github.com/Getty/p5-www-dnsmadeeasy
138             Pull request and additional contributors are welcome
139              
140             Issue Tracker
141              
142             http://github.com/Getty/p5-www-dnsmadeeasy/issues
143              
144             =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
145              
146             =head1 SUPPORT
147              
148             =head2 Source Code
149              
150             The code is open to the world, and available for you to hack on. Please feel free to browse it and play
151             with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
152             from your repository :)
153              
154             L<https://github.com/Getty/p5-www-dnsmadeeasy>
155              
156             git clone https://github.com/Getty/p5-www-dnsmadeeasy.git
157              
158             =head1 AUTHOR
159              
160             Torsten Raudssus <torsten@raudssus.de>
161              
162             =head1 COPYRIGHT AND LICENSE
163              
164             This software is copyright (c) 2012 by L<Torsten Raudssus|https://raudssus.de/>.
165              
166             This is free software; you can redistribute it and/or modify it under
167             the same terms as the Perl 5 programming language system itself.
168              
169             =cut