onufitness_mobile/lib/screens/accounts/model/user_progress_response_model.dart
2026-01-13 11:36:24 +05:30

118 lines
3.1 KiB
Dart

import 'dart:convert';
UserProgressResponseModel userProgressResponseModelFromJson(String str) =>
UserProgressResponseModel.fromJson(json.decode(str));
String userProgressResponseModelToJson(UserProgressResponseModel data) =>
json.encode(data.toJson());
class UserProgressResponseModel {
bool? isSuccess;
int? statusCode;
String? message;
Data? data;
dynamic errors;
UserProgressResponseModel({
this.isSuccess,
this.statusCode,
this.message,
this.data,
this.errors,
});
factory UserProgressResponseModel.fromJson(Map<String, dynamic> json) =>
UserProgressResponseModel(
isSuccess: json["isSuccess"],
statusCode: json["statusCode"],
message: json["message"],
data: json["data"] == null ? null : Data.fromJson(json["data"]),
errors: json["errors"],
);
Map<String, dynamic> toJson() => {
"isSuccess": isSuccess,
"statusCode": statusCode,
"message": message,
"data": data?.toJson(),
"errors": errors,
};
}
class Data {
List<ChallengePogress>? challenges;
List<dynamic>? goals;
int? totalChallenges;
int? totalGoals;
Data({this.challenges, this.goals, this.totalChallenges, this.totalGoals});
factory Data.fromJson(Map<String, dynamic> json) => Data(
challenges:
json["challenges"] == null
? []
: List<ChallengePogress>.from(
json["challenges"]!.map((x) => ChallengePogress.fromJson(x)),
),
goals:
json["goals"] == null
? []
: List<dynamic>.from(json["goals"]!.map((x) => x)),
totalChallenges: json["totalChallenges"],
totalGoals: json["totalGoals"],
);
Map<String, dynamic> toJson() => {
"challenges":
challenges == null
? []
: List<dynamic>.from(challenges!.map((x) => x.toJson())),
"goals": goals == null ? [] : List<dynamic>.from(goals!.map((x) => x)),
"totalChallenges": totalChallenges,
"totalGoals": totalGoals,
};
}
class ChallengePogress {
String? userId;
int? challengeId;
String? challengeTitle;
String? status;
String? taskUnit;
double? totalMetricValue;
ChallengePogress({
this.userId,
this.challengeId,
this.challengeTitle,
this.status,
this.taskUnit,
this.totalMetricValue,
});
factory ChallengePogress.fromJson(Map<String, dynamic> json) =>
ChallengePogress(
userId: json["userID"],
challengeId:
json["challengeID"] is String
? int.tryParse(json["challengeID"])
: json["challengeID"],
challengeTitle: json["challengeTitle"],
status: json["status"],
taskUnit: json["taskUnit"],
totalMetricValue:
json["totalMetricValue"] is int
? (json["totalMetricValue"] as int).toDouble()
: json["totalMetricValue"]?.toDouble(),
);
Map<String, dynamic> toJson() => {
"userID": userId,
"challengeID": challengeId,
"challengeTitle": challengeTitle,
"status": status,
"taskUnit": taskUnit,
"totalMetricValue": totalMetricValue,
};
}