From c7dda565b3716d8c77277b88b264886043e3110f Mon Sep 17 00:00:00 2001 From: Francesco Paolo Severino <96546612+fpseverino@users.noreply.github.com> Date: Sat, 7 Sep 2024 22:48:15 +0200 Subject: [PATCH] Fix build errors (#19) * Fix build errors --- .github/CODEOWNERS | 1 + Sources/SendGridKit/SendGridClient.swift | 3 ++- Tests/SendGridKitTests/SendGridTestsKit.swift | 21 ++++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..37a58a4 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @Andrewangeta @fpseverino \ No newline at end of file diff --git a/Sources/SendGridKit/SendGridClient.swift b/Sources/SendGridKit/SendGridClient.swift index 9dd1a2d..53b1e7a 100644 --- a/Sources/SendGridKit/SendGridClient.swift +++ b/Sources/SendGridKit/SendGridClient.swift @@ -1,7 +1,8 @@ -import Foundation +@preconcurrency import Foundation import NIO import AsyncHTTPClient import NIOHTTP1 +import NIOFoundationCompat public struct SendGridClient: Sendable { let apiURL = "https://api.sendgrid.com/v3/mail/send" diff --git a/Tests/SendGridKitTests/SendGridTestsKit.swift b/Tests/SendGridKitTests/SendGridTestsKit.swift index c65ec2e..1f9c17f 100644 --- a/Tests/SendGridKitTests/SendGridTestsKit.swift +++ b/Tests/SendGridKitTests/SendGridTestsKit.swift @@ -18,12 +18,27 @@ class SendGridKitTests: XCTestCase { func testSendEmail() async throws { // TODO: Replace to address with the email address you'd like to recieve your test email - let emailAddress = EmailAddress(email: "TO-ADDRESS", name: "Test User") + let emailAddress = EmailAddress("TO-ADDRESS") // TODO: Replace from address with the email address associated with your verified Sender Identity let fromEmailAddress = EmailAddress(email: "FROM-ADDRESS", name: "Test") + let personalization = Personalization(to: [emailAddress], subject: "Test Email") - let emailContent = EmailContent(type: "text/plain", value: "This email was sent using SendGridKit!") - let email = SendGridEmail(personalizations: [personalization], from: fromEmailAddress, content: [emailContent]) + + let attachment = EmailAttachment( + content: "Hello, World!".data(using: .utf8)!.base64EncodedString(), + type: "text/plain", + filename: "hello.txt", + disposition: "attachment" + ) + + let emailContent = EmailContent("This email was sent using SendGridKit!") + + let email = SendGridEmail( + personalizations: [personalization], + from: fromEmailAddress, + content: [emailContent], + attachments: [attachment] + ) do { try await client.send(email: email)