Line data Source code
1 : const _successStatus = "AMB0000";
2 :
3 : class ApiResponse {
4 : /// The status code of the response, all status outside of `AMB0000` are error statuses
5 : ///
6 : /// The format is `AMOCCEE`
7 : ///
8 : /// With:
9 : /// - `AM` being the prefix
10 : /// - `O` the origin of the error, it can be `B` if the error comes from the Web API,
11 : /// `F` if the error comes from the mobile application and finally `A` if the error comes from the AI
12 : /// - `CC` the two digit for the category
13 : /// - `EE` the two digit for the error number
14 : final String statusCode;
15 : final bool success;
16 : final String? message;
17 : final dynamic data;
18 :
19 6 : ApiResponse(
20 : {required this.statusCode,
21 : required this.success,
22 : this.message,
23 : this.data});
24 :
25 12 : factory ApiResponse.fromJson(Map<String, dynamic> json) => ApiResponse(
26 6 : statusCode: json["status"],
27 12 : success: json["status"] == _successStatus,
28 6 : message: json["message"],
29 6 : data: json["result"],
30 : );
31 : }
|