Skip to content

Commit

Permalink
Updated get user scores API with score_percentiles (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
haneeshv authored Oct 20, 2023
1 parent 05d737d commit 1dba6f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Sift/Request/ScoreRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class ScoreRequest : SiftRequest

public string UserId { get; set; }
public List<String> AbuseTypes { get; set; } = new List<string>();
public bool IncludeScorePercentile { get; set; }

public override HttpRequestMessage Request {
get
Expand All @@ -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;
}
}
Expand Down
9 changes: 4 additions & 5 deletions Test/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2590,14 +2590,13 @@ public void TestGetScoreRequest()
{
UserId = "123",
ApiKey = "345",
AbuseTypes = new List<string>() { "payment_abuse", "promotion_abuse" }
AbuseTypes = new List<string>() { "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()));
}
}
}

}

0 comments on commit 1dba6f7

Please sign in to comment.