From e12e9edba8dd78aa73c203a92a56df0589d8d398 Mon Sep 17 00:00:00 2001 From: mroloux Date: Tue, 24 Jul 2018 11:03:20 +0200 Subject: [PATCH] Subaccount can be assigned an e-mail address --- SeatsioDotNet.Test/SeatsioClientTest.cs | 7 ++++++- .../Subaccounts/CreateSubaccountTest.cs | 15 +++++++++++++++ SeatsioDotNet/SeatsioDotNet.csproj | 2 +- SeatsioDotNet/Subaccounts/Subaccount.cs | 1 + SeatsioDotNet/Subaccounts/Subaccounts.cs | 7 +++++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/SeatsioDotNet.Test/SeatsioClientTest.cs b/SeatsioDotNet.Test/SeatsioClientTest.cs index 2c96f3c..029b435 100644 --- a/SeatsioDotNet.Test/SeatsioClientTest.cs +++ b/SeatsioDotNet.Test/SeatsioClientTest.cs @@ -20,13 +20,18 @@ protected SeatsioClientTest() private TestUser CreateTestUser() { var restClient = new RestClient(BaseUrl); - var email = "test" + new Random().Next() + "@seats.io"; + var email = RandomEmail(); var password = "12345678"; var request = new RestRequest("/system/public/users", Method.POST) .AddJsonBody(new {email, password}); return RestUtil.AssertOk(restClient.Execute(request)); } + protected static string RandomEmail() + { + return "test" + new Random().Next() + "@seats.io"; + } + protected string CreateTestChart() { return CreateTestChartFromJson(TestChartJson()); diff --git a/SeatsioDotNet.Test/Subaccounts/CreateSubaccountTest.cs b/SeatsioDotNet.Test/Subaccounts/CreateSubaccountTest.cs index 8542e50..a7e8601 100644 --- a/SeatsioDotNet.Test/Subaccounts/CreateSubaccountTest.cs +++ b/SeatsioDotNet.Test/Subaccounts/CreateSubaccountTest.cs @@ -24,5 +24,20 @@ public void NameIsOptional() Assert.Null(subaccount.Name); } + + [Fact] + public void TestWithEmail() + { + var email = RandomEmail(); + var subaccount = Client.Subaccounts.CreateWithEmail(email); + + Assert.NotEqual(0, subaccount.Id); + Assert.NotNull(subaccount.SecretKey); + Assert.NotNull(subaccount.DesignerKey); + Assert.NotNull(subaccount.PublicKey); + Assert.Null(subaccount.Name); + Assert.True(subaccount.Active); + Assert.Equal(email, subaccount.Email); + } } } \ No newline at end of file diff --git a/SeatsioDotNet/SeatsioDotNet.csproj b/SeatsioDotNet/SeatsioDotNet.csproj index a45887a..3ca9dbe 100644 --- a/SeatsioDotNet/SeatsioDotNet.csproj +++ b/SeatsioDotNet/SeatsioDotNet.csproj @@ -2,7 +2,7 @@ Library true - 29 + 30 mroloux;bverbeken Official Seats.io .NET API client Official Seats.io .NET API client diff --git a/SeatsioDotNet/Subaccounts/Subaccount.cs b/SeatsioDotNet/Subaccounts/Subaccount.cs index 6e05cc2..bf772f7 100644 --- a/SeatsioDotNet/Subaccounts/Subaccount.cs +++ b/SeatsioDotNet/Subaccounts/Subaccount.cs @@ -7,6 +7,7 @@ public class Subaccount public string DesignerKey { get; set; } public string PublicKey { get; set; } public string Name { get; set; } + public string Email { get; set; } public bool Active { get; set; } } } \ No newline at end of file diff --git a/SeatsioDotNet/Subaccounts/Subaccounts.cs b/SeatsioDotNet/Subaccounts/Subaccounts.cs index 3da4a21..a892a5d 100644 --- a/SeatsioDotNet/Subaccounts/Subaccounts.cs +++ b/SeatsioDotNet/Subaccounts/Subaccounts.cs @@ -25,6 +25,13 @@ public Subaccount Create(string name) var restRequest = new RestRequest("/subaccounts", Method.POST) .AddJsonBody(new {name}); return AssertOk(_restClient.Execute(restRequest)); + } + + public Subaccount CreateWithEmail(string email) + { + var restRequest = new RestRequest("/subaccounts", Method.POST) + .AddJsonBody(new {email}); + return AssertOk(_restClient.Execute(restRequest)); } public Subaccount Retrieve(long id)