NAME
SMS::Send::Retarus - SMS::Send driver for the Retarus SMS for Applications webservice
VERSION
version 0.001
SYNOPSIS
use SMS::Send;
use Try::Tiny;
my $sender = SMS::Send->new('Retarus',
_login => 'foo',
_password => 'bar',
);
try {
# $sent is always true because we throw exceptions on all failures
my $sent = $sender->send_sms(
to => '+43123123456789',
text => 'This is a test message',
# this becomes options in the REST call
_options => {
src => '+12345678901234567890' || 'CUSTOM_TEXT',
}
);
# if you still want to conform to the SMS::Send::Driver API for the
# case you change the driver
if ( $sent ) {
# $sent is a hashref containing everything the API returns
print "Message sent ok: " . $sent->{jobId} . "\n";
} else {
# this API doesn't allow to know the reason of the failure
# which is why this driver always throws exceptions as objects
print "Failed to send message\n";
}
}
catch {
# $_ is a SMS::Send::Retarus::Exception object that stringifies to the
# error message
print "Failed to send message: $_\n";
};
DESCRIPTION
This module currently uses the JSON REST API according to the Retarus documentation from the 23rd March 2016.
METHODS
send_sms
Is called by "send_sms" in SMS::Send and passes all arguments starting with an underscore to the request having the first underscore removed as shown in the SYNOPSIS above. The list of supported options can be found in the Retarus SMS for Applications documentation which sadly isn't publicly available.
Returns true if the message was successfully sent.
Throws a "SMS::Send::Retarus::Exception" object if any error like a timeout in the underlying connection occurred or the API didn't respond with a success http status code.
SMS::Send::Retarus::Exception
All exceptions thrown are SMS::Send::Retarus::Exception objects subclassed from Exception::Class. They stringify to the error message, which is also returned by the error and message methods. The other methods are response, which contains the API response if it was decodeable, and status which is the status code of the HTTP response.
AUTHOR
Alexander Hartmaier <abraxxa@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Alexander Hartmaier.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.