aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/SMS.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/SMS.pm')
-rw-r--r--perllib/FixMyStreet/SMS.pm16
1 files changed, 7 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/SMS.pm b/perllib/FixMyStreet/SMS.pm
index c71cceadc..dff27e018 100644
--- a/perllib/FixMyStreet/SMS.pm
+++ b/perllib/FixMyStreet/SMS.pm
@@ -3,7 +3,7 @@ package FixMyStreet::SMS;
use strict;
use warnings;
-# use JSON::MaybeXS;
+use JSON::MaybeXS;
use Moo;
use Number::Phone::Lib;
use WWW::Twilio::API;
@@ -44,7 +44,7 @@ sub send_token {
return {
random => $random,
token => $token_obj->token,
- result => $result,
+ %$result,
};
}
@@ -55,13 +55,11 @@ sub send {
To => $params{to},
Body => $params{body},
);
- # At present, we do nothing and assume sent okay.
- # TODO add error checking
- # my $data = decode_json($output->{content});
- # if ($output->{code} != 200) {
- # return { error => "$data->{message} ($data->{code})" };
- # }
- # return { success => $data->{sid} };
+ my $data = decode_json($output->{content});
+ if ($output->{code} >= 400) {
+ return { error => "$data->{message} ($data->{code})" };
+ }
+ return { success => $data->{sid} };
}
=head2 parse_username