-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathSocketlabs.php
More file actions
72 lines (54 loc) · 1.79 KB
/
Socketlabs.php
File metadata and controls
72 lines (54 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace Socketlabs\Appwrite\Adapter;
use Appwrite\Messaging\Adapter;
use Socketlabs\Messaging\Client;
use Socketlabs\Messaging\Email;
class SocketlabsAdapter extends Adapter
{
private Client $client;
public function __construct(Client $client)
{
$this->client = $client;
}
public function send(array $message): bool
{
$email = new Email();
$email
->setFrom($message['from'])
->setTo($message['to'])
->setSubject($message['subject'])
->setBody($message['body']);
$response = $this->client->send($email);
return $response->isSuccess();
}
public function trackOpen(string $messageId): bool
{
$response = $this->client->trackOpen($messageId);
return $response->isSuccess();
}
public function trackClick(string $messageId, string $link): bool
{
$response = $this->client->trackClick($messageId, $link);
return $response->isSuccess();
}
public function getTemplate(string $templateId): array
{
$response = $this->client->getTemplate($templateId);
return $response->getData();
}
public function createTemplate(array $template): string
{
$response = $this->client->createTemplate($template);
return $response->getData()['id'];
}
public function updateTemplate(string $templateId, array $template): bool
{
$response = $this->client->updateTemplate($templateId, $template);
return $response->isSuccess();
}
public function deleteTemplate(string $templateId): bool
{
$response = $this->client->deleteTemplate($templateId);
return $response->isSuccess();
}
}