|
<?php |
|
|
|
namespace App\Gateways; |
|
|
|
use Illuminate\Support\Facades\Http; |
|
|
|
class TextlocalSms |
|
{ |
|
public $apikey = 'NDQ3MjYxNTczORYjdsusdTYIUSJTesting='; |
|
public $sender = 'TSTING'; |
|
public $message; |
|
public $mobiles; |
|
public $output; |
|
|
|
public function __construct($mobiles=null) |
|
{ |
|
if ($mobiles) { |
|
$this->mobiles = is_array($mobiles) ? $mobiles : [$mobiles]; |
|
}else{ |
|
$this->mobiles = []; |
|
} |
|
} |
|
|
|
public function mobiles($mobiles) |
|
{ |
|
$this->mobiles = is_array($mobiles) ? $mobiles : [$mobiles]; |
|
} |
|
|
|
public function message($template, $params) |
|
{ |
|
$templateFun = 'sms_'.$template; |
|
$this->message = $this->$templateFun($params); |
|
return $this; |
|
} |
|
|
|
public function send($mobiles=null) |
|
{ |
|
if ($mobiles) { |
|
$this->mobiles($mobiles); |
|
} |
|
|
|
$this->output = Http::asForm() |
|
->post('https://api.textlocal.in/send/', [ |
|
'apikey' => $this->apikey, |
|
'numbers' => implode(',', $this->mobiles), |
|
'sender' => $this->sender, |
|
'message' => urlencode($this->message) |
|
]) |
|
->json(); |
|
|
|
return $this; |
|
} |
|
|
|
public function output() |
|
{ |
|
return $this->output; |
|
} |
|
|
|
public function sms_booking_complete($params) |
|
{ |
|
return "Hi ".$params['name'].", you have successfully booked a vehicle having Reg No ".$params['regNo']." for ".$params['bookingDate'].". We will inform you for further updates. Company PVT. LTD."; |
|
} |
|
|
|
public function sms_vehicle_approved($params) |
|
{ |
|
return "Hi ".$params['name'].", your vehicle , Reg No ".$params['regNo']." has been approved. Please wait for your bookings, we will inform you when you have any booking. Company PVT. LTD."; |
|
} |
|
|
|
public function sms_vehicle_registered($params) |
|
{ |
|
return "Hi ".$params['name'].", your vehicle , Reg No ".$params['regNo']." has been registered. We will inform you when the details will be checked and verified. Company PVT. LTD."; |
|
} |
|
|
|
public function sms_send_otp($params) |
|
{ |
|
return "Hi ".$params['name'].", the OTP to login to your Bmyroad account is ".$params['otp'].". Valid till ".$params['timeout'].". Do not share this to anyone. Company PVT. LTD."; |
|
} |
|
} |