Skip to content

Commit

Permalink
Merge pull request #20 from alissn/main
Browse files Browse the repository at this point in the history
[feat] update setToken method in ghasedak and smsir driver
  • Loading branch information
aryala7 authored Oct 7, 2023
2 parents b843c0f + ba43505 commit b1a6316
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
@@ -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
@@ -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);
8 changes: 7 additions & 1 deletion src/Drivers/Ghasedak/GhasedakMessage.php
Original file line number Diff line number Diff line change
@@ -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;
}
7 changes: 6 additions & 1 deletion src/Drivers/SmsIr/SmsIrMessage.php
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit b1a6316

Please sign in to comment.