mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-30 00:36:28 +00:00
36 lines
782 B
Dart
36 lines
782 B
Dart
|
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;
|
||
|
}
|
||
|
}
|