-
Notifications
You must be signed in to change notification settings - Fork 1
/
MPSolution.ts
180 lines (170 loc) · 4.31 KB
/
MPSolution.ts
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import { MPSolutionConfig } from "../../index";
import MPUtils from "./MPUtils";
/**
* Governs the topmost settings for a MapsIndoors solution.
*
* @export
* @class MPSolution
* @typedef {MPSolution}
*/
export default class MPSolution {
/**
* Creates an instance of MPSolution.
*
* @constructor
* @private
* @param {string} id
* @param {string} name
* @param {MPSolutionConfig} solutionConfig
* @param {string} defaultLanguage
* @param {string[]} availableLanguages
* @param {string[]} modules
* @param {?string} [locationTemplates]
* @param {?string} [customerId]
* @param {?string} [mapClientUrl]
*/
private constructor(
public readonly id: string,
public readonly name: string,
public readonly solutionConfig: MPSolutionConfig,
public readonly defaultLanguage: string,
public readonly availableLanguages: string[],
private readonly modules: string[],
public readonly locationTemplates?: string,
public readonly customerId?: string,
public mapClientUrl?: string,
) { }
/**
* Creator for MPSolution, used to decode JSON from the MapsIndoors SDK.
*
* @public
* @static
* @param {MPSolutionParams} object
* @returns {MPSolution}
*/
public static create(object: MPSolutionParams): MPSolution {
return new MPSolution(
object?.id,
object?.name,
MPSolutionConfig.create(object?.solutionConfig),
object?.defaultLanguage,
object?.availableLanguages,
object?.modules,
object?.locationTemplates,
object?.customerId,
object?.mapClientUrl,
);
}
/**
* Check if the solution supports a language.
*
* @public
* @param {?string} [language]
* @returns {boolean}
*/
public hasLanguage(language?: string): boolean {
return language ? this.availableLanguages.includes(language) : false;
}
/**
* Check whether the 22nd zoom level is available for select map providers.
*
* @public
* @returns {boolean}
*/
public isZoom22Enabled(): boolean {
return this.modules.includes("z22");
}
/**
* Check whether wall extrusions are available for select map providers.
*
* @public
* @returns {boolean}
*/
public is3DWallsEnabled(): boolean {
return this.modules.includes("3dwalls");
}
/**
* Check whether room extrusions are available for select map providers.
*
* @public
* @returns {boolean}
*/
public is3DExtrusionsEnabled(): boolean {
return this.modules.includes("3dextrusions");
}
/**
* Parses a venue ID and a location ID to create a mapClientUrl.
*
* @public
* @async
* @param {string} venueId
* @param {string} locationId
* @returns {Promise<string>}
*/
public async parseMapClient(venueId: string, locationId: string): Promise<string> {
return MPUtils.parseMapClientUrl(venueId, locationId);
}
}
/**
* Parameter interface for {@link MPSolution}.
*
* @export
* @interface MPSolutionParams
* @typedef {MPSolutionParams}
*/
export interface MPSolutionParams {
/**
* The solution's ID.
*
* @type {string}
*/
id: string;
/**
* The solution's name.
*
* @type {string}
*/
name: string;
/**
* The solution's configuration object.
*
* @type {MPSolutionConfig}
*/
solutionConfig: MPSolutionConfig;
/**
* The id of the solution in customer systems.
*
* @type {?string}
*/
customerId?: string;
/**
* The solution's default language.
*
* @type {string}
*/
defaultLanguage: string;
/**
* An array of available languages for the solution.
*
* @type {string[]}
*/
availableLanguages: string[];
/**
* The URL used to fetch data from the CMS.
*
* @type {?string}
*/
mapClientUrl?: string;
/**
* The solution's location template.
*
* @type {?string}
*/
locationTemplates?: string;
/**
* An array of modules that define some behaviors of the SDK set through the CMS.
*
* @type {string[]}
*/
modules: string[];
}