From e0f018cae29c7c996a4abd20202dd490c0fe32ad Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Wed, 27 Sep 2023 21:01:45 +0530 Subject: [PATCH] Deprecated ablyrest#Request method, refactored to RequestV2 method --- src/IO.Ably.Shared/AblyRest.cs | 9 ++++++++- src/IO.Ably.Tests.Shared/Rest/RequestSandBoxSpecs.cs | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/IO.Ably.Shared/AblyRest.cs b/src/IO.Ably.Shared/AblyRest.cs index 4b7e74a53..452114685 100644 --- a/src/IO.Ably.Shared/AblyRest.cs +++ b/src/IO.Ably.Shared/AblyRest.cs @@ -308,6 +308,13 @@ internal async Task HttpPaginatedRequestInternal(Paginate return await ExecuteHttpPaginatedRequest(request, requestParams, HttpPaginatedRequestInternal); } + [Obsolete("Use RequestV2 instead")] + public async Task Request(string method, string path, Dictionary requestParams = null, JToken body = null, Dictionary headers = null) + { + var httpMethod = new HttpMethod(method); + return await Request(httpMethod, path, requestParams, body, headers); + } + /// /// 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. @@ -318,7 +325,7 @@ internal async Task HttpPaginatedRequestInternal(Paginate /// (optional; may be null): a json string RequestBody. It will be sent as a json object. /// (optional; may be null): any additional headers to send; see API-specific documentation. /// a page of results. - public async Task Request(string method, string path, Dictionary requestParams = null, string body = null, Dictionary headers = null) + public async Task RequestV2(string method, string path, Dictionary requestParams = null, string body = null, Dictionary headers = null) { var httpMethod = new HttpMethod(method); JToken requestBody = null; diff --git a/src/IO.Ably.Tests.Shared/Rest/RequestSandBoxSpecs.cs b/src/IO.Ably.Tests.Shared/Rest/RequestSandBoxSpecs.cs index 69e714edb..78369caf8 100644 --- a/src/IO.Ably.Tests.Shared/Rest/RequestSandBoxSpecs.cs +++ b/src/IO.Ably.Tests.Shared/Rest/RequestSandBoxSpecs.cs @@ -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."); } } @@ -100,7 +100,7 @@ public async Task Request_SimpleGet(Protocol protocol) var testParams = new Dictionary { { "testParams", "testParamValue" } }; var testHeaders = new Dictionary { { "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"); @@ -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); @@ -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);