Permalink
Browse files

Update to match TxtLocal API changes

  • Loading branch information...
1 parent 7508584 commit b1fc6d764a79ea095b0519f0d41efa97791fb6ba @evdb committed Apr 20, 2011
Showing with 5 additions and 3 deletions.
  1. +4 −2 lib/Net/SMS/TxtLocal.pm
  2. +1 −1 t/bad_username.t
View
@@ -113,13 +113,15 @@ to their servers and is a good way to test that the connection is available.
sub get_credit_balance {
my $self = shift;
- my $credits = $self->_make_request(
+ my $response = $self->_make_request(
{
path => '/getcredits.php',
query => {},
}
);
+ my $credits = $response->{Credits} || 0;
+
# clean up the repsonse and check it makes sense
$credits =~ s{ \s* (\d+) \s* }{$1}x;
croak "Bad credit value: '$credits' " if $credits =~ m{\D};
@@ -210,7 +212,7 @@ sub _make_request {
my $data = decode_json($content);
# check for the error key and croak if it is there
- croak "Error with request: '$data->{ERROR}'" if $data->{ERROR};
+ croak "Error with request: '$data->{Error}'" if $data->{Error};
return $data;
}
View
@@ -27,7 +27,7 @@ ok $txtlocal, "created an object";
# try to get the credit level
throws_ok #
sub { $txtlocal->get_credit_balance }, #
- qr{Invalid request - please check uname and pword}, #
+ qr{Invalid login}, #
"died trying to get credit balance";
# try to get the credit level and check that it dies with a helpful message

0 comments on commit b1fc6d7

Please sign in to comment.