Skip to content

Commit

Permalink
Switched from account ID to workspace key
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Oct 3, 2019
1 parent 283b08f commit f33a9c8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion SeatsioDotNet.Test/HoldTokens/RetrieveHoldTokenTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void Test()
Assert.Equal(holdToken.Token, retrievedHoldToken.Token);
Assert.Equal(holdToken.ExpiresAt, retrievedHoldToken.ExpiresAt);
Assert.InRange(holdToken.ExpiresInSeconds, 14 * 60, 15 * 60);
Assert.True(holdToken.AccountId > 0);
Assert.NotNull(holdToken.workspaceKey);
}
}
}
4 changes: 2 additions & 2 deletions SeatsioDotNet.Test/SeatsioClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ protected SeatsioClient CreateSeatsioClient(string secretKey)
return new SeatsioClient(secretKey, null, BaseUrl);
}

protected SeatsioClient CreateSeatsioClient(string secretKey, long accountId)
protected SeatsioClient CreateSeatsioClient(string secretKey, string workspaceKey)
{
return new SeatsioClient(secretKey, accountId, BaseUrl);
return new SeatsioClient(secretKey, workspaceKey, BaseUrl);
}
}
}
2 changes: 1 addition & 1 deletion SeatsioDotNet.Test/Subaccounts/RetrieveSubaccountTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Test()
Assert.Equal(subaccount.PublicKey, retrievedSubaccount.PublicKey);
Assert.Equal("joske", retrievedSubaccount.Name);
Assert.True(retrievedSubaccount.Active);
Assert.True(retrievedSubaccount.AccountId > 0);
Assert.NotNull(retrievedSubaccount.workspaceKey);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace SeatsioDotNet.Test
{
public class AccountIdAuthenticationTest : SeatsioClientTest
public class WorkspaceKeyAuthenticationTest : SeatsioClientTest
{
[Fact]
public void Test()
{
var subaccount = Client.Subaccounts.Create();

var subaccountClient = CreateSeatsioClient(User.SecretKey, subaccount.AccountId);
var subaccountClient = CreateSeatsioClient(User.SecretKey, subaccount.workspaceKey);
var holdToken = subaccountClient.HoldTokens.Create();

Assert.Equal(subaccount.AccountId, holdToken.AccountId);
Assert.Equal(subaccount.workspaceKey, holdToken.workspaceKey);
}
}
}
2 changes: 1 addition & 1 deletion SeatsioDotNet/HoldTokens/HoldToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class HoldToken
public string Token { get; set; }
public DateTimeOffset ExpiresAt { get; set; }
public int ExpiresInSeconds { get; set; }
public long AccountId { get; set; }
public string workspaceKey { get; set; }
}
}
12 changes: 6 additions & 6 deletions SeatsioDotNet/SeatsioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class SeatsioClient
public ChartReports.ChartReports ChartReports { get; }
public UsageReports.UsageReports UsageReports { get; }

public SeatsioClient(string secretKey, long? accountId, string baseUrl)
public SeatsioClient(string secretKey, string workspaceKey, string baseUrl)
{
var restClient = CreateRestClient(secretKey, accountId, baseUrl);
var restClient = CreateRestClient(secretKey, workspaceKey, baseUrl);
Charts = new Charts.Charts(restClient);
Events = new Events.Events(restClient);
Accounts = new Accounts.Accounts(restClient);
Expand All @@ -27,21 +27,21 @@ public SeatsioClient(string secretKey, long? accountId, string baseUrl)
UsageReports = new UsageReports.UsageReports(restClient);
}

public SeatsioClient(string secretKey, long? accountId) : this(secretKey, accountId, "https://api.seatsio.net")
public SeatsioClient(string secretKey, string workspaceKey) : this(secretKey, workspaceKey, "https://api.seatsio.net")
{
}

public SeatsioClient(string secretKey) : this(secretKey, null)
{
}

private static RestClient CreateRestClient(string secretKey, long? accountId, string baseUrl)
private static RestClient CreateRestClient(string secretKey, string workspaceKey, string baseUrl)
{
var client = new RestClient(baseUrl);
client.Authenticator = new HttpBasicAuthenticator(secretKey, null);
if (accountId != null)
if (workspaceKey != null)
{
client.AddDefaultHeader("X-Account-ID", accountId.ToString());
client.AddDefaultHeader("X-Workspace-Key", workspaceKey.ToString());
}

return client;
Expand Down
2 changes: 1 addition & 1 deletion SeatsioDotNet/Subaccounts/Subaccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class Subaccount
{
public long Id { get; set; }
public long AccountId { get; set; }
public string workspaceKey { get; set; }
public string SecretKey { get; set; }
public string DesignerKey { get; set; }
public string PublicKey { get; set; }
Expand Down

0 comments on commit f33a9c8

Please sign in to comment.