-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignalWrapper.cs
More file actions
730 lines (579 loc) · 27 KB
/
SignalWrapper.cs
File metadata and controls
730 lines (579 loc) · 27 KB
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
using System;
using System.Net;
using System.Threading.Tasks;
using RestSharp;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace SignalWrapper
{
public class SignalApiClient : IDisposable
{
private readonly RestClient _client;
private bool _disposed = false;
public SignalApiClient(string baseUrl, int timeoutMilliseconds = 30000)
{
var options = new RestClientOptions(baseUrl)
{
ThrowOnAnyError = false,
Timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds)
};
_client = new RestClient(options);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_client?.Dispose();
}
_disposed = true;
}
// General
public async Task<About> GetAboutAsync() => await ExecuteAsync<About>(new RestRequest("/v1/about", Method.Get));
public async Task<Configuration> GetConfigurationAsync() => await ExecuteAsync<Configuration>(new RestRequest("/v1/configuration", Method.Get));
public async Task SetConfigurationAsync(Configuration config) => await ExecuteAsync(new RestRequest("/v1/configuration", Method.Post).AddJsonBody(config));
// Accounts
public async Task<List<string>> GetAccountsAsync() => await ExecuteAsync<List<string>>(new RestRequest("/v1/accounts", Method.Get));
public async Task SetPinAsync(string number, string pin) => await ExecuteAsync(new RestRequest($"/v1/accounts/{number}/pin", Method.Post).AddJsonBody(new { pin }));
public async Task RemovePinAsync(string number) => await ExecuteAsync(new RestRequest($"/v1/accounts/{number}/pin", Method.Delete));
public async Task RateLimitChallengeAsync(string number, RateLimitChallengeRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/accounts/{number}/rate-limit-challenge", Method.Post).AddJsonBody(request));
public async Task UpdateAccountSettingsAsync(string number, UpdateAccountSettingsRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/accounts/{number}/settings", Method.Put).AddJsonBody(request));
public async Task<SetUsernameResponse> SetUsernameAsync(string number, SetUsernameRequest request) =>
await ExecuteAsync<SetUsernameResponse>(new RestRequest($"/v1/accounts/{number}/username", Method.Post).AddJsonBody(request));
public async Task RemoveUsernameAsync(string number) =>
await ExecuteAsync(new RestRequest($"/v1/accounts/{number}/username", Method.Delete));
// Devices
public async Task RegisterNumberAsync(string number, RegisterNumberRequest request = null) =>
await ExecuteAsync(new RestRequest($"/v1/register/{number}", Method.Post).AddJsonBody(request ?? new RegisterNumberRequest()));
public async Task VerifyNumberAsync(string number, string token, VerifyNumberSettings settings = null) =>
await ExecuteAsync(new RestRequest($"/v1/register/{number}/verify/{token}", Method.Post).AddJsonBody(settings ?? new VerifyNumberSettings()));
// Messages
[Obsolete("/v1/send is deprecated.")]
public async Task<string> SendMessageLegacyAsync(SendMessageLegacy message) =>
await ExecuteAsStringAsync(new RestRequest("/v1/send", Method.Post).AddJsonBody(message));
public async Task<SendMessageResponse> SendMessageAsync(SendMessage message) =>
await ExecuteAsync<SendMessageResponse>(new RestRequest("/v2/send", Method.Post).AddJsonBody(message));
// Contacts
public async Task<List<ListContactsResponse>> GetContactsAsync(string number) =>
await ExecuteAsync<List<ListContactsResponse>>(new RestRequest($"/v1/contacts/{number}", Method.Get));
public async Task UpdateContactAsync(string number, UpdateContactRequest contact) =>
await ExecuteAsync(new RestRequest($"/v1/contacts/{number}", Method.Put).AddJsonBody(contact));
public async Task<ListContactsResponse> GetContactAsync(string number, string uuid) =>
await ExecuteAsync<ListContactsResponse>(new RestRequest($"/v1/contacts/{number}/{uuid}", Method.Get));
public async Task<string?> GetContactAvatarAsync(string number, string uuid) =>
await ExecuteAsStringAsync(new RestRequest($"/v1/contacts/{number}/{uuid}/avatar", Method.Get));
public async Task SyncContactsAsync(string number) =>
await ExecuteAsync(new RestRequest($"/v1/contacts/{number}/sync", Method.Post));
// Attachments
public async Task<List<string>> GetAttachmentsAsync() =>
await ExecuteAsync<List<string>>(new RestRequest("/v1/attachments", Method.Get));
public async Task<string?> GetAttachmentAsync(string attachmentId) =>
await ExecuteAsStringAsync(new RestRequest($"/v1/attachments/{attachmentId}", Method.Get));
public async Task DeleteAttachmentAsync(string attachmentId) =>
await ExecuteAsync(new RestRequest($"/v1/attachments/{attachmentId}", Method.Delete));
// Groups
public async Task<List<GroupEntry>> GetGroupsAsync(string number) =>
await ExecuteAsync<List<GroupEntry>>(new RestRequest($"/v1/groups/{number}", Method.Get));
public async Task<CreateGroupResponse> CreateGroupAsync(string number, CreateGroupRequest request) =>
await ExecuteAsync<CreateGroupResponse>(new RestRequest($"/v1/groups/{number}", Method.Post).AddJsonBody(request));
public async Task<GroupEntry> GetGroupAsync(string number, string groupid) =>
await ExecuteAsync<GroupEntry>(new RestRequest($"/v1/groups/{number}/{groupid}", Method.Get));
public async Task UpdateGroupAsync(string number, string groupid, UpdateGroupRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/groups/{number}/{groupid}", Method.Put).AddJsonBody(request));
public async Task DeleteGroupAsync(string number, string groupid) =>
await ExecuteAsync(new RestRequest($"/v1/groups/{number}/{groupid}", Method.Delete));
public async Task AddGroupAdminsAsync(string number, string groupid, ChangeGroupAdminsRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/groups/{number}/{groupid}/admins", Method.Post).AddJsonBody(request));
public async Task RemoveGroupAdminsAsync(string number, string groupid, ChangeGroupAdminsRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/groups/{number}/{groupid}/admins", Method.Delete).AddJsonBody(request));
public async Task<string?> GetGroupAvatarAsync(string number, string groupid) =>
await ExecuteAsStringAsync(new RestRequest($"/v1/groups/{number}/{groupid}/avatar", Method.Get));
public async Task BlockGroupAsync(string number, string groupid) =>
await ExecuteAsync(new RestRequest($"/v1/groups/{number}/{groupid}/block", Method.Post));
public async Task JoinGroupAsync(string number, string groupid) =>
await ExecuteAsync(new RestRequest($"/v1/groups/{number}/{groupid}/join", Method.Post));
public async Task AddGroupMembersAsync(string number, string groupid, ChangeGroupMembersRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/groups/{number}/{groupid}/members", Method.Post).AddJsonBody(request));
public async Task RemoveGroupMembersAsync(string number, string groupid, ChangeGroupMembersRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/groups/{number}/{groupid}/members", Method.Delete).AddJsonBody(request));
public async Task QuitGroupAsync(string number, string groupid) =>
await ExecuteAsync(new RestRequest($"/v1/groups/{number}/{groupid}/quit", Method.Post));
// Identities
public async Task<List<IdentityEntry>> GetIdentitiesAsync(string number) =>
await ExecuteAsync<List<IdentityEntry>>(new RestRequest($"/v1/identities/{number}", Method.Get));
public async Task TrustIdentityAsync(string number, string numberToTrust, TrustIdentityRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/identities/{number}/trust/{numberToTrust}", Method.Put).AddJsonBody(request));
// Profiles
public async Task UpdateProfileAsync(string number, UpdateProfileRequest profile) =>
await ExecuteAsync(new RestRequest($"/v1/profiles/{number}", Method.Put).AddJsonBody(profile));
// Reactions
public async Task SendReactionAsync(string number, ReactionModel reaction) =>
await ExecuteAsync(new RestRequest($"/v1/reactions/{number}", Method.Post).AddJsonBody(reaction));
public async Task RemoveReactionAsync(string number, ReactionModel reaction) =>
await ExecuteAsync(new RestRequest($"/v1/reactions/{number}", Method.Delete).AddJsonBody(reaction));
// Receipts
public async Task SendReceiptAsync(string number, Receipt receipt) =>
await ExecuteAsync(new RestRequest($"/v1/receipts/{number}", Method.Post).AddJsonBody(receipt));
// Search
public async Task<List<SearchResponse>> SearchAsync(string number, List<string> numbers) =>
await ExecuteAsync<List<SearchResponse>>(new RestRequest($"/v1/search/{number}", Method.Get)
.AddQueryParameter("numbers", string.Join(",", numbers)));
// Sticker Packs
public async Task<List<ListInstalledStickerPacksResponse>> GetStickerPacksAsync(string number) =>
await ExecuteAsync<List<ListInstalledStickerPacksResponse>>(new RestRequest($"/v1/sticker-packs/{number}", Method.Get));
public async Task AddStickerPackAsync(string number, AddStickerPackRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/sticker-packs/{number}", Method.Post).AddJsonBody(request));
// Typing Indicators
public async Task ShowTypingIndicatorAsync(string number, TypingIndicatorRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/typing-indicator/{number}", Method.Put).AddJsonBody(request));
public async Task HideTypingIndicatorAsync(string number, TypingIndicatorRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/typing-indicator/{number}", Method.Delete).AddJsonBody(request));
// QR Code Link
public async Task<string?> GenerateQrCodeLinkAsync(string deviceName, int? qrcodeVersion = null) =>
await ExecuteAsStringAsync(new RestRequest("/v1/qrcodelink", Method.Get)
.AddQueryParameter("device_name", deviceName)
.AddQueryParameter("qrcode_version", qrcodeVersion?.ToString()));
// Health Check
public async Task HealthCheckAsync() =>
await ExecuteAsync(new RestRequest("/v1/health", Method.Get));
// Devices (additional)
public async Task<List<ListDevicesResponse>> GetDevicesAsync(string number) =>
await ExecuteAsync<List<ListDevicesResponse>>(new RestRequest($"/v1/devices/{number}", Method.Get));
public async Task LinkDeviceAsync(string number, AddDeviceRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/devices/{number}", Method.Post).AddJsonBody(request));
// Unregister
public async Task UnregisterNumberAsync(string number, UnregisterNumberRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/unregister/{number}", Method.Post).AddJsonBody(request));
// Remote Delete
public async Task<RemoteDeleteResponse> RemoteDeleteAsync(string number, RemoteDeleteRequest request) =>
await ExecuteAsync<RemoteDeleteResponse>(new RestRequest($"/v1/remote-delete/{number}", Method.Delete).AddJsonBody(request));
// Receive Messages
public async Task<List<string>> ReceiveMessagesAsync(string number, int? timeout = null, bool? ignoreAttachments = null,
bool? ignoreStories = null, int? maxMessages = null, bool? sendReadReceipts = null)
{
var request = new RestRequest($"/v1/receive/{number}", Method.Get);
if (timeout.HasValue)
request.AddQueryParameter("timeout", timeout.Value.ToString());
if (ignoreAttachments.HasValue)
request.AddQueryParameter("ignore_attachments", ignoreAttachments.Value.ToString().ToLower());
if (ignoreStories.HasValue)
request.AddQueryParameter("ignore_stories", ignoreStories.Value.ToString().ToLower());
if (maxMessages.HasValue)
request.AddQueryParameter("max_messages", maxMessages.Value.ToString());
if (sendReadReceipts.HasValue)
request.AddQueryParameter("send_read_receipts", sendReadReceipts.Value.ToString().ToLower());
return await ExecuteAsync<List<string>>(request);
}
// Configuration Settings
public async Task<TrustModeResponse> GetAccountSettingsAsync(string number) =>
await ExecuteAsync<TrustModeResponse>(new RestRequest($"/v1/configuration/{number}/settings", Method.Get));
public async Task SetAccountSettingsAsync(string number, TrustModeRequest request) =>
await ExecuteAsync(new RestRequest($"/v1/configuration/{number}/settings", Method.Post).AddJsonBody(request));
// Private methods
private async Task<T> ExecuteAsync<T>(RestRequest request) where T : class, new()
{
var response = await _client.ExecuteAsync<T>(request);
HandleResponse(response);
return response.Data;
}
private async Task ExecuteAsync(RestRequest request)
{
var response = await _client.ExecuteAsync(request);
HandleResponse(response);
}
private async Task<string?> ExecuteAsStringAsync(RestRequest request)
{
var response = await _client.ExecuteAsync(request);
HandleResponse(response);
return response.Content ?? string.Empty;
}
private void HandleResponse(RestResponse response)
{
if (response.StatusCode == HttpStatusCode.OK ||
response.StatusCode == HttpStatusCode.Created ||
response.StatusCode == HttpStatusCode.NoContent)
return;
Error? error = null;
try
{
var content = response.Content ?? string.Empty;
if (!string.IsNullOrEmpty(content))
{
error = JsonConvert.DeserializeObject<Error>(content);
}
}
catch
{
// If deserialization fails, fall back to content as string
throw new Exception($"Request failed with status {response.StatusCode}: {response.Content ?? "No content"}");
}
throw new Exception($"API Error: {error?.Message ?? "Unknown error"}");
}
}
// Core Models
public class About
{
public int Build { get; set; }
public string Mode { get; set; }
public string Version { get; set; }
public List<string> Versions { get; set; }
public Dictionary<string, List<string>> Capabilities { get; set; }
}
public class Configuration
{
public LoggingConfiguration Logging { get; set; }
}
public class LoggingConfiguration
{
public string Level { get; set; }
}
public class Error
{
[JsonProperty("error")]
public string Message { get; set; }
}
// Account Models
public class RegisterNumberRequest
{
[JsonProperty("captcha")]
public string Captcha { get; set; }
[JsonProperty("use_voice")]
public bool UseVoice { get; set; }
}
public class VerifyNumberSettings
{
[JsonProperty("pin")]
public string Pin { get; set; }
}
// Message Models
public class SendMessageLegacy
{
[JsonProperty("base64_attachment")]
public string Base64Attachment { get; set; }
[JsonProperty("is_group")]
public bool IsGroup { get; set; }
[JsonProperty("message")]
public string Message { get; set; }
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("recipients")]
public List<string> Recipients { get; set; }
}
public class SendMessage
{
[JsonProperty("base64_attachments")]
public List<string> Base64Attachments { get; set; }
[JsonProperty("message")]
public string Message { get; set; }
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("recipients")]
public List<string> Recipients { get; set; }
[JsonProperty("text_mode")]
public string TextMode { get; set; } = "normal";
[JsonProperty("edit_timestamp")]
public long? EditTimestamp { get; set; }
[JsonProperty("link_preview")]
public LinkPreviewType LinkPreview { get; set; }
[JsonProperty("mentions")]
public List<MessageMention> Mentions { get; set; }
[JsonProperty("notify_self")]
public bool? NotifySelf { get; set; }
[JsonProperty("quote_author")]
public string QuoteAuthor { get; set; }
[JsonProperty("quote_mentions")]
public List<MessageMention> QuoteMentions { get; set; }
[JsonProperty("quote_message")]
public string QuoteMessage { get; set; }
[JsonProperty("quote_timestamp")]
public long? QuoteTimestamp { get; set; }
[JsonProperty("sticker")]
public string Sticker { get; set; }
[JsonProperty("view_once")]
public bool? ViewOnce { get; set; }
}
public class LinkPreviewType
{
public string Base64Thumbnail { get; set; }
public string Description { get; set; }
public string Title { get; set; }
public string Url { get; set; }
}
public class MessageMention
{
public string Author { get; set; }
public int Length { get; set; }
public int Start { get; set; }
}
public class SendMessageResponse
{
[JsonProperty("timestamp")]
public string Timestamp { get; set; }
}
// Contact Models
public class ListContactsResponse
{
public string Number { get; set; }
public string Name { get; set; }
public string GivenName { get; set; }
public ContactProfile Profile { get; set; }
public bool Blocked { get; set; }
public string Color { get; set; }
public string MessageExpiration { get; set; }
public Nickname Nickname { get; set; }
public string Note { get; set; }
public string ProfileName { get; set; }
public string Username { get; set; }
public string Uuid { get; set; }
}
public class ContactProfile
{
public string GivenName { get; set; }
public string About { get; set; }
public bool HasAvatar { get; set; }
public long LastUpdatedTimestamp { get; set; }
public string Lastname { get; set; }
}
public class Nickname
{
public string LastName { get; set; }
public string FirstName { get; set; }
public string Name { get; set; }
}
// Group Models
public class GroupEntry
{
public string Id { get; set; }
public string Name { get; set; }
public List<string> Members { get; set; }
public List<string> Admins { get; set; }
public bool Blocked { get; set; }
public string Description { get; set; }
public string InternalId { get; set; }
public string InviteLink { get; set; }
public List<string> PendingInvites { get; set; }
public List<string> PendingRequests { get; set; }
}
public class CreateGroupRequest
{
public string Name { get; set; }
public List<string> Members { get; set; }
public string Description { get; set; }
public GroupPermissions Permissions { get; set; }
public int? ExpirationTime { get; set; }
public string GroupLink { get; set; }
}
public class GroupPermissions
{
public string AddMembers { get; set; } = "only-admins";
public string EditGroup { get; set; } = "only-admins";
public string SendMessages { get; set; } = "every-member";
}
public class CreateGroupResponse
{
public string Id { get; set; }
}
// Identity Models
public class IdentityEntry
{
public string Number { get; set; }
public string Uuid { get; set; }
public string Fingerprint { get; set; }
public string SafetyNumber { get; set; }
public string Status { get; set; }
public string Added { get; set; }
}
// Profile Models
public class UpdateProfileRequest
{
public string Name { get; set; }
public string About { get; set; }
public string Base64Avatar { get; set; }
}
// Reaction Models
public class ReactionModel
{
[JsonProperty("reaction")]
public string Reaction { get; set; }
[JsonProperty("recipient")]
public string Recipient { get; set; }
[JsonProperty("target_author")]
public string TargetAuthor { get; set; }
[JsonProperty("timestamp")]
public long? Timestamp { get; set; }
}
// Receipt Models
public class Receipt
{
[JsonProperty("receipt_type")]
public string ReceiptType { get; set; }
[JsonProperty("recipient")]
public string Recipient { get; set; }
[JsonProperty("timestamp")]
public long? Timestamp { get; set; }
}
// Search Models
public class SearchResponse
{
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("registered")]
public bool Registered { get; set; }
}
// Sticker Pack Models
public class ListInstalledStickerPacksResponse
{
[JsonProperty("pack_id")]
public string PackId { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("author")]
public string Author { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("installed")]
public bool Installed { get; set; }
}
public class AddStickerPackRequest
{
[JsonProperty("pack_id")]
public string PackId { get; set; }
[JsonProperty("pack_key")]
public string PackKey { get; set; }
}
// Typing Indicator Models
public class TypingIndicatorRequest
{
[JsonProperty("recipient")]
public string Recipient { get; set; }
}
// Device Models
public class ListDevicesResponse
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("creation_timestamp")]
public long CreationTimestamp { get; set; }
[JsonProperty("last_seen_timestamp")]
public long LastSeenTimestamp { get; set; }
}
public class AddDeviceRequest
{
[JsonProperty("uri")]
public string Uri { get; set; } = string.Empty;
}
// Unregister Models
public class UnregisterNumberRequest
{
[JsonProperty("delete_account")]
public bool DeleteAccount { get; set; }
[JsonProperty("delete_local_data")]
public bool DeleteLocalData { get; set; }
}
// Remote Delete Models
public class RemoteDeleteRequest
{
[JsonProperty("recipient")]
public string Recipient { get; set; }
[JsonProperty("timestamp")]
public long? Timestamp { get; set; }
}
public class RemoteDeleteResponse
{
[JsonProperty("timestamp")]
public string Timestamp { get; set; }
}
// Update Contact Models
public class UpdateContactRequest
{
[JsonProperty("recipient")]
public string Recipient { get; set; } = string.Empty;
[JsonProperty("name")]
public string Name { get; set; } = string.Empty;
[JsonProperty("expiration_in_seconds")]
public int? ExpirationInSeconds { get; set; }
}
// Update Group Models
public class UpdateGroupRequest
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("base64_avatar")]
public string Base64Avatar { get; set; }
[JsonProperty("expiration_time")]
public int? ExpirationTime { get; set; }
[JsonProperty("group_link")]
public string GroupLink { get; set; }
[JsonProperty("permissions")]
public GroupPermissions Permissions { get; set; }
}
// Trust Identity Models
public class TrustIdentityRequest
{
[JsonProperty("trust_all_known_keys")]
public bool TrustAllKnownKeys { get; set; }
[JsonProperty("verified_safety_number")]
public string VerifiedSafetyNumber { get; set; }
}
// Configuration Settings Models
public class TrustModeRequest
{
[JsonProperty("trust_mode")]
public string TrustMode { get; set; }
}
public class TrustModeResponse
{
[JsonProperty("trust_mode")]
public string TrustMode { get; set; }
}
// Change Group Admins/Members Models
public class ChangeGroupAdminsRequest
{
[JsonProperty("admins")]
public List<string> Admins { get; set; }
}
public class ChangeGroupMembersRequest
{
[JsonProperty("members")]
public List<string> Members { get; set; }
}
// Rate Limit Challenge Models
public class RateLimitChallengeRequest
{
[JsonProperty("challenge_token")]
public string ChallengeToken { get; set; }
[JsonProperty("captcha")]
public string Captcha { get; set; }
}
// Account Settings Models
public class UpdateAccountSettingsRequest
{
[JsonProperty("discoverable_by_number")]
public bool? DiscoverableByNumber { get; set; }
[JsonProperty("share_number")]
public bool? ShareNumber { get; set; }
}
// Username Models
public class SetUsernameRequest
{
[JsonProperty("username")]
public string Username { get; set; }
}
public class SetUsernameResponse
{
[JsonProperty("username")]
public string Username { get; set; }
[JsonProperty("username_link")]
public string UsernameLink { get; set; }
}
}