From 2498f37a903f823110ac276fd5df3d51f834683e Mon Sep 17 00:00:00 2001 From: Melvin Gundlach Date: Tue, 15 Nov 2022 13:47:00 +0100 Subject: [PATCH 1/3] Update SendGridKit to version 2.0.1 --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 6e00f3a..dbe2c9f 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"), - .package(url: "https://github.com/vapor-community/sendgrid-kit.git", from: "1.0.0"), + .package(url: "https://github.com/vapor-community/sendgrid-kit.git", from: "2.0.1"), ], targets: [ .target(name: "SendGrid", dependencies: [ From 005c4e8eb446084ac4885c32b09f9175d3897265 Mon Sep 17 00:00:00 2001 From: Melvin Gundlach Date: Mon, 26 Jun 2023 15:53:42 +0200 Subject: [PATCH 2/3] Update SendGridKit to version 2.0.2 --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index dbe2c9f..4de3fe8 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"), - .package(url: "https://github.com/vapor-community/sendgrid-kit.git", from: "2.0.1"), + .package(url: "https://github.com/vapor-community/sendgrid-kit.git", from: "2.0.2"), ], targets: [ .target(name: "SendGrid", dependencies: [ From f2d16e2fb856095948c132bbbceff2ec85809cad Mon Sep 17 00:00:00 2001 From: Melvin Gundlach Date: Mon, 26 Jun 2023 16:39:54 +0200 Subject: [PATCH 3/3] Update README for async/await --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6e99722..71242d2 100644 --- a/README.md +++ b/README.md @@ -46,19 +46,17 @@ import SendGrid let email = SendGridEmail(…) -return req.application.sendgrid.client.send([email], on: req.eventLoop) +try await req.application.sendgrid.client.send(email) ~~~~ ## Error handling -If the request to the API failed for any reason a `SendGridError` is the result -of the future, and has an `errors` property that contains an array of errors -returned by the API: + +If the request to the API failed for any reason a `SendGridError` is thrown and has an `errors` property that contains an array of errors returned by the API: ~~~~swift -return req.application.sendgrid.client.send([email], on: req.eventLoop).flatMapError { error in - if let sendgridError = error as? SendGridError { - req.logger.error("\(error)") - } - // ... +do { + try await req.application.sendgrid.client.send(email) +} catch let error as SendGridError { + req.logger.error("\(error)") } ~~~~