You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
886 B
35 lines
886 B
|
1 month ago
|
<?php
|
||
|
|
|
||
|
|
namespace App\Services\Sms;
|
||
|
|
|
||
|
|
use App\Models\SmsVerification;
|
||
|
|
use App\Support\SmsConfig;
|
||
|
|
|
||
|
|
class SubmailSmsSender implements SmsSender
|
||
|
|
{
|
||
|
|
public function __construct(private readonly SubmailSmsClient $client)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public function sendVerification(SmsVerification $record): SmsSendResult
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
SmsConfig::assertReadyForRealSending();
|
||
|
|
} catch (\Throwable $e) {
|
||
|
|
return SmsSendResult::failure(
|
||
|
|
SmsVerification::PROVIDER_SUBMAIL,
|
||
|
|
null,
|
||
|
|
'CONFIG_INCOMPLETE',
|
||
|
|
$e->getMessage(),
|
||
|
|
['error' => 'config_incomplete']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
return $this->client->sendTemplate(
|
||
|
|
(string) $record->mobile,
|
||
|
|
(string) config('sms.submail.login_template_id'),
|
||
|
|
['code' => (string) $record->code],
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|