Skip to content

Commit

Permalink
Removed email from subaccount and publicKey from account
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Feb 4, 2020
1 parent c62bd37 commit 4576e8d
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 93 deletions.
5 changes: 1 addition & 4 deletions SeatsioDotNet.Test/Accounts/RetrieveMyAccountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
32 changes: 1 addition & 31 deletions SeatsioDotNet.Test/Subaccounts/CreateSubaccountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
2 changes: 1 addition & 1 deletion SeatsioDotNet.Test/Subaccounts/ListAllSubaccountsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
25 changes: 4 additions & 21 deletions SeatsioDotNet.Test/Subaccounts/UpdateSubaccountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
11 changes: 11 additions & 0 deletions SeatsioDotNet.Test/TestUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
1 change: 0 additions & 1 deletion SeatsioDotNet/Accounts/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Expand Down
2 changes: 1 addition & 1 deletion SeatsioDotNet/SeatsioDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<IsPackable>true</IsPackable>
<Version>66</Version>
<Version>67</Version>
<Authors>mroloux;bverbeken</Authors>
<Title>Official Seats.io .NET API client</Title>
<Description>Official Seats.io .NET API client</Description>
Expand Down
1 change: 0 additions & 1 deletion SeatsioDotNet/Subaccounts/Subaccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Expand Down
43 changes: 13 additions & 30 deletions SeatsioDotNet/Subaccounts/Subaccounts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, object>();
if (email != null)
{
requestBody.Add("email", email);
}
if (name != null)
{
requestBody.Add("name", name);
Expand All @@ -54,18 +40,14 @@ public Subaccount Retrieve(long id)
return AssertOk(_restClient.Execute<Subaccount>(restRequest));
}

public void Update(long id, string name = null, string email = null)
public void Update(long id, string name = null)
{
var requestBody = new Dictionary<string, object>();
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);
Expand Down Expand Up @@ -116,18 +98,19 @@ 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<Chart>(restRequest));
}

public IEnumerable<Subaccount> ListAll()
{
return List().All();
}

public IEnumerable<Subaccount> ListAll(string filter)
{
return ParametrizedList().All(SubaccountListParams(filter));
Expand All @@ -137,7 +120,7 @@ public Page<Subaccount> ListFirstPage(int? pageSize = null)
{
return List().FirstPage(pageSize: pageSize);
}

public Page<Subaccount> ListFirstPage(string filter, int? pageSize = null)
{
return ParametrizedList().FirstPage(listParams: SubaccountListParams(filter), pageSize: pageSize);
Expand All @@ -147,7 +130,7 @@ public Page<Subaccount> ListPageAfter(long id, int? pageSize = null)
{
return List().PageAfter(id, pageSize: pageSize);
}

public Page<Subaccount> ListPageAfter(long id, string filter, int? pageSize = null)
{
return ParametrizedList().PageAfter(id, SubaccountListParams(filter), pageSize: pageSize);
Expand All @@ -157,7 +140,7 @@ public Page<Subaccount> ListPageBefore(long id, int? pageSize = null)
{
return List().PageBefore(id, pageSize: pageSize);
}

public Page<Subaccount> ListPageBefore(long id, string filter, int? pageSize = null)
{
return ParametrizedList().PageBefore(id, SubaccountListParams(filter), pageSize: pageSize);
Expand All @@ -167,12 +150,12 @@ private Lister<Subaccount> List()
{
return new Lister<Subaccount>(new PageFetcher<Subaccount>(_restClient, "/subaccounts"));
}

private ParametrizedLister<Subaccount> ParametrizedList()
{
return new ParametrizedLister<Subaccount>(new PageFetcher<Subaccount>(_restClient, "/subaccounts"));
}

private Dictionary<string, object> SubaccountListParams(string filter)
{
var chartListParams = new Dictionary<string, object>();
Expand Down

0 comments on commit 4576e8d

Please sign in to comment.