| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 39 | ); | ||||||||||||||
| 40 | |||||||||||||||
| 41 | 1 | ▶ | if (defined $response) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 42 | 0 | ▶ | warn "send_sms succeeded: ".$response->{messages}->[0]->{parts} if $args{_verbose}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | 0 | return 1; | |||||||||||||
| 44 | } | ||||||||||||||
| 45 | 1 | ▶ | warn "send_sms failed: ".$self->{_sms}->error_message if $args{_verbose}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | 1 | return 0; | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | |||||||||||||||
| 49 | 1 | 1; | |||||||||||||
| 50 | |||||||||||||||
| 51 | __END__ | ||||||||||||||