31 lines
675 B
TypeScript
31 lines
675 B
TypeScript
import { Entity } from "./definitions";
|
|
|
|
export class Affinity implements Entity {
|
|
id?: string;
|
|
groupId: string;
|
|
affinities: { [key: string]: number };
|
|
|
|
constructor(id: string, groupId: string, affinities: { [key: string]: number }) {
|
|
this.id = id;
|
|
this.groupId = groupId;
|
|
this.affinities = affinities;
|
|
}
|
|
}
|
|
|
|
export class AffinitySerializer {
|
|
fromJson(json: any): Affinity {
|
|
return new Affinity(json.id, json.groupId, json.affinities);
|
|
}
|
|
|
|
toJson(affinity: Affinity): any {
|
|
return {
|
|
id: affinity.id,
|
|
groupId: affinity.groupId,
|
|
affinities: affinity.affinities
|
|
};
|
|
}
|
|
|
|
apiPath(): string {
|
|
return 'affinities';
|
|
}
|
|
} |