Files
social-app/apps/lib/features/auth/data/apis/auth_api.dart
T

36 lines
1.0 KiB
Dart
Raw Normal View History

import 'package:social_app/data/network/i_api_client.dart';
import '../models/signup_request.dart';
import '../models/login_request.dart';
import '../models/auth_response.dart';
2026-02-25 14:51:21 +08:00
class AuthApi {
final IApiClient _client;
static const _prefix = '/api/v1/auth';
2026-02-25 14:51:21 +08:00
AuthApi(this._client);
Future<void> sendOtp(OtpSendRequest request) async {
await _client.post('$_prefix/otp/send', data: request.toJson());
2026-02-25 14:51:21 +08:00
}
Future<AuthResponse> createPhoneSession(LoginRequest request) async {
2026-02-25 14:51:21 +08:00
final response = await _client.post(
'$_prefix/phone-session',
2026-02-25 14:51:21 +08:00
data: request.toJson(),
);
return AuthResponse.fromJson(response.data);
}
Future<AuthResponse> refreshSession(RefreshRequest request) async {
2026-02-25 14:51:21 +08:00
final response = await _client.post(
'$_prefix/sessions/refresh',
2026-02-25 14:51:21 +08:00
data: request.toJson(),
);
return AuthResponse.fromJson(response.data);
}
Future<void> deleteSession(LogoutRequest request) async {
await _client.delete('$_prefix/sessions', data: request.toJson());
2026-02-25 14:51:21 +08:00
}
}