From 69063b1ad909ffee9ef17467be47f4d5da3bd620 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2024 13:36:37 +0000 Subject: [PATCH] Bump RestSharp from 108.0.2 to 112.0.0 in /coffeecard/CoffeeCard.Library (#282) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [RestSharp](https://github.com/restsharp/RestSharp) from 108.0.2 to 112.0.0.
Release notes

Sourced from RestSharp's releases.

112.0.0

What's Changed

New Contributors

Full Changelog: https://github.com/restsharp/RestSharp/compare/111.4.1...112.0.0

111.4.1

What's Changed

New Contributors

Full Changelog: https://github.com/restsharp/RestSharp/compare/111.4.0...111.4.1

111.4.0

What's Changed

New Contributors

Full Changelog: https://github.com/restsharp/RestSharp/compare/111.3.0...111.4.0

111.3.0

What's Changed

New Contributors

Full Changelog: https://github.com/restsharp/RestSharp/compare/111.2.0...111.3.0

111.2.0

What's Changed

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=RestSharp&package-manager=nuget&previous-version=108.0.2&new-version=112.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/AnalogIO/analog-core/network/alerts).
--------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andreas Trøstrup --- .../CoffeeCard.Library/CoffeeCard.Library.csproj | 2 +- .../Services/MailgunEmailSender.cs | 16 +++++++++------- coffeecard/CoffeeCard.WebApi/Startup.cs | 12 ++++++++++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/coffeecard/CoffeeCard.Library/CoffeeCard.Library.csproj b/coffeecard/CoffeeCard.Library/CoffeeCard.Library.csproj index afccfeee..a2b42c13 100644 --- a/coffeecard/CoffeeCard.Library/CoffeeCard.Library.csproj +++ b/coffeecard/CoffeeCard.Library/CoffeeCard.Library.csproj @@ -10,7 +10,7 @@ - + diff --git a/coffeecard/CoffeeCard.Library/Services/MailgunEmailSender.cs b/coffeecard/CoffeeCard.Library/Services/MailgunEmailSender.cs index 227b778c..b44d664e 100644 --- a/coffeecard/CoffeeCard.Library/Services/MailgunEmailSender.cs +++ b/coffeecard/CoffeeCard.Library/Services/MailgunEmailSender.cs @@ -7,12 +7,10 @@ namespace CoffeeCard.Library.Services; -public class MailgunEmailSender(MailgunSettings mailgunSettings) : IEmailSender +public class MailgunEmailSender(MailgunSettings mailgunSettings, IRestClient restClient) : IEmailSender { public async Task SendEmailAsync(MimeMessage mail) { - using var client = new RestClient(mailgunSettings.MailgunApiUrl); - client.Authenticator = new HttpBasicAuthenticator("api", mailgunSettings.ApiKey); var request = new RestRequest(); request.AddParameter("domain", mailgunSettings.Domain, ParameterType.UrlSegment); @@ -23,12 +21,16 @@ public async Task SendEmailAsync(MimeMessage mail) request.AddParameter("html", mail.HtmlBody); request.Method = Method.Post; - var response = await client.ExecutePostAsync(request); + var response = await restClient.ExecutePostAsync(request); if (!response.IsSuccessful) { - Log.Error("Error sending request to Mailgun. StatusCode: {statusCode} ErrorMessage: {errorMessage}", - response.StatusCode, response.ErrorMessage); + Log.Error( + "Error sending request to Mailgun. StatusCode: {statusCode} ErrorMessage: {errorMessage}", + response.StatusCode, + response.ErrorMessage + ); } } -} \ No newline at end of file +} + diff --git a/coffeecard/CoffeeCard.WebApi/Startup.cs b/coffeecard/CoffeeCard.WebApi/Startup.cs index e227dc7e..46468c78 100644 --- a/coffeecard/CoffeeCard.WebApi/Startup.cs +++ b/coffeecard/CoffeeCard.WebApi/Startup.cs @@ -31,6 +31,8 @@ using NJsonSchema.Generation; using NSwag; using NSwag.Generation.Processors.Security; +using RestSharp; +using RestSharp.Authenticators; using AccountService = CoffeeCard.Library.Services.AccountService; using IAccountService = CoffeeCard.Library.Services.IAccountService; using IPurchaseService = CoffeeCard.Library.Services.IPurchaseService; @@ -95,6 +97,16 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddSingleton(_environment.ContentRootFileProvider); + services.AddSingleton(provider => + { + var mailgunSettings = provider.GetRequiredService(); + var options = new RestClientOptions(mailgunSettings.MailgunApiUrl) + { + Authenticator = new HttpBasicAuthenticator("api", mailgunSettings.ApiKey), + }; + return new RestClient(options); + }); + services.AddScoped(); services.AddScoped(); services.AddMobilePayHttpClients(_configuration.GetSection("MobilePaySettingsV2").Get());