|
|
@ -10,12 +10,26 @@ use GuzzleHttp\Client as HttpClient; |
|
|
|
class SmsChannel |
|
|
|
{ |
|
|
|
/** |
|
|
|
* The API URL for Socket. |
|
|
|
* The API URL for sms. |
|
|
|
* |
|
|
|
* @var string |
|
|
|
*/ |
|
|
|
protected $sms_url; |
|
|
|
|
|
|
|
/** |
|
|
|
* The api key for sms inside sms.ir panel. |
|
|
|
* |
|
|
|
* @var string |
|
|
|
*/ |
|
|
|
protected $api_key; |
|
|
|
|
|
|
|
/** |
|
|
|
* The secret key for sms inside sms.ir panel. |
|
|
|
* |
|
|
|
* @var string |
|
|
|
*/ |
|
|
|
protected $secret_key; |
|
|
|
|
|
|
|
/** |
|
|
|
* The HTTP client instance. |
|
|
|
* |
|
|
@ -29,10 +43,12 @@ class SmsChannel |
|
|
|
* @param \GuzzleHttp\Client $http |
|
|
|
* @return void |
|
|
|
*/ |
|
|
|
public function __construct(HttpClient $http, string $sms_url) |
|
|
|
public function __construct(HttpClient $http, string $sms_url, string $api_key, string $secret_key) |
|
|
|
{ |
|
|
|
$this->http = $http; |
|
|
|
$this->sms_url = $sms_url; |
|
|
|
$this->api_key = $api_key; |
|
|
|
$this->secret_key = $secret_key; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -49,7 +65,7 @@ class SmsChannel |
|
|
|
|
|
|
|
$message->to($notifiable->routeNotificationFor('sms', $notification)); |
|
|
|
|
|
|
|
if (! $message->to || ! ($message->params && $message->template_id) || ! $message->verification_code) { |
|
|
|
if (! $message->to || (! ($message->params && $message->template_id) && ! $message->verification_code)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -75,8 +91,8 @@ class SmsChannel |
|
|
|
protected function getToken() |
|
|
|
{ |
|
|
|
$body = [ |
|
|
|
'UserApiKey' => config('smsirlaravel.api-key'), |
|
|
|
'SecretKey' => config('smsirlaravel.secret-key'), |
|
|
|
'UserApiKey' => $this->api_key, |
|
|
|
'SecretKey' => $this->secret_key, |
|
|
|
'System' => 'laravel_v_1_4' |
|
|
|
]; |
|
|
|
|
|
|
|