Skip to content

Commit

Permalink
Deprecated ablyrest#Request method, refactored to RequestV2 method
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Sep 27, 2023
1 parent 5a196b2 commit e0f018c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/IO.Ably.Shared/AblyRest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ internal async Task<HttpPaginatedResponse> HttpPaginatedRequestInternal(Paginate
return await ExecuteHttpPaginatedRequest(request, requestParams, HttpPaginatedRequestInternal);
}

[Obsolete("Use RequestV2 instead")]
public async Task<HttpPaginatedResponse> Request(string method, string path, Dictionary<string, string> requestParams = null, JToken body = null, Dictionary<string, string> headers = null)

Check failure on line 312 in src/IO.Ably.Shared/AblyRest.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 312 in src/IO.Ably.Shared/AblyRest.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 312 in src/IO.Ably.Shared/AblyRest.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

Check failure on line 312 in src/IO.Ably.Shared/AblyRest.cs

View workflow job for this annotation

GitHub Actions / check (net7.0)

Check failure on line 312 in src/IO.Ably.Shared/AblyRest.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

Check failure on line 312 in src/IO.Ably.Shared/AblyRest.cs

View workflow job for this annotation

GitHub Actions / check (net6.0)

{
var httpMethod = new HttpMethod(method);
return await Request(httpMethod, path, requestParams, body, headers);
}

/// <summary>
/// Make a generic HTTP request against an endpoint representing a collection
/// of some type; this is to provide a forward compatibility path for new APIs.
Expand All @@ -318,7 +325,7 @@ internal async Task<HttpPaginatedResponse> HttpPaginatedRequestInternal(Paginate
/// <param name="body">(optional; may be null): a json string RequestBody. It will be sent as a json object.</param>
/// <param name="headers">(optional; may be null): any additional headers to send; see API-specific documentation.</param>
/// <returns>a page of results.</returns>
public async Task<HttpPaginatedResponse> Request(string method, string path, Dictionary<string, string> requestParams = null, string body = null, Dictionary<string, string> headers = null)
public async Task<HttpPaginatedResponse> RequestV2(string method, string path, Dictionary<string, string> requestParams = null, string body = null, Dictionary<string, string> headers = null)
{
var httpMethod = new HttpMethod(method);
JToken requestBody = null;
Expand Down
10 changes: 5 additions & 5 deletions src/IO.Ably.Tests.Shared/Rest/RequestSandBoxSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public async Task Request_ShouldAcceptCorrectHttpVerbs(Protocol protocol)
mockHttp.When(new HttpMethod(verb), "https://localhost/*").Respond(HttpStatusCode.OK, "application/json", "{ \"verb\": \"" + verb + "\" }");
client.HttpClient.Client = mockHttp.ToHttpClient();

var response = await client.Request(verb, "/");
var response = await client.RequestV2(verb, "/");
response.Success.Should().BeTrue($"'{verb}' verb should be supported ");
response.StatusCode.Should().Be(HttpStatusCode.OK);
response.Items.First()["verb"].ToString().Should().Be(verb);

var failedResponse = await client.Request("INVALID_HTTP_VERB", "/");
var failedResponse = await client.RequestV2("INVALID_HTTP_VERB", "/");
failedResponse.Success.Should().BeFalse($"'INVALID_HTTP_VERB' should fail because '{verb}' verb is expected by mock HTTP server.");
}
}
Expand All @@ -100,7 +100,7 @@ public async Task Request_SimpleGet(Protocol protocol)
var testParams = new Dictionary<string, string> { { "testParams", "testParamValue" } };
var testHeaders = new Dictionary<string, string> { { "X-Test-Header", "testHeaderValue" } };

var paginatedResponse = await client.Request(HttpMethod.Get.Method, _channelPath, testParams, null, testHeaders);
var paginatedResponse = await client.RequestV2(HttpMethod.Get.Method, _channelPath, testParams, null, testHeaders);

_lastRequest.Headers.Should().ContainKey("Authorization");
_lastRequest.Headers.Should().ContainKey("X-Test-Header");
Expand Down Expand Up @@ -190,7 +190,7 @@ await ValidateMessages(channel, (message, messageIndex) =>
}
]
}";
paginatedResponse = await client.Request(HttpMethod.Post.Method, "/messages", null, jsonPayload, null);
paginatedResponse = await client.RequestV2(HttpMethod.Post.Method, "/messages", null, jsonPayload, null);

ValidateResponse(paginatedResponse, 5);

Expand Down Expand Up @@ -375,7 +375,7 @@ public async Task RequestFails_Non200StatusResponseShouldNotRaiseException(Proto
}));

client.HttpClient.SetPreferredHost("echo.ably.io/respondwith?status=400");
var response = await client.Request(HttpMethod.Post.Method, "/");
var response = await client.RequestV2(HttpMethod.Post.Method, "/");
response.Success.Should().BeFalse();
response.StatusCode.Should().Be(HttpStatusCode.BadRequest);

Expand Down

0 comments on commit e0f018c

Please sign in to comment.