File Coverage

blib/lib/SMS/Send/AQL.pm
Criterion Covered Total %
statement 12 24 50.0
branch 0 4 0.0
condition 0 5 0.0
subroutine 4 6 66.6
pod 2 2 100.0
total 18 41 43.9


line stmt bran cond sub pod time code
1             package SMS::Send::AQL;
2              
3             # $Id: AQL.pm 281 2008-03-09 01:54:50Z davidp $
4              
5 1     1   40744 use strict;
  1         2  
  1         117  
6 1     1   7 use warnings;
  1         2  
  1         34  
7 1     1   1040 use SMS::AQL;
  1         79828  
  1         55  
8             our $VERSION = '0.04';
9 1     1   13 use base 'SMS::Send::Driver';
  1         1  
  1         1127  
10              
11              
12              
13              
14             =head1 NAME
15              
16             SMS::Send::AQL - SMS::Send driver to send messages via AQL (www.aql.com)
17              
18             =head1 SYNOPSIS
19              
20             use SMS::Send;
21            
22             # Create a sender
23             my $sender = SMS::Send->new('AQL',
24             _login => 'your_aql_username',
25             _password => 'your_aql_password',
26             _sender => 'sender number',
27             );
28            
29             # Send a message
30             my $sent = $sender->send_sms(
31             text => 'This is a test message',
32             to => '+61 (4) 1234 5678',
33             );
34            
35             if ( $sent ) {
36             print "Message sent ok\n";
37             } else {
38             print "Failed to send message\n";
39             }
40              
41              
42             =head1 DESCRIPTION
43              
44             A driver for SMS::Send to send SMS text messages via AQL (www.aql.com)
45              
46             This is not intended to be used directly, but instead called by SMS::Send
47             (see synopsis above for a basic illustration, and see SMS::Send's documentation
48             for further information).
49              
50              
51              
52             =head1 METHODS
53              
54             =over 4
55              
56             =item new
57              
58             Constructor, takes argument pairs passed by SMS::Send, returns an SMS::Send::AQL
59             object. See usage synopsis for example, and see SMS::Send documentation for
60             further info on using SMS::Send drivers.
61              
62             =cut
63              
64             sub new {
65              
66 0     0 1   my ($class, %args) = @_;
67              
68 0           my $self = bless { %args }, $class;
69            
70             # Previous versions of this module documented _username as the param name
71             # for the username; unfortunately there's no "standard" for SMS::Send
72             # drivers, but the general concensus seems to be to use _login, but we'll
73             # continue to support _username too.
74 0 0 0       if (!exists $args{_login} && exists $args{_username}) {
75 0           $args{_login} = delete $args{_username};
76             }
77            
78 0 0         if (grep { ! $args{$_} } qw(_login _password)) {
  0            
79 0           die "_login (or _username) and _password required";
80             }
81            
82            
83            
84 0   0       $self->{aql} = new SMS::AQL({
85             username => $args{_login},
86             password => $args{_password},
87             options => {
88             sender => $args{_sender} || 'SMS::AQL',
89             },
90             });
91            
92 0           return $self;
93              
94             }
95              
96              
97              
98             =item send_sms
99              
100             Send the message - see SMS::Send for details.
101              
102             =cut
103              
104             sub send_sms {
105              
106 0     0 1   my ($self, %args) = @_;
107            
108             # AQL's gateway won't accept numbers in the format +441234567890,
109             # it wants to see 00441234567890 instead:
110 0           $args{to} =~ s/^\+/00/;
111            
112            
113 0           return $self->{aql}->send_sms(@args{ qw (to text) });
114              
115             }
116              
117              
118              
119             =back
120              
121             =head1 AUTHOR
122              
123             David Precious, Edavidp@preshweb.co.ukE
124              
125              
126             =head1 COPYRIGHT AND LICENSE
127              
128             Copyright (C) 2008-2011 by David Precious
129              
130             This library is free software; you can redistribute it and/or modify
131             it under the same terms as Perl itself, either Perl version 5.8.7 or,
132             at your option, any later version of Perl 5 you may have available.
133              
134              
135             =cut
136              
137              
138              
139             1;
140             __END__