43 lines
1.0 KiB
Dart
43 lines
1.0 KiB
Dart
import 'package:grpc/grpc_web.dart';
|
|
import 'package:softplayer_dart_proto/src/accounts/v1/accounts_v1.pb.dart';
|
|
import 'package:softplayer_dart_proto/src/accounts/v1/accounts_v1.pbgrpc.dart';
|
|
|
|
class AccountLocalData {
|
|
AccountLocalData({
|
|
required this.uuid,
|
|
required this.token,
|
|
});
|
|
String uuid;
|
|
String token;
|
|
}
|
|
|
|
class AccountsGrpc {
|
|
final GrpcWebClientChannel channel;
|
|
late AccountsServiceClient accountsStub;
|
|
AccountsGrpc({
|
|
required this.channel,
|
|
});
|
|
|
|
void init() {
|
|
accountsStub = AccountsServiceClient(channel);
|
|
}
|
|
|
|
Future<AccountLocalData> signUp(
|
|
String username, String email, String password) async {
|
|
final request = SignUpRequest(
|
|
data: AccountData(
|
|
name: username,
|
|
email: email,
|
|
),
|
|
password: AccountPassword(
|
|
password: password,
|
|
));
|
|
try {
|
|
final response = await accountsStub.signUp(request);
|
|
return AccountLocalData(uuid: "test", token: "test");
|
|
} catch (e) {
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|