Files
eatvio_app/lib/data/models/userRegistrationModel/user_registration_model.dart
2023-12-26 16:06:24 +03:00

103 lines
2.7 KiB
Dart

import 'dart:convert';
import 'package:http/http.dart' as http;
class UserRegistrationSheet {
String firstName;
String lastName;
String email;
String password;
String passwordConfirmation;
String termsAccepted;
String birthdate;
String gender;
String country;
String city;
String lang;
String weight;
String height;
String chestCircumference;
String waistCircumference;
String hipCircumference;
String bloodPressureUp;
String bloodPressureDown;
String hasHypo = '';
String hasHyper = '';
String aboutAllergy = '';
String aboutTakingPils = '';
String aboutSportHobbies = '';
String favoriteFoods = '';
String unfavoriteFoods = '';
String additionalInfo = '';
UserRegistrationSheet({
required this.firstName,
required this.lastName,
required this.email,
required this.password,
required this.passwordConfirmation,
required this.termsAccepted,
required this.birthdate,
required this.gender,
required this.country,
required this.city,
required this.lang,
required this.weight,
required this.height,
required this.chestCircumference,
required this.waistCircumference,
required this.hipCircumference,
required this.bloodPressureUp,
required this.bloodPressureDown,
required this.hasHypo,
required this.hasHyper,
required this.aboutAllergy,
required this.aboutTakingPils,
required this.aboutSportHobbies,
required this.favoriteFoods,
required this.unfavoriteFoods,
required this.additionalInfo,
});
Map<String, dynamic> toJson() {
return {
'first_name': firstName,
'last_name': lastName,
'email': email,
'password': password,
'password_confirmation': passwordConfirmation,
'terms': termsAccepted,
'birthdate': birthdate.toString(),
'gender': gender,
'country': country,
'city': city,
'lang': lang,
'weight': weight,
'height': height,
'chest_circumference': chestCircumference,
'waist_circumference': waistCircumference,
'hip_circumference': hipCircumference,
'blood_pressure_up': bloodPressureUp,
'blood_pressure_down': bloodPressureDown,
'has_hypo': hasHypo,
'has_hyper': hasHyper,
'about_alergy': aboutAllergy,
'about_taking_pils': aboutTakingPils,
'about_sport_hobbies': aboutSportHobbies,
'favorite_foods': favoriteFoods,
'unfavorite_foods': unfavoriteFoods,
'additional_info': additionalInfo,
};
}
Future<void> sendJson(Uri url) async {
final response = await http.post(
url,
headers: {'Content-Type': 'application/json'},
body: jsonEncode(toJson()),
);
if (response.statusCode != 200) {
throw Exception('Failed to send data');
}
}
}