Performed first authentication
This commit is contained in:
30
moneymgr_mobile/lib/services/api/auth_api.dart
Normal file
30
moneymgr_mobile/lib/services/api/auth_api.dart
Normal file
@ -0,0 +1,30 @@
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:moneymgr_mobile/services/api/api_client.dart';
|
||||
|
||||
part 'auth_api.g.dart';
|
||||
part 'auth_api.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class AuthInfo with _$AuthInfo {
|
||||
const factory AuthInfo({
|
||||
required int id,
|
||||
required String mail,
|
||||
required String name,
|
||||
required int time_create,
|
||||
required int time_update,
|
||||
}) = _AuthInfo;
|
||||
|
||||
factory AuthInfo.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthInfoFromJson(json);
|
||||
}
|
||||
|
||||
/// Auth API
|
||||
extension AuthApi on ApiClient {
|
||||
/// Get authentication information
|
||||
Future<AuthInfo> authInfo() async {
|
||||
final response = await execute("/auth/info", method: "GET");
|
||||
return AuthInfo.fromJson(response.data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user