feat : profile and map
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
|
||||
import 'package:rasadyar_inspection/data/model/response/user_profile/user_profile_model.dart';
|
||||
|
||||
abstract class UserRemoteDataSource {
|
||||
|
||||
Future<UserProfileModel?> getProfile({required String token});
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_inspection/data/data_source/remote/user/user_data_source.dart';
|
||||
import 'package:rasadyar_inspection/data/model/response/user_profile/user_profile_model.dart';
|
||||
|
||||
class UserRemoteDataSourceImp extends UserRemoteDataSource {
|
||||
final DioRemote _httpClient;
|
||||
final String _BASE_URL = 'auth/api/v1/';
|
||||
|
||||
UserRemoteDataSourceImp(this._httpClient);
|
||||
|
||||
@override
|
||||
Future<UserProfileModel?> getProfile({required String token}) async {
|
||||
var res = await _httpClient.get<UserProfileModel>(
|
||||
'${_BASE_URL}user/profile/',
|
||||
fromJson: UserProfileModel.fromJson,
|
||||
headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer $token'},
|
||||
);
|
||||
|
||||
if (res.data == null) {
|
||||
throw Exception('Failed to load user profile');
|
||||
}
|
||||
|
||||
return res.data!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user