From 1dba6f7a2b8bde6fc61a72d28b06e85f1cb787bc Mon Sep 17 00:00:00 2001 From: haneeshv <135820493+haneeshv@users.noreply.github.com> Date: Fri, 20 Oct 2023 17:19:25 +0530 Subject: [PATCH] Updated get user scores API with score_percentiles (#63) --- Sift/Request/ScoreRequest.cs | 6 ++++++ Test/Test.cs | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Sift/Request/ScoreRequest.cs b/Sift/Request/ScoreRequest.cs index 0bbee7b3..71d6091d 100644 --- a/Sift/Request/ScoreRequest.cs +++ b/Sift/Request/ScoreRequest.cs @@ -10,6 +10,7 @@ public class ScoreRequest : SiftRequest public string UserId { get; set; } public List AbuseTypes { get; set; } = new List(); + public bool IncludeScorePercentile { get; set; } public override HttpRequestMessage Request { get @@ -31,6 +32,11 @@ protected override Uri Url url = url.AddQuery("abuse_types", string.Join(",", AbuseTypes)); } + if (IncludeScorePercentile) + { + url = url.AddQuery("fields", "SCORE_PERCENTILES"); + } + return url; } } diff --git a/Test/Test.cs b/Test/Test.cs index 695b46d7..9d4c78f7 100644 --- a/Test/Test.cs +++ b/Test/Test.cs @@ -2590,14 +2590,13 @@ public void TestGetScoreRequest() { UserId = "123", ApiKey = "345", - AbuseTypes = new List() { "payment_abuse", "promotion_abuse" } + AbuseTypes = new List() { "payment_abuse", "promotion_abuse" }, + IncludeScorePercentile = true }; - var url = scoreRequest.Request.RequestUri!.ToString(); - - Assert.Equal("https://api.sift.com/v205/users/123/score?api_key=345&abuse_types=payment_abuse,promotion_abuse", + Assert.Equal("https://api.sift.com/v205/users/123/score?api_key=345&abuse_types=payment_abuse,promotion_abuse&fields=SCORE_PERCENTILES", Uri.UnescapeDataString(scoreRequest.Request.RequestUri!.ToString())); - } + } } }