api and storage restructure

This commit is contained in:
2026-05-05 22:00:07 +02:00
parent 4f796dac2e
commit 9b5a70b285
53 changed files with 318 additions and 460 deletions
@@ -0,0 +1,50 @@
import 'package:http/http.dart' as http;
import '../../../apiParams.dart';
import '../../../apiResponse.dart';
import '../talkApi.dart';
/// Small POST/DELETE-only Talk endpoints that have no response payload.
/// Each class extends [TalkApi] with `assemble` returning `null`. They share
/// no state — they're collected here purely to avoid eight near-empty files.
class SetFavorite extends TalkApi {
final String chatToken;
final bool favoriteState;
SetFavorite(this.chatToken, this.favoriteState) : super('v4/room/$chatToken/favorite', null);
@override
ApiResponse? assemble(String raw) => null;
@override
Future<http.Response> request(Uri uri, ApiParams? body, Map<String, String>? headers) =>
favoriteState ? http.post(uri, headers: headers) : http.delete(uri, headers: headers);
}
class LeaveRoom extends TalkApi {
final String chatToken;
LeaveRoom(this.chatToken) : super('v4/room/$chatToken/participants/self', null);
@override
ApiResponse? assemble(String raw) => null;
@override
Future<http.Response> request(Uri uri, ApiParams? body, Map<String, String>? headers) =>
http.delete(uri, headers: headers);
}
class DeleteMessage extends TalkApi {
final String chatToken;
final int messageId;
DeleteMessage(this.chatToken, this.messageId) : super('v1/chat/$chatToken/$messageId', null);
@override
ApiResponse? assemble(String raw) => null;
@override
Future<http.Response> request(Uri uri, ApiParams? body, Map<String, String>? headers) =>
http.delete(uri, headers: headers);
}