getUserActions method

Future<UserActionsResult> getUserActions()

Implementation

Future<UserActionsResult> getUserActions() async {
  try {
    final token = _appState.token;
    if (token == null || token.isEmpty) {
      throw Exception('Missing auth token');
    }

    final response = await ApiClient().post(
      '/customer-portal/user-actions',
      options: Options(
        headers: {
          'Authorization': 'Bearer $token',
          'Content-Type': 'application/json',
        },
      ),
    );

    return UserActionsResult.fromJson(response.data);
  } on DioException catch (e) {
    if (e.response?.data is Map<String, dynamic>) {
      return UserActionsResult.fromJson(e.response?.data as Map<String, dynamic>);
    }
    return UserActionsResult.fromJson({});
  } catch (e) {
    debugPrint('Error fetching user actions: $e');
    return UserActionsResult.fromJson({});
  }
}