Skip to content

Commit

Permalink
[feat] update satToken method in ghasedak,smsir driver
Browse files Browse the repository at this point in the history
  • Loading branch information
alissn committed Oct 6, 2023
1 parent b843c0f commit ba43505
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,21 @@ $message =(new SmsMessage())
->driver()
->setTemplate("invoice-paid")
->setTo('09121111111')
->setTokens(['123','456','789']);
->setTokens([
'123', // token
'456', // token2
'789', // token3
'111', // token10, with 4 space
'222', // token20, with 8 space
]);

# SmsIr
$message =(new SmsMessage())
->driver()
->setTemplate('100000')
->setTemplate('invoice-paid')
->setTo('09121111111')
->setTokens([
['name' => 'code' , 'value' => '123']
'code' => '123' // 'variable_name' => 'value'
]);

# Ghasedak
Expand All @@ -104,8 +110,8 @@ $message =(new SmsMessage())
->setTemplate("invoice-paid")
->setTo('09121111111')
->setTokens([
'param1' => 'test1',
'param2' => 'test2'
'test1', // param1
'test2' // param2
]);

$response = Chapaar::verify($message);
Expand Down
8 changes: 7 additions & 1 deletion src/Drivers/Ghasedak/GhasedakMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ public function getTokens(): array

public function setTokens(array $tokens): self
{
$this->tokens = $tokens;
$token_array = [];
foreach ($tokens as $key => $token) {
$key_name = is_numeric($key) ? sprintf('param%s', $key + 1) : $key;
$token_array[$key_name] = $token;
}

$this->tokens = $token_array;

return $this;
}
Expand Down
7 changes: 6 additions & 1 deletion src/Drivers/SmsIr/SmsIrMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ public function getTokens(): array

public function setTokens(array $tokens): self
{
$this->tokens = $tokens;
$token_array = [];
foreach ($tokens as $key => $token) {
$token_array[] = ['name' => $key, 'value' => $token];
}

$this->tokens = $token_array;

return $this;
}
Expand Down

0 comments on commit ba43505

Please sign in to comment.