isUsKycCompleted method
Checks if US KYC documents have been added by the user Returns true if US KYC is completed, false otherwise
Throws an exception if the API call fails or user is not authenticated
Implementation
Future<bool> isUsKycCompleted() 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] US KYC API Response: $data');
return data['usakycadded'] == true;
} else {
throw Exception(
'API request failed with status: ${response.statusCode}');
}
} catch (e) {
throw Exception('Failed to check US KYC status: $e');
}
}