Skip to content

Commit d5e9ec4

Browse files
feat: add msisdnCooldownInMinutes parameter to messages api's (#7)
* feat: add msisdnCooldownInMinutes parameter to messages api's * Update tests.yml * Update tests.yml * test: fix tests --------- Co-authored-by: Kris Thomsen <[email protected]>
1 parent e40e847 commit d5e9ec4

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
php-versions: ['7.4', '8.0', '8.1', '8.2']
15+
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3']
1616

1717
steps:
1818
- uses: actions/checkout@v4

src/RequestModels/Message.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Message
2121
protected string $encoding = self::ENCODING_GSM7;
2222
protected ?string $messageId = null;
2323
protected ?string $countryHint = null;
24+
protected ?int $msisdnCooldownInMinutes = null;
2425

2526
/**
2627
* @var mixed
@@ -107,6 +108,13 @@ public function setCountryHint(string $countryHint): self
107108
return $this;
108109
}
109110

111+
public function setMsisdnCooldownInMinutes(?int $msisdnCooldownInMinutes): self
112+
{
113+
$this->msisdnCooldownInMinutes = $msisdnCooldownInMinutes;
114+
115+
return $this;
116+
}
117+
110118
public function toArray(): array
111119
{
112120
return [
@@ -123,6 +131,7 @@ public function toArray(): array
123131
'respectBlacklist' => $this->respectBlacklist,
124132
'statusCallbackUrl' => $this->statusCallbackUrl,
125133
'encoding' => $this->encoding,
134+
'msisdnCooldownInMinutes' => $this->msisdnCooldownInMinutes,
126135
];
127136
}
128137

@@ -180,4 +189,9 @@ public function getCountryHint(): ?string
180189
{
181190
return $this->countryHint;
182191
}
192+
193+
public function getMsisdnCooldownInMinutes(): ?int
194+
{
195+
return $this->msisdnCooldownInMinutes;
196+
}
183197
}

tests/Unit/Endpoints/MessagesApiTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public function test_sends_a_single_message_with_all_possible_fields()
137137
'respectBlacklist' => false,
138138
'statusCallbackUrl' => 'https://example.com/inmobile/callback',
139139
'encoding' => Message::ENCODING_UCS2,
140+
'msisdnCooldownInMinutes' => null,
140141
], $payload['messages'][0]);
141142

142143
return true;

tests/Unit/RequestModels/MessageTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public function test_create_a_message()
2121
->flash()
2222
->ignoreBlacklist()
2323
->setEncoding(Message::ENCODING_GSM7)
24-
->setStatusCallbackUrl('https://example.com/callback');
24+
->setStatusCallbackUrl('https://example.com/callback')
25+
->setMsisdnCooldownInMinutes(60);
2526

2627
$this->assertEquals('Hello World', $message->getText());
2728
$this->assertEquals(4512345678, $message->getRecipient());
@@ -34,6 +35,7 @@ public function test_create_a_message()
3435
$this->assertFalse($message->getRespectBlacklist());
3536
$this->assertEquals(Message::ENCODING_GSM7, $message->getEncoding());
3637
$this->assertEquals('https://example.com/callback', $message->getStatusCallbackUrl());
38+
$this->assertEquals(60, $message->getMsisdnCooldownInMinutes());
3739
}
3840

3941
public function test_convert_to_array()
@@ -49,7 +51,8 @@ public function test_convert_to_array()
4951
->flash()
5052
->ignoreBlacklist()
5153
->setEncoding(Message::ENCODING_GSM7)
52-
->setStatusCallbackUrl('https://example.com/callback');
54+
->setStatusCallbackUrl('https://example.com/callback')
55+
->setMsisdnCooldownInMinutes(60);
5356

5457
$this->assertEquals([
5558
'to' => '4512345678',
@@ -63,6 +66,7 @@ public function test_convert_to_array()
6366
'respectBlacklist' => false,
6467
'statusCallbackUrl' => 'https://example.com/callback',
6568
'encoding' => Message::ENCODING_GSM7,
69+
'msisdnCooldownInMinutes' => 60,
6670
], $message->toArray());
6771
}
6872
}

0 commit comments

Comments
 (0)