|
1 | 1 | import Foundation |
2 | 2 |
|
3 | | -public struct SendGridEmail: Codable, Sendable { |
| 3 | +public struct SendGridEmail<DynamicTemplateData: Codable & Sendable>: Codable, Sendable { |
4 | 4 | /// An array of messages and their metadata. |
5 | 5 | /// |
6 | 6 | /// Each object within `personalizations` can be thought of as an envelope - |
7 | 7 | /// it defines who should receive an individual message and how that message should be handled. |
8 | | - public var personalizations: [Personalization] |
| 8 | + public var personalizations: [Personalization<DynamicTemplateData>] |
9 | 9 |
|
10 | 10 | public var from: EmailAddress |
11 | 11 |
|
@@ -79,7 +79,7 @@ public struct SendGridEmail: Codable, Sendable { |
79 | 79 | public var trackingSettings: TrackingSettings? |
80 | 80 |
|
81 | 81 | public init( |
82 | | - personalizations: [Personalization], |
| 82 | + personalizations: [Personalization<DynamicTemplateData>], |
83 | 83 | from: EmailAddress, |
84 | 84 | replyTo: EmailAddress? = nil, |
85 | 85 | replyToList: [EmailAddress]? = nil, |
@@ -136,3 +136,43 @@ public struct SendGridEmail: Codable, Sendable { |
136 | 136 | case trackingSettings = "tracking_settings" |
137 | 137 | } |
138 | 138 | } |
| 139 | + |
| 140 | +public extension SendGridEmail where DynamicTemplateData == [String: String] { |
| 141 | + init( |
| 142 | + personalizations: [Personalization<[String: String]>], |
| 143 | + from: EmailAddress, |
| 144 | + replyTo: EmailAddress? = nil, |
| 145 | + replyToList: [EmailAddress]? = nil, |
| 146 | + subject: String? = nil, |
| 147 | + content: [EmailContent]? = nil, |
| 148 | + attachments: [EmailAttachment]? = nil, |
| 149 | + templateID: String? = nil, |
| 150 | + headers: [String: String]? = nil, |
| 151 | + categories: [String]? = nil, |
| 152 | + customArgs: [String: String]? = nil, |
| 153 | + sendAt: Date? = nil, |
| 154 | + batchID: String? = nil, |
| 155 | + asm: AdvancedSuppressionManager? = nil, |
| 156 | + ipPoolName: String? = nil, |
| 157 | + mailSettings: MailSettings? = nil, |
| 158 | + trackingSettings: TrackingSettings? = nil |
| 159 | + ) { |
| 160 | + self.personalizations = personalizations |
| 161 | + self.from = from |
| 162 | + self.replyTo = replyTo |
| 163 | + self.replyToList = replyToList |
| 164 | + self.subject = subject |
| 165 | + self.content = content |
| 166 | + self.attachments = attachments |
| 167 | + self.templateID = templateID |
| 168 | + self.headers = headers |
| 169 | + self.categories = categories |
| 170 | + self.customArgs = customArgs |
| 171 | + self.sendAt = sendAt |
| 172 | + self.batchID = batchID |
| 173 | + self.asm = asm |
| 174 | + self.ipPoolName = ipPoolName |
| 175 | + self.mailSettings = mailSettings |
| 176 | + self.trackingSettings = trackingSettings |
| 177 | + } |
| 178 | +} |
0 commit comments