From b1acd722cec07bddb4b14d09d25ecdc9baeb5d8f Mon Sep 17 00:00:00 2001 From: alexandrumatei Date: Tue, 5 Nov 2024 14:58:07 +0200 Subject: [PATCH 1/2] (version_upgrade) Upgrades RestSharp from v107.3.0 to v112.1.0. Changes in ISerializer members and RestClient's serializer declaration --- MangoPay.SDK.Tests/MangoPay.SDK.Tests.csproj | 2 +- MangoPay.SDK/Core/MangoPayJsonSerializer.cs | 3 ++- MangoPay.SDK/Core/RestTool.cs | 15 +++++++-------- MangoPay.SDK/MangoPay.SDK.csproj | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/MangoPay.SDK.Tests/MangoPay.SDK.Tests.csproj b/MangoPay.SDK.Tests/MangoPay.SDK.Tests.csproj index de6d686..155afb7 100644 --- a/MangoPay.SDK.Tests/MangoPay.SDK.Tests.csproj +++ b/MangoPay.SDK.Tests/MangoPay.SDK.Tests.csproj @@ -22,7 +22,7 @@ - + diff --git a/MangoPay.SDK/Core/MangoPayJsonSerializer.cs b/MangoPay.SDK/Core/MangoPayJsonSerializer.cs index 1e7af32..b5cec77 100644 --- a/MangoPay.SDK/Core/MangoPayJsonSerializer.cs +++ b/MangoPay.SDK/Core/MangoPayJsonSerializer.cs @@ -1,11 +1,12 @@ using Newtonsoft.Json; +using RestSharp; using RestSharp.Serializers; namespace MangoPay.SDK.Core { public sealed class MangoPayJsonSerializer : ISerializer { - public string ContentType { get; set; } + public ContentType ContentType { get; set; } public string Serialize(object obj) { diff --git a/MangoPay.SDK/Core/RestTool.cs b/MangoPay.SDK/Core/RestTool.cs index 975016e..6e8d4d2 100644 --- a/MangoPay.SDK/Core/RestTool.cs +++ b/MangoPay.SDK/Core/RestTool.cs @@ -1,11 +1,11 @@ -using Common.Logging; -using MangoPay.SDK.Entities; -using RestSharp; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Threading.Tasks; +using Common.Logging; +using MangoPay.SDK.Entities; +using RestSharp; namespace MangoPay.SDK.Core { @@ -24,11 +24,10 @@ private RestSharpDto(string url, int timeout) _options = new RestClientOptions(url) { ThrowOnAnyError = false, - Timeout = timeout + Timeout = new TimeSpan(timeout) }; - Client = new RestClient(_options); - Client.UseSerializer(); + Client = new RestClient(_options, configureSerialization: s => s.UseSerializer(() => new MangoPaySerializer())); } public static RestSharpDto GetInstance(string url, int timeout) @@ -140,7 +139,7 @@ private void CheckResponseCode(RestResponse restResponse) if (restResponse.ResponseStatus == ResponseStatus.TimedOut) throw new TimeoutException(restResponse.ErrorMessage); - if (restResponse.ErrorException is System.Net.ProtocolViolationException) + if (restResponse.ErrorException is ProtocolViolationException) throw restResponse.ErrorException; throw new ResponseException(restResponse.Content, responseCode); diff --git a/MangoPay.SDK/MangoPay.SDK.csproj b/MangoPay.SDK/MangoPay.SDK.csproj index 579a4d9..c08456a 100644 --- a/MangoPay.SDK/MangoPay.SDK.csproj +++ b/MangoPay.SDK/MangoPay.SDK.csproj @@ -21,7 +21,7 @@ - + From 75afc9256adb1577915fed279d257d7c547a5c31 Mon Sep 17 00:00:00 2001 From: alexandrumatei Date: Fri, 8 Nov 2024 15:01:44 +0200 Subject: [PATCH 2/2] Modifies timeout according to milliseconds --- MangoPay.SDK/Core/RestTool.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MangoPay.SDK/Core/RestTool.cs b/MangoPay.SDK/Core/RestTool.cs index 6e8d4d2..25e4e32 100644 --- a/MangoPay.SDK/Core/RestTool.cs +++ b/MangoPay.SDK/Core/RestTool.cs @@ -19,12 +19,13 @@ public class RestSharpDto public RestClient Client { get; } + // options need timout in milliseconds private RestSharpDto(string url, int timeout) { _options = new RestClientOptions(url) { ThrowOnAnyError = false, - Timeout = new TimeSpan(timeout) + Timeout = new TimeSpan(timeout * 1000L) }; Client = new RestClient(_options, configureSerialization: s => s.UseSerializer(() => new MangoPaySerializer()));