| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mslm::EmailVerify; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
28
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
107
|
|
|
6
|
1
|
|
|
1
|
|
8
|
use Mslm::Common qw($default_base_url $default_user_agent $default_api_key DEFAULT_TIMEOUT); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
134
|
|
|
7
|
1
|
|
|
1
|
|
8
|
use URI; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
717
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $sv_api_path = '/api/sv/v1'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
0
|
|
|
0
|
1
|
|
my ( $class, $api_key, %opts ) = @_; |
|
14
|
0
|
|
|
|
|
|
my $self = {}; |
|
15
|
0
|
|
0
|
|
|
|
my $timeout = $opts{timeout} || DEFAULT_TIMEOUT; |
|
16
|
0
|
|
0
|
|
|
|
my $user_agent = $opts{user_agent} || $default_user_agent; |
|
17
|
0
|
|
0
|
|
|
|
my $base_url = $opts{base_url} || $default_base_url; |
|
18
|
0
|
|
0
|
|
|
|
my $access_key = $api_key || $default_api_key; |
|
19
|
0
|
|
|
|
|
|
$self->{base_url} = URI->new($base_url); |
|
20
|
0
|
|
|
|
|
|
$self->{api_key} = $access_key; |
|
21
|
0
|
|
|
|
|
|
$self->{user_agent} = $user_agent; |
|
22
|
0
|
|
|
|
|
|
my $default_http_client = LWP::UserAgent->new; |
|
23
|
0
|
|
|
|
|
|
$default_http_client->ssl_opts( 'verify_hostname' => 0 ); |
|
24
|
0
|
|
|
|
|
|
$default_http_client->default_headers( |
|
25
|
|
|
|
|
|
|
HTTP::Headers->new( |
|
26
|
|
|
|
|
|
|
Accept => 'application/json' |
|
27
|
|
|
|
|
|
|
) |
|
28
|
|
|
|
|
|
|
); |
|
29
|
0
|
|
|
|
|
|
$default_http_client->agent($user_agent); |
|
30
|
0
|
|
|
|
|
|
$default_http_client->timeout($timeout); |
|
31
|
0
|
|
0
|
|
|
|
$self->{http_client} = $opts{http_client} || $default_http_client; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$self->{common_client} = Mslm::Common->new( |
|
34
|
|
|
|
|
|
|
http_client => $self->{http_client}, |
|
35
|
|
|
|
|
|
|
base_url => $self->{base_url}, |
|
36
|
|
|
|
|
|
|
user_agent => $self->{user_agent}, |
|
37
|
|
|
|
|
|
|
api_key => $self->{api_key} |
|
38
|
0
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
bless $self, $class; |
|
41
|
0
|
|
|
|
|
|
return $self; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub error_msg { |
|
45
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $self->{message}; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub single_verify { |
|
51
|
0
|
|
|
0
|
1
|
|
my ( $self, $email, %opts ) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Setting options just for this request |
|
54
|
0
|
|
|
|
|
|
my $client = $self->{common_client}; |
|
55
|
0
|
|
0
|
|
|
|
my $base_url = URI->new( $opts{base_url} ) || $self->{base_url}; |
|
56
|
0
|
|
0
|
|
|
|
my $user_agent = $opts{user_agent} || $self->{user_agent}; |
|
57
|
0
|
|
0
|
|
|
|
my $api_key = $opts{api_key} || $self->{api_key}; |
|
58
|
0
|
|
0
|
|
|
|
my $http_client = $opts{http_client} || $self->{http_client}; |
|
59
|
0
|
|
0
|
|
|
|
my $disable_url_encoding = $opts{disable_url_encoding} || '0'; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Prepare and send request |
|
62
|
0
|
|
|
|
|
|
my $qp = { email => $email }; |
|
63
|
0
|
|
|
|
|
|
my $reqUrl = $client->prepare_url( |
|
64
|
|
|
|
|
|
|
$sv_api_path, |
|
65
|
|
|
|
|
|
|
$qp, |
|
66
|
|
|
|
|
|
|
base_url => $base_url, |
|
67
|
|
|
|
|
|
|
api_key => $api_key, |
|
68
|
|
|
|
|
|
|
disable_url_encoding => $disable_url_encoding |
|
69
|
|
|
|
|
|
|
); |
|
70
|
0
|
|
|
|
|
|
my ( $response, $msg ) = |
|
71
|
|
|
|
|
|
|
$client->req_and_resp( $http_client, 'GET', $reqUrl, undef, |
|
72
|
|
|
|
|
|
|
user_agent => $user_agent ); |
|
73
|
0
|
|
|
|
|
|
$self->{message} = $msg; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
return defined $response ? $response : undef; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub set_base_url { |
|
79
|
0
|
|
|
0
|
1
|
|
my ( $self, $base_url_str ) = @_; |
|
80
|
0
|
|
|
|
|
|
my $base_url = URI->new($base_url_str); |
|
81
|
0
|
|
|
|
|
|
$self->{base_url} = $base_url; |
|
82
|
0
|
|
|
|
|
|
$self->{common_client}->set_base_url($base_url); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub set_http_client { |
|
86
|
0
|
|
|
0
|
1
|
|
my ( $self, $http_client ) = @_; |
|
87
|
0
|
|
|
|
|
|
$self->{http_client} = $http_client; |
|
88
|
0
|
|
|
|
|
|
$self->{common_client}->set_http_client($http_client); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub set_user_agent { |
|
92
|
0
|
|
|
0
|
1
|
|
my ( $self, $user_agent ) = @_; |
|
93
|
0
|
|
|
|
|
|
$self->{user_agent} = $user_agent; |
|
94
|
0
|
|
|
|
|
|
$self->{common_client}->set_user_agent($user_agent); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub set_api_key { |
|
98
|
0
|
|
|
0
|
1
|
|
my ( $self, $api_key ) = @_; |
|
99
|
0
|
|
|
|
|
|
$self->{api_key} = $api_key; |
|
100
|
0
|
|
|
|
|
|
$self->{common_client}->set_api_key($api_key); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
=pod |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 NAME |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Mslm::EmailVerify - Perl module for email verification using an API |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
use Mslm::EmailVerify; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $email_verifier = Mslm::EmailVerify->new($api_key); |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# Single email verification |
|
117
|
|
|
|
|
|
|
my $verification_result = $email_verifier->single_verify('example@example.com'); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Set base URL |
|
120
|
|
|
|
|
|
|
$email_verifier->set_base_url('https://example.com'); |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The Mslm::EmailVerify module provides methods to perform email verification using an API. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 METHODS |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 new |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Creates a new instance of Mslm::EmailVerify. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head3 Arguments |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over 4 |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * C<$api_key> (string) - The API key required for authentication. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * C<%opts> (hash) - Optional parameters. You can pass in the following opts: C, C, C, and C. These settings can also be done via the setter functions named: C, C, C, C. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 error_msg |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Returns a string containing the error message of the last operation, it returns an empty |
|
145
|
|
|
|
|
|
|
string if the last operation was successful |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 single_verify |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Verifies a single email address. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head3 Arguments |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=over 4 |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * C<$email> (string) - The email address to be verified. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * C<%opts> (hash) - Optional parameters. You can pass in the following opts: C, C, C, C, and C. These options will only work for the current request. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 set_base_url |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Sets the base URL for API requests. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head3 Arguments |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=over 4 |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * C<$base_url_str> (string) - The base URL to be set for API requests. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=back |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 set_http_client |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Sets the HTTP client for making requests. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head3 Arguments |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=over 4 |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * C<$http_client> (LWP::UserAgent) - The HTTP client to be set. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 set_user_agent |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Sets the user agent for API requests. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head3 Arguments |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=over 4 |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * C<$user_agent> (string) - The user agent string to be set. |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=back |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 set_api_key |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Sets the API key for authentication. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head3 Arguments |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=over 4 |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item * C<$api_key> (string) - The API key to be set. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=back |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 AUTHOR |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Mslm, C<< >> |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Copyright (c) 2022-now mslm. All rights reserved. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
# End of Mslm::EmailVerify |