line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LINE::Bot::Message::Narrowcast; |
2
|
3
|
|
|
3
|
|
282492
|
use strict; |
|
3
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
92
|
|
3
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
76
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
957
|
use LINE::Bot::API::Client; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
81
|
|
6
|
3
|
|
|
3
|
|
1446
|
use LINE::Bot::API::Response::NarrowcastStatus; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
115
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
3
|
|
|
|
|
1127
|
DEFAULT_MESSAGING_API_ENDPOINT => 'https://api.line.me/v2/bot/', |
10
|
3
|
|
|
3
|
|
20
|
}; |
|
3
|
|
|
|
|
7
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
3
|
|
|
3
|
0
|
3831
|
my ($class, %args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
27
|
my $client = LINE::Bot::API::Client->new(%args); |
16
|
|
|
|
|
|
|
bless { |
17
|
|
|
|
|
|
|
client => $client, |
18
|
|
|
|
|
|
|
channel_secret => $args{channel_secret}, |
19
|
|
|
|
|
|
|
channel_access_token => $args{channel_access_token}, |
20
|
3
|
|
50
|
|
|
180
|
messaging_api_endpoint => $args{messaging_api_endpoint} // DEFAULT_MESSAGING_API_ENDPOINT, |
21
|
|
|
|
|
|
|
}, $class; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub request { |
25
|
3
|
|
|
3
|
0
|
16
|
my ($self, $method, $path, @payload) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return $self->{client}->$method( |
28
|
3
|
|
|
|
|
29
|
$self->{messaging_api_endpoint} . $path, |
29
|
|
|
|
|
|
|
@payload, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub send_message { |
34
|
2
|
|
|
2
|
1
|
2150
|
my ($self, $messages, $recipient, $demographic, $limit, $options) = @_; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
6
|
my @headers = (); |
37
|
2
|
100
|
66
|
|
|
24
|
if ($options && defined($options->{'retry_key'})) { |
38
|
1
|
|
|
|
|
4
|
push @headers, 'X-Line-Retry-Key' => $options->{'retry_key'}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
25
|
my $res = $self->request( |
42
|
|
|
|
|
|
|
post => 'message/narrowcast', |
43
|
|
|
|
|
|
|
\@headers, |
44
|
|
|
|
|
|
|
+{ |
45
|
|
|
|
|
|
|
messages => $messages, |
46
|
|
|
|
|
|
|
recipient => $recipient, |
47
|
|
|
|
|
|
|
filter => { |
48
|
|
|
|
|
|
|
demographic => $demographic, |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
limit => $limit, |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
10
|
LINE::Bot::API::Response::Common->new(%{ $res }); |
|
2
|
|
|
|
|
18
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub get_narrowcast_message_status { |
58
|
1
|
|
|
1
|
1
|
2030
|
my ($self, $request_id) = @_; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
6
|
my $res = $self->request( |
61
|
|
|
|
|
|
|
get => "message/progress/narrowcast?requestId=${request_id}" |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
3
|
LINE::Bot::API::Response::NarrowcastStatus->new(%{ $res }); |
|
1
|
|
|
|
|
16
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
__END__ |