parent
2cd6d98aca
commit
bbe4fd1c14
|
@ -108,7 +108,11 @@ sub send_sms {
|
||||||
'hex-content=' . $options{message}
|
'hex-content=' . $options{message}
|
||||||
];
|
];
|
||||||
if (defined($options{from}) && $options{from} ne '') {
|
if (defined($options{from}) && $options{from} ne '') {
|
||||||
push @$get_param, 'from=' . $options{from}
|
push @$get_param, 'from=' . $options{from};
|
||||||
|
}
|
||||||
|
if (defined($options{dlr}) && $options{dlr} eq 'yes') {
|
||||||
|
push @$get_param, 'dlr=yes', 'dlr-url=' . $options{dlr_url},
|
||||||
|
'dlr-level=' . $options{dlr_level}, 'dlr-method=' . $options{dlr_method};
|
||||||
}
|
}
|
||||||
|
|
||||||
my $rv = 'Error sending sms';
|
my $rv = 'Error sending sms';
|
||||||
|
|
|
@ -26,6 +26,10 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Encode;
|
use Encode;
|
||||||
|
|
||||||
|
my $map_dlr_level = {
|
||||||
|
'sms-c' => 1, terminal => 2, both => 3
|
||||||
|
};
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
@ -35,13 +39,15 @@ sub new {
|
||||||
'from:s' => { name => 'from'},
|
'from:s' => { name => 'from'},
|
||||||
'to:s' => { name => 'to' },
|
'to:s' => { name => 'to' },
|
||||||
'message:s' => { name => 'message' },
|
'message:s' => { name => 'message' },
|
||||||
'coding:s' => { name => 'coding', default => 8 }
|
'coding:s' => { name => 'coding', default => 8 },
|
||||||
|
'dlr-url:s' => { name => 'dlr_url' },
|
||||||
|
'dlr-level:s' => { name => 'dlr_level' },
|
||||||
|
'dlr-method:s' => { name => 'dlr_method' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
@ -64,6 +70,26 @@ sub check_options {
|
||||||
$self->{output}->add_option_msg(short_msg => 'Please set --message option');
|
$self->{output}->add_option_msg(short_msg => 'Please set --message option');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{dlr_enabled} = 'no';
|
||||||
|
my $dlr_options = { dlr_url => 1, dlr_level => 1, dlr_method => 1 };
|
||||||
|
foreach (('dlr_url', 'dlr_level', 'dlr_method')) {
|
||||||
|
if (defined($self->{option_results}->{$_}) && $self->{option_results}->{$_} ne '') {
|
||||||
|
if (/level/ && !defined($map_dlr_level->{ $self->{option_results}->{$_} })) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'Wrong --dlr-level option');
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
} elsif (/method/ && $self->{option_results}->{$_} !~ /^GET|POST$/) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'Wrong --dlr-method option');
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
$self->{dlr_enabled} = 'yes';
|
||||||
|
delete $dlr_options->{$_};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scalar(keys %$dlr_options) =~ /1|2/) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'Please set ' . join(' ', (map { s/_/-/g; $_ } keys(%$dlr_options))) . ' option(s)');
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub encoding_message {
|
sub encoding_message {
|
||||||
|
@ -84,7 +110,11 @@ sub run {
|
||||||
to => $self->{option_results}->{to},
|
to => $self->{option_results}->{to},
|
||||||
from => $self->{option_results}->{from},
|
from => $self->{option_results}->{from},
|
||||||
message => $self->{option_results}->{message},
|
message => $self->{option_results}->{message},
|
||||||
coding => $self->{option_results}->{coding}
|
coding => $self->{option_results}->{coding},
|
||||||
|
dlr => $self->{dlr_enabled},
|
||||||
|
dlr_url => $self->{option_results}->{dlr_url},
|
||||||
|
dlr_level => $self->{dlr_enabled} eq 'yes' ? $map_dlr_level->{ $self->{option_results}->{dlr_level} } : undef,
|
||||||
|
dlr_method => $self->{option_results}->{dlr_method}
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($response =~ /Error/) {
|
if ($response =~ /Error/) {
|
||||||
|
@ -124,6 +154,18 @@ Specify the message to send.
|
||||||
|
|
||||||
Sets the Data Coding Scheme bits (Default: 8 (UCS2)).
|
Sets the Data Coding Scheme bits (Default: 8 (UCS2)).
|
||||||
|
|
||||||
|
=item B<--dlr-url>
|
||||||
|
|
||||||
|
Sets DLR-URL.
|
||||||
|
|
||||||
|
=item B<--dlr-level>
|
||||||
|
|
||||||
|
Sets DLR level (can be: 'sms-c', 'terminal', 'both').
|
||||||
|
|
||||||
|
=item B<--dlr-method>
|
||||||
|
|
||||||
|
Sets DLR method (can be: 'GET', 'POST').
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
Loading…
Reference in New Issue