Files
clinicpro/src/Sms/Provider/RanginehProvider.php
T
hamed de1a78a235 feat: Implement SMS sending functionality with KavehNegar and Rangineh providers
- Add SendSmsMessage class for encapsulating SMS message data.
- Create KavehNegarProvider and RanginehProvider classes implementing SmsProviderInterface for sending SMS.
- Implement SmsLogRepository and SmsTemplateRepository for managing SMS logs and templates.
- Develop SendSmsHandler for handling SMS sending messages.
- Create SmsService to manage SMS dispatching and logging.
- Add UserProfileController for managing user profiles with CRUD operations.
- Implement UserProfile entity and repository for user profile data management.
- Update symfony.lock and bootstrap.php for project dependencies and environment setup.
2026-06-09 22:00:34 +03:30

51 lines
1.5 KiB
PHP

<?php
namespace App\Sms\Provider;
use Symfony\Contracts\HttpClient\HttpClientInterface;
class RanginehProvider implements SmsProviderInterface
{
private const BASE = 'https://rest.payamresan.com/api/v1';
public function __construct(
private readonly HttpClientInterface $httpClient,
private readonly string $apiKey,
private readonly string $sender,
) {}
public function getName(): string { return 'rangineh'; }
public function send(string $mobile, string $message): bool
{
try {
$resp = $this->httpClient->request('POST', self::BASE . '/send', [
'json' => ['from' => $this->sender, 'to' => [$mobile], 'text' => $message],
'headers' => ['ApiKey' => $this->apiKey],
'timeout' => 10,
]);
return $resp->getStatusCode() === 200;
} catch (\Throwable) {
return false;
}
}
public function sendTemplate(string $mobile, string $templateCode, array $vars): bool
{
try {
$resp = $this->httpClient->request('POST', self::BASE . '/send/verify', [
'json' => [
'mobile' => $mobile,
'template' => $templateCode,
'params' => $vars,
],
'headers' => ['ApiKey' => $this->apiKey],
'timeout' => 10,
]);
return $resp->getStatusCode() === 200;
} catch (\Throwable) {
return false;
}
}
}