2021-05-21 11:42:08 +02:00
|
|
|
import { Syncable, Addressable, mergeKey } from '@cicnet/crdt-meta';
|
2021-02-08 18:31:29 +01:00
|
|
|
|
|
|
|
class Phone extends Syncable implements Addressable {
|
|
|
|
|
|
|
|
address: string
|
|
|
|
value: number
|
|
|
|
|
2021-04-09 15:00:15 +02:00
|
|
|
constructor(address:string, v:string) {
|
2021-02-08 18:31:29 +01:00
|
|
|
const o = {
|
|
|
|
msisdn: v,
|
|
|
|
}
|
|
|
|
super('', o);
|
|
|
|
Phone.toKey(v).then((phid) => {
|
|
|
|
this.id = phid;
|
|
|
|
this.address = address;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-09 15:00:15 +02:00
|
|
|
public static async toKey(msisdn:string) {
|
|
|
|
return await mergeKey(Buffer.from(msisdn), Buffer.from(':cic.phone'));
|
2021-02-08 18:31:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public key(): string {
|
|
|
|
return this.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
Phone,
|
|
|
|
}
|