Skip to content

Commit cf14b61

Browse files
committed
Added quickstart files
1 parent 2bbc35b commit cf14b61

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎src/Common/session.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// tslint:disable-next-line: no-implicit-dependencies
2+
import { Session } from '@refinitiv-data/data';
3+
import creds from '../../session.config.json';
4+
5+
6+
const createDesktopSession = () =>
7+
Session.Desktop.Definition({
8+
appKey: creds.sessions.desktop.appKey!,
9+
}).getSession();
10+
11+
12+
const createPlatformSession = () =>
13+
Session.Platform.Definition({
14+
appKey: creds.sessions.platform.appKey!,
15+
userName: creds.sessions.platform.rdpUser!,
16+
password: creds.sessions.platform.rdpPassword!,
17+
takeSignOnControl: true,
18+
}).getSession();
19+
20+
21+
const createContainerSession = () =>
22+
Session.Container.Definition({
23+
appKey: creds.sessions.container.appKey!,
24+
}).getSession();
25+
26+
27+
export function getSession(sessionType?: 'platform' | 'desktop' | 'container'): Session.Session {
28+
const sType = sessionType || creds.sessions.default;
29+
switch(sType) {
30+
case 'platform':
31+
return createPlatformSession();
32+
case 'desktop':
33+
return createDesktopSession();
34+
case 'container':
35+
return createContainerSession();
36+
default:
37+
throw new Error('Invalid Session Type. Should be either - platform or desktop or container');
38+
}
39+
}

0 commit comments

Comments
 (0)