import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:grpc/grpc_web.dart';
import 'package:softplayer_dart_proto/test/v1/test_v1.pbgrpc.dart';
import 'package:softplayer_web/core/grpc/grpc_client.dart';

final testGrpcProvider = Provider<TestGrpcRepository>((ref) {
  return TestGrpcRepository(ref.watch(testServiceClientProvider));
});

class TestGrpcRepository {
  TestGrpcRepository(this._client);
  final TestServiceClient _client;

  ResponseFuture<PongResponse> pong() {
    try {
      final response = _client.pong(PongRequest());
      return response;
    } catch (error) {
      rethrow;
    }
  }
}
