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)