Skip to content

Commit

Permalink
[feat] handle store messages
Browse files Browse the repository at this point in the history
  • Loading branch information
aryala7 committed Nov 25, 2023
1 parent c1de8c5 commit 0c60c36
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Chapaar.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function getDefaultDriver(): DriverConnector
public function send($message): object
{
$response = $this->driver($message->getDriver())->send($message);
if(config('chapaar.store_sms_messages') && count($response)) {
SmsSent::dispatch($message->driver,$message,$response['status']);
if(config('chapaar.store_sms_messages')) {
SmsSent::dispatch($response);
}
return $response;

Expand All @@ -36,8 +36,8 @@ public function send($message): object
public function verify(DriverMessage $message): object
{
$response = $this->driver($message->getDriver())->verify($message);
if(config('chapaar.store_sms_messages') && count($response)) {
SmsSent::dispatch($message->getDriver(),$message,$response['status']);
if(config('chapaar.store_sms_messages')) {
SmsSent::dispatch($response);
}
return $response;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/DriverConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function verify($message);

public function outbox($page_size = 100, $page_number = 1): object;

public function generateResponse(int $status, string $message, array $data = null): object;
public function generateResponse(int $status, string $message, string $driver, array $data = null): object;

public function generateAccountResponse($credit, $expire_date): object;

Expand Down
8 changes: 5 additions & 3 deletions src/Models/SmsMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

use Illuminate\Database\Eloquent\Casts\AsCollection;
use Illuminate\Database\Eloquent\Model;
use TookanTech\Chapaar\Enums\Drivers;

class SmsMessage extends Model
{
protected $fillable = [
'provider',
'driver',
'data',
'status',
];

protected $cast = [
protected $casts = [
'driver' => Drivers::class,
'data' => AsCollection::class
]
];
}

0 comments on commit 0c60c36

Please sign in to comment.