-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSMTP.php
More file actions
129 lines (113 loc) · 3.23 KB
/
SMTP.php
File metadata and controls
129 lines (113 loc) · 3.23 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
namespace Utopia\Migration\Resources\Settings;
use Utopia\Migration\Resource;
use Utopia\Migration\Transfer;
/**
* Singleton resource representing the project's custom SMTP configuration.
* Password is not migrated — the source API never exposes it.
*/
class SMTP extends Resource
{
public function __construct(
string $id,
private readonly bool $enabled = false,
private readonly string $senderName = '',
private readonly string $senderEmail = '',
private readonly string $replyToName = '',
private readonly string $replyToEmail = '',
private readonly string $host = '',
private readonly int $port = 0,
private readonly string $username = '',
private readonly string $secure = '',
string $createdAt = '',
string $updatedAt = '',
) {
$this->id = $id;
$this->createdAt = $createdAt;
$this->updatedAt = $updatedAt;
}
/**
* @param array<string, mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
$array['id'],
(bool) ($array['enabled'] ?? false),
(string) ($array['senderName'] ?? ''),
(string) ($array['senderEmail'] ?? ''),
(string) ($array['replyToName'] ?? ''),
(string) ($array['replyToEmail'] ?? ''),
(string) ($array['host'] ?? ''),
(int) ($array['port'] ?? 0),
(string) ($array['username'] ?? ''),
(string) ($array['secure'] ?? ''),
createdAt: $array['createdAt'] ?? '',
updatedAt: $array['updatedAt'] ?? '',
);
}
/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'enabled' => $this->enabled,
'senderName' => $this->senderName,
'senderEmail' => $this->senderEmail,
'replyToName' => $this->replyToName,
'replyToEmail' => $this->replyToEmail,
'host' => $this->host,
'port' => $this->port,
'username' => $this->username,
'secure' => $this->secure,
'createdAt' => $this->createdAt,
'updatedAt' => $this->updatedAt,
];
}
public static function getName(): string
{
return Resource::TYPE_SMTP;
}
public function getGroup(): string
{
return Transfer::GROUP_SETTINGS;
}
public function getEnabled(): bool
{
return $this->enabled;
}
public function getSenderName(): string
{
return $this->senderName;
}
public function getSenderEmail(): string
{
return $this->senderEmail;
}
public function getReplyToName(): string
{
return $this->replyToName;
}
public function getReplyToEmail(): string
{
return $this->replyToEmail;
}
public function getHost(): string
{
return $this->host;
}
public function getPort(): int
{
return $this->port;
}
public function getUsername(): string
{
return $this->username;
}
public function getSecure(): string
{
return $this->secure;
}
}