From b46486a1e01222f1980c79731750579e3839b584 Mon Sep 17 00:00:00 2001 From: sherlockvn Date: Mon, 24 Jun 2024 14:46:53 +0700 Subject: [PATCH] add displayname and avatarurl to presence response --- lib/src/generated/model.dart | 15 ++++++++++++++- lib/src/model/presence_content.dart | 16 +++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/src/generated/model.dart b/lib/src/generated/model.dart index 3ab82f7..c445517 100644 --- a/lib/src/generated/model.dart +++ b/lib/src/generated/model.dart @@ -1579,6 +1579,8 @@ class GetPresenceResponse { this.lastActiveAgo, required this.presence, this.statusMsg, + this.avatarUrl, + this.displayname, }); GetPresenceResponse.fromJson(Map json) @@ -1587,7 +1589,10 @@ class GetPresenceResponse { lastActiveAgo = ((v) => v != null ? v as int : null)(json['last_active_ago']), presence = PresenceType.values.fromString(json['presence'] as String)!, - statusMsg = ((v) => v != null ? v as String : null)(json['status_msg']); + statusMsg = ((v) => v != null ? v as String : null)(json['status_msg']), + avatarUrl = ((v) => v != null ? v as String : null)(json['avatar_url']), + displayname = + ((v) => v != null ? v as String : null)(json['displayname']); Map toJson() { final currentlyActive = this.currentlyActive; final lastActiveAgo = this.lastActiveAgo; @@ -1597,6 +1602,8 @@ class GetPresenceResponse { if (lastActiveAgo != null) 'last_active_ago': lastActiveAgo, 'presence': presence.name, if (statusMsg != null) 'status_msg': statusMsg, + if (avatarUrl != null) 'avatar_url': avatarUrl, + if (displayname != null) 'displayname': displayname, }; } @@ -1612,6 +1619,12 @@ class GetPresenceResponse { /// The state message for this user if one was set. String? statusMsg; + + /// The avatarUrl of current user if have + String? avatarUrl; + + /// The displayname of current user if have + String? displayname; } /// diff --git a/lib/src/model/presence_content.dart b/lib/src/model/presence_content.dart index 2566596..5e1dd1f 100644 --- a/lib/src/model/presence_content.dart +++ b/lib/src/model/presence_content.dart @@ -28,13 +28,17 @@ class PresenceContent { int? lastActiveAgo; String? statusMsg; bool? currentlyActive; + String? avatarUrl; + String? displayname; PresenceContent.fromJson(Map json) - : presence = PresenceType.values.firstWhere( - (p) => p.toString().split('.').last == json['presence']), + : presence = + PresenceType.values.firstWhere((p) => p.toString().split('.').last == json['presence']), lastActiveAgo = json.tryGet('last_active_ago'), statusMsg = json.tryGet('status_msg'), - currentlyActive = json.tryGet('currently_active'); + currentlyActive = json.tryGet('currently_active'), + avatarUrl = json.tryGet('avatar_url'), + displayname = json.tryGet('displayname'); Map toJson() { final data = {}; @@ -48,6 +52,12 @@ class PresenceContent { if (currentlyActive != null) { data['currently_active'] = currentlyActive; } + if (avatarUrl != null) { + data['avatar_url'] = avatarUrl; + } + if (displayname != null) { + data['displayname'] = displayname; + } return data; } }