1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-04-12 00:43:13 +00:00

feat(*): recreate package with new name

This commit is contained in:
Krishna Acondy
2020-07-07 19:53:35 +01:00
commit 066f953863
150 changed files with 48625 additions and 0 deletions

51
src/SAS9ApiClient.ts Normal file
View File

@@ -0,0 +1,51 @@
/**
* A client for interfacing with the SAS9 REST API
*
*/
export class SAS9ApiClient {
constructor(private serverUrl: string) {}
/**
* returns on object containing the server URL
*/
public getConfig() {
return {
serverUrl: this.serverUrl,
};
}
/**
* Updates serverurl which is not null
* @param serverUrl - the URL of the server.
*/
public setConfig(serverUrl: string) {
if (serverUrl) this.serverUrl = serverUrl;
}
/**
* Executes code on a SAS9 server.
* @param linesOfCode - an array of lines of code to execute
* @param serverName - the server to execute the code on
* @param repositoryName - the repository to execute the code on
*/
public async executeScript(
linesOfCode: string[],
serverName: string,
repositoryName: string
) {
const requestPayload = linesOfCode.join("\n");
const executeScriptRequest = {
method: "PUT",
headers: {
Accept: "application/json",
},
body: `command=${requestPayload}`,
};
const executeScriptResponse = await fetch(
`${this.serverUrl}/sas/servers/${serverName}/cmd?repositoryName=${repositoryName}`,
executeScriptRequest
).then((res) => res.text());
return executeScriptResponse;
}
}