Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. import 'package:meta/meta.dart';
  2. import 'package:json_annotation/json_annotation.dart';
  3.  
  4. part 'submit_survey_question_options_model.g.dart';
  5.  
  6. @JsonSerializable(nullable: false)
  7. class SubmitSurveyQuestionOptionsModel {
  8. String questionId;
  9. String answer;
  10.  
  11. SubmitSurveyQuestionOptionsModel(
  12. {@required this.questionId, @required this.answer});
  13.  
  14. factory SubmitSurveyQuestionOptionsModel.fromJson(
  15. Map<String, dynamic> json) =>
  16. _$SubmitSurveyQuestionOptionsModelFromJson(json);
  17.  
  18. Map<String, dynamic> toJson() =>
  19. _$SubmitSurveyQuestionOptionsModelToJson(this);
  20. }
  21.  
  22.  
  23.  
  24. Future<SubmitSurveyModel> submitSurvey(
  25. String userId,
  26. String facultyId,
  27. String surveyId,
  28. List<SubmitSurveyQuestionOptionsModel> submitSurveyQuestionOptionList,
  29. String subjectId) async {
  30. Map<String, dynamic> body = {
  31. "userId": userId,
  32. "facultyId": facultyId,
  33. "surveyId": surveyId,
  34. "survey": submitSurveyQuestionOptionList,
  35. "subjectId": subjectId
  36. };
  37.  
  38. final response = await http.post(
  39. SUBMIT_SURVEY_URL,
  40. body: json.encode(body),
  41. );
  42.  
  43. SubmitSurveyModel submitSurveyModel = standardSerializers.deserializeWith(
  44. SubmitSurveyModel.serializer, json.decode(response.body));
  45.  
  46.  
  47. return submitSurveyModel;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement