-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathNoCodesConfigBuilder.ts
More file actions
53 lines (47 loc) · 1.52 KB
/
NoCodesConfigBuilder.ts
File metadata and controls
53 lines (47 loc) · 1.52 KB
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
import type {NoCodesListener} from './dto/NoCodesListener';
import NoCodesConfig from './NoCodesConfig';
class NoCodesConfigBuilder {
private readonly projectKey: string;
private noCodesListener: NoCodesListener | undefined = undefined;
private proxyUrl: string | undefined = undefined;
constructor(projectKey: string) {
this.projectKey = projectKey;
}
/**
* Provide a listener to be notified about NoCodes events.
*
* Make sure you provide this listener for being up-to-date with the NoCodes events.
* Else you can lose some important updates. Also, please, consider that this listener
* should live for the whole lifetime of the application.
*
* @param noCodesListener listener to be called when NoCodes events occur.
* @return builder instance for chain calls.
*/
setNoCodesListener(noCodesListener: NoCodesListener): NoCodesConfigBuilder {
this.noCodesListener = noCodesListener;
return this;
}
/**
* Set proxy URL for NoCodes SDK.
*
* @param proxyUrl proxy URL to use for API requests.
* @return builder instance for chain calls.
*/
setProxyURL(proxyUrl: string): NoCodesConfigBuilder {
this.proxyUrl = proxyUrl;
return this;
}
/**
* Generate {@link NoCodesConfig} instance with all the provided configurations.
*
* @return the complete {@link NoCodesConfig} instance.
*/
build(): NoCodesConfig {
return new NoCodesConfig(
this.projectKey,
this.noCodesListener,
this.proxyUrl
);
}
}
export default NoCodesConfigBuilder;