Skip to content

Commit

Permalink
Updated VerimorService and Facade.
Browse files Browse the repository at this point in the history
  • Loading branch information
bozkurtemre committed Jun 2, 2022
1 parent 53bdd98 commit ce536d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
4 changes: 4 additions & 0 deletions src/Facades/Verimor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use Emrebbozkurt\VerimorSms\VerimorService;
use Illuminate\Support\Facades\Facade;

/**
* @method static mixed send($to, $message, $params = [])
*
*/
class Verimor extends Facade
{
/**
Expand Down
34 changes: 17 additions & 17 deletions src/VerimorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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;
}
}

0 comments on commit ce536d6

Please # to comment.