import 'package:boilerplate/data/data_source/remote/api_provider.dart';
import 'package:boilerplate/data/models/notification/get_notifications_res_model.dart';
import 'package:boilerplate/data/models/notification/save_fcm_token_req_model.dart';
import 'package:boilerplate/data/repositories/base_repository.dart';
import 'package:injectable/injectable.dart';

@injectable
class NotificationRepository extends BaseRepository {
  final ApiProvider _api;

  NotificationRepository(this._api);

  Future<bool> saveFCMToken(SaveFCMTokenReqModel req) async {
    final response = await _api.post('/api/fcm-token', body: req.toJson())
      ..responseHandler();
    print("SaveFCM =>${response.statusMessage}");
    return response.statusCode == 200;
  }

  Future<GetNotificationsResModel> getNotifications(int userId) async {
    final response = await _api.get('/api/notification/$userId')
      ..responseHandler();

    return GetNotificationsResModel.fromJson(response.data);
  }
}
