100 lines
3.3 KiB
Dart
100 lines
3.3 KiB
Dart
|
|
|
|
import 'package:regroup/Common/api_urls.dart';
|
|
import 'package:regroup/Common/base_manager.dart';
|
|
import 'package:regroup/Common/controller/data/network/network_api.dart';
|
|
import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/Model/GetEditProfileBus.dart';
|
|
import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/Model/GetEditProfileIndi.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
GetEditProfileIndi? getEditProfileIndi;
|
|
GetEditProfileBus? getEditProfileBus;
|
|
List<String> listofUserInterests = [];
|
|
|
|
bool accountvisibility = true;
|
|
|
|
class EditProfileApi {
|
|
EditProfileApi();
|
|
|
|
Future<ResponseData<dynamic>> postEditProfileIndividual(var data) async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
final response =
|
|
await NetworkApiServices().postApi(data, ApiUrls.posteditprofile);
|
|
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
if (response.data['status'] == 'success') {
|
|
} else {
|
|
return ResponseData<dynamic>(
|
|
response.data['message'], ResponseStatus.FAILED);
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> getEditProfileIndividual() async {
|
|
final response = await NetworkApiServices().getApi(ApiUrls.geteditprofile);
|
|
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
if (response.data["status"] == "success") {
|
|
getEditProfileIndi = GetEditProfileIndi.fromJson(response.data);
|
|
accountvisibility = getEditProfileIndi!.data!.accountVisibility == 1;
|
|
getUserIntersetFromResponse();
|
|
}
|
|
return ResponseData<dynamic>(
|
|
response.data['message'], ResponseStatus.SUCCESS,
|
|
data: response.data);
|
|
} else {
|
|
return ResponseData<dynamic>(
|
|
response.data['message'], ResponseStatus.FAILED);
|
|
}
|
|
}
|
|
|
|
getUserIntersetFromResponse() {
|
|
for (var interests in getEditProfileIndi!.data!.interest!) {
|
|
String interestName = interests.name ?? "null";
|
|
int index = listofUserInterests.indexOf(interestName);
|
|
if (index != -1) {
|
|
listofUserInterests[index] = interestName;
|
|
} else {
|
|
listofUserInterests.add(interestName);
|
|
}
|
|
}
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> postEditProfileBusiness(var data) async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
final response = await NetworkApiServices()
|
|
.postApi(data, ApiUrls.posteditprofilebusiness);
|
|
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
if (response.data['status'] == 'success') {
|
|
} else {
|
|
return ResponseData<dynamic>(
|
|
response.data['message'], ResponseStatus.FAILED);
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> getEditProfileBusiness() async {
|
|
final response = await NetworkApiServices().getApi(
|
|
ApiUrls.geteditprofilebusiness,
|
|
);
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
getEditProfileBus = GetEditProfileBus.fromJson(response.data);
|
|
|
|
if (response.data["status"] == "success") {
|
|
print("Success---->");
|
|
return ResponseData<dynamic>(
|
|
response.data['message'], ResponseStatus.SUCCESS,
|
|
data: response.data);
|
|
} else {
|
|
return ResponseData<dynamic>(
|
|
response.data['message'], ResponseStatus.FAILED);
|
|
}
|
|
}
|
|
|
|
return response;
|
|
}
|
|
}
|