| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace ElkenGit\EknotifierPHP;
- use Carbon\Carbon;
- /**
- * Class SmsNotifier to provide SMS Notifier integration for EKNotifier Service.
- */
- class EknotifierSms extends EknotifierCommon
- {
- /**
- * Instantiate EknotifierSms Class.
- *
- * @param string|null $url
- * @param string|null $applicationCode
- * @param string|null $applicationPassword
- * @throws \Exception
- */
- public function __construct(string $url = null, string $applicationCode = null, string $applicationPassword = null)
- {
- parent::__construct($url, $applicationCode, $applicationPassword);
- }
- /**
- * Send an SMS.
- *
- * @param string $phoneNumber
- * @param string $text
- * @param int $userId
- * @return bool
- * @throws \GuzzleHttp\Exception\GuzzleException
- */
- public function sendSMS(string $phoneNumber, string $text, int $userId = 0): bool
- {
- $token = $this->getAuthToken();
- $request = [
- 'name' => $this->applicationCode . ' SMS ' . $phoneNumber,
- 'send_at' => date('Y-m-d H:i:s', time()),
- 'recipients' => [
- [
- 'application_user_id' => $userId,
- 'delivery_destination' => $phoneNumber,
- 'delivery_type' => 'SMS',
- 'body' => $text
- ]
- ]
- ];
- return $this->postAPI('notification/send', $request, $token);
- }
- }
|