From 4576e8d64d714783efbc64ff8e7ebf770284dbff Mon Sep 17 00:00:00 2001 From: mroloux Date: Tue, 4 Feb 2020 10:23:34 +0100 Subject: [PATCH] Removed email from subaccount and publicKey from account --- .../Accounts/RetrieveMyAccountTest.cs | 5 +-- .../Subaccounts/CreateSubaccountTest.cs | 32 +------------- .../Subaccounts/ListActiveSubaccountsTest.cs | 2 +- .../Subaccounts/ListAllSubaccountsTest.cs | 2 +- .../ListFirstPageOfSubaccountsTest.cs | 2 +- .../ListPageOfSubaccountsAfterTest.cs | 2 +- .../Subaccounts/UpdateSubaccountTest.cs | 25 ++--------- SeatsioDotNet.Test/TestUser.cs | 11 +++++ SeatsioDotNet/Accounts/Account.cs | 1 - SeatsioDotNet/SeatsioDotNet.csproj | 2 +- SeatsioDotNet/Subaccounts/Subaccount.cs | 1 - SeatsioDotNet/Subaccounts/Subaccounts.cs | 43 ++++++------------- 12 files changed, 35 insertions(+), 93 deletions(-) diff --git a/SeatsioDotNet.Test/Accounts/RetrieveMyAccountTest.cs b/SeatsioDotNet.Test/Accounts/RetrieveMyAccountTest.cs index 94a4c5b..2ce5a26 100644 --- a/SeatsioDotNet.Test/Accounts/RetrieveMyAccountTest.cs +++ b/SeatsioDotNet.Test/Accounts/RetrieveMyAccountTest.cs @@ -12,13 +12,10 @@ public void Test() Assert.NotNull(account.SecretKey); Assert.NotNull(account.DesignerKey); - Assert.NotNull(account.PublicKey); Assert.NotNull(account.Email); Assert.True(account.Settings.DraftChartDrawingsEnabled); Assert.True(account.Settings.HoldOnSelectForGAs); - Assert.Equal(ChartValidationLevel.ERROR, account.Settings.ChartValidation.ValidateDuplicateLabels); - Assert.Equal(ChartValidationLevel.ERROR, account.Settings.ChartValidation.ValidateObjectsWithoutCategories); - Assert.Equal(ChartValidationLevel.ERROR, account.Settings.ChartValidation.ValidateUnlabeledObjects); + Assert.Equal(ChartValidationLevel.OFF, account.Settings.ChartValidation.ValidateDuplicateLabels); } } } \ No newline at end of file diff --git a/SeatsioDotNet.Test/Subaccounts/CreateSubaccountTest.cs b/SeatsioDotNet.Test/Subaccounts/CreateSubaccountTest.cs index 13134d2..4cc830b 100644 --- a/SeatsioDotNet.Test/Subaccounts/CreateSubaccountTest.cs +++ b/SeatsioDotNet.Test/Subaccounts/CreateSubaccountTest.cs @@ -22,37 +22,7 @@ public void NameIsOptional() { var subaccount = Client.Subaccounts.Create(); - 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); - } - - [Fact] - public void TestWithEmailAndName() - { - var email = RandomEmail(); - var subaccount = Client.Subaccounts.CreateWithEmail(email, "jeff"); - - Assert.NotEqual(0, subaccount.Id); - Assert.NotNull(subaccount.SecretKey); - Assert.NotNull(subaccount.DesignerKey); - Assert.NotNull(subaccount.PublicKey); - Assert.Equal("jeff", subaccount.Name); - Assert.True(subaccount.Active); - Assert.Equal(email, subaccount.Email); + Assert.NotNull(subaccount.Name); } } } \ No newline at end of file diff --git a/SeatsioDotNet.Test/Subaccounts/ListActiveSubaccountsTest.cs b/SeatsioDotNet.Test/Subaccounts/ListActiveSubaccountsTest.cs index f43d0a1..621ef9f 100644 --- a/SeatsioDotNet.Test/Subaccounts/ListActiveSubaccountsTest.cs +++ b/SeatsioDotNet.Test/Subaccounts/ListActiveSubaccountsTest.cs @@ -15,7 +15,7 @@ public void Test() var subaccounts = Client.Subaccounts.Active.All(); - Assert.Equal(new[] {subaccount3.Id, subaccount1.Id}, subaccounts.Select(s => s.Id)); + Assert.Equal(new[] {subaccount3.Id, subaccount1.Id, User.MainWorkspace.PrimaryUser.Id}, subaccounts.Select(s => s.Id)); } } } \ No newline at end of file diff --git a/SeatsioDotNet.Test/Subaccounts/ListAllSubaccountsTest.cs b/SeatsioDotNet.Test/Subaccounts/ListAllSubaccountsTest.cs index 0878f76..af9ca39 100644 --- a/SeatsioDotNet.Test/Subaccounts/ListAllSubaccountsTest.cs +++ b/SeatsioDotNet.Test/Subaccounts/ListAllSubaccountsTest.cs @@ -14,7 +14,7 @@ public void Test() var subaccounts = Client.Subaccounts.ListAll(); - Assert.Equal(new[] {subaccount3.Id, subaccount2.Id, subaccount1.Id}, subaccounts.Select(s => s.Id)); + Assert.Equal(new[] {subaccount3.Id, subaccount2.Id, subaccount1.Id, User.MainWorkspace.PrimaryUser.Id}, subaccounts.Select(s => s.Id)); } [Fact] diff --git a/SeatsioDotNet.Test/Subaccounts/ListFirstPageOfSubaccountsTest.cs b/SeatsioDotNet.Test/Subaccounts/ListFirstPageOfSubaccountsTest.cs index ee61e82..a34fcd6 100644 --- a/SeatsioDotNet.Test/Subaccounts/ListFirstPageOfSubaccountsTest.cs +++ b/SeatsioDotNet.Test/Subaccounts/ListFirstPageOfSubaccountsTest.cs @@ -14,7 +14,7 @@ public void AllOnFirstPage() var page = Client.Subaccounts.ListFirstPage(); - Assert.Equal(new[] {subaccount3.Id, subaccount2.Id, subaccount1.Id}, page.Items.Select(s => s.Id)); + Assert.Equal(new[] {subaccount3.Id, subaccount2.Id, subaccount1.Id, User.MainWorkspace.PrimaryUser.Id}, page.Items.Select(s => s.Id)); Assert.Null(page.NextPageStartsAfter); Assert.Null(page.PreviousPageEndsBefore); } diff --git a/SeatsioDotNet.Test/Subaccounts/ListPageOfSubaccountsAfterTest.cs b/SeatsioDotNet.Test/Subaccounts/ListPageOfSubaccountsAfterTest.cs index 6c6cc2a..2bce1a1 100644 --- a/SeatsioDotNet.Test/Subaccounts/ListPageOfSubaccountsAfterTest.cs +++ b/SeatsioDotNet.Test/Subaccounts/ListPageOfSubaccountsAfterTest.cs @@ -14,7 +14,7 @@ public void WithPreviousPage() var page = Client.Subaccounts.ListPageAfter(subaccount3.Id); - Assert.Equal(new[] {subaccount2.Id, subaccount1.Id}, page.Items.Select(s => s.Id)); + Assert.Equal(new[] {subaccount2.Id, subaccount1.Id, User.MainWorkspace.PrimaryUser.Id}, page.Items.Select(s => s.Id)); Assert.Null(page.NextPageStartsAfter); Assert.Equal(subaccount2.Id, page.PreviousPageEndsBefore.Value); } diff --git a/SeatsioDotNet.Test/Subaccounts/UpdateSubaccountTest.cs b/SeatsioDotNet.Test/Subaccounts/UpdateSubaccountTest.cs index d8e79b5..f8c0c69 100644 --- a/SeatsioDotNet.Test/Subaccounts/UpdateSubaccountTest.cs +++ b/SeatsioDotNet.Test/Subaccounts/UpdateSubaccountTest.cs @@ -7,40 +7,23 @@ public class UpdateSubaccountTest : SeatsioClientTest [Fact] public void Test() { - var email = RandomEmail(); var subaccount = Client.Subaccounts.Create("joske"); - - Client.Subaccounts.Update(subaccount.Id, "jefke", email); - - var retrievedSubaccount = Client.Subaccounts.Retrieve(subaccount.Id); - Assert.Equal("jefke", retrievedSubaccount.Name); - Assert.Equal(email, retrievedSubaccount.Email); - } - - [Fact] - public void EmailIsOptional() - { - var email = RandomEmail(); - var subaccount = Client.Subaccounts.CreateWithEmail(email, "joske"); Client.Subaccounts.Update(subaccount.Id, "jefke"); var retrievedSubaccount = Client.Subaccounts.Retrieve(subaccount.Id); Assert.Equal("jefke", retrievedSubaccount.Name); - Assert.Equal(email, retrievedSubaccount.Email); - } - + } + [Fact] public void NameIsOptional() { - var email = RandomEmail(); var subaccount = Client.Subaccounts.Create("joske"); - - Client.Subaccounts.Update(subaccount.Id, email: email); + + Client.Subaccounts.Update(subaccount.Id); var retrievedSubaccount = Client.Subaccounts.Retrieve(subaccount.Id); Assert.Equal("joske", retrievedSubaccount.Name); - Assert.Equal(email, retrievedSubaccount.Email); } } } \ No newline at end of file diff --git a/SeatsioDotNet.Test/TestUser.cs b/SeatsioDotNet.Test/TestUser.cs index ccb7f1e..dc4e899 100644 --- a/SeatsioDotNet.Test/TestUser.cs +++ b/SeatsioDotNet.Test/TestUser.cs @@ -4,5 +4,16 @@ public class TestUser { public string SecretKey { get; set; } public string DesignerKey { get; set; } + public TestUserWorkspace MainWorkspace { get; set; } + } + + public class TestUserWorkspace + { + public TestTechnicalUser PrimaryUser { get; set; } + } + + public class TestTechnicalUser + { + public long Id { get; set; } } } \ No newline at end of file diff --git a/SeatsioDotNet/Accounts/Account.cs b/SeatsioDotNet/Accounts/Account.cs index 4d35413..6c3549e 100644 --- a/SeatsioDotNet/Accounts/Account.cs +++ b/SeatsioDotNet/Accounts/Account.cs @@ -4,7 +4,6 @@ public class Account { public string SecretKey { get; set; } public string DesignerKey { get; set; } - public string PublicKey { get; set; } public string Email { get; set; } public AccountSettings Settings { get; set; } } diff --git a/SeatsioDotNet/SeatsioDotNet.csproj b/SeatsioDotNet/SeatsioDotNet.csproj index cf3a759..a319b91 100644 --- a/SeatsioDotNet/SeatsioDotNet.csproj +++ b/SeatsioDotNet/SeatsioDotNet.csproj @@ -2,7 +2,7 @@ Library true - 66 + 67 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 fbb6327..91dd4ba 100644 --- a/SeatsioDotNet/Subaccounts/Subaccount.cs +++ b/SeatsioDotNet/Subaccounts/Subaccount.cs @@ -9,7 +9,6 @@ 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; } public Workspace workspace { get; set; } } diff --git a/SeatsioDotNet/Subaccounts/Subaccounts.cs b/SeatsioDotNet/Subaccounts/Subaccounts.cs index 781b69c..3833e4f 100644 --- a/SeatsioDotNet/Subaccounts/Subaccounts.cs +++ b/SeatsioDotNet/Subaccounts/Subaccounts.cs @@ -21,22 +21,8 @@ public Subaccounts(RestClient restClient) } public Subaccount Create(string name) - { - return DoCreate(null, name); - } - - public Subaccount CreateWithEmail(string email, string name = null) - { - return DoCreate(email, name); - } - - private Subaccount DoCreate(string email = null, string name = null) { var requestBody = new Dictionary(); - if (email != null) - { - requestBody.Add("email", email); - } if (name != null) { requestBody.Add("name", name); @@ -54,18 +40,14 @@ public Subaccount Retrieve(long id) return AssertOk(_restClient.Execute(restRequest)); } - public void Update(long id, string name = null, string email = null) + public void Update(long id, string name = null) { var requestBody = new Dictionary(); - if (email != null) - { - requestBody.Add("email", email); - } if (name != null) { requestBody.Add("name", name); } - + var restRequest = new RestRequest("/subaccounts/{id}", Method.POST) .AddUrlSegment("id", id) .AddJsonBody(requestBody); @@ -116,10 +98,11 @@ public Chart CopyChartToParent(long id, string chartKey) public Chart CopyChartToSubaccount(long fromId, long toId, string chartKey) { - var restRequest = new RestRequest("/subaccounts/{fromId}/charts/{chartKey}/actions/copy-to/{toId}", Method.POST) - .AddUrlSegment("fromId", fromId) - .AddUrlSegment("chartKey", chartKey) - .AddUrlSegment("toId", toId.ToString()); + var restRequest = + new RestRequest("/subaccounts/{fromId}/charts/{chartKey}/actions/copy-to/{toId}", Method.POST) + .AddUrlSegment("fromId", fromId) + .AddUrlSegment("chartKey", chartKey) + .AddUrlSegment("toId", toId.ToString()); return AssertOk(_restClient.Execute(restRequest)); } @@ -127,7 +110,7 @@ public IEnumerable ListAll() { return List().All(); } - + public IEnumerable ListAll(string filter) { return ParametrizedList().All(SubaccountListParams(filter)); @@ -137,7 +120,7 @@ public Page ListFirstPage(int? pageSize = null) { return List().FirstPage(pageSize: pageSize); } - + public Page ListFirstPage(string filter, int? pageSize = null) { return ParametrizedList().FirstPage(listParams: SubaccountListParams(filter), pageSize: pageSize); @@ -147,7 +130,7 @@ public Page ListPageAfter(long id, int? pageSize = null) { return List().PageAfter(id, pageSize: pageSize); } - + public Page ListPageAfter(long id, string filter, int? pageSize = null) { return ParametrizedList().PageAfter(id, SubaccountListParams(filter), pageSize: pageSize); @@ -157,7 +140,7 @@ public Page ListPageBefore(long id, int? pageSize = null) { return List().PageBefore(id, pageSize: pageSize); } - + public Page ListPageBefore(long id, string filter, int? pageSize = null) { return ParametrizedList().PageBefore(id, SubaccountListParams(filter), pageSize: pageSize); @@ -167,12 +150,12 @@ private Lister List() { return new Lister(new PageFetcher(_restClient, "/subaccounts")); } - + private ParametrizedLister ParametrizedList() { return new ParametrizedLister(new PageFetcher(_restClient, "/subaccounts")); } - + private Dictionary SubaccountListParams(string filter) { var chartListParams = new Dictionary();