File Coverage

blib/lib/WebService/ThrowAwayMail.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             package WebService::ThrowAwayMail;
2              
3             our $VERSION = '0.05';
4              
5 2     2   49021 use Moo;
  2         25180  
  2         13  
6 2     2   3348 use MooX::LazierAttributes qw/rw lzy/;
  2         5798  
  2         8  
7 2     2   1095 use MooX::ValidateSubs;
  2         886  
  2         10  
8 2     2   50308 use Types::Standard qw/Object Str HashRef/;
  2         205412  
  2         30  
9            
10 2     2   3304 use HTTP::Tiny;
  2         102157  
  2         101  
11 2     2   17 use Carp qw/croak/;
  2         3  
  2         464  
12              
13             attributes (
14             tiny => [rw, Object, {lzy, default => sub {HTTP::Tiny->new}}],
15             base_url => [Str, {lzy, default => 'https://throwawaymail.org/getalias/text'}],
16             );
17              
18             validate_subs (
19             get_alias => { params => [], returns => [[Str]] },
20             get => { params => [ [Str, 'base_url'] ], returns => [[HashRef]] },
21             );
22              
23             sub get {
24             my $response = $_[0]->tiny->get($_[1]);
25             $response->{success} and return $response;
26             croak sprintf "something went terribly wrong status - %s - reason - %s",
27             $response->{status}, $response->{reason};
28             }
29              
30             sub get_alias {
31             return $_[0]->get->{content};
32             }
33              
34             1;
35              
36             __END__