-
Notifications
You must be signed in to change notification settings - Fork 1
/
ArcheTypeResource.ts
29 lines (22 loc) · 1 KB
/
ArcheTypeResource.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
import { NamedResource, NamedResourceEditOptions } from './NamedResource';
import { ResourceType, ResourceTypeGet } from '../api/ResourceType';
import { ArcheType } from '../api/ArcheType';
import { Hue } from '../hue/Hue';
export interface ArcheTypeResourceEditOptions extends NamedResourceEditOptions {
archeType?: ArcheType;
}
export type ArcheTypeResourceCreateOptions = Required<ArcheTypeResourceEditOptions>;
export abstract class ArcheTypeResource<T extends ResourceType> extends NamedResource<T> {
public data: ResourceTypeGet<T> & { metadata: { name: string; archetype: ArcheType } };
constructor(bridge: Hue, data: ResourceTypeGet<T> & { metadata: { name: string; archetype: ArcheType } }) {
super(bridge, data);
this.data = data;
}
get archeType(): ArcheType {
return this.data.metadata.archetype;
}
public async setArcheType(archeType: ArcheType): Promise<void> {
await this.edit({ archeType });
}
public abstract edit(options: { name?: string; archeType?: ArcheType }): Promise<void>;
}