getPinStatus method
Checks the PIN status for a user.
Returns a PinStatusResponse. Gracefully degrades to a no-PIN state on error.
Implementation
Future<PinStatusResponse> getPinStatus({
required String userId,
required String businessId,
String population = 'External',
}) async {
final trace = await monitoringService.createTrace(name: 'getPinStatus', operation: 'PIN_STATUS');
try {
_ensureInitialised();
final response = await client.get(
url: '$_iamServiceUrl/iam/api/v1/iam/pin/$userId/status'
'?businessId=$businessId&population=$population',
user: _user,
);
if (response?.statusCode == 200 && response?.data != null) {
return PinStatusResponse.fromJson(
response!.data as Map<String, dynamic>,
);
}
return PinStatusResponse(
hasPin: false,
status: null,
locked: false,
failedAttempts: 0,
lastVerifiedAt: null,
);
} catch (e, s) {
logger.error(this, 'Error getting PIN status', error: e, stackTrace: s);
// Graceful degradation — treat as no PIN
return PinStatusResponse(
hasPin: false,
status: null,
locked: false,
failedAttempts: 0,
lastVerifiedAt: null,
);
} finally {
trace.stop();
}
}