Skip to content

Commit c785428

Browse files
authored
Merge pull request #13 from laemol/master
Added method to add a reference
2 parents 9165e26 + 5360f79 commit c785428

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ You must install the service provider:
4949

5050
## Setting up your Messagebird account
5151

52-
Add your Messagebird Access Key, Default originator (name or number of sender), and default recipients to your `config/services.php`:
52+
Add the environment variables to your `config/services.php`:
5353

5454
```php
5555
// config/services.php
@@ -62,6 +62,18 @@ Add your Messagebird Access Key, Default originator (name or number of sender),
6262
...
6363
```
6464

65+
Add your Messagebird Access Key, Default originator (name or number of sender), and default recipients to your `.env`:
66+
67+
```php
68+
// .env
69+
...
70+
MESSAGEBIRD_ACCESS_KEY=
71+
MESSAGEBIRD_ORIGINATOR=
72+
MESSAGEBIRD_RECIPIENTS=
73+
],
74+
...
75+
```
76+
6577
Notice: The originator can contain a maximum of 11 alfa-numeric characters.
6678

6779
## Usage
@@ -87,6 +99,18 @@ class VpsServerOrdered extends Notification
8799
}
88100
```
89101

102+
Additionally you can add recipients (single value or array)
103+
104+
``` php
105+
return (new MessagebirdMessage("Your {$notifiable->service} was ordered!"))->setRecipients($recipients);
106+
```
107+
108+
In order to handle a status report you can also set a reference
109+
110+
``` php
111+
return (new MessagebirdMessage("Your {$notifiable->service} was ordered!"))->setReference($id);
112+
```
113+
90114
## Changelog
91115

92116
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

src/MessagebirdMessage.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class MessagebirdMessage
77
public $body;
88
public $originator;
99
public $recipients;
10+
public $reference;
1011

1112
public static function create($body = '')
1213
{
@@ -15,7 +16,7 @@ public static function create($body = '')
1516

1617
public function __construct($body = '')
1718
{
18-
if (! empty($body)) {
19+
if (!empty($body)) {
1920
$this->body = trim($body);
2021
}
2122
}
@@ -45,6 +46,13 @@ public function setRecipients($recipients)
4546
return $this;
4647
}
4748

49+
public function setReference($reference)
50+
{
51+
$this->reference = $reference;
52+
53+
return $this;
54+
}
55+
4856
public function toJson()
4957
{
5058
return json_encode($this);

tests/MessagebirdClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function setUp()
1414
{
1515
$this->guzzle = Mockery::mock(new Client());
1616
$this->client = Mockery::mock(new MessagebirdClient($this->guzzle, 'test_ek1qBbKbHoA20gZHM40RBjxzX'));
17-
$this->message = (new MessagebirdMessage('Message content'))->setOriginator('APPNAME')->setRecipients('31650520659');
17+
$this->message = (new MessagebirdMessage('Message content'))->setOriginator('APPNAME')->setRecipients('31650520659')->setReference('000123');
1818
}
1919

2020
public function tearDown()

0 commit comments

Comments
 (0)