<?php

namespace App\Services;

use Twilio\Rest\Client;

class TwilioService 
{
    protected $client;
    protected $whatsappNumber;
    protected $smsNumber;

    public function __construct()
    { 

    
      
        $this->whatsappNumber = 'whatsapp:+14155238886';
        $this->smsNumber = '+1 425 532 5824'; 
        
           $this->client = new Client(
            'AC00127a65d85c8fa9fea84f1d1c017da4',
            '75d354254ff5df0ede78633467f8515c'
        );
    }
 
    public function sendOtp($to, $otp)
    {
        $message = "Dear User,
Your OTP for Bluhealth Portal login is $otp. Please do not share this OTP with anyone. It is valid for 5 minutes.
Thank you,
Bluhealth Team";
        $this->client->messages->create(

            'whatsapp:' . $to,
            [
                'from' => $this->whatsappNumber,
                'body' => $message
            ]
        );
    }


    public function sendOtpViaSms($to, $otp)
    {
          $message = "Dear User,
Your OTP for Bluhealth Portal login is $otp. Please do not share this OTP with anyone. It is valid for 5 minutes.
Thank you,
Bluhealth Team";;
        $this->client->messages->create(
            $to,
            [
                'from' => $this->smsNumber,
                'body' => $message
            ]
        );
    }
}


