forked from ringcentral/ringcentral-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSDK.js
121 lines (94 loc) · 2.83 KB
/
SDK.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import * as Utils from './core/Utils';
import Cache from './core/Cache';
import * as Externals from './core/Externals';
import Observable from './core/Observable';
import Queue from './core/Queue';
import Client from './http/Client';
import ApiResponse from './http/ApiResponse';
import * as HttpUtils from './http/Utils';
import {default as ClientMock} from './mocks/ClientMock';
import Mock from './mocks/Mock';
import Registry from './mocks/Registry';
import Platform from './platform/Platform';
import Auth from './platform/Auth';
import PubnubMockFactory from './pubnub/PubnubFactory';
import Subscription from './subscription/Subscription';
import CachedSubscription from './subscription/CachedSubscription';
require("regenerator/runtime");
export default class SDK {
static version = '2.0.1';
static server = {
sandbox: 'https://platform.devtest.ringcentral.com',
production: 'https://platform.ringcentral.com'
};
/**
* @constructor
* @param {object} [options]
* @param {string} [options.server]
* @param {string} [options.cachePrefix]
* @param {string} [options.appSecret]
* @param {string} [options.appKey]
* @param {string} [options.appName]
* @param {string} [options.appVersion]
* @param {string} [options.pubnubFactory]
* @param {string} [options.client]
*/
constructor(options) {
options = options || {};
this._cache = new Cache(Externals.localStorage, options.cachePrefix);
this._client = options.client || new Client();
this._platform = new Platform(this._client, this._cache, options.server, options.appKey, options.appSecret);
this._pubnubFactory = options.pubnubFactory || Externals.PUBNUB;
}
/**
* @return {Platform}
*/
platform() {
return this._platform;
}
/**
* @return {Subscription}
*/
createSubscription() {
return new Subscription(this._pubnubFactory, this._platform);
}
/**
* @return {CachedSubscription}
*/
createCachedSubscription(cacheKey) {
return new CachedSubscription(this._pubnubFactory, this._platform, this._cache, cacheKey);
}
/**
* @return {Cache}
*/
cache() {
return this._cache;
}
static core = {
Cache: Cache,
Observable: Observable,
Utils: Utils,
Externals: Externals,
Queue: Queue
};
static http = {
Client: Client,
ApiResponse: ApiResponse,
Utils: HttpUtils
};
static platform = {
Auth: Auth,
Platform: Platform
};
static subscription = {
Subscription: Subscription
};
static mocks = {
Client: ClientMock,
Registry: Registry,
Mock: Mock
};
static pubnub = {
PubnubMockFactory: PubnubMockFactory
};
}