결재 API 계약 보완 및 테스트 정리
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../../../core/network/api_client.dart';
|
||||
import '../../../../core/network/api_routes.dart';
|
||||
import '../../domain/entities/auth_session.dart';
|
||||
import '../../domain/entities/login_request.dart';
|
||||
import '../../domain/repositories/auth_repository.dart';
|
||||
import '../dtos/auth_session_dto.dart';
|
||||
|
||||
/// 인증 관련 엔드포인트를 호출하는 원격 저장소 구현체.
|
||||
class AuthRepositoryRemote implements AuthRepository {
|
||||
AuthRepositoryRemote({required ApiClient apiClient}) : _api = apiClient;
|
||||
|
||||
final ApiClient _api;
|
||||
|
||||
static const _basePath = '${ApiRoutes.apiV1}/auth';
|
||||
|
||||
@override
|
||||
Future<AuthSession> login(LoginRequest request) async {
|
||||
final response = await _api.post<Map<String, dynamic>>(
|
||||
'$_basePath/login',
|
||||
data: {
|
||||
'identifier': request.identifier,
|
||||
'password': request.password,
|
||||
'remember_me': request.rememberMe,
|
||||
},
|
||||
options: Options(responseType: ResponseType.json),
|
||||
);
|
||||
final json = (response.data?['data'] as Map<String, dynamic>?) ?? {};
|
||||
return AuthSessionDto.fromJson(json).toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<AuthSession> refresh(String refreshToken) async {
|
||||
final response = await _api.post<Map<String, dynamic>>(
|
||||
'$_basePath/refresh',
|
||||
data: {'refresh_token': refreshToken},
|
||||
options: Options(responseType: ResponseType.json),
|
||||
);
|
||||
final json = (response.data?['data'] as Map<String, dynamic>?) ?? {};
|
||||
return AuthSessionDto.fromJson(json).toEntity();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user