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

29 lines
660 B
TypeScript
Raw Normal View History

2022-02-11 13:13:06 +00:00
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,
};
}
}