Skip to content

Commit 927cf12

Browse files
authored
Merge pull request #15 from goper-leo/master
Add optional attributes for adding origination number.
2 parents 39967dd + b2b1405 commit 927cf12

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

src/Sns.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public function send(SnsMessage $message, $destination)
4242
];
4343
}
4444

45+
if (! empty($message->getOriginationNumber())) {
46+
$attributes += [
47+
'AWS.MM.SMS.OriginationNumber' => [
48+
'DataType' => 'String',
49+
'StringValue' => $message->getOriginationNumber(),
50+
],
51+
];
52+
}
53+
4554
$parameters = [
4655
'Message' => $message->getBody(),
4756
'PhoneNumber' => $destination,

src/SnsMessage.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ class SnsMessage
2929
*/
3030
protected $sender = '';
3131

32+
/**
33+
* The origination number of the message.
34+
*
35+
* @var string
36+
*/
37+
protected $originationNumber = '';
38+
3239
public function __construct($content)
3340
{
3441
if (is_string($content)) {
@@ -131,4 +138,26 @@ public function getSender()
131138
{
132139
return $this->sender;
133140
}
141+
142+
/**
143+
* Sets the message origination number identification.
144+
*
145+
* @return $this
146+
*/
147+
public function originationNumber(string $originationNumber)
148+
{
149+
$this->originationNumber = $originationNumber;
150+
151+
return $this;
152+
}
153+
154+
/**
155+
* Get the message origination number identification.
156+
*
157+
* @return string
158+
*/
159+
public function getOriginationNumber()
160+
{
161+
return $this->originationNumber;
162+
}
134163
}

tests/SnsMessageTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,19 @@ public function it_can_accept_all_the_contents_when_constructing_a_message()
8787
$this->assertEquals('Transactional', $message->getDeliveryType());
8888
$this->assertEquals('Test', $message->getSender());
8989
}
90+
91+
/** @test */
92+
public function it_can_send_sms_message_with_origination_number()
93+
{
94+
$originationNumber = '+13347814073';
95+
$message = SnsMessage::create([
96+
'body' => 'Message text',
97+
'sender' => 'Test',
98+
'originationNumber' => $originationNumber,
99+
]);
100+
101+
$this->assertEquals('Message text', $message->getBody());
102+
$this->assertEquals('Test', $message->getSender());
103+
$this->assertEquals($originationNumber, $message->getOriginationNumber());
104+
}
90105
}

0 commit comments

Comments
 (0)