Skip to content

Commit

Permalink
Add some inits and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Sep 21, 2024
1 parent 73d540c commit 3547866
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Sources/SendGridKit/Models/MailSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions Sources/SendGridKit/Models/TrackingSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion Tests/SendGridKitTests/SendGridTestsKit.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Testing
import AsyncHTTPClient
@testable import SendGridKit
import SendGridKit

struct SendGridKitTests {
var client: SendGridClient
Expand Down Expand Up @@ -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
}
}
}

0 comments on commit 3547866

Please sign in to comment.