import '../../models/contribution_model.dart';
import '../../../core/network/api_client.dart';
import '../../../core/network/api_endpoints.dart';
import '../../../core/error/exceptions.dart';

abstract class ContributionRemoteDataSource {
  Future<ContributionModel> getUserContribution(String accountSequence);
}

class ContributionRemoteDataSourceImpl implements ContributionRemoteDataSource {
  final ApiClient client;

  ContributionRemoteDataSourceImpl({required this.client});

  @override
  Future<ContributionModel> getUserContribution(String accountSequence) async {
    try {
      final response = await client.get(ApiEndpoints.contribution(accountSequence));
      return ContributionModel.fromJson(response.data);
    } catch (e) {
      throw ServerException(e.toString());
    }
  }
}
