Skip to content

Commit

Permalink
create facade
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullahGhanem committed Apr 17, 2019
1 parent 8b3d655 commit caaa35a
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added src/.DS_Store
Binary file not shown.
17 changes: 17 additions & 0 deletions src/Facades/Smsmisr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Ghanem\LaravelSmsmisr\Facades;

use Illuminate\Support\Facades\Facade;

class Smsmisr extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'smsmisr';
}
}
72 changes: 71 additions & 1 deletion src/Smsmisr.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function buildHttpClient(): Client
* @param string|null $from
* @return \Psr\Http\Message\ResponseInterface
*/
public function send(string $message, string $to, $sender = null): ResponseInterface
public function send(string $message, string $to, $sender = null)
{
$sender = $sender ?? $this->config['sender'];
$client = $this->buildHttpClient();
Expand All @@ -64,4 +64,74 @@ public function send(string $message, string $to, $sender = null): ResponseInter

return $response;
}

/**
* @param string $message
* @param string $to
* @param string|null $from
* @return \Psr\Http\Message\ResponseInterface
*/
public function sendVerify(string $message, string $to, $sender = null)
{
$sender = $sender ?? $this->config['sender'];
$client = $this->buildHttpClient();

$response = $client->post($this->config['endpoint'].'/verify', [
'query' => [
'username' => $this->config['endpoint'],
'password' => $this->config['endpoint'],
'sender' => $sender,
'language' => 1,
'message' => $message,
'mobile' => $to,
'DelayUntil' => null,
]
]);

return $response;
}

/**
* @param string $message
* @param string $to
* @param string|null $from
* @return \Psr\Http\Message\ResponseInterface
*/
public function balance()
{
$client = $this->buildHttpClient();

$response = $client->post($this->config['endpoint'].'/Request', [
'query' => [
'username' => $this->config['endpoint'],
'password' => $this->config['endpoint'],
'request' => 'status',
'SMSID' => 7511,
]
]);

return $response;
}

/**
* @param string $message
* @param string $to
* @param string|null $from
* @return \Psr\Http\Message\ResponseInterface
*/
public function balanceVerify()
{
$client = $this->buildHttpClient();

$response = $client->post($this->config['endpoint'].'/vRequest', [
'query' => [
'username' => $this->config['endpoint'],
'password' => $this->config['endpoint'],
'request' => 'status',
'SMSID' => 7511,
]
]);

return $response;
}
}
10 changes: 8 additions & 2 deletions src/SmsmisrServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@

class SmsmisrServiceProvider extends ServiceProvider
{
/** @var bool $defer */
/**
* @var bool $defer Indicates if loading of the provider is deferred.
*/
protected $defer = false;
/** @var string $configName */

/**
* [$configName description]
* @var string
*/
protected $configName = 'smsmisr';

public function register()
Expand Down

0 comments on commit caaa35a

Please sign in to comment.