Send/CMTelecom.pm

filter: Statementstmt 94.1% 32 / 34 Branchbran 42.8% 6 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 82.7% 48 / 58 SCAR 21.5
CC
8
Cov
79%
send_sms
9.2
new
3.1
BEGIN
1.0
CRAP 8.6
« API/CMTelecom.pm ↑ Summary
1 package SMS::Send::CMTelecom;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use SMS::API::CMTelecom;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use base 'SMS::Send::Driver';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 $SMS::Send::CMTelecom::VERSION = '0.03';
12  
13 sub new {
14 1 ▶ my ($class, %args) = @_;
Subroutine new: called CC=3 SCAR=11.2
Pod documented
15 1 my $self = \%args;
16  
17 1 ▶ croak '_producttoken missing' if not exists $self->{_producttoken};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_producttoken"} 0 1 1
18  
19 $self->{_sms} = SMS::API::CMTelecom->new(
20 product_token => $self->{_producttoken},
21 1 );
22  
23 1 ▶ $self->{_verbose} = 0 unless exists $self->{_verbose};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_verbose"} 1 0 1
24  
25 1 return bless $self, $class;
26 }
27  
28 sub send_sms {
29 1 ▶ my ($self, %args) = @_;
Subroutine send_sms: called CC=6 SCAR=22.1
Pod documented
30  
31 # remove leading +
32 1 ( my $recipient = $args{to} ) =~ s/^\+//;
33  
34 my $response = $self->{_sms}->send(
35 message => $args{text},
36 recipients => $recipient,
37 exists $args{reference} ? (reference => $args{reference}) : (),
38 1 ▶ exists $args{_from} ? (sender => $args{_from}) : (),
Branch: 2 branches
BranchTrueFalseTotal
exists $args{'reference'} ? : 0 1 1
exists $args{'_from'} ? : 0 1 1
39 );
40  
41 1 ▶ if (defined $response) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $response) 0 1 1
42 0 ▶ warn "send_sms succeeded: ".$response->{messages}->[0]->{parts} if $args{_verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"_verbose"} 0 0 0
43 0 return 1;
44 }
45 1 ▶ warn "send_sms failed: ".$self->{_sms}->error_message if $args{_verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"_verbose"} 0 1 1
46 1 return 0;
47 }
48  
49 1 1;
50  
51 __END__
« API/CMTelecom.pm ↑ Summary