From ce536d6bd5fdc84146f9eb1ecd9b3922c1ae6457 Mon Sep 17 00:00:00 2001 From: Emre Bozkurt Date: Fri, 3 Jun 2022 02:19:32 +0300 Subject: [PATCH] Updated VerimorService and Facade. --- src/Facades/Verimor.php | 4 ++++ src/VerimorService.php | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Facades/Verimor.php b/src/Facades/Verimor.php index 9da80ca..c6b137e 100644 --- a/src/Facades/Verimor.php +++ b/src/Facades/Verimor.php @@ -5,6 +5,10 @@ use Emrebbozkurt\VerimorSms\VerimorService; use Illuminate\Support\Facades\Facade; +/** + * @method static mixed send($to, $message, $params = []) + * + */ class Verimor extends Facade { /** diff --git a/src/VerimorService.php b/src/VerimorService.php index 17bb272..4f102c2 100644 --- a/src/VerimorService.php +++ b/src/VerimorService.php @@ -63,18 +63,18 @@ public function __construct($config) * * @return VerimorService */ - public function send($to, $message, $params = []) + public static function send($to, $message, $params = []) { - $this->to = $to; - $this->message = $message; - $this->params = $params; - return $this->request(); + self::$to = $to; + self::$message = $message; + self::$params = $params; + return self::request(); } /** * Returning to response * - * @return string + * @return \Illuminate\Http\JsonResponse */ public function response() { @@ -96,26 +96,26 @@ public function status() * * @return VerimorService */ - protected function request() + protected static function request() { $data = [ - 'username' => $this->config['username'], - 'password' => $this->config['password'], - 'custom_id' => $this->params['custom_id'] ?? $this->config['custom_id'], - 'datacoding' => $this->params['datacoding'] ?? $this->config['datacoding'], - 'valid_for' => $this->params['valid_for'] ?? $this->config['valid_for'], + 'username' => self::$config['username'], + 'password' => self::$config['password'], + 'custom_id' => self::$params['custom_id'] ?? self::$config['custom_id'], + 'datacoding' => self::$params['datacoding'] ?? self::$config['datacoding'], + 'valid_for' => self::$params['valid_for'] ?? self::$config['valid_for'], 'send_at' => Carbon::now()->toDateTimeString(), 'messages' => [ - 'msg' => $this->message, - 'dest' => $this->to + 'msg' => self::$message, + 'dest' => self::$to ] ]; $request = Http::post('http://sms.verimor.com.tr/v2/send.json', $data); - $this->response = ['message' => $request->body(), 'status' => $request->status()]; - $this->status = $request->status(); + self::$response = ['message' => $request->body(), 'status' => $request->status()]; + self::$status = $request->status(); - return $this; + return self::class; } }