getAppInfo method
Implementation
Future<void> getAppInfo(GetAppInfo getAppInfo) async {
getAppInfo.onLoading();
final url = Uri.parse(
'https://api.plentrasphere.com/v2/client/?class=default&action=getAppInfo&appKey=$appKey');
try {
final response = await http.get(url);
if (response.statusCode == 200) {
final jsonData = json.decode(response.body);
final code = jsonData['response']['code'];
final status = jsonData['response']['status'];
final info = jsonData['info'];
if (code == 400) {
if (status == "app-expired") {
getAppInfo.onAppNotActive(info['appName']);
getAppInfo.onLoadfinished();
return;
}
getAppInfo.onError(status);
getAppInfo.onLoadfinished();
return;
}
if (info['homeCover']['status']) {
getAppInfo.onHomeCover(info['homeCover']['image']);
}
if (info['whatsappChat']['status']) {
getAppInfo.onWhatsappChat(info['whatsappChat']['dialingCode']['code'],
info['whatsappChat']['phoneNumber']);
}
getAppInfo.onResult(
info['appName'],
info['appIcon'],
info['appType'],
info['appLocation'],
);
getAppInfo.onLoadfinished();
} else {
getAppInfo.onError('HTTP ${response.statusCode}');
getAppInfo.onLoadfinished();
}
} catch (e) {
getAppInfo.onError(e.toString());
getAppInfo.onLoadfinished();
}
}