Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add displayname and avatarurl to presence response #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/src/generated/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,8 @@ class GetPresenceResponse {
this.lastActiveAgo,
required this.presence,
this.statusMsg,
this.avatarUrl,
this.displayname,
});

GetPresenceResponse.fromJson(Map<String, Object?> json)
Expand All @@ -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<String, Object?> toJson() {
final currentlyActive = this.currentlyActive;
final lastActiveAgo = this.lastActiveAgo;
Expand All @@ -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,
};
}

Expand All @@ -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;
}

///
Expand Down
16 changes: 13 additions & 3 deletions lib/src/model/presence_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ class PresenceContent {
int? lastActiveAgo;
String? statusMsg;
bool? currentlyActive;
String? avatarUrl;
String? displayname;

PresenceContent.fromJson(Map<String, Object?> 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<int>('last_active_ago'),
statusMsg = json.tryGet<String>('status_msg'),
currentlyActive = json.tryGet<bool>('currently_active');
currentlyActive = json.tryGet<bool>('currently_active'),
avatarUrl = json.tryGet<String>('avatar_url'),
displayname = json.tryGet<String>('displayname');

Map<String, Object?> toJson() {
final data = <String, Object?>{};
Expand All @@ -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;
}
}
Loading