129 lines
3.4 KiB
Dart
129 lines
3.4 KiB
Dart
import 'dart:collection';
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'customer_property.dart';
|
|
|
|
class Customer {
|
|
String? name;
|
|
String? email;
|
|
String? firstname;
|
|
String? sex;
|
|
int? age;
|
|
String? active;
|
|
int? customerId;
|
|
String? password;
|
|
int? birthYear;
|
|
String? goal;
|
|
String? fitnessLevel;
|
|
String? bodyType;
|
|
int? admin;
|
|
int? trainer;
|
|
int? dataPolicyAllowed;
|
|
String? firebaseUid;
|
|
DateTime? dateAdd;
|
|
DateTime? dateChange;
|
|
int? emailSubscription;
|
|
int? sportId;
|
|
DateTime? syncedDate;
|
|
DateTime? trialDate;
|
|
String? firebaseRegToken;
|
|
String? lang;
|
|
int? lifeLong;
|
|
|
|
LinkedHashMap<String, CustomerProperty> properties = LinkedHashMap();
|
|
|
|
Customer(
|
|
{customerId,
|
|
name,
|
|
firstname,
|
|
email,
|
|
sex,
|
|
age,
|
|
active,
|
|
password,
|
|
birthYear,
|
|
bodyType,
|
|
fitnessLevel,
|
|
goal,
|
|
admin,
|
|
trainer,
|
|
dataPolicyAllowed,
|
|
firebaseUid,
|
|
dateAdd,
|
|
dateChange}) {
|
|
dateAdd = DateTime.now();
|
|
dateChange = DateTime.now();
|
|
}
|
|
|
|
Customer.fromJson(Map json) {
|
|
customerId = json['customerId'];
|
|
name = json['name'];
|
|
firstname = json['firstname'];
|
|
email = json['email'];
|
|
sex = json['sex'];
|
|
age = json['age'];
|
|
active = json['active'];
|
|
birthYear = json['birthYear'];
|
|
bodyType = json['bodyType'];
|
|
fitnessLevel = json['fitnessLevel'];
|
|
goal = json['goal'];
|
|
admin = json['admin'];
|
|
lifeLong = json['lifeLong'];
|
|
|
|
trainer = json['trainer'];
|
|
firebaseUid = json['firebaseUid'];
|
|
firebaseRegToken = json['firebaseRegToken'];
|
|
lang = json['lang'];
|
|
|
|
dataPolicyAllowed = json['dataPolicyAllowed'];
|
|
emailSubscription = json['emailSubscription'];
|
|
sportId = json['sportId'];
|
|
syncedDate = json['syncedDate'] == null ? null : DateTime.parse(json['syncedDate']);
|
|
trialDate = json['trialDate'] == null ? null : DateTime.parse(json['trialDate']);
|
|
|
|
dateAdd = json['dateAdd'] == null ? DateTime.parse("0000-00-00") : DateTime.parse(json['dateAdd']);
|
|
dateChange = json['dateChange'] == null ? DateTime.parse("0000-00-00") : DateTime.parse(json['dateChange']);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"name": name,
|
|
"firstname": firstname,
|
|
"email": email,
|
|
"age": age,
|
|
"sex": sex,
|
|
"active": 'Y',
|
|
"password": password,
|
|
"birthYear": birthYear,
|
|
"bodyType": bodyType,
|
|
"fitnessLevel": fitnessLevel,
|
|
"goal": goal,
|
|
"admin": admin,
|
|
"trainer": trainer,
|
|
"dataPolicyAllowed": dataPolicyAllowed,
|
|
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(dateAdd!),
|
|
"dateChange": DateFormat('yyyy-MM-dd HH:mm:ss').format(dateChange!),
|
|
"emailSubscription": emailSubscription,
|
|
"sportId": sportId,
|
|
"syncedDate": syncedDate == null ? null : DateFormat('yyyy-MM-dd HH:mm:ss').format(syncedDate!),
|
|
"trialDate": trialDate == null ? null : DateFormat('yyyy-MM-dd HH:mm:ss').format(trialDate!),
|
|
"firebaseRegToken": firebaseRegToken,
|
|
"lang": lang,
|
|
"lifeLong": lifeLong,
|
|
};
|
|
|
|
@override
|
|
String toString() => toJson().toString();
|
|
|
|
double getProperty(String propertyName) {
|
|
if (properties[propertyName] == null) {
|
|
return 0;
|
|
} else {
|
|
return properties[propertyName]!.propertyValue;
|
|
}
|
|
}
|
|
|
|
setProperty(String propertyName, double value) {
|
|
properties[propertyName]!.propertyValue = value;
|
|
}
|
|
}
|