From 9f980286f71568537d029d5f75aa96250db22f43 Mon Sep 17 00:00:00 2001 From: Akshay Kumar Date: Mon, 13 Mar 2023 11:13:44 +0530 Subject: [PATCH] Add PATCH & DELETE request extensions. --- src/RestSharp/RestClient.Extensions.cs | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/RestSharp/RestClient.Extensions.cs b/src/RestSharp/RestClient.Extensions.cs index 1ed035160..0502fc91c 100644 --- a/src/RestSharp/RestClient.Extensions.cs +++ b/src/RestSharp/RestClient.Extensions.cs @@ -82,6 +82,56 @@ public static Task> ExecutePutAsync( ) => client.ExecuteAsync(request, Method.Put, cancellationToken); + /// + /// Executes a PATCH-style request asynchronously, authenticating if needed. + /// The response content then gets deserialized to T. + /// + /// Target deserialization type + /// + /// Request to be executed + /// The cancellation token + /// Deserialized response content + public static Task> ExecutePatchAsync( + this RestClient client, + RestRequest request, + CancellationToken cancellationToken = default + ) + => client.ExecuteAsync(request, Method.Patch, cancellationToken); + + /// + /// Executes a PATCH-style asynchronously, authenticating if needed + /// + /// + /// Request to be executed + /// Cancellation token + public static Task ExecutePatchAsync(this RestClient client, RestRequest request, CancellationToken cancellationToken = default) + => client.ExecuteAsync(request, Method.Patch, cancellationToken); + + /// + /// Executes a DELETE-style asynchronously, authenticating if needed + /// + /// + /// Request to be executed + /// Cancellation token + public static Task ExecuteDeleteAsync(this RestClient client, RestRequest request, CancellationToken cancellationToken = default) + => client.ExecuteAsync(request, Method.Delete, cancellationToken); + + /// + /// Executes a DELETE-style request asynchronously, authenticating if needed. + /// The response content then gets deserialized to T. + /// + /// Target deserialization type + /// + /// Request to be executed + /// The cancellation token + /// Deserialized response content + public static Task> ExecuteDeleteAsync( + this RestClient client, + RestRequest request, + CancellationToken cancellationToken = default + ) + => client.ExecuteAsync(request, Method.Delete, cancellationToken); + /// /// Executes a PUP-style asynchronously, authenticating if needed ///