1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-30 00:36:28 +00:00
comunicmobile/lib/helpers/likes_helper.dart

36 lines
782 B
Dart
Raw Normal View History

2019-05-11 13:35:07 +00:00
import 'package:comunic/enums/likes_type.dart';
import 'package:comunic/models/api_request.dart';
import 'package:meta/meta.dart';
/// Likes helper
///
/// @author Pierre HUBERT
const LikesAPIMap = {
LikesType.USER: "user",
LikesType.POST: "post",
LikesType.COMMENT: "comment",
LikesType.GROUP: "group",
};
class LikesHelper {
/// Update liking status of an element
Future<bool> setLiking({
@required LikesType type,
@required bool like,
@required int id,
}) async {
return (await APIRequest(
uri: "likes/update",
needLogin: true,
args: {
"type": LikesAPIMap[type],
"like": like.toString(),
"id": id.toString(),
},
).exec())
.code ==
200;
}
}