From 07dacc55d9871ee76c1b275d0b4d330499d913e8 Mon Sep 17 00:00:00 2001 From: Ethan Bray Date: Tue, 1 Nov 2016 16:24:14 +0000 Subject: [PATCH 1/2] Add the ability to set the smscat code for a message. --- classes/Request.php | 4 ++++ classes/SMSMessage.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/classes/Request.php b/classes/Request.php index b4509db..03974d5 100644 --- a/classes/Request.php +++ b/classes/Request.php @@ -56,6 +56,10 @@ public function send() $arrParams['udh'] = $this->strUdh; } + if ($this->intCategory) { + $arrParams['smscat'] = $this->intCategory; + } + $this->objLogger->addDebug('Sending the following to txtNation:', $arrParams); $objClient = new Client([ diff --git a/classes/SMSMessage.php b/classes/SMSMessage.php index a60f5df..ee3d494 100644 --- a/classes/SMSMessage.php +++ b/classes/SMSMessage.php @@ -25,6 +25,7 @@ class SMSMessage extends Request protected $fltValue = null; protected $strCurrency = null; protected $intReply = null; + protected $intCategory = null; protected $strEncoding = null; protected $blBinary = null; protected $strUdh = null; @@ -200,6 +201,21 @@ public function binary($blBinary) return $this; } + public function category($intCategory) + { + if (!(Validator::numeric()->notEmpty()->length(3)->validate($intCategory))) { + $this->objLogger->addError('Category must be a numeric string with a length of 3.'); + + throw new SMSMessageException('Category must be a numeric string with a length of 3.'); + } + + $this->intCategory = $intCategory; + + $this->objLogger->addDebug('Category has been set to ' . $intCategory); + + return $this; + } + protected function validate() { $this->objLogger->addDebug('Validating the request'); From 964d0630ecb07db6a900249ef85b39ec2a9d2762 Mon Sep 17 00:00:00 2001 From: Ethan Bray Date: Tue, 1 Nov 2016 16:49:00 +0000 Subject: [PATCH 2/2] Fix bug with validation of category integer length. --- classes/SMSMessage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/SMSMessage.php b/classes/SMSMessage.php index ee3d494..edc9ef8 100644 --- a/classes/SMSMessage.php +++ b/classes/SMSMessage.php @@ -203,7 +203,7 @@ public function binary($blBinary) public function category($intCategory) { - if (!(Validator::numeric()->notEmpty()->length(3)->validate($intCategory))) { + if (!(Validator::numeric()->notEmpty()->length(3, 3)->validate($intCategory))) { $this->objLogger->addError('Category must be a numeric string with a length of 3.'); throw new SMSMessageException('Category must be a numeric string with a length of 3.');