Skip to content

Commit

Permalink
Add QueriesRemaining and FundsRemaining
Browse files Browse the repository at this point in the history
Remove CreditsRemaining
  • Loading branch information
oschwald committed Jun 3, 2016
1 parent 28d8a0d commit 5b7e0e7
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 19 deletions.
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
[Bb]in/
[Oo]bj/

# dotnet CLI stuff
.dotnetcli/
scripts/

# mstest test results
TestResults

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# Visual Studo 2015 cache/options directory
.vs/

# User-specific files
*.suo
*.user
Expand Down Expand Up @@ -81,6 +88,7 @@ publish

# NuGet Packages Directory
packages
*.lock.json

# Windows Azure Build Output
csx
Expand All @@ -89,9 +97,14 @@ csx
# Windows Store app package directory
AppPackages/

# Idea
.idea
*.iml

# Others
[Bb]in
[Oo]bj
artifacts
sql
TestResults
[Tt]est[Rr]esult*
Expand All @@ -100,6 +113,7 @@ ClientBin
[Ss]tyle[Cc]op.*
~$*
*.dbmdl
*.sw?
Generated_Code #added for RIA/Silverlight projects

# Backup & report files from converting an old project file to a newer
Expand All @@ -110,4 +124,3 @@ UpgradeLog*.XML

.gh-pages
.doxygen.conf

11 changes: 8 additions & 3 deletions MaxMind.MinFraud.UnitTest/Response/InsightsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public void TestInsights()
{"shipping_address", new JObject {{"is_in_ip_country", true}}},
{"billing_address", new JObject {{"is_in_ip_country", true}}},
{
"credits_remaining",
"funds_remaining",
1.20
},
{
"queries_remaining",
123
},
{
Expand All @@ -37,9 +41,10 @@ public void TestInsights()
Assert.IsTrue(insights.ShippingAddress.IsInIPCountry);
Assert.IsTrue(insights.BillingAddress.IsInIPCountry);
Assert.AreEqual(id, insights.Id.ToString());
Assert.AreEqual(123, insights.CreditsRemaining);
Assert.AreEqual(1.20, insights.FundsRemaining);
Assert.AreEqual(123, insights.QueriesRemaining);
Assert.AreEqual(0.01, insights.RiskScore);
Assert.AreEqual("INVALID_INPUT", insights.Warnings[0].Code);
}
}
}
}
8 changes: 5 additions & 3 deletions MaxMind.MinFraud.UnitTest/Response/ScoreTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ public void TestScore()
var score = new JObject
{
{"id", id},
{"credits_remaining", 123},
{"funds_remaining", 1.20},
{"queries_remaining", 123},
{"ip_address", new JObject { { "risk", 0.01} } },
{"risk_score", 0.01},
{"warnings", new JArray {new JObject {{"code", "INVALID_INPUT"}}}}
}.ToObject<Score>();

Assert.AreEqual(id, score.Id.ToString());
Assert.AreEqual(123, score.CreditsRemaining);
Assert.AreEqual(1.20, score.FundsRemaining);
Assert.AreEqual(123, score.QueriesRemaining);
Assert.AreEqual(0.01, score.IPAddress.Risk);
Assert.AreEqual(0.01, score.RiskScore);
Assert.AreEqual("INVALID_INPUT", score.Warnings[0].Code);
}
}
}
}
3 changes: 2 additions & 1 deletion MaxMind.MinFraud.UnitTest/TestData/factors-response.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"id": "27d26476-e2bc-11e4-92b8-962e705b4af5",
"risk_score": 0.01,
"credits_remaining": 1000,
"funds_remaining": 10.01,
"queries_remaining": 1000,
"ip_address": {
"risk": 0.01,
"city": {
Expand Down
5 changes: 3 additions & 2 deletions MaxMind.MinFraud.UnitTest/TestData/insights-response.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"id": "27d26476-e2bc-11e4-92b8-962e705b4af5",
"risk_score": 0.01,
"credits_remaining": 1000,
"funds_remaining": 10.01,
"queries_remaining": 1000,
"ip_address": {
"risk": 0.01,
"city": {
Expand Down Expand Up @@ -137,4 +138,4 @@
"warning": "Encountered value at \/account\/username_md5 that does meet the required constraints"
}
]
}
}
5 changes: 3 additions & 2 deletions MaxMind.MinFraud.UnitTest/TestData/score-response.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"risk_score": 0.01,
"id": "27d26476-e2bc-11e4-92b8-962e705b4af5",
"credits_remaining": 1000,
"funds_remaining": 10.01,
"queries_remaining": 1000,
"ip_address": {
"risk": 99.0
},
Expand All @@ -17,4 +18,4 @@
"warning": "Encountered value at \/account\/username_md5 that does meet the required constraints"
}
]
}
}
19 changes: 13 additions & 6 deletions MaxMind.MinFraud/Response/Score.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class Score
private List<Warning> _warnings = new List<Warning>();

/// <summary>
/// The approximate number of service credits remaining on your
/// account.
/// The approximate US dollar value of the funds remaining on your
/// MaxMind account.
/// </summary>
[JsonProperty("credits_remaining")]
public long? CreditsRemaining { get; internal set; }
[JsonProperty("funds_remaining")]
public decimal? FundsRemaining { get; internal set; }

/// <summary>
/// This is a UUID that identifies the minFraud request. Please use
Expand All @@ -34,6 +34,13 @@ public class Score
[JsonProperty("ip_address")]
public IIPAddress IPAddress { get; internal set; } = new ScoreIPAddress();

/// <summary>
/// The approximate number of queries remaining for this service
/// before your account runs out of funds.
/// </summary>
[JsonProperty("queries_remaining")]
public long? QueriesRemaining { get; internal set; }

/// <summary>
/// This property contains the risk score, from 0.01 to 99. A
/// higher score indicates a higher risk of fraud.For example, a score of 20
Expand All @@ -60,7 +67,7 @@ public class Score
public override string ToString()
{
var warnings = string.Join("; ", Warnings.Select(x => x.Message));
return $"Warnings: [{warnings}], CreditsRemaining: {CreditsRemaining}, Id: {Id}, RiskScore: {RiskScore}";
return $"Warnings: [{warnings}], FundsRemaining: {FundsRemaining}, Id: {Id}, QueriesRemaining: {QueriesRemaining}, RiskScore: {RiskScore}";
}
}
}
}
10 changes: 9 additions & 1 deletion releasenotes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Release Notes
=============

0.6.0 (2016-XX-XX)
------------------

* BREAKING CHANGE: `CreditsRemaining` has been removed from the web service
models and has been replaced by `QueriesRemaining`.
* Added `QueriesRemaining` and `FundsRemaining`. Note that `FundsRemaining`
will not be returned by the web service until our new credit system is in
place.

0.5.0 (2016-05-23)
------------------

Expand All @@ -13,7 +22,6 @@ Release Notes
`Ccnow`, `Dalpay`, `Epay` (replaces `Epayeu`), `Payplus`, `Pinpayments`,
`Quickpay`, and `Verepay`.


0.4.0-beta2 (2016-01-29)
------------------------

Expand Down

0 comments on commit 5b7e0e7

Please sign in to comment.