Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DigitalOcean.API.Tests/Clients/DropletsClientTest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using DigitalOcean.API.Clients;
using DigitalOcean.API.Http;
using DigitalOcean.API.Models.Responses;
using NSubstitute;
using RestSharp;
using Xunit;
using Action = DigitalOcean.API.Models.Responses.Action;

namespace DigitalOcean.API.Tests.Clients {
public class DropletsClientTest {
Expand Down Expand Up @@ -140,6 +142,7 @@ public void CorrectRequestForDeleteByTag() {
}

[Fact]
[Obsolete]
public void CorrectRequestForListDropletNeighbors() {
var factory = Substitute.For<IConnection>();
var client = new DropletsClient(factory);
Expand Down
4 changes: 2 additions & 2 deletions DigitalOcean.API/DigitalOcean.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<ItemGroup>
<None Include="icon.png" Pack="true" Visible="false" PackagePath="" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="110.2.0" />
<PackageReference Include="RestSharp" Version="112.1.0" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="112.1.0" />
</ItemGroup>
</Project>
2 changes: 0 additions & 2 deletions DigitalOcean.API/Extensions/RestSharpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static async Task<T> ExecuteTask<T>(this IRestClient client, RestRequest

public static async Task<RestResponse> ExecuteTaskRaw(this IRestClient client, RestRequest request) {
var ret = await GetResponseContentAsync(client, request);
request.OnBeforeDeserialization(ret);
return ret.ThrowIfException();
}

Expand Down Expand Up @@ -50,7 +49,6 @@ private static Task<RestResponse> GetResponseContentAsync(IRestClient theClient,
}

public static T Deserialize<T>(this RestResponse response) {
response.Request.OnBeforeDeserialization(response);
try {
var parsedJson = (JObject)JsonConvert.DeserializeObject(response.Content);
return JsonDeserializationHelper.DeserializeWithRootElementName<T>(parsedJson, response.Request.RootElement);
Expand Down
7 changes: 6 additions & 1 deletion DigitalOcean.API/Http/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Interceptors;

namespace DigitalOcean.API.Http {
public class Connection : IConnection {
Expand Down Expand Up @@ -96,7 +97,11 @@ public async Task<IReadOnlyList<T>> GetPaginated<T>(string endpoint, IList<Param

private RestRequest BuildRequest(string endpoint, IEnumerable<Parameter> parameters) {
var request = new RestRequest(endpoint) {
OnBeforeDeserialization = r => { Rates = new RateLimit(r.Headers); }
Interceptors = new List<Interceptor>() {
new CompatibilityInterceptor() {
OnBeforeDeserialization = r => { Rates = new RateLimit(r.Headers); }
}
}
};

if (parameters == null) {
Expand Down