initialize method
Initialize the service
Implementation
Future<void> initialize() async {
final prefs = await _prefsInstance;
// Add cache interceptor for offline support
final cacheInterceptor = CacheSetup.getCacheInterceptor();
if (cacheInterceptor != null) {
_apiClient.addCacheInterceptor(cacheInterceptor);
}
// Add auth interceptor for automatic token refresh
_apiClient.addAuthInterceptor(AuthInterceptor(this));
// Restore authentication state
final accessToken = await _getAccessToken();
if (accessToken != null) {
_apiClient.setAuthToken(accessToken);
// Restore organization context
final orgId = prefs.getString(_orgKey);
if (orgId != null) {
_apiClient.setOrganization(orgId);
}
}
}