isIndiaKycCompleted method
Checks if Indian KYC documents have been added by the user Returns true if Indian KYC is completed, false otherwise
Throws an exception if the API call fails or user is not authenticated
Implementation
Future<bool> isIndiaKycCompleted() async {
final accessToken = await getAccessToken();
if (accessToken == null) {
throw Exception('User not authenticated. Please sign in first.');
}
try {
// Get user ID from storage
final userId = await TokenStorage.getUserId();
if (userId == null) {
throw Exception('User ID not found in storage. Please sign in first.');
}
// Construct API URL based on environment
final apiBaseUrl = Remit2AnyEnvironmentConfig.isDev
? 'https://dev.api.remit2any.com'
: 'https://api.remit2any.com';
final url =
Uri.parse('$apiBaseUrl/users/$userId/userProfileCompleteness');
final response = await http.get(
url,
headers: {
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json',
},
);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
print('[DEBUG] India KYC API Response: $data');
return data['kycadded'] == true;
} else {
throw Exception(
'API request failed with status: ${response.statusCode}');
}
} catch (e) {
throw Exception('Failed to check India KYC status: $e');
}
}