@@ -20,6 +20,8 @@ namespace Telesign
2020 public class RestClient : IDisposable
2121 {
2222 public static readonly string sdkVersion = System . Reflection . Assembly . GetCallingAssembly ( ) . GetName ( ) . Version . ToString ( ) ;
23+ public static readonly HttpMethod PatchMethod = new HttpMethod ( "PATCH" ) ;
24+
2325 protected string userAgent ;
2426 protected string customerId ;
2527 protected string apiKey ;
@@ -191,7 +193,7 @@ public static Dictionary<string, string> GenerateTelesignHeaders(string customer
191193
192194 if ( contentType == null )
193195 {
194- if ( methodName == "POST" || methodName == "PUT" )
196+ if ( methodName == "POST" || methodName == "PUT" || methodName == "PATCH" )
195197 contentType = "application/x-www-form-urlencoded" ;
196198 else
197199 contentType = "" ;
@@ -344,7 +346,7 @@ private TelesignResponse Execute(string resource, HttpMethod method, Dictionary<
344346
345347 private async Task < TelesignResponse > ExecuteAsync ( string resource , HttpMethod method , Dictionary < string , string > parameters )
346348 {
347- if ( parameters == null )
349+ if ( parameters == null )
348350 parameters = new Dictionary < string , string > ( ) ;
349351
350352 string resourceUri = string . Format ( "{0}{1}" , restEndpoint , resource ) ;
@@ -353,7 +355,7 @@ private async Task<TelesignResponse> ExecuteAsync(string resource, HttpMethod me
353355 string urlEncodedFields = await formBody . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
354356
355357 HttpRequestMessage request ;
356- if ( method == HttpMethod . Post || method == HttpMethod . Put )
358+ if ( method == HttpMethod . Post || method == HttpMethod . Put || method == PatchMethod )
357359 {
358360 request = new HttpRequestMessage ( method , resourceUri )
359361 {
@@ -469,5 +471,28 @@ public Task<TelesignResponse> PostAsync(string resource, Dictionary<string, obje
469471 {
470472 return ExecuteAsync ( resource , HttpMethod . Post , parameters ) ;
471473 }
474+
475+ /// <summary>
476+ /// Generic TeleSign REST API PATCH handler (form-urlencoded).
477+ /// </summary>
478+ /// <param name="resource">The partial resource URI to perform the request against.</param>
479+ /// <param name="parameters">Body params to perform the PATCH request with.</param>
480+ /// <returns>The TelesignResponse for the request.</returns>
481+ public TelesignResponse Patch ( string resource , Dictionary < string , string > parameters )
482+ {
483+ return Execute ( resource , PatchMethod , parameters ) ;
484+ }
485+ public Task < TelesignResponse > PatchAsync ( string resource , Dictionary < string , string > parameters )
486+ {
487+ return ExecuteAsync ( resource , PatchMethod , parameters ) ;
488+ }
489+ public TelesignResponse Patch ( string resource , Dictionary < string , object > parameters )
490+ {
491+ return Execute ( resource , PatchMethod , parameters ) ;
492+ }
493+ public Task < TelesignResponse > PatchAsync ( string resource , Dictionary < string , object > parameters )
494+ {
495+ return ExecuteAsync ( resource , PatchMethod , parameters ) ;
496+ }
472497 }
473- }
498+ }
0 commit comments