feat: 增强日历功能并集成 AgentScope 代理服务
This commit is contained in:
@@ -12,43 +12,43 @@ class FriendsApi {
|
||||
return data.map((json) => FriendResponse.fromJson(json)).toList();
|
||||
}
|
||||
|
||||
Future<List<FriendResponse>> getIncomingRequests() async {
|
||||
final response = await _client.get('$_prefix/requests/inbox');
|
||||
final List<dynamic> data = response.data;
|
||||
return data.map((json) => FriendResponse.fromJson(json)).toList();
|
||||
}
|
||||
|
||||
Future<List<FriendResponse>> getOutgoingRequests() async {
|
||||
Future<List<FriendRequestResponse>> getOutgoingRequests() async {
|
||||
final response = await _client.get('$_prefix/requests/outgoing');
|
||||
final List<dynamic> data = response.data;
|
||||
return data.map((json) => FriendResponse.fromJson(json)).toList();
|
||||
return data.map((json) => FriendRequestResponse.fromJson(json)).toList();
|
||||
}
|
||||
|
||||
Future<FriendResponse> sendRequest(String targetUserId) async {
|
||||
final response = await _client.post(
|
||||
'$_prefix/requests',
|
||||
data: {'target_user_id': targetUserId},
|
||||
);
|
||||
return FriendResponse.fromJson(response.data);
|
||||
Future<FriendRequestResponse> sendRequest(
|
||||
String targetUserId, {
|
||||
String? content,
|
||||
}) async {
|
||||
final data = {'target_user_id': targetUserId, 'content': content};
|
||||
final response = await _client.post('$_prefix/requests', data: data);
|
||||
return FriendRequestResponse.fromJson(response.data);
|
||||
}
|
||||
|
||||
Future<FriendResponse> acceptRequest(String friendshipId) async {
|
||||
Future<FriendRequestResponse> acceptRequest(String friendshipId) async {
|
||||
final response = await _client.post(
|
||||
'$_prefix/requests/$friendshipId/accept',
|
||||
);
|
||||
return FriendResponse.fromJson(response.data);
|
||||
return FriendRequestResponse.fromJson(response.data);
|
||||
}
|
||||
|
||||
Future<FriendResponse> declineRequest(String friendshipId) async {
|
||||
Future<FriendRequestResponse> declineRequest(String friendshipId) async {
|
||||
final response = await _client.post(
|
||||
'$_prefix/requests/$friendshipId/decline',
|
||||
);
|
||||
return FriendResponse.fromJson(response.data);
|
||||
return FriendRequestResponse.fromJson(response.data);
|
||||
}
|
||||
|
||||
Future<void> removeFriend(String friendshipId) async {
|
||||
await _client.delete('$_prefix/$friendshipId');
|
||||
}
|
||||
|
||||
Future<FriendRequestResponse> getRequestById(String friendshipId) async {
|
||||
final response = await _client.get('$_prefix/requests/$friendshipId');
|
||||
return FriendRequestResponse.fromJson(response.data);
|
||||
}
|
||||
}
|
||||
|
||||
class FriendResponse {
|
||||
@@ -94,3 +94,34 @@ class UserBasicInfo {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FriendRequestResponse {
|
||||
final String id;
|
||||
final UserBasicInfo sender;
|
||||
final UserBasicInfo recipient;
|
||||
final String? content;
|
||||
final String status;
|
||||
final DateTime createdAt;
|
||||
|
||||
FriendRequestResponse({
|
||||
required this.id,
|
||||
required this.sender,
|
||||
required this.recipient,
|
||||
this.content,
|
||||
required this.status,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory FriendRequestResponse.fromJson(Map<String, dynamic> json) {
|
||||
return FriendRequestResponse(
|
||||
id: json['id'] as String,
|
||||
sender: UserBasicInfo.fromJson(json['sender'] as Map<String, dynamic>),
|
||||
recipient: UserBasicInfo.fromJson(
|
||||
json['recipient'] as Map<String, dynamic>,
|
||||
),
|
||||
content: json['content'] as String?,
|
||||
status: json['status'] as String,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user