You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
916 B
Dart

import 'package:isekai_wiki/api/response/watch.dart';
import 'mw_api.dart';
class MWApiWatch {
static Future<MWResponse<List<WatchActionResponseList>>> watchPage(
{List<String>? titles, List<int>? pageIds, bool unwatch = false}) async {
Map<String, dynamic> query = {};
if (titles != null) {
query["titles"] = titles.join("|");
}
if (pageIds != null) {
query["pageids"] = pageIds.join("|");
}
if (unwatch) {
query["unwatch"] = "1";
}
var mwRes = await MWApi.post("watch", params: query, withToken: "watch", returnRoot: true);
var data = WatchActionResponse.fromJson(mwRes.data);
return mwRes.replaceData(data.watch);
}
static Future<MWResponse<List<WatchActionResponseList>>> unwatchPage(
{List<String>? titles, List<int>? pageIds, bool unwatch = false}) {
return watchPage(titles: titles, pageIds: pageIds, unwatch: true);
}
}