2019-07-05 09:40:43 +00:00
|
|
|
import 'package:comunic/enums/post_kind.dart';
|
|
|
|
import 'package:comunic/enums/post_target.dart';
|
|
|
|
import 'package:comunic/enums/post_visibility_level.dart';
|
|
|
|
|
2021-03-13 17:03:20 +00:00
|
|
|
import 'api_request.dart';
|
|
|
|
|
2019-07-05 09:40:43 +00:00
|
|
|
/// New post information
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
2020-04-25 09:58:45 +00:00
|
|
|
class NewSurvey {
|
|
|
|
final String question;
|
|
|
|
final Set<String> answers;
|
2020-05-18 15:58:54 +00:00
|
|
|
final bool allowNewChoicesCreation;
|
2020-04-25 09:58:45 +00:00
|
|
|
|
|
|
|
const NewSurvey({
|
2022-03-10 18:39:57 +00:00
|
|
|
required this.question,
|
|
|
|
required this.answers,
|
|
|
|
required this.allowNewChoicesCreation,
|
2020-04-25 09:58:45 +00:00
|
|
|
}) : assert(question != null),
|
2020-05-18 15:58:54 +00:00
|
|
|
assert(answers.length > 1),
|
|
|
|
assert(allowNewChoicesCreation != null);
|
2020-04-25 09:58:45 +00:00
|
|
|
}
|
|
|
|
|
2019-07-05 09:40:43 +00:00
|
|
|
class NewPost {
|
|
|
|
final PostTarget target;
|
|
|
|
final int targetID;
|
|
|
|
final PostVisibilityLevel visibility;
|
|
|
|
final String content;
|
2022-03-10 18:39:57 +00:00
|
|
|
final BytesFile? image;
|
|
|
|
final String? url;
|
|
|
|
final List<int>? pdf;
|
2019-07-05 09:40:43 +00:00
|
|
|
final PostKind kind;
|
2022-03-10 18:39:57 +00:00
|
|
|
final DateTime? timeEnd;
|
|
|
|
final NewSurvey? survey;
|
|
|
|
final String? youtubeId;
|
2019-07-05 09:40:43 +00:00
|
|
|
|
2020-04-24 11:35:05 +00:00
|
|
|
const NewPost({
|
2022-03-10 18:39:57 +00:00
|
|
|
required this.target,
|
|
|
|
required this.targetID,
|
|
|
|
required this.visibility,
|
|
|
|
required this.content,
|
|
|
|
required this.kind,
|
|
|
|
required this.image,
|
|
|
|
required this.url,
|
|
|
|
required this.pdf,
|
|
|
|
required this.timeEnd,
|
|
|
|
required this.survey,
|
|
|
|
required this.youtubeId,
|
2019-07-05 09:40:43 +00:00
|
|
|
}) : assert(target != null),
|
|
|
|
assert(targetID != null),
|
|
|
|
assert(visibility != null),
|
|
|
|
assert(content != null),
|
|
|
|
assert(kind != PostKind.TEXT || content.length > 3),
|
2020-04-24 11:35:05 +00:00
|
|
|
assert(kind != PostKind.IMAGE || image != null),
|
2020-04-25 12:38:15 +00:00
|
|
|
assert(kind != PostKind.WEB_LINK || url != null),
|
2020-04-25 06:23:52 +00:00
|
|
|
assert(kind != PostKind.PDF || pdf != null),
|
2020-04-25 09:58:45 +00:00
|
|
|
assert(kind != PostKind.COUNTDOWN || timeEnd != null),
|
2020-04-25 15:16:33 +00:00
|
|
|
assert(kind != PostKind.SURVEY || survey != null),
|
|
|
|
assert(kind != PostKind.YOUTUBE || youtubeId != null);
|
2019-07-05 09:40:43 +00:00
|
|
|
}
|