-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUser.ts
89 lines (68 loc) · 2.7 KB
/
User.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import {JsonObject, JsonProperty, JsonConvert, ValueCheckingMode, OperationMode} from "json2typescript";
import { Party, TemplateId } from "../ledger/Types";
@JsonObject("User.AddFriend")
class AddFriend {
@JsonProperty("friend", Party)
friend: Party = '';
static template = undefined as unknown as typeof User;
static choiceName = 'AddFriend';
static toJSON(addFriend: AddFriend): unknown {
const jsonConvert = new JsonConvert();
jsonConvert.valueCheckingMode = ValueCheckingMode.DISALLOW_NULL;
// TODO(MH): For some reason the conversion to JSON does not work right now.
jsonConvert.operationMode = OperationMode.DISABLE;
return jsonConvert.serializeObject<AddFriend>(addFriend);
}
}
@JsonObject("User.RemoveFriend")
class RemoveFriend {
@JsonProperty("friend", Party)
friend: Party = '';
static template = undefined as unknown as typeof User;
static choiceName = 'RemoveFriend';
static toJSON(removeFriend: RemoveFriend): unknown {
const jsonConvert = new JsonConvert();
jsonConvert.valueCheckingMode = ValueCheckingMode.DISALLOW_NULL;
// TODO(MH): For some reason the conversion to JSON does not work right now.
jsonConvert.operationMode = OperationMode.DISABLE;
return jsonConvert.serializeObject<RemoveFriend>(removeFriend);
}
}
@JsonObject("User.Delete")
class Delete {
static template = undefined as unknown as typeof User;
static choiceName = 'Delete';
static toJSON(delete_: Delete): unknown {
const jsonConvert = new JsonConvert();
jsonConvert.valueCheckingMode = ValueCheckingMode.DISALLOW_NULL;
// TODO(MH): For some reason the conversion to JSON does not work right now.
jsonConvert.operationMode = OperationMode.DISABLE;
return jsonConvert.serializeObject<Delete>(delete_);
}
}
@JsonObject("User")
export class User {
@JsonProperty("party", Party)
party: Party = '';
@JsonProperty("friends", [Party])
friends: Party[] = [];
static templateId: TemplateId = {moduleName: "User", entityName: "User"};
static fromJSON(json: unknown): User {
const jsonConvert = new JsonConvert();
jsonConvert.valueCheckingMode = ValueCheckingMode.DISALLOW_NULL;
return jsonConvert.deserializeObject(json, User);
}
static toJSON(user: User): unknown {
const jsonConvert = new JsonConvert();
jsonConvert.valueCheckingMode = ValueCheckingMode.DISALLOW_NULL;
// TODO(MH): For some reason the conversion to JSON does not work right now.
jsonConvert.operationMode = OperationMode.DISABLE;
return jsonConvert.serializeObject<User>(user);
}
static AddFriend = AddFriend;
static RemoveFriend = RemoveFriend;
static Delete = Delete;
}
AddFriend.template = User;
RemoveFriend.template = User;
Delete.template = User;