AppRequest.fromJSON constructor
AppRequest.fromJSON(
- dynamic data
Implementation
AppRequest.fromJSON(dynamic data) {
try {
id = data["id"] ?? "";
from = data["from"] ?? "";
to = data["to"] ?? "";
createdTime = data["createdTime"] ?? 0;
expiresAt = data["expiresAt"] ?? 0;
if(data["newOffer"] != null) {
newOffer = EventOffer.fromJSON(data["newOffer"]);
}
message = data["message"] ?? "";
unread = data["unread"] ?? true;
collectiveId = data["collectiveId"] ?? "";
eventId = data["eventId"] ?? "";
positionRequestedId = data["positionRequestedId"] ?? "";
instrument = data["instrument"] != null ? Instrument.fromJSON(data["instrument"]) : null;
percentageCoverage = double.parse((data["percentageCoverage"] ?? '0').toString());
distanceKm = data["distanceKm"] ?? 0;
requestDecision = EnumToString.fromString(RequestDecision.values, data["requestDecision"] ?? RequestDecision.pending.name) ?? RequestDecision.pending;
gameRequestType = data["gameRequestType"] != null
? EnumToString.fromString(GameRequestType.values, data["gameRequestType"])
: null;
payload = (data["payload"] is Map)
? Map<String, dynamic>.from(data["payload"] as Map)
: {};
type = EnumToString.fromString(RequestType.values, data["type"] ?? RequestType.collaboration.name)
?? RequestType.collaboration;
} catch (e, st) {
NeomErrorLogger.recordError(e, st, module: 'neom_core', operation: 'AppRequest.fromJSON');
}
}