Skip to content

Commit

Permalink
added Malaysia Mode enable for Malaysia user only. Other country plea…
Browse files Browse the repository at this point in the history
…se set your own full +[CountryCode]
  • Loading branch information
shiroamada committed May 15, 2022
1 parent ebbf82c commit f63c6d4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Add your ultrasms instanceId and token to your `config/services.php`:
'ultrasms' => [
'instanceId' => env('ULTRASMS_INSTANCEID'),
'token' => env('ULTRASMS_TOKEN'),
'isMalaysiaMode' => env('ULTRASMS_MALAYSIA_MODE') ?? 0,
'isDebug' => env('ULTRASMS_DEBUG_ENABLE') ?? 0,
'debugReceiveNumber' => env('ULTRASMS_DEBUG_RECEIVE_NUMBER'),
],
Expand Down
4 changes: 4 additions & 0 deletions src/UltraSmsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class UltraSmsApi
/** @var string */
protected $token;

/** @var integer */
public $isMalaysiaMode;

/** @var integer */
public $isDebug;

Expand All @@ -41,6 +44,7 @@ public function __construct($config)
$this->instanceId = $config['instanceId'];
$this->token = $config['token'];

$this->isMalaysiaMode = $config['isMalaysiaMode'];
$this->isDebug = $config['isDebug'];
$this->debugReceiveNumber = $config['debugReceiveNumber'];

Expand Down
20 changes: 14 additions & 6 deletions src/UltraSmsChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,23 @@ protected function sendMessage($recipient, UltraSmsMessage $message)
}
else
{
//this is for malaysia number use case, other country kindly fork your version
if ($recipient[0] == '6')
if($this->ultrasms->isMalaysiaMode)
{
$valid_mobile = '+' . $recipient;
//this is for malaysia number use case,
if ($recipient[0] == '6')
{
$valid_mobile = '+' . $recipient;
}

if ($recipient[0] == '0')
{
$valid_mobile = '+6' . $recipient;
}
}

if ($recipient[0] == '0')
else
{
$valid_mobile = '+6' . $recipient;
//please set +[CountryCode]
$valid_mobile = $recipient;
}
}

Expand Down

0 comments on commit f63c6d4

Please sign in to comment.