-
Notifications
You must be signed in to change notification settings - Fork 1
/
MPUserRoleCollection.ts
37 lines (35 loc) · 1.13 KB
/
MPUserRoleCollection.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
import MPCollection from "./MPCollection";
import MapsIndoors, {MPUserRole} from "../../index";
/**
* A collection of user role objects fetched from {@link MapsIndoors}. Uses {@link MPUserRole.id} as key.
*
* @export
* @class MPUserRoleCollection
* @typedef {MPUserRoleCollection}
* @extends {MPCollection<MPUserRole>}
*/
export default class MPUserRoleCollection extends MPCollection<MPUserRole> {
/**
* Creates an instance of MPUserRoleCollection.
*
* @constructor
* @private
* @param {MPUserRole[]} userroles A collection of user roles
*/
private constructor(userroles: MPUserRole[]) {
super();
this.map = new Map(userroles.map((role) => [role.id, role]));
}
/**
* Creator for MPUserRoleCollection, used to decode JSON from the MapsIndoors SDK.
*
* @public
* @static
* @param {?*} [object]
* @returns {MPUserRoleCollection}
*/
public static create(object?: any) : MPUserRoleCollection {
let userroles: MPUserRole[] = object?.map((venue: any) => MPUserRole.create(venue));
return new MPUserRoleCollection(userroles);
}
}