getGeo method
Implementation
Future<LiveTalkGeoEntity?> getGeo() async {
try {
var headers = {
'Content-Type': 'application/json',
};
final response = await http.get(
Uri.parse('$_baseUrl/geo'),
headers: headers,
);
if ((response.statusCode ~/ 100) > 2) {
print('❌ Geo Error: ${response.reasonPhrase}');
throw LiveTalkError(message: {"message": response.reasonPhrase});
}
if (response.statusCode == 200) {
final data = response.body;
final jsonData = json.decode(data);
if (jsonData["status_code"] == -9999) {
print('❌ Geo API Error: ${jsonData["message"]}');
throw LiveTalkError(message: jsonData);
}
final payload = json.decode(jsonData["payload"]);
final result = LiveTalkGeoEntity.fromJson(payload);
return result;
}
return null;
} catch (error) {
print('❌ Exception during getGeo: $error');
rethrow;
}
}