This repository has been archived on 2024-09-23. You can view files and clone it, but cannot push or open issues or pull requests.
rocketchat-scim/scim/Meta.ts
2022-02-11 14:13:06 +01:00

28 lines
660 B
TypeScript

type ValueGetter = () => string;
export class SCIMMeta {
public resourceType: string;
public created: Date;
public lastModified: Date;
public version: string;
private id: ValueGetter;
constructor(resourceType: string, id: ValueGetter) {
this.id = id;
this.resourceType = resourceType;
const now = Date.now();
this.created = new Date(now);
this.lastModified = new Date(now);
}
public get location(): string {
return `/${this.resourceType}s/${this.id()}`;
}
public toJSON() {
return {
...this,
location: this.location,
};
}
}