implement keytoken list and all-messages list
This commit is contained in:
@@ -39,6 +39,7 @@ class MessageFilter {
|
||||
DateTime? timeBefore;
|
||||
DateTime? timeAfter;
|
||||
bool? hasSenderName;
|
||||
List<String>? senderUserID;
|
||||
|
||||
MessageFilter({
|
||||
this.channelIDs,
|
||||
@@ -49,6 +50,7 @@ class MessageFilter {
|
||||
this.priority,
|
||||
this.timeBefore,
|
||||
this.timeAfter,
|
||||
this.senderUserID,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -281,7 +283,7 @@ class APIClient {
|
||||
);
|
||||
}
|
||||
|
||||
static Future<(String, List<SCNMessage>)> getMessageList(TokenSource auth, String pageToken, {int? pageSize, MessageFilter? filter}) async {
|
||||
static Future<(String, List<SCNMessage>)> getMessageList(TokenSource auth, String pageToken, {int? pageSize, MessageFilter? filter, bool? includeNonSuscribed}) async {
|
||||
return await _request(
|
||||
name: 'getMessageList',
|
||||
method: 'GET',
|
||||
@@ -298,6 +300,8 @@ class APIClient {
|
||||
if (filter?.timeAfter != null) 'after': [filter!.timeAfter!.toIso8601String()],
|
||||
if (filter?.priority != null) 'priority': filter!.priority!.map((p) => p.toString()).toList(),
|
||||
if (filter?.usedKeys != null) 'used_key': filter!.usedKeys!,
|
||||
if (filter?.senderUserID != null) 'sender_user_id': filter!.senderUserID!,
|
||||
if (includeNonSuscribed ?? false) 'subscription_status': ['all'],
|
||||
},
|
||||
fn: (json) => SCNMessage.fromPaginatedJsonArray(json, 'messages', 'next_page_token'),
|
||||
authToken: auth.getToken(),
|
||||
@@ -426,6 +430,22 @@ class APIClient {
|
||||
);
|
||||
}
|
||||
|
||||
static Future<KeyToken> updateKeyToken(TokenSource auth, String kid, {String? name, bool? allChannels, List<String>? channels, String? permissions}) async {
|
||||
return await _request(
|
||||
name: 'updateKeyToken',
|
||||
method: 'PATCH',
|
||||
relURL: 'users/${auth.getUserID()}/keys/${kid}',
|
||||
jsonBody: {
|
||||
if (name != null) 'name': name,
|
||||
if (allChannels != null) 'all_channels': allChannels,
|
||||
if (channels != null) 'channels': channels,
|
||||
if (permissions != null) 'permissions': permissions,
|
||||
},
|
||||
fn: KeyToken.fromJson,
|
||||
authToken: auth.getToken(),
|
||||
);
|
||||
}
|
||||
|
||||
static Future<KeyTokenWithToken> createKeyToken(TokenSource auth, String name, String perm, bool allChannels, {List<String>? channels}) async {
|
||||
return await _request(
|
||||
name: 'createKeyToken',
|
||||
|
Reference in New Issue
Block a user