65 lines
1.6 KiB
Dart
65 lines
1.6 KiB
Dart
import 'package:http/http.dart' as http;
|
|
|
|
import '../../../api_params.dart';
|
|
import '../../../api_response.dart';
|
|
import '../talk_api.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);
|
|
}
|