Skip to content

Commit e746306

Browse files
committed
Adding in BARRED result which is returned when end users have previously opted out
1 parent cf05e36 commit e746306

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

classes/SMSMessageResult.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class SMSMessageResult extends Result
1313

1414
// a few error codes
1515
const ERROR_NO_CREDITS = 'NO CREDITS';
16+
const ERROR_BARRED = 'BARRED';
17+
1618
const ERROR_IR_101 = 'IR-101';
1719
const ERROR_IR_102 = 'IR-102';
1820
const ERROR_IR_103 = 'IR-103';
@@ -49,6 +51,7 @@ class SMSMessageResult extends Result
4951
// how the error codes translate into real person speak
5052
protected $arrErrorMessages = [
5153
self::ERROR_NO_CREDITS => 'No credits remaining. Visit https://clients.txtnation.com/ and request more credits.',
54+
self::ERROR_BARRED => 'The end user has previously sent in a STOP request preventing any further messages.',
5255

5356
self::ERROR_IR_101 => 'Duplicate post. You have already replied to a message this ID. In most cases you can only reply to a message once.',
5457
self::ERROR_IR_102 => 'Missing details. A binary transaction has been requested, but the UDH has not been specified. You should set this with the SMSMessage::udh() method.',
@@ -103,7 +106,7 @@ public function getErrorCode()
103106
{
104107
$arrMatches = [];
105108

106-
if (preg_match('/((IR|E)\-\d{3})|(NO CREDITS)/', (string) $this->objResult->getBody(), $arrMatches)) {
109+
if (preg_match('/((IR|E)\-\d{3})|(NO CREDITS)|(BARRED)/', (string) $this->objResult->getBody(), $arrMatches)) {
107110
$this->strErrorCode = $arrMatches[0];
108111
}
109112

0 commit comments

Comments
 (0)