Skip to content

Commit

Permalink
Merge branch 'release-0.12.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dnl-blkv committed Oct 11, 2017
2 parents 26823da + 57d2154 commit 0b5b73e
Show file tree
Hide file tree
Showing 190 changed files with 3,679 additions and 2,252 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BunqSdk/Model/Generated linguist-generated=true
BunqSdk/Model/Generated/* linguist-generated=true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,4 @@ bunq.conf
**/Tmp/
bunq-test.conf
config.json
.idea/.idea.BunqSdk/.idea/preferred-vcs.xml
6 changes: 3 additions & 3 deletions BunqSdk.Samples/AttachmentPublicSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using Bunq.Sdk.Context;
using Bunq.Sdk.Http;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Samples.Utils;

namespace Bunq.Sdk.Samples
Expand All @@ -11,8 +11,8 @@ public class AttachmentPublicSample : ISample
{
private const string CONTENT_TYPE_IMAGE_JPEG = "image/jpeg";
private const string DESCRIPTION_TEST_JPG_ATTACHMENT = "A test JPG attachment.";
private const string PATH_ATTACHMENT_IN = "Samples/Assets/Attachment.jpg";
private const string PATH_ATTACHMENT_OUT = "Samples/Tmp/AttachmentOut.jpg";
private const string PATH_ATTACHMENT_IN = "Assets/Attachment.jpg";
private const string PATH_ATTACHMENT_OUT = "Tmp/AttachmentOut.jpg";

public void Run()
{
Expand Down
2 changes: 1 addition & 1 deletion BunqSdk.Samples/CardDebitSample.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Bunq.Sdk.Samples.Utils;

Expand Down
2 changes: 1 addition & 1 deletion BunqSdk.Samples/CustomerStatementExportSample.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Samples.Utils;

namespace Bunq.Sdk.Samples
Expand Down
2 changes: 1 addition & 1 deletion BunqSdk.Samples/MonetaryAccountSample.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Samples.Utils;

namespace Bunq.Sdk.Samples
Expand Down
2 changes: 1 addition & 1 deletion BunqSdk.Samples/PaymentBatchSample.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Bunq.Sdk.Samples.Utils;

Expand Down
2 changes: 1 addition & 1 deletion BunqSdk.Samples/PaymentListSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Http;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Samples.Utils;

namespace Bunq.Sdk.Samples
Expand Down
6 changes: 5 additions & 1 deletion BunqSdk.Samples/PaymentSample.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Bunq.Sdk.Samples.Utils;

Expand Down Expand Up @@ -33,6 +33,10 @@ public void Run()
var paymentId = Payment.Create(apiContext, paymentMap, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID).Value;

Console.WriteLine(Payment.Get(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, paymentId));

// Save the API context to account for all the changes that might have occurred to it
// during the sample execution
apiContext.Save();
}
}
}
2 changes: 1 addition & 1 deletion BunqSdk.Samples/RequestSample.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Bunq.Sdk.Samples.Utils;

Expand Down
2 changes: 1 addition & 1 deletion BunqSdk.Samples/UserListSample.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Samples.Utils;

namespace Bunq.Sdk.Samples
Expand Down
8 changes: 2 additions & 6 deletions BunqSdk.Tests/BunqSdkTestBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Exception;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;

namespace Bunq.Sdk.Tests
{
Expand Down Expand Up @@ -36,17 +36,13 @@ protected static ApiContext GetApiContext()
try
{
apiContext = ApiContext.Restore(FILENAME_CONTEXT_CONF);
User.List(apiContext);
}
catch (BunqException)
{
apiContext = CreateApiContext();
}
catch (ApiException)
{
apiContext = CreateApiContext();
}

apiContext.EnsureSessionActive();
apiContext.Save(FILENAME_CONTEXT_CONF);

return apiContext;
Expand Down
3 changes: 1 addition & 2 deletions BunqSdk.Tests/Config.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Immutable;
using System.IO;
using System.IO;
using Bunq.Sdk.Model.Generated.Object;
using Newtonsoft.Json.Linq;

Expand Down
2 changes: 1 addition & 1 deletion BunqSdk.Tests/Http/PaginationScenarioTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Bunq.Sdk.Context;
using Bunq.Sdk.Http;
using Bunq.Sdk.Json;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System.IO;
using Bunq.Sdk.Context;
using Bunq.Sdk.Http;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Xunit;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System.IO;
using Bunq.Sdk.Context;
using Bunq.Sdk.Http;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Xunit;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Xunit;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using System.Collections.Generic;
using System.IO;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Xunit;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Xunit;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Xunit;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Xunit;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Xunit;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using System;
using System.IO;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated.Endpoint;
using Xunit;
using Xunit.Sdk;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
/// Session
/// </summary>
public class SessionTest : BunqSdkTestBase
{
/// <summary>
/// Name of the context configuration file.
/// </summary>
private const string FILENAME_CONTEXT_CONF = "../../../bunq-test.conf";

/// <summary>
/// Config values.
/// </summary>
Expand All @@ -29,6 +37,8 @@ public class SessionTest : BunqSdkTestBase
public void TestSessionDeletion()
{
Session.Delete(API_CONTEXT, SESSION_ID_DUMMY);

File.Delete(FILENAME_CONTEXT_CONF);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using Bunq.Sdk.Context;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Model.Generated.Object;
using Xunit;

namespace Bunq.Sdk.Tests.Model.Generated
namespace Bunq.Sdk.Tests.Model.Generated.Endpoint
{
/// <summary>
/// Tests:
Expand Down
2 changes: 1 addition & 1 deletion BunqSdk/BunqSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageId>Bunq.Sdk</PackageId>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>0.11.0.0</VersionPrefix>
<VersionPrefix>0.12.0.0</VersionPrefix>
<VersionSuffix>beta</VersionSuffix>
</PropertyGroup>
<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions BunqSdk/Context/ApiContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System.Text;
using Bunq.Sdk.Exception;
using Bunq.Sdk.Json;
using Bunq.Sdk.Model;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Model.Core;
using Bunq.Sdk.Model.Generated.Endpoint;
using Bunq.Sdk.Security;
using Newtonsoft.Json;

Expand Down
2 changes: 1 addition & 1 deletion BunqSdk/Context/InstallationContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Security.Cryptography;
using Bunq.Sdk.Model;
using Bunq.Sdk.Model.Core;
using Bunq.Sdk.Security;

namespace Bunq.Sdk.Context
Expand Down
2 changes: 1 addition & 1 deletion BunqSdk/Context/SessionContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Bunq.Sdk.Model;
using Bunq.Sdk.Model.Core;
using Newtonsoft.Json;

namespace Bunq.Sdk.Context
Expand Down
25 changes: 4 additions & 21 deletions BunqSdk/Exception/ApiException.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
using System.Collections.Generic;


namespace Bunq.Sdk.Exception
{
/// <summary>
/// Exception triggered by API requests failed on the server side.
/// </summary>
public class ApiException : System.Exception
{
/// <summary>
/// Glue to concatenate the error messages.
/// </summary>
private const string GLUE_ERROR_MESSAGES = "\n";

public int ResponseCode { get; private set; }
public IList<string> Messages { get; private set; }

/// <param name="responseCode">The HTTP Response code of the failed request.</param>
/// <param name="messages">The list of messages related to this exception.</param>
public ApiException(int responseCode, IList<string> messages) : base(
ConcatenateMessages(messages))
/// <param name="message">The error message related to this exception.</param>
public ApiException(int responseCode, string message) : base(message)
{
ResponseCode = responseCode;
Messages = messages;
}

private static string ConcatenateMessages(IEnumerable<string> messages)
{
return string.Join(GLUE_ERROR_MESSAGES, messages);
}
}
}
}
9 changes: 9 additions & 0 deletions BunqSdk/Exception/BadRequestException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Bunq.Sdk.Exception
{
public class BadRequestException : ApiException
{
public BadRequestException(int responseCode, string message) : base(responseCode, message)
{
}
}
}
Loading

0 comments on commit 0b5b73e

Please sign in to comment.