Skip to content

Commit bd4650e

Browse files
committed
Merge branch 'master' of github.com:herald-project/herald-client-php
2 parents 542aa4e + 6194c9e commit bd4650e

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/Client.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function send(MessageInterface $message, $skipNamePrefix = false)
5858
]);
5959

6060
return $res->getStatusCode() == 200;
61+
6162
}
6263

6364
public function preview(MessageInterface $message, $skipNamePrefix = false)
@@ -94,7 +95,7 @@ public function templateExists($templateName, $skipNamePrefix = false)
9495

9596
$body = $res->getBody();
9697
if ($body) {
97-
if ($body->read(2) == 'ok') {
98+
if ('ok' == $body->read(2)) {
9899
return true;
99100
}
100101
}
@@ -128,7 +129,7 @@ public function getMessages()
128129

129130
$body = $res->getBody();
130131
if ($body) {
131-
if ($body->read(2) == 'ok') {
132+
if ('ok' == $body->read(2)) {
132133
return true;
133134
}
134135
}
@@ -158,7 +159,7 @@ public function getMessageById($messageId)
158159

159160
$body = $res->getBody();
160161
if ($body) {
161-
if ($body->read(2) == 'ok') {
162+
if ('ok' == $body->read(2)) {
162163
return true;
163164
}
164165
}
@@ -178,6 +179,7 @@ private function doQuery($method, $url, $data = null)
178179
$guzzleclient = new GuzzleClient();
179180

180181
if (stristr($method, 'get') !== false) {
182+
181183
$res = $guzzleclient->get($this->baseUrl.'/'.$url, [
182184
'auth' => [$this->username, $this->password],
183185
]);
@@ -194,6 +196,12 @@ private function doQuery($method, $url, $data = null)
194196
public function getLists()
195197
{
196198
return $this->doQuery('GET', 'list');
199+
200+
}
201+
202+
public function getTemplates()
203+
{
204+
return $this->doQuery('GET', 'templates');
197205
}
198206

199207
public function getContacts($listId)
@@ -331,7 +339,7 @@ private function parseAddresses($addresses)
331339
}
332340
if (is_string($addresses)) {
333341
// old format json string, parse to array
334-
if ($addresses[0] != '[') {
342+
if ('[' != $addresses[0]) {
335343
// Expecting a json array, assuming single address
336344
$address = new Address();
337345
//todo: parse in id, uuid and type if set

0 commit comments

Comments
 (0)