line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Sendy::API;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
34686
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp ('croak');
|
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
55
|
|
6
|
1
|
|
|
1
|
|
998
|
use LWP::UserAgent;
|
|
1
|
|
|
|
|
63104
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
12
|
use URI;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
634
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.03';
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new {
|
12
|
0
|
|
|
0
|
1
|
|
my $class = shift;
|
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my %self = (
|
15
|
|
|
|
|
|
|
api_key => '',
|
16
|
|
|
|
|
|
|
url => '',
|
17
|
|
|
|
|
|
|
@_
|
18
|
|
|
|
|
|
|
);
|
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
0
|
|
|
|
return unless ( $self{api_key} && $self{url} );
|
21
|
0
|
|
|
|
|
|
return bless \%self, $class;
|
22
|
|
|
|
|
|
|
}
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub subscribe {
|
25
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
26
|
0
|
|
|
|
|
|
my %args = @_;
|
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
0
|
|
|
|
unless ( $args{list} && $args{email} ) {
|
29
|
0
|
|
|
|
|
|
croak
|
30
|
|
|
|
|
|
|
"subscribe(): usage error. 'list' and 'email' attributes are required";
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $url = URI->new_abs( 'subscribe', $self->{url} )->as_string;
|
34
|
0
|
|
|
|
|
|
$args{boolean} = "true";
|
35
|
0
|
|
|
|
|
|
return $self->post( $url, \%args );
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub unsubscribe {
|
39
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
40
|
0
|
|
|
|
|
|
my %args = @_;
|
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
0
|
|
|
|
unless ( $args{list} && $args{email} ) {
|
43
|
0
|
|
|
|
|
|
croak
|
44
|
|
|
|
|
|
|
"unsubscribe(): usage error. 'list' and 'email' attributes are required";
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $url = URI->new_abs( 'unsubscribe', $self->{url} )->as_string;
|
48
|
0
|
|
|
|
|
|
$args{boolean} = "true";
|
49
|
0
|
|
|
|
|
|
return $self->post( $url, \%args );
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub subscription_status {
|
53
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
54
|
0
|
|
|
|
|
|
my %args = @_;
|
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
0
|
|
|
|
unless ( $args{list} && $args{email} ) {
|
57
|
0
|
|
|
|
|
|
croak
|
58
|
|
|
|
|
|
|
"subscription_status(): usage error. 'list_id' and 'email' attributes are required";
|
59
|
|
|
|
|
|
|
}
|
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$args{api_key} = $self->{api_key};
|
62
|
0
|
|
|
|
|
|
$args{list_id} = $args{list};
|
63
|
0
|
|
|
|
|
|
delete $args{list};
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $url =
|
66
|
|
|
|
|
|
|
URI->new_abs( 'api/subscribers/subscription-status.php', $self->{url} );
|
67
|
0
|
|
|
|
|
|
return $self->post( $url, \%args );
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub active_subscriber_count {
|
71
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
72
|
0
|
|
|
|
|
|
my %args = @_;
|
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
unless ( $args{list} ) {
|
75
|
0
|
|
|
|
|
|
croak
|
76
|
|
|
|
|
|
|
"active_subscriber_count(): usage error. 'list' attribute is required";
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
$args{api_key} = $self->{api_key};
|
80
|
0
|
|
|
|
|
|
$args{list_id} = $args{list};
|
81
|
0
|
|
|
|
|
|
delete $args{list};
|
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $url = URI->new_abs( 'api/subscribers/active-subscriber-count.php',
|
84
|
|
|
|
|
|
|
$self->{url} );
|
85
|
0
|
|
|
|
|
|
return $self->post( $url, \%args );
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _ua {
|
89
|
0
|
|
|
0
|
|
|
my $self = shift;
|
90
|
0
|
0
|
|
|
|
|
return $self->{_UA} if $self->{_UA};
|
91
|
0
|
|
|
|
|
|
return $self->{_UA} = LWP::UserAgent->new;
|
92
|
|
|
|
|
|
|
}
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub post {
|
95
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
96
|
0
|
|
|
|
|
|
my ( $url, $params ) = @_;
|
97
|
|
|
|
|
|
|
|
98
|
0
|
0
|
0
|
|
|
|
unless ( ref($params) && ( ref($params) eq 'HASH' ) ) {
|
99
|
0
|
|
|
|
|
|
croak 'post(): usage error. $params must be a hashref';
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return $self->_ua->post(@_);
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1;
|
106
|
|
|
|
|
|
|
__END__
|