Skip to content

Commit 0f6c1a2

Browse files
authored
Merge pull request #12 from TechTomaz/feat/rebase_sms_options
Feat/rebase sms options
2 parents eebcabc + bc1f113 commit 0f6c1a2

File tree

4 files changed

+61
-44
lines changed

4 files changed

+61
-44
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,22 @@ The FortySixElksSMS have the following methods, all chainable.
8686
### Available Message methods for sms
8787

8888

89-
``from($mixed)``. Accepts a string up to 11 characters or number. Sms will be sent with that name.
89+
``from($mixed)`` Accepts a string up to 11 characters or number. Sms will be sent with that name.
9090

91-
``to($number)``. International phone number.
91+
``to($number)`` International phone number.
9292

93-
``line($string)``. Every string in a line will be on its own row.
93+
``line($string)`` Every string in a line will be on its own row.
94+
95+
``flash()`` Will set the message type to flash. Will not endup in sms inbox. See [This tweet](https://twitter.com/46elks/status/583183559420178432) to find out how it looks on an iphone.
96+
97+
``dryrun()`` Enable when you want to verify your API request without actually sending an SMS to a mobile phone.
98+
No SMS message will be sent when this is enabled.
99+
100+
``whendelivered('http://localhost')`` This webhook URL will receive a POST request every time the delivery status changes.
101+
102+
``dontlog()`` Enable to avoid storing the message text in your history.
103+
The other parameters will still be stored.
94104

95-
``flash()``. Will set the message type to flash. Will not endup in sms inbox. See [This tweet](https://twitter.com/46elks/status/583183559420178432) to find out how it looks on an iphone.
96105
#### MMS
97106
To use MMS simply use `new FortySixElksMMS()` instead of `new FortySixElksSMS()`
98107

src/FortySixElksMedia.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class FortySixElksMedia
1616
*/
1717
protected $payload = [
1818
'lines' => [],
19-
'subject' => '',
2019
];
2120

2221
/**
@@ -73,18 +72,6 @@ public function line($line)
7372
return $this;
7473
}
7574

76-
/**
77-
* @param $subject
78-
*
79-
* @return $this
80-
*/
81-
public function subject($subject)
82-
{
83-
$this->payload['subject'] = $subject;
84-
85-
return $this;
86-
}
87-
8875
/**
8976
* @param $phone_number
9077
*
@@ -116,12 +103,4 @@ public function getContent()
116103
{
117104
return implode(PHP_EOL, $this->payload['lines']);
118105
}
119-
120-
/**
121-
* @return mixed
122-
*/
123-
public function getSubject()
124-
{
125-
return $this->payload['subject'];
126-
}
127106
}

src/FortySixElksSMS.php

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
class FortySixElksSMS extends FortySixElksMedia implements FortySixElksMediaInterface
88
{
99
const ENDPOINT = 'https://api.46elks.com/a1/SMS';
10+
1011
public $type = 'SMS';
12+
protected $flash = 'no';
13+
protected $dry = 'no';
14+
protected $whendelivered = null;
15+
protected $log = false;
1116

1217
/**
1318
* FortySixElksSMS constructor.
@@ -25,10 +30,13 @@ public function send()
2530
try {
2631
$response = $this->client->request('POST', self::ENDPOINT, [
2732
'form_params' => [
28-
'from' => $this->from,
29-
'message' => $this->getContent(),
30-
'to' => $this->phone_number,
31-
'flashsms' => (isset($this->payload['flash']) && $this->payload['flash']) ? 'yes' : 'no',
33+
'from' => $this->from,
34+
'message' => $this->getContent(),
35+
'to' => $this->phone_number,
36+
'flashsms' => $this->flash,
37+
'dryrun' => $this->dry,
38+
'whendelivered' => $this->whendelivered,
39+
'dontlog' => $this->log,
3240
],
3341

3442
]);
@@ -44,9 +52,44 @@ public function send()
4452
return $this;
4553
}
4654

55+
/**
56+
* @return $this
57+
*/
4758
public function flash()
4859
{
49-
$this->payload['flash'] = true;
60+
$this->flash = $this->payload['flash'] ?? 'yes';
61+
62+
return $this;
63+
}
64+
65+
/**
66+
* @return $this
67+
*/
68+
public function dry()
69+
{
70+
$this->dry = $this->payload['dryrun'] ?? 'yes';
71+
72+
return $this;
73+
}
74+
75+
/**
76+
* @param string $url
77+
*
78+
* @return $this
79+
*/
80+
public function whendelivered($url)
81+
{
82+
$this->whendelivered = $this->payload['whendelivered'] ?? $url;
83+
84+
return $this;
85+
}
86+
87+
/**
88+
* @return $this
89+
*/
90+
public function dontLog()
91+
{
92+
$this->log = $this->payload['dontLog'] ?? 'message';
5093

5194
return $this;
5295
}

tests/FortySixElksMediaTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ public function testSMSTest()
1515
//test content
1616
$this->assertInstanceOf(FortySixElksSMS::class, $class->line('test line'));
1717
$this->assertContains('test', $class->getContent());
18-
19-
//test subject
20-
$this->assertEquals(
21-
'test subject',
22-
$class->subject('test subject')
23-
->getSubject()
24-
);
2518
}
2619

2720
public function testMMSTest()
@@ -33,12 +26,5 @@ public function testMMSTest()
3326
//test content
3427
$this->assertInstanceOf(FortySixElksMMS::class, $class->line('test line'));
3528
$this->assertContains('test', $class->getContent());
36-
37-
//test subject
38-
$this->assertEquals(
39-
'test subject',
40-
$class->subject('test subject')
41-
->getSubject()
42-
);
4329
}
4430
}

0 commit comments

Comments
 (0)