get method
Implementation
@override
Future<void> get(String id,
{Map<String, dynamic>? params, bool isMock = false}) async {
try {
this.toLoadingStatus();
late Map<String, dynamic> data;
String? consentMessageId = params?["consent-message-id"];
if (consentMessageId == null) {
throw ("Consent message id must not empty");
}
params?.remove("consent-message-id");
if (params == null) {
params = {};
}
if (isMock) {
await TimeHelper.sleep();
data = {"data": this.options.getMockItem()};
} else {
Response response = await Requester.get(
"${this.options.getFindUrl() ?? this.options.getBaseUrl()}/$consentMessageId"
.replaceFirst(":id", id),
params);
Map<String, dynamic> js = json.decode(utf8.decode(response.bodyBytes));
data = {"data": js};
}
super.setInnerData(data["data"]);
this.dataSC.add(this.data);
this.toLoadedStatus();
} catch (e) {
this.alertError(e);
this.toErrorStatus(e);
}
}