From 5ad532bc631f99d99b1978989199661829193ace Mon Sep 17 00:00:00 2001 From: Marcus Molchany Date: Thu, 24 Aug 2023 15:30:22 -0700 Subject: [PATCH] feat: add share simulation method --- lib/executors/Simulator.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/executors/Simulator.ts b/lib/executors/Simulator.ts index dff0858..d7a1296 100644 --- a/lib/executors/Simulator.ts +++ b/lib/executors/Simulator.ts @@ -229,6 +229,16 @@ export class Simulator { return data; } + private async executeSimulationShareRequest(simulationId: string): Promise { + await this.apiV2.post( + ` + /account/${this.configuration.accountName} + /project/${this.configuration.projectName} + /simulations/${simulationId}/share + `, + ); + } + /** * Simulates a transaction by encoding overrides, building a request body, and executing a simulation request. * @async @@ -302,4 +312,19 @@ export class Simulator { handleError(error); } } + + /** + * Makes the dashboard page for a simulation that was created with `save` or `save_if_fails` + * publicly viewable + * @async + * @function + * @param {string} simulationId - The ID of the simulation to be shared. + */ + async shareSimulation(simulationId: string) { + try { + await this.executeSimulationShareRequest(simulationId); + } catch (error) { + handleError(error); + } + } }