Skip to content

Commit

Permalink
Added call to regenerate secret key of workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Apr 27, 2020
1 parent aafd119 commit 27dac42
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SeatsioDotNet.Test.Subaccounts
{
public class RegenerateDesignerKeyTest : SeatsioClientTest
public class RegenerateSubaccountDesignerKeyTest : SeatsioClientTest
{
[Fact]
public void Test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SeatsioDotNet.Test.Subaccounts
{
public class RegenerateSecretKeyTest : SeatsioClientTest
public class RegenerateSubaccountSecretKeyTest : SeatsioClientTest
{
[Fact]
public void Test()
Expand Down
20 changes: 20 additions & 0 deletions SeatsioDotNet.Test/Workspaces/RegenerateWorkspaceSecretKeyTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Xunit;

namespace SeatsioDotNet.Test.Workspaces
{
public class RegenerateWorkspaceSecretKeyTest : SeatsioClientTest
{
[Fact]
public void Test()
{
var workspace = Client.Workspaces.Create("a ws");

var newSecretKey = Client.Workspaces.RegenerateSecretKey(workspace.Key);

Assert.NotNull(newSecretKey);
Assert.NotEqual(newSecretKey, workspace.SecretKey);
var retrievedWorkspace = Client.Workspaces.Retrieve(workspace.Key);
Assert.Equal(newSecretKey, retrievedWorkspace.SecretKey);
}
}
}
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>70.2.0</Version>
<Version>70.3.0</Version>
<Authors>mroloux;bverbeken</Authors>
<Title>Official Seats.io .NET API client</Title>
<Description>Official Seats.io .NET API client</Description>
Expand Down
8 changes: 8 additions & 0 deletions SeatsioDotNet/Workspaces/Workspaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public void Update(string key, string name)
AssertOk(_restClient.Execute<object>(restRequest));
}

public string RegenerateSecretKey(string key)
{
var restRequest = new RestRequest("/workspaces/{key}/actions/regenerate-secret-key", Method.POST)
.AddUrlSegment("key", key);
var response = AssertOk(_restClient.Execute<Dictionary<string, string>>(restRequest));
return response["secretKey"];
}

public IEnumerable<Workspace> ListAll()
{
return List().All();
Expand Down

0 comments on commit 27dac42

Please sign in to comment.