addPost method
Future<PostModel?>
addPost({
- required dynamic user,
- dynamic title,
- dynamic description,
- dynamic type,
- dynamic attachedUrl,
- dynamic pollQuestionId,
Implementation
Future<PostModel?> addPost(
{required user, title, description, type, attachedUrl, pollQuestionId}) {
Log(
logName: 'AddPost',
className: 'Post',
methodName: 'addPost',
type: 'INFO',
text:
'{event: Add Post, user: ${currentUser?.userPayloadId}, user is ${currentUser?.firstName} ${currentUser?.lastName}, user id: ${user.id}, title: $title, description: $description, type: $type, attachedUrl: $attachedUrl, poll question id: $pollQuestionId',
);
return _httpService
.addPost(
user: user,
description: description,
type: type,
attachedUrl: attachedUrl,
title: title,
pollQuestionId: pollQuestionId)
.then((data) async {
if (data.statusCode >= 200 && data.statusCode < 300) {
List<dynamic> res = json.decode(data.body);
List<PostModel> postData =
res.map((i) => PostModel.fromJson(i)).toList();
if (postData[0] != null) return postData[0];
return null;
}
return null;
});
}