blib/lib/emailvalidation.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 38 CC 2 SCAR 11.5
CC
2
Cov
0%
info
6.0
new
2.0
BEGIN
2.0
CRAP 3.1
1 package Emailvalidation;
2  
3 use strict;
4 use warnings;
5  
6 use LWP::UserAgent;
7 use JSON;
8  
9 our $VERSION = '1.0';
10 our $BASE_URL = 'https://api.emailvalidation.io';
11  
12 sub new {
13 my ($class, %args) = @_;
14  
15 my $self = {};
16  
17 $self->{ua} = LWP::UserAgent->new;
18 $self->{ua}->ssl_opts('verify_hostname' => 0);
19 $self->{ua}->default_headers(HTTP::Headers->new(
20 Accept => 'application/json',
21 apikey => $args{apikey}
22 ));
23  
24 $self->{ua}->agent('Emailvalidation/Perl/$VERSION');
25  
26  
27 return bless $self, $class;
28 }
29  
30 sub info {
31  
32 my ($self, $email) = @_;
33  
34 my $url = $BASE_URL . '/v1/info?email=' . $email;
35 my $response = $self->{ua}->get($url);
36  
37  
38 if ($response->is_success) {
39  
40 my $data = $response->decoded_content;
41 return $data;
42 }
43 else {
44 die $response->decoded_content;
45 }
46 }
47  
48 1;