1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 09:24:35 +00:00

chore(refactor): remove unnecessary variables, use jobs path from config

This commit is contained in:
Krishna Acondy
2021-05-27 08:40:50 +01:00
parent e9affb862d
commit 9676488ff2
2 changed files with 8 additions and 12 deletions

View File

@@ -28,12 +28,7 @@ export class Sas9JobExecutor extends BaseJobExecutor {
? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
: sasJob
: sasJob
const jobUri = ''
let apiUrl = `${config.serverUrl}${this.jobsPath}?${
jobUri.length > 0
? '__program=' + program + '&_job=' + jobUri
: '_program=' + program
}`
let apiUrl = `${config.serverUrl}${this.jobsPath}?${'_program=' + program}`
apiUrl = `${apiUrl}${
config.username && config.password
? '&_username=' + config.username + '&_password=' + config.password
@@ -60,7 +55,11 @@ export class Sas9JobExecutor extends BaseJobExecutor {
}
}
await this.requestClient.login(config.username, config.password)
await this.requestClient.login(
config.username,
config.password,
this.jobsPath
)
const contentType =
data && Object.keys(data).length
? 'multipart/form-data; boundary=' + (formData as any)._boundary
@@ -81,9 +80,6 @@ export class Sas9JobExecutor extends BaseJobExecutor {
const requestParams: any = {}
if (config.debug) {
requestParams['_omittextlog'] = 'false'
requestParams['_omitsessionresults'] = 'false'
requestParams['_debug'] = 131
}

View File

@@ -21,12 +21,12 @@ export class Sas9RequestClient extends RequestClient {
}
}
public async login(username: string, password: string) {
public async login(username: string, password: string, jobsPath: string) {
const codeInjectorPath = `/User Folders/${username}/My Folder/sasjs/runner`
if (this.httpClient.defaults.jar) {
;(this.httpClient.defaults.jar as tough.CookieJar).removeAllCookies()
await this.get(
`/SASStoredProcess/do?_program=${codeInjectorPath}&_username=${username}&_password=${password}`,
`${jobsPath}?_program=${codeInjectorPath}&_username=${username}&_password=${password}`,
undefined,
'text/plain'
)