Skip to content

Commit

Permalink
Merge pull request #2 from maxmind/greg/gift-inputs
Browse files Browse the repository at this point in the history
Add gift inputs
  • Loading branch information
eilara committed Jul 30, 2015
2 parents 2980089 + d2c7f29 commit 6b6e91f
Show file tree
Hide file tree
Showing 36 changed files with 548 additions and 230 deletions.
4 changes: 2 additions & 2 deletions MaxMind.MinFraud.UnitTest/MaxMind.MinFraud.UnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="MaxMind.Db, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.Db.1.1.0-beta1\lib\net40\MaxMind.Db.dll</HintPath>
<HintPath>..\packages\MaxMind.Db.1.1.0\lib\net40\MaxMind.Db.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaxMind.GeoIP2, Version=2.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.GeoIP2.2.3.1-beta1\lib\net40\MaxMind.GeoIP2.dll</HintPath>
<HintPath>..\packages\MaxMind.GeoIP2.2.3.1\lib\net40\MaxMind.GeoIP2.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
Expand Down
23 changes: 18 additions & 5 deletions MaxMind.MinFraud.UnitTest/Request/OrderTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using MaxMind.MinFraud.Exception;
using MaxMind.MinFraud.Exception;
using MaxMind.MinFraud.Request;
using NUnit.Framework;
using System;

namespace MaxMind.MinFraud.UnitTest.Request
{
Expand All @@ -10,8 +10,8 @@ public class OrderTest
[Test]
public void TestAmount()
{
var order = new Order(amount: (decimal) 1.1);
Assert.AreEqual((decimal) 1.1, order.Amount);
var order = new Order(amount: (decimal)1.1);
Assert.AreEqual((decimal)1.1, order.Amount);
}

[Test]
Expand All @@ -33,7 +33,6 @@ public void TestCurrencyThatIsTooShort()
Assert.That(() => new Order(currency: "US"), Throws.TypeOf<ArgumentException>());
}


[Test]
public void TestCurrencyThatIsTooLong()
{
Expand Down Expand Up @@ -74,5 +73,19 @@ public void TestReferrerUri()
var order = new Order(referrerUri: uri);
Assert.AreEqual(uri, order.ReferrerUri);
}

[Test]
public void TestIsGift()
{
var order = new Order(isGift: true);
Assert.AreEqual(order.IsGift, true);
}

[Test]
public void TestHasGiftMessage()
{
var order = new Order(hasGiftMessage: true);
Assert.AreEqual(order.HasGiftMessage, true);
}
}
}
15 changes: 8 additions & 7 deletions MaxMind.MinFraud.UnitTest/Request/TestHelper.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using MaxMind.MinFraud.Request;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Mail;
using MaxMind.MinFraud.Request;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace MaxMind.MinFraud.UnitTest.Request
{
Expand Down Expand Up @@ -85,12 +85,14 @@ public static Transaction CreateFullRequest()
),
order:
new Order(
amount: (decimal) 323.21,
amount: (decimal)323.21,
currency: "USD",
discountCode: "FIRST",
affiliateId: "af12",
subaffiliateId: "saf42",
referrerUri: new Uri("http://www.amazon.com/")
referrerUri: new Uri("http://www.amazon.com/"),
isGift: true,
hasGiftMessage: false
),
shoppingCart: new List<ShoppingCartItem>
{
Expand All @@ -110,7 +112,6 @@ public static Transaction CreateFullRequest()
);
}


public static string ReadJsonFile(string name)
{
return
Expand Down
6 changes: 4 additions & 2 deletions MaxMind.MinFraud.UnitTest/TestData/full-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"discount_code": "FIRST",
"affiliate_id": "af12",
"subaffiliate_id": "saf42",
"referrer_uri": "http://www.amazon.com/"
"referrer_uri": "http://www.amazon.com/",
"is_gift": true,
"has_gift_message": false
},
"shopping_cart": [
{
Expand All @@ -81,4 +83,4 @@
"user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36",
"accept_language": "en-US,en;q=0.8"
}
}
}
4 changes: 2 additions & 2 deletions MaxMind.MinFraud.UnitTest/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MaxMind.Db" version="1.1.0-beta1" targetFramework="net452" />
<package id="MaxMind.GeoIP2" version="2.3.1-beta1" targetFramework="net452" />
<package id="MaxMind.Db" version="1.1.0" targetFramework="net452" />
<package id="MaxMind.GeoIP2" version="2.3.1" targetFramework="net452" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net452" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net452" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net452" />
Expand Down
26 changes: 26 additions & 0 deletions MaxMind.MinFraud/Exception/AuthenticationException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

Expand All @@ -12,12 +13,37 @@ namespace MaxMind.MinFraud.Exception
[Serializable]
public class AuthenticationException : MinFraudException
{
/// <summary>
/// Constructor.
/// </summary>
public AuthenticationException() : base()
{
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">Exception message.</param>
public AuthenticationException(string message) : base(message)
{
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">Exception message.</param>
/// <param name="innerException">The underlying exception that caused this one.</param>
public AuthenticationException(string message, System.Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Initializes a new instance of the exception class with serialized data.
/// </summary>
/// <param name="info">The object that holds the serialized object data.</param>
/// <param name="context">The contextual information about the source or destination.</param>
protected AuthenticationException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
30 changes: 27 additions & 3 deletions MaxMind.MinFraud/Exception/HttpException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@ namespace MaxMind.MinFraud.Exception
[Serializable]
public class HttpException : IOException
{
/// <summary>
/// Constructor.
/// </summary>
public HttpException() : base()
{
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">A message describing the reason why the exception was thrown.</param>
public HttpException(string message) : base(message)
{
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">A message describing the reason why the exception was thrown.</param>
/// <param name="innerException">The underlying exception that caused this one.</param>
public HttpException(string message, System.Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="HttpException" /> class.
/// </summary>
Expand Down Expand Up @@ -51,8 +75,8 @@ public HttpException(string message, HttpStatusCode httpStatus, Uri uri, System.
/// <param name="context">The source for this deserialization.</param>
protected HttpException(SerializationInfo info, StreamingContext context) : base(info, context)
{
HttpStatus = (HttpStatusCode) info.GetValue("HttpStatus", typeof (HttpStatusCode));
this.Uri = (Uri) info.GetValue("Uri", typeof (Uri));
HttpStatus = (HttpStatusCode)info.GetValue("HttpStatus", typeof(HttpStatusCode));
this.Uri = (Uri)info.GetValue("Uri", typeof(Uri));
}

/// <summary>
Expand All @@ -77,4 +101,4 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
info.AddValue("Uri", Uri);
}
}
}
}
26 changes: 26 additions & 0 deletions MaxMind.MinFraud/Exception/InsufficientFundsException.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.Serialization;

namespace MaxMind.MinFraud.Exception
{
Expand All @@ -8,12 +9,37 @@ namespace MaxMind.MinFraud.Exception
[Serializable]
public class InsufficientFundsException : System.Exception
{
/// <summary>
/// Constructor.
/// </summary>
public InsufficientFundsException() : base()
{
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">Exception message.</param>
public InsufficientFundsException(string message) : base(message)
{
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">Exception message.</param>
/// <param name="innerException">The underlying exception that caused this one.</param>
public InsufficientFundsException(string message, System.Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Initializes a new instance of the exception class with serialized data.
/// </summary>
/// <param name="info">The object that holds the serialized object data.</param>
/// <param name="context">The contextual information about the source or destination.</param>
protected InsufficientFundsException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
43 changes: 40 additions & 3 deletions MaxMind.MinFraud/Exception/InvalidRequestException.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#region

using Newtonsoft.Json;
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
using Newtonsoft.Json;

#endregion

Expand All @@ -16,6 +16,30 @@ namespace MaxMind.MinFraud.Exception
[Serializable]
public class InvalidRequestException : MinFraudException
{
/// <summary>
/// Constructor.
/// </summary>
public InvalidRequestException() : base()
{
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">The message from the web service.</param>
public InvalidRequestException(string message) : base(message)
{
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">The message from the web service.</param>
/// <param name="innerException">The underlying exception that caused this one.</param>
public InvalidRequestException(string message, System.Exception innerException) : base(message, innerException)
{
}

/// <summary>
/// Constructor.
/// </summary>
Expand All @@ -28,6 +52,19 @@ public InvalidRequestException(string message, string code, Uri uri) : base(mess
this.Uri = uri;
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="message">The message from the web service.</param>
/// <param name="code">The machine-readable error code.</param>
/// <param name="uri">The URI that was queried.</param>
/// <param name="innerException">The underlying exception that caused this one.</param>
public InvalidRequestException(string message, string code, Uri uri, System.Exception innerException) : base(message, innerException)
{
Code = code;
this.Uri = uri;
}

/// <summary>
/// Constructor for deserialization.
/// </summary>
Expand All @@ -38,7 +75,7 @@ protected InvalidRequestException(SerializationInfo info, StreamingContext conte
: base(info, context)
{
Code = info.GetString("Code");
this.Uri = (Uri) info.GetValue("Uri", typeof (Uri));
this.Uri = (Uri)info.GetValue("Uri", typeof(Uri));
}

/// <summary>
Expand All @@ -65,4 +102,4 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
base.GetObjectData(info, context);
}
}
}
}
9 changes: 8 additions & 1 deletion MaxMind.MinFraud/Exception/MinFraudException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ namespace MaxMind.MinFraud.Exception
[Serializable]
public class MinFraudException : System.Exception
{
/// <summary>
/// Constructor.
/// </summary>
public MinFraudException() : base()
{
}

/// <summary>
/// Constructor.
/// </summary>
Expand All @@ -22,7 +29,7 @@ public MinFraudException(string message) : base(message)
/// Constructor.
/// </summary>
/// <param name="message">Exception message.</param>
/// <param name="innerException">The previous exception.</param>
/// <param name="innerException">The underlying exception that caused this one.</param>
public MinFraudException(string message, System.Exception innerException) : base(message, innerException)
{
}
Expand Down
6 changes: 4 additions & 2 deletions MaxMind.MinFraud/MaxMind.MinFraud.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\MaxMind.MinFraud.xml</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>ExtendedCorrectnessRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="MaxMind.Db, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.Db.1.1.0-beta1\lib\net40\MaxMind.Db.dll</HintPath>
<HintPath>..\packages\MaxMind.Db.1.1.0\lib\net40\MaxMind.Db.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaxMind.GeoIP2, Version=2.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaxMind.GeoIP2.2.3.1-beta1\lib\net40\MaxMind.GeoIP2.dll</HintPath>
<HintPath>..\packages\MaxMind.GeoIP2.2.3.1\lib\net40\MaxMind.GeoIP2.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
Expand Down
Loading

0 comments on commit 6b6e91f

Please sign in to comment.