diff --git a/src/main/java/seatsio/charts/Charts.java b/src/main/java/seatsio/charts/Charts.java index fbd80e8..167c80d 100644 --- a/src/main/java/seatsio/charts/Charts.java +++ b/src/main/java/seatsio/charts/Charts.java @@ -153,6 +153,14 @@ public Chart copyToWorkspace(String chartKey, String toWorkspaceKey) { return gson().fromJson(response, Chart.class); } + public Chart copyToWorkspace(String chartKey, String fromWorkspaceKey, String toWorkspaceKey) { + String response = unirest.stringResponse(UnirestWrapper.post(baseUrl + "/charts/{chartKey}/version/published/actions/copy/from/{fromWorkspaceKey}/to/{toWorkspaceKey}") + .routeParam("chartKey", chartKey) + .routeParam("fromWorkspaceKey", fromWorkspaceKey) + .routeParam("toWorkspaceKey", toWorkspaceKey)); + return gson().fromJson(response, Chart.class); + } + public void addTag(String key, String tag) { unirest.stringResponse(UnirestWrapper.post(baseUrl + "/charts/{key}/tags/{tag}") .routeParam("key", key) diff --git a/src/test/java/seatsio/charts/CopyChartFromWorkspaceToTest.java b/src/test/java/seatsio/charts/CopyChartFromWorkspaceToTest.java new file mode 100644 index 0000000..605869c --- /dev/null +++ b/src/test/java/seatsio/charts/CopyChartFromWorkspaceToTest.java @@ -0,0 +1,29 @@ +package seatsio.charts; + +import org.junit.jupiter.api.Test; +import seatsio.SeatsioClient; +import seatsio.SeatsioClientTest; +import seatsio.workspaces.Workspace; + +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CopyChartFromWorkspaceToTest extends SeatsioClientTest { + + @Test + public void test() { + Chart chart = client.charts.create("my chart", "BOOTHS"); + Workspace toWorkspace = client.workspaces.create("my ws"); + + Chart copiedChart = client.charts.copyToWorkspace(chart.key, workspace.key, toWorkspace.key); + + SeatsioClient workspaceClient = new SeatsioClient(toWorkspace.secretKey, null, apiUrl()); + assertThat(copiedChart.name).isEqualTo("my chart"); + Chart retrievedChart = workspaceClient.charts.retrieve(copiedChart.key); + assertThat(retrievedChart.name).isEqualTo("my chart"); + Map drawing = workspaceClient.charts.retrievePublishedVersion(copiedChart.key); + assertThat(drawing.get("venueType")).isEqualTo("BOOTHS"); + } + +}