zoom-cli 0.2.6

Agent-friendly Zoom CLI with JSON output, structured exit codes, and schema introspection
Documentation
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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
use serde::{Deserialize, Serialize};

fn is_none_or_empty(s: &Option<String>) -> bool {
    s.as_deref().is_none_or(str::is_empty)
}

// ── Pagination ────────────────────────────────────────────────────────────────

/// Implemented by every paginated list type so `ZoomClient::get_all_pages` can
/// collect results across multiple API requests transparently.
pub trait Paginated: Sized {
    /// Returns the token for the next page, or `None` / empty when exhausted.
    fn next_page_token(&self) -> Option<&str>;
    /// Merge `next` page's items into `self`, discarding `next`'s metadata.
    fn append_page(&mut self, next: Self);
}

// ── Meeting ──────────────────────────────────────────────────────────────────

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Meeting {
    pub id: u64,
    pub topic: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub join_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub password: Option<String>,
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub meeting_type: Option<u8>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MeetingList {
    pub meetings: Vec<Meeting>,
    #[serde(skip_serializing_if = "is_none_or_empty")]
    pub next_page_token: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_records: Option<u64>,
    #[serde(skip_serializing)]
    pub page_count: Option<u32>,
    #[serde(skip_serializing)]
    pub page_size: Option<u32>,
}

#[derive(Debug, Serialize)]
pub struct CreateMeetingRequest {
    pub topic: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub password: Option<String>,
    #[serde(rename = "type")]
    pub meeting_type: u8,
}

#[derive(Debug, Serialize, Default)]
pub struct UpdateMeetingRequest {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub topic: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
}

// ── User ─────────────────────────────────────────────────────────────────────

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct User {
    pub id: String,
    pub email: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub display_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub user_type: Option<u8>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub created_at: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_login_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pic_url: Option<String>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct UserList {
    pub users: Vec<User>,
    #[serde(skip_serializing_if = "is_none_or_empty")]
    pub next_page_token: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_records: Option<u64>,
    #[serde(skip_serializing)]
    pub page_count: Option<u32>,
    #[serde(skip_serializing)]
    pub page_size: Option<u32>,
}

// ── User management ──────────────────────────────────────────────────────────

#[derive(Debug, Serialize)]
pub struct CreateUserInfo {
    pub email: String,
    #[serde(rename = "type")]
    pub user_type: u8,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub first_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_name: Option<String>,
}

#[derive(Debug, Serialize)]
pub struct CreateUserRequest {
    pub action: String,
    pub user_info: CreateUserInfo,
}

#[derive(Debug, Serialize)]
pub struct UserStatusRequest {
    pub action: String,
}

// ── Recording ─────────────────────────────────────────────────────────────────

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CloudRecording {
    pub id: u64,
    pub topic: String,
    pub start_time: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_size: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recording_count: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recording_files: Option<Vec<RecordingFile>>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct RecordingFile {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_type: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_extension: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file_size: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub play_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub download_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recording_type: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recording_start: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recording_end: Option<String>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct RecordingList {
    // Zoom names this field "meetings" internally; we expose it as "recordings".
    #[serde(rename(deserialize = "meetings", serialize = "recordings"))]
    pub recordings: Option<Vec<CloudRecording>>,
    #[serde(skip_serializing_if = "is_none_or_empty")]
    pub next_page_token: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_records: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub to: Option<String>,
}

// ── Recording control ────────────────────────────────────────────────────────

#[derive(Debug, Serialize)]
pub struct RecordingControlRequest {
    pub action: String,
}

// ── Meeting status ────────────────────────────────────────────────────────────

#[derive(Debug, Serialize)]
pub struct MeetingStatusRequest {
    pub action: String,
}

// ── Meeting invitation ────────────────────────────────────────────────────────

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MeetingInvitation {
    pub invitation: String,
}

// ── Participants ──────────────────────────────────────────────────────────────

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Participant {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub user_email: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub join_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub leave_time: Option<String>,
    // Duration in seconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct ParticipantList {
    pub participants: Vec<Participant>,
    #[serde(skip_serializing_if = "is_none_or_empty")]
    pub next_page_token: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_records: Option<u64>,
    #[serde(skip_serializing)]
    pub page_count: Option<u32>,
    #[serde(skip_serializing)]
    pub page_size: Option<u32>,
}

// ── Reports ───────────────────────────────────────────────────────────────────

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MeetingReportItem {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub uuid: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub topic: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_minutes: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub participants_count: Option<u32>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct UserMeetingReportList {
    pub meetings: Vec<MeetingReportItem>,
    #[serde(skip_serializing_if = "is_none_or_empty")]
    pub next_page_token: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_records: Option<u64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub from: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub to: Option<String>,
    #[serde(skip_serializing)]
    pub page_count: Option<u32>,
    #[serde(skip_serializing)]
    pub page_size: Option<u32>,
}

// ── Meeting participant report ────────────────────────────────────────────────

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MeetingParticipantReport {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub user_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub user_email: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub join_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub leave_time: Option<String>,
    /// Participation duration in seconds.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u64>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct MeetingParticipantReportList {
    pub participants: Vec<MeetingParticipantReport>,
    #[serde(skip_serializing_if = "is_none_or_empty")]
    pub next_page_token: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_records: Option<u64>,
    #[serde(skip_serializing)]
    pub page_size: Option<u32>,
}

// ── Webinar ───────────────────────────────────────────────────────────────────

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Webinar {
    pub id: u64,
    pub topic: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_time: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub join_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub agenda: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub webinar_type: Option<u8>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct WebinarList {
    pub webinars: Vec<Webinar>,
    #[serde(skip_serializing_if = "is_none_or_empty")]
    pub next_page_token: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_records: Option<u64>,
    #[serde(skip_serializing)]
    pub page_size: Option<u32>,
}

// ── Paginated impls ───────────────────────────────────────────────────────────

impl Paginated for MeetingList {
    fn next_page_token(&self) -> Option<&str> {
        self.next_page_token.as_deref().filter(|s| !s.is_empty())
    }

    fn append_page(&mut self, next: Self) {
        self.meetings.extend(next.meetings);
        // Normalize empty string to None — empty token means no more pages.
        self.next_page_token = next.next_page_token.filter(|t| !t.is_empty());
    }
}

impl Paginated for UserList {
    fn next_page_token(&self) -> Option<&str> {
        self.next_page_token.as_deref().filter(|s| !s.is_empty())
    }

    fn append_page(&mut self, next: Self) {
        self.users.extend(next.users);
        self.next_page_token = next.next_page_token.filter(|t| !t.is_empty());
    }
}

impl Paginated for RecordingList {
    fn next_page_token(&self) -> Option<&str> {
        self.next_page_token.as_deref().filter(|s| !s.is_empty())
    }

    fn append_page(&mut self, next: Self) {
        match (self.recordings.as_mut(), next.recordings) {
            (Some(dst), Some(src)) => dst.extend(src),
            (None, Some(src)) => self.recordings = Some(src),
            _ => {}
        }
        self.next_page_token = next.next_page_token.filter(|t| !t.is_empty());
    }
}

impl Paginated for ParticipantList {
    fn next_page_token(&self) -> Option<&str> {
        self.next_page_token.as_deref().filter(|s| !s.is_empty())
    }

    fn append_page(&mut self, next: Self) {
        self.participants.extend(next.participants);
        self.next_page_token = next.next_page_token.filter(|t| !t.is_empty());
    }
}

impl Paginated for UserMeetingReportList {
    fn next_page_token(&self) -> Option<&str> {
        self.next_page_token.as_deref().filter(|s| !s.is_empty())
    }

    fn append_page(&mut self, next: Self) {
        self.meetings.extend(next.meetings);
        self.next_page_token = next.next_page_token.filter(|t| !t.is_empty());
    }
}

impl Paginated for MeetingParticipantReportList {
    fn next_page_token(&self) -> Option<&str> {
        self.next_page_token.as_deref().filter(|s| !s.is_empty())
    }
    fn append_page(&mut self, next: Self) {
        self.participants.extend(next.participants);
        self.next_page_token = next.next_page_token.filter(|t| !t.is_empty());
    }
}

impl Paginated for WebinarList {
    fn next_page_token(&self) -> Option<&str> {
        self.next_page_token.as_deref().filter(|s| !s.is_empty())
    }

    fn append_page(&mut self, next: Self) {
        self.webinars.extend(next.webinars);
        self.next_page_token = next.next_page_token.filter(|t| !t.is_empty());
    }
}

// ── Auth ──────────────────────────────────────────────────────────────────────

#[derive(Debug, Deserialize)]
pub struct TokenResponse {
    pub access_token: String,
    pub token_type: String,
    pub expires_in: u64,
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn meeting_deserializes_from_zoom_api_shape() {
        let json = r#"{
            "id": 123456789,
            "topic": "Weekly Standup",
            "start_time": "2026-04-03T09:00:00Z",
            "duration": 30,
            "join_url": "https://zoom.us/j/123456789",
            "start_url": "https://zoom.us/s/123456789",
            "status": "waiting",
            "created_at": "2026-04-02T10:00:00Z",
            "type": 2
        }"#;
        let m: Meeting = serde_json::from_str(json).unwrap();
        assert_eq!(m.id, 123456789);
        assert_eq!(m.topic, "Weekly Standup");
        assert_eq!(m.duration, Some(30));
        assert_eq!(m.meeting_type, Some(2));
    }

    #[test]
    fn meeting_serializes_skipping_null_fields() {
        let m = Meeting {
            id: 1,
            topic: "Test".into(),
            start_time: None,
            duration: Some(30),
            join_url: None,
            start_url: None,
            status: None,
            created_at: None,
            password: None,
            meeting_type: Some(2),
        };
        let v: serde_json::Value = serde_json::to_value(&m).unwrap();
        assert!(v.get("start_time").is_none(), "null fields must be omitted");
        assert!(v.get("join_url").is_none(), "null fields must be omitted");
        assert_eq!(v["duration"], 30);
    }

    #[test]
    fn meeting_list_deserializes_with_pagination() {
        let json = r#"{
            "meetings": [
                {"id": 111, "topic": "A"},
                {"id": 222, "topic": "B"}
            ],
            "total_records": 2,
            "page_count": 1,
            "page_size": 30
        }"#;
        let list: MeetingList = serde_json::from_str(json).unwrap();
        assert_eq!(list.meetings.len(), 2);
        assert_eq!(list.total_records, Some(2));
        assert!(list.next_page_token.is_none());
    }

    #[test]
    fn meeting_list_serializes_without_page_internals() {
        let list = MeetingList {
            meetings: vec![],
            next_page_token: Some("".into()),
            total_records: Some(0),
            page_count: Some(1),
            page_size: Some(100),
        };
        let v: serde_json::Value = serde_json::to_value(&list).unwrap();
        assert!(
            v.get("page_count").is_none(),
            "page internals must be hidden"
        );
        assert!(
            v.get("page_size").is_none(),
            "page internals must be hidden"
        );
        assert!(
            v.get("next_page_token").is_none(),
            "empty token must be omitted"
        );
        assert_eq!(v["total_records"], 0);
    }

    #[test]
    fn user_deserializes_from_zoom_api_shape() {
        let json = r#"{
            "id": "user-abc-123",
            "email": "alice@example.com",
            "display_name": "Alice Smith",
            "first_name": "Alice",
            "last_name": "Smith",
            "status": "active",
            "type": 2
        }"#;
        let u: User = serde_json::from_str(json).unwrap();
        assert_eq!(u.id, "user-abc-123");
        assert_eq!(u.email, "alice@example.com");
        assert_eq!(u.display_name, Some("Alice Smith".into()));
        assert_eq!(u.user_type, Some(2));
    }

    #[test]
    fn user_serializes_skipping_null_fields() {
        let u = User {
            id: "u1".into(),
            email: "a@b.com".into(),
            display_name: Some("Alice".into()),
            first_name: None,
            last_name: None,
            status: Some("active".into()),
            user_type: Some(2),
            created_at: None,
            last_login_time: None,
            pic_url: None,
        };
        let v: serde_json::Value = serde_json::to_value(&u).unwrap();
        assert!(v.get("first_name").is_none());
        assert!(v.get("pic_url").is_none());
        assert_eq!(v["display_name"], "Alice");
    }

    #[test]
    fn recording_file_deserializes_with_optional_fields() {
        let json = r#"{
            "id": "rec-file-001",
            "file_type": "MP4",
            "file_size": 104857600,
            "download_url": "https://zoom.us/rec/download/abc123",
            "status": "completed",
            "recording_type": "shared_screen_with_speaker_view"
        }"#;
        let f: RecordingFile = serde_json::from_str(json).unwrap();
        assert_eq!(f.file_type, Some("MP4".into()));
        assert_eq!(f.file_size, Some(104857600));
    }

    #[test]
    fn recording_list_deserializes_meetings_key() {
        let json = r#"{
            "meetings": [
                {"id": 1, "topic": "Test", "start_time": "2026-01-01T10:00:00Z"}
            ],
            "total_records": 1,
            "from": "2026-01-01",
            "to": "2026-04-01",
            "next_page_token": ""
        }"#;
        let list: RecordingList = serde_json::from_str(json).unwrap();
        assert_eq!(list.recordings.as_ref().unwrap().len(), 1);
        assert_eq!(list.total_records, Some(1));
    }

    #[test]
    fn recording_list_serializes_recordings_key() {
        let list = RecordingList {
            recordings: Some(vec![]),
            next_page_token: Some("".into()),
            total_records: Some(0),
            from: Some("2026-01-01".into()),
            to: Some("2026-04-01".into()),
        };
        let v: serde_json::Value = serde_json::to_value(&list).unwrap();
        assert!(
            v.get("meetings").is_none(),
            "must serialize as 'recordings', not 'meetings'"
        );
        assert!(v.get("recordings").is_some());
        assert!(
            v.get("next_page_token").is_none(),
            "empty token must be omitted"
        );
    }

    #[test]
    fn token_response_deserializes() {
        let json = r#"{
            "access_token": "eyJhbGc...",
            "token_type": "bearer",
            "expires_in": 3599
        }"#;
        let t: TokenResponse = serde_json::from_str(json).unwrap();
        assert_eq!(t.access_token, "eyJhbGc...");
        assert_eq!(t.expires_in, 3599);
    }

    #[test]
    fn create_meeting_request_serializes_skipping_nones() {
        let req = CreateMeetingRequest {
            topic: "Demo".into(),
            start_time: None,
            duration: Some(45),
            password: None,
            meeting_type: 2,
        };
        let json: serde_json::Value = serde_json::to_value(&req).unwrap();
        assert_eq!(json["topic"], "Demo");
        assert_eq!(json["duration"], 45);
        assert_eq!(json["type"], 2);
        assert!(
            json.get("start_time").is_none(),
            "None fields must be omitted"
        );
        assert!(
            json.get("password").is_none(),
            "None fields must be omitted"
        );
    }

    #[test]
    fn participant_list_deserializes() {
        let json = r#"{
            "participants": [
                {
                    "id": "u1",
                    "name": "Alice",
                    "user_email": "alice@example.com",
                    "join_time": "2026-04-01T10:00:00Z",
                    "leave_time": "2026-04-01T11:00:00Z",
                    "duration": 3600
                }
            ],
            "total_records": 1,
            "page_size": 300,
            "next_page_token": ""
        }"#;
        let list: ParticipantList = serde_json::from_str(json).unwrap();
        assert_eq!(list.participants.len(), 1);
        assert_eq!(list.participants[0].name, Some("Alice".into()));
        assert_eq!(list.participants[0].duration, Some(3600));
        // page internals and empty token must not serialize
        let v: serde_json::Value = serde_json::to_value(&list).unwrap();
        assert!(v.get("page_size").is_none());
        assert!(v.get("next_page_token").is_none());
    }

    #[test]
    fn meeting_list_paginated_append_merges_items() {
        let mut first = MeetingList {
            meetings: vec![Meeting {
                id: 1,
                topic: "First".into(),
                start_time: None,
                duration: None,
                join_url: None,
                start_url: None,
                status: None,
                created_at: None,
                password: None,
                meeting_type: None,
            }],
            next_page_token: Some("tok".into()),
            total_records: Some(2),
            page_count: None,
            page_size: None,
        };
        let second = MeetingList {
            meetings: vec![Meeting {
                id: 2,
                topic: "Second".into(),
                start_time: None,
                duration: None,
                join_url: None,
                start_url: None,
                status: None,
                created_at: None,
                password: None,
                meeting_type: None,
            }],
            next_page_token: Some("".into()),
            total_records: Some(2),
            page_count: None,
            page_size: None,
        };
        first.append_page(second);
        assert_eq!(first.meetings.len(), 2);
        assert_eq!(first.next_page_token(), None, "empty token is exhausted");
        assert_eq!(
            first.total_records,
            Some(2),
            "total_records preserved from first page"
        );
    }

    #[test]
    fn recording_list_paginated_append_merges_option_vec() {
        let mut first = RecordingList {
            recordings: Some(vec![CloudRecording {
                id: 1,
                topic: "Rec 1".into(),
                start_time: "2026-01-01T10:00:00Z".into(),
                duration: None,
                total_size: None,
                recording_count: None,
                recording_files: None,
            }]),
            next_page_token: Some("t".into()),
            total_records: Some(2),
            from: None,
            to: None,
        };
        let second = RecordingList {
            recordings: Some(vec![CloudRecording {
                id: 2,
                topic: "Rec 2".into(),
                start_time: "2026-01-02T10:00:00Z".into(),
                duration: None,
                total_size: None,
                recording_count: None,
                recording_files: None,
            }]),
            next_page_token: None,
            total_records: Some(2),
            from: None,
            to: None,
        };
        first.append_page(second);
        assert_eq!(first.recordings.as_ref().unwrap().len(), 2);
        assert_eq!(first.next_page_token(), None);
    }

    #[test]
    fn webinar_list_deserializes_and_serializes() {
        let json = r#"{
            "webinars": [
                {
                    "id": 12345678,
                    "topic": "Product Launch",
                    "start_time": "2026-05-01T14:00:00Z",
                    "duration": 60,
                    "type": 5
                }
            ],
            "total_records": 1,
            "page_size": 300
        }"#;
        let list: WebinarList = serde_json::from_str(json).unwrap();
        assert_eq!(list.webinars.len(), 1);
        assert_eq!(list.webinars[0].id, 12345678);
        assert_eq!(list.webinars[0].topic, "Product Launch");
        assert_eq!(list.webinars[0].webinar_type, Some(5));
        // page_size must not appear in output
        let v: serde_json::Value = serde_json::to_value(&list).unwrap();
        assert!(v.get("page_size").is_none());
    }

    #[test]
    fn webinar_list_paginated_append_merges_items() {
        let mut first = WebinarList {
            webinars: vec![Webinar {
                id: 1,
                topic: "First".into(),
                start_time: None,
                duration: None,
                join_url: None,
                agenda: None,
                status: None,
                webinar_type: None,
            }],
            next_page_token: Some("tok".into()),
            total_records: Some(2),
            page_size: None,
        };
        let second = WebinarList {
            webinars: vec![Webinar {
                id: 2,
                topic: "Second".into(),
                start_time: None,
                duration: None,
                join_url: None,
                agenda: None,
                status: None,
                webinar_type: None,
            }],
            next_page_token: Some("".into()),
            total_records: Some(2),
            page_size: None,
        };
        first.append_page(second);
        assert_eq!(first.webinars.len(), 2);
        assert_eq!(first.next_page_token(), None);
    }

    #[test]
    fn meeting_report_list_deserializes() {
        let json = r#"{
            "meetings": [
                {
                    "uuid": "abc==",
                    "id": 123,
                    "topic": "Standup",
                    "start_time": "2026-04-01T09:00:00Z",
                    "duration": 30,
                    "participants_count": 5
                }
            ],
            "total_records": 1,
            "from": "2026-04-01",
            "to": "2026-04-30"
        }"#;
        let list: UserMeetingReportList = serde_json::from_str(json).unwrap();
        assert_eq!(list.meetings.len(), 1);
        assert_eq!(list.meetings[0].participants_count, Some(5));
    }
}