diff --git a/Sources/SendGridKit/Models/MailSettings.swift b/Sources/SendGridKit/Models/MailSettings.swift index 35b7df7..de1463c 100644 --- a/Sources/SendGridKit/Models/MailSettings.swift +++ b/Sources/SendGridKit/Models/MailSettings.swift @@ -50,6 +50,10 @@ public struct MailSettings: Codable, Sendable { public struct Setting: Codable, Sendable { /// Indicates if this setting is enabled. public var enable: Bool + + public init(enable: Bool) { + self.enable = enable + } } public struct Footer: Codable, Sendable { diff --git a/Sources/SendGridKit/Models/TrackingSettings.swift b/Sources/SendGridKit/Models/TrackingSettings.swift index 1d06306..4a1bb34 100644 --- a/Sources/SendGridKit/Models/TrackingSettings.swift +++ b/Sources/SendGridKit/Models/TrackingSettings.swift @@ -44,6 +44,11 @@ public struct ClickTracking: Codable, Sendable { /// Indicates if this setting should be included in the text/plain portion of your email. public var enableText: Bool + + public init(enable: Bool, enableText: Bool) { + self.enable = enable + self.enableText = enableText + } private enum CodingKeys: String, CodingKey { case enable diff --git a/Tests/SendGridKitTests/SendGridTestsKit.swift b/Tests/SendGridKitTests/SendGridTestsKit.swift index 972fa94..3c23cdc 100644 --- a/Tests/SendGridKitTests/SendGridTestsKit.swift +++ b/Tests/SendGridKitTests/SendGridTestsKit.swift @@ -1,6 +1,6 @@ import Testing import AsyncHTTPClient -@testable import SendGridKit +import SendGridKit struct SendGridKitTests { var client: SendGridClient @@ -74,4 +74,24 @@ struct SendGridKitTests { true } } + + @Test func dynamicTemplateData() async throws { + struct DynamicTemplateData: Codable, Sendable { + let text: String + let integer: Int + let double: Double + } + let dynamicTemplateData = DynamicTemplateData(text: "Hello, World!", integer: 42, double: 3.14) + + // TODO: Replace the addresses with real email addresses + let personalization = Personalization(to: [EmailAddress("TO-ADDRESS")], subject: "Test Email", dynamicTemplateData: dynamicTemplateData) + let email = SendGridEmail(personalizations: [personalization], from: EmailAddress("FROM-ADDRESS"), content: [EmailContent("Hello, World!")]) + + try await withKnownIssue { + try await client.send(email: email) + } when: { + // TODO: Replace with `false` when you have a valid API key + true + } + } }