Skip to content

Commit 1d89dbd

Browse files
Pull request #11: Feature/EOA-2063 Update functionality
Merge in SDK/csharp_telesign from feature/EOA-2063-Update-functionality to developer * commit 'da05666685d86cba875ddd9faf16781a4be39023': updated the release.md and version Added Patch method in RestClient
2 parents d0576e8 + da05666 commit 1d89dbd

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.6.0
2+
- Added PATCH method to RestClient.cs file
3+
- Updated version in the Telesign.csproj
4+
15
2.5.0
26
- Added tracking to requests
37
- Updated instructions in README file to install this SDK by default using the latest version.

Telesign/RestClient.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

Telesign/Telesign.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<Nullable>disable</Nullable>
1717
<PackageIcon>nuget_icon.png</PackageIcon>
1818
<PackageReadmeFile>README.md</PackageReadmeFile>
19-
<Version>2.5.0</Version>
19+
<Version>2.6.0</Version>
2020
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2121
</PropertyGroup>
2222

0 commit comments

Comments
 (0)