Skip to content

Commit c22884c

Browse files
feat(client): add getSession method
1 parent d7dd4a9 commit c22884c

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

dist/apiclient.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export declare class APIClient {
88
enableDebugMode(): APIClient;
99
disableDebugMode(): APIClient;
1010
getPOSTData(cmd: any): string;
11+
getSession(): string | null;
1112
getURL(): string;
1213
getVersion(): string;
1314
saveSession(session: any): APIClient;

dist/apiclient.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apiclient.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/apiclient.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ export class APIClient {
7373
return data;
7474
}
7575

76+
/**
77+
* Get the API Session that is currently set
78+
* @returns API Session or null
79+
*/
80+
public getSession(): string | null {
81+
const sessid = this.socketConfig.getSession();
82+
return (sessid === "") ? null : sessid;
83+
}
84+
7685
/**
7786
* Get the API connection url that is currently set
7887
* @returns API connection url currently in use

test/apiclient.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ describe('APIClient class', function () {
7878
})
7979
})
8080

81+
describe('#.getSession', function () {
82+
it('validate response', function () {
83+
const session = cl.getSession()
84+
expect(session).to.be.null()
85+
})
86+
})
87+
88+
describe('#.getSession', function () {
89+
it('validate response', function () {
90+
const sessid = 'testSessionID12345678'
91+
cl.setSession(sessid)
92+
const session = cl.getSession()
93+
expect(session).to.be.equal(sessid)
94+
cl.setSession('')
95+
})
96+
})
97+
8198
describe('#.getURL', function () {
8299
it('validate default socket url', function () {
83100
const url = cl.getURL()

0 commit comments

Comments
 (0)