-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLibCalTypes.cs
506 lines (378 loc) · 13 KB
/
LibCalTypes.cs
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
// Generated with https://quicktype.io
using Newtonsoft.Json;
namespace LibCalTypes;
public class EventsResponse
{
[JsonProperty("events")]
public List<Event> Events { get; set; }
}
public class Event
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("allday")]
public bool AllDay { get; set; }
[JsonProperty("start")]
public DateTimeOffset Start { get; set; }
[JsonProperty("end")]
public DateTimeOffset End { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("url")]
public Url Url { get; set; }
[JsonProperty("location")]
public Location Location { get; set; }
[JsonProperty("campus")]
public Campus Campus { get; set; }
[JsonProperty("category")]
public List<Category> Category { get; set; }
[JsonProperty("owner")]
public Owner Owner { get; set; }
[JsonProperty("presenter")]
public string Presenter { get; set; }
[JsonProperty("calendar")]
public Calendar Calendar { get; set; }
[JsonProperty("seats")]
public long? Seats { get; set; }
[JsonProperty("registration")]
public bool Registration { get; set; }
[JsonProperty("has_registration_opened")]
public bool HasRegistrationOpened { get; set; }
[JsonProperty("has_registration_closed")]
public bool HasRegistrationClosed { get; set; }
[JsonProperty("physical_seats")]
public long PhysicalSeats { get; set; }
[JsonProperty("physical_seats_taken")]
public long PhysicalSeatsTaken { get; set; }
[JsonProperty("online_seats")]
public long OnlineSeats { get; set; }
[JsonProperty("online_seats_taken")]
public long OnlineSeatsTaken { get; set; }
[JsonProperty("seats_taken")]
public long SeatsTaken { get; set; }
[JsonProperty("wait_list")]
public bool WaitList { get; set; }
[JsonProperty("color")]
public string Color { get; set; }
[JsonProperty("featured_image")]
public Uri FeaturedImage { get; set; }
[JsonProperty("geolocation")]
public object Geolocation { get; set; }
[JsonProperty("future_dates")]
public List<FutureDate> FutureDates { get; set; }
[JsonProperty("more_info")]
public string MoreInfo { get; set; }
[JsonProperty("setup_time")]
public long SetupTime { get; set; }
[JsonProperty("teardown_time")]
public long TeardownTime { get; set; }
[JsonProperty("online_user_id")]
public long OnlineUserId { get; set; }
[JsonProperty("zoom_email")]
public string ZoomEmail { get; set; }
[JsonProperty("online_meeting_id")]
public string OnlineMeetingId { get; set; }
[JsonProperty("online_host_url")]
public Uri OnlineHostUrl { get; set; }
[JsonProperty("online_join_url")]
public Uri OnlineJoinUrl { get; set; }
[JsonProperty("online_join_password")]
public string OnlineJoinPassword { get; set; }
[JsonProperty("online_provider")]
public string OnlineProvider { get; set; }
[JsonIgnore]
public List<Registrant> Registrants { get; set; }
}
public class Calendar
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("public")]
public Uri Public { get; set; }
[JsonProperty("admin")]
public Uri Admin { get; set; }
}
public class Campus
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
public class Category
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonIgnore]
public long EventId { get; set; }
}
public class Owner
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
public class Location
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("type")]
public long Type { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
public class Url
{
[JsonProperty("public")]
public Uri Public { get; set; }
[JsonProperty("admin")]
public Uri Admin { get; set; }
}
public class FutureDate
{
[JsonProperty("event_id")]
public long FutureEventId { get; set; }
[JsonProperty("start")]
public DateTimeOffset Start { get; set; }
}
public class RegistrationsResponse
{
[JsonProperty("event_id")]
public long EventId { get; set; }
[JsonProperty("registrants")]
public List<Registrant> Registrants { get; set; }
}
public class Registrant
{
[JsonIgnore]
public string UserHash { get; set; }
[JsonProperty("booking_id")]
public long BookingId { get; set; }
[JsonProperty("registration_type")]
public string RegistrationType { get; set; }
[JsonProperty("first_name")]
public string FirstName { get; set; }
[JsonProperty("last_name")]
public string LastName { get; set; }
[JsonProperty("barcode")]
public string Barcode { get; set; }
[JsonProperty("phone")]
public string Phone { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("registered_date")]
public DateTimeOffset RegisteredDate { get; set; }
[JsonProperty("attendance")]
public string Attendance { get; set; }
}
public class AppointmentBooking
{
[JsonIgnore]
public string UserHash { get; set; }
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("fromDate")]
public DateTimeOffset FromDate { get; set; }
[JsonProperty("toDate")]
public DateTimeOffset ToDate { get; set; }
[JsonProperty("firstName")]
public string FirstName { get; set; }
[JsonProperty("lastName")]
public string LastName { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("userId")]
public long UserId { get; set; }
[JsonProperty("location")]
public string Location { get; set; }
[JsonProperty("locationId")]
public long LocationId { get; set; }
[JsonProperty("group")]
public string Group { get; set; }
[JsonProperty("groupId")]
public long GroupId { get; set; }
[JsonProperty("categoryId")]
public long CategoryId { get; set; }
[JsonProperty("directions")]
public string Directions { get; set; }
[JsonProperty("cancelled")]
public bool Cancelled { get; set; }
[JsonProperty("answers")]
[JsonConverter(typeof(AnswerConverter))]
public List<QuestionAnswer> Answers { get; set; }
}
public class QuestionAnswer
{
public long BookingId { get; set; }
public long QuestionId { get; set; }
public string Answer { get; set; }
}
class AnswerConverter : JsonConverter<List<QuestionAnswer>>
{
public override List<QuestionAnswer> ReadJson(JsonReader reader, Type objectType,
List<QuestionAnswer> existingValue, bool hasExistingValue,
JsonSerializer serializer)
{
/* Answers is either an object containing question ids and answers, or an empty array. For example:
"answers": {
"q20355": "Pennsylvania Resident",
"q20356": "Growth and Establishment",
"q20357": "Advertising and Promotional Material ",
"q20358": "Industry Reports and Data, Consumer Demographics and Psychographics",
"q40080": "-",
"q20359": "Other"
}
OR
"answers": []
*/
if (reader.TokenType == JsonToken.StartArray)
{
// Expect the array to be empty, so skip its token, and return an empty list
reader.Skip();
return new List<QuestionAnswer>();
}
var answers = serializer.Deserialize<Dictionary<string, string>>(reader)
?? throw new Exception("Failed to deserialize Answers object");
var questionAnswers = answers.Select(x => new QuestionAnswer
{
QuestionId = long.Parse(x.Key.TrimStart('q')),
Answer = x.Value
});
return hasExistingValue ? existingValue.Concat(questionAnswers).ToList() : questionAnswers.ToList();
}
public override void WriteJson(JsonWriter writer, List<QuestionAnswer> value, JsonSerializer serializer)
{
// This likely won't be called ever, but this should change the answers back to the API format if needed
if (value is not null && value.Any())
{
serializer.Serialize(writer, value.ToDictionary(q => $"q{q.QuestionId}", q => q.Answer));
}
else { serializer.Serialize(writer, Array.Empty<object>()); }
}
}
public class AppointmentUser
{
[JsonProperty("user_id")]
public long UserId { get; set; }
[JsonProperty("first_name")]
public string FirstName { get; set; }
[JsonProperty("last_name")]
public string LastName { get; set; }
[JsonProperty("nickname")]
public string Nickname { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("url")]
public Uri Url { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
}
public class AppointmentQuestion
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("label")]
public string Label { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("required")]
public bool Required { get; set; }
[JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(OptionConverter))]
public List<QuestionOption> Options { get; set; }
}
public class QuestionOption
{
public long QuestionId { get; set; }
public string Option { get; set; }
}
class OptionConverter : JsonConverter<List<QuestionOption>>
{
public override List<QuestionOption> ReadJson(JsonReader reader, Type objectType,
List<QuestionOption> existingValue, bool hasExistingValue,
JsonSerializer serializer)
{
// Options is just an array of strings, which is wrapped so it can be a database entity
var options = serializer.Deserialize<List<string>>(reader) ??
throw new Exception("Failed to deserialize options");
return options.Select(option => new QuestionOption { Option = option }).ToList();
}
public override void WriteJson(JsonWriter writer, List<QuestionOption> value, JsonSerializer serializer)
{
serializer.Serialize(writer, value?.Select(x => x.Option).ToList());
}
}
public class SpaceBooking
{
[JsonIgnore]
public string UserHash { get; set; }
[JsonProperty("bookId")]
public string BookId { get; set; }
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("eid")]
public long ItemId { get; set; }
[JsonProperty("cid")]
public long CategoryId { get; set; }
[JsonProperty("lid")]
public long LocationId { get; set; }
[JsonProperty("fromDate")]
public DateTimeOffset FromDate { get; set; }
[JsonProperty("toDate")]
public DateTimeOffset ToDate { get; set; }
[JsonProperty("created")]
public DateTimeOffset Created { get; set; }
[JsonProperty("firstName")]
public string FirstName { get; set; }
[JsonProperty("lastName")]
public string LastName { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("account")]
public string Account { get; set; }
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("location_name")]
public string LocationName { get; set; }
[JsonProperty("category_name")]
public string CategoryName { get; set; }
[JsonProperty("item_name")]
public string ItemName { get; set; }
[JsonProperty("nickname", NullValueHandling = NullValueHandling.Ignore)]
public string Nickname { get; set; }
[JsonProperty("cancelled", NullValueHandling = NullValueHandling.Ignore)]
public DateTimeOffset? Cancelled { get; set; }
}
public class ArchivedSpaceBooking
{
public long Id { get; set; }
public string BookingId { get; set; }
public string SpaceId { get; set; }
public string SpaceName { get; set; }
public string Location { get; set; }
public string Zone { get; set; }
public string Category { get; set; }
public string UserHash { get; set; }
public DateTime? FromDate { get; set; }
public DateTime? ToDate { get; set; }
public DateTime? CreatedDate { get; set; }
public string EventId { get; set; }
public string EventTitle { get; set; }
public DateTime? EventStart { get; set; }
public DateTime? EventEnd { get; set; }
public string Status { get; set; }
public string CancelledByUser { get; set; }
public DateTime? CancelledAt { get; set; }
public string ShowedUp { get; set; }
public DateTime? CheckedInDate { get; set; }
public DateTime? CheckedOutDate { get; set; }
public string Cost { get; set; }
public string BookingFormAnswers { get; set; }
}