Message/Narrowcast.pm

filter: Statementstmt 100% 32 / 32 Branchbran 100% 2 / 2 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 9 / 9 Podpod 50.0% 2 / 4 totaltotal 89.0% 49 / 55 CC 4 SCAR 5.1
CC
4
Cov
95%
send_message
3.0
new
2.0
BEGIN
1.0
CRAP 1.7
« API/Response/AudienceGroupForImpressionRetargeting.pm ↑ Summary API/Response/AudienceGroupForUploadingUserId.pm »
1 package LINE::Bot::Message::Narrowcast;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use LINE::Bot::API::Client;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use LINE::Bot::API::Response::NarrowcastStatus;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 DEFAULT_MESSAGING_API_ENDPOINT => 'https://api.line.me/v2/bot/',
10 3 };
11  
12 3 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
13 3 my ($class, %args) = @_;
14  
15 3 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 ▶ messaging_api_endpoint => $args{messaging_api_endpoint} // DEFAULT_MESSAGING_API_ENDPOINT,
Condition50%1/2
$args{"messaging_api_endpoint"} // "https://api.line.me/v2/bot/"
l!l
03
MC/DC0%0/1
$args{"messaging_api_endpoint"} // "https://api.line.me/v2/bot/"
$args{"messaging_api_endpoint"}
Truth table50%1/2
A
A= $args{"messaging_api_endpoint"}
Aresult
11
00
21 }, $class;
22 }
23  
24 3 ▶sub request {
Subroutine request: called CC=1 SCAR=0.0
Pod undocumented
25 3 my ($self, $method, $path, @payload) = @_;
26  
27 return $self->{client}->$method(
28 3 $self->{messaging_api_endpoint} . $path,
29 @payload,
30 );
31 }
32  
33 2 ▶sub send_message {
Subroutine send_message: called CC=3 SCAR=11.0
Pod documented
34 2 my ($self, $messages, $recipient, $demographic, $limit, $options) = @_;
35  
36 2 my @headers = ();
37 2 ▶ if ($options && defined($options->{'retry_key'})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options and defined $options->{"retry_key"}) 1 1 2
Condition66%2/3
$options and defined $options->{"retry_key"}
!ll&&!rl&&r
101
MC/DC50%1/2
$options and defined $options->{"retry_key"}
$options defined $options->{"retry_key"}
Truth table66%2/3
A and B
A= $optionsB= defined $options->{"retry_key"}
ABresult
0X0
100
111
38 1 push @headers, 'X-Line-Retry-Key' => $options->{'retry_key'};
39 }
40  
41 2 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 LINE::Bot::API::Response::Common->new(%{ $res });
55 }
56  
57 1 ▶sub get_narrowcast_message_status {
Subroutine get_narrowcast_message_status: called CC=1 SCAR=0.0
Pod documented
58 1 my ($self, $request_id) = @_;
59  
60 1 my $res = $self->request(
61 get => "message/progress/narrowcast?requestId=${request_id}"
62 );
63  
64 1 LINE::Bot::API::Response::NarrowcastStatus->new(%{ $res });
65 }
66  
67 3 1;
68 __END__
« API/Response/AudienceGroupForImpressionRetargeting.pm ↑ Summary API/Response/AudienceGroupForUploadingUserId.pm »