import 'dart:convert'; import 'dart:developer'; import 'package:dio/dio.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:shared_preferences/shared_preferences.dart'; import 'package:http/http.dart' as http; class Profilepostmethod { Profilepostmethod(); Dio dio = Dio(); String basicAuth = 'Basic ' + base64.encode( utf8.encode('RegroupUserName:71%@L%es^bUX94`J9XT*@bh,._WWM{\$%^^&&')); Future> postContactus(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postcontactus, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postReportandbug(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postreportbug, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postBlockuser(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postblock, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postunfollowuser(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postunfollow, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postRemoveuser(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postremoveuser, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postChangepassword(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postchangepassword, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postChangepassverifyotp(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postchangepassverify, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postTimeline(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.posttimeline, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postAccountvisibility(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postaccountvisibility, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postDeleteaccount(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postdeleteaccount, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postLogoutaccount() async { Response response; SharedPreferences prefs = await SharedPreferences.getInstance(); String? token = prefs.getString('access-token'); try { response = await dio.post( ApiUrls.postlogoutaccount, options: Options( headers: {'authorization': basicAuth, 'access-token': token}, ), ); log(response.toString()); } on Exception catch (e) { if (e is DioException) { log(e.response.toString()); if (e.response == null) { return ResponseData( 'Oops something Went Wrong, Please try again!', ResponseStatus.FAILED, ); } if (e.response!.statusCode == 401) { prefs.remove('token'); prefs.remove('refreshToken'); // Get.toNamed(RouteName.login); return ResponseData( 'Oops something Went Wrong, Please try again!', ResponseStatus.FAILED, ); } if (e.response!.statusCode == 403) { if (e.response!.data['message'] is List) { return ResponseData( e.response!.data['message'][0]!, ResponseStatus.FAILED, data: e.response!.data); } else { return ResponseData( e.response!.data['message'], ResponseStatus.FAILED, data: e.response!.data); } } } return ResponseData( 'Oops something Went Wrong', ResponseStatus.FAILED, ); } if (response.statusCode == 200 || response.statusCode == 201) { return ResponseData("success", ResponseStatus.SUCCESS, data: response.data); } else if (response.statusCode == 203) { print(response.data); return ResponseData("success", ResponseStatus.PRIVATE, data: response.data); } else { try { return ResponseData( response.data['message'].toString(), ResponseStatus.FAILED); } catch (_) { return ResponseData( response.statusMessage!, ResponseStatus.FAILED); } } } Future> postEditTimeline(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postedittimeline, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postRemoveTimeline(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postremovetimeline, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postRemoveCertification(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postremovecertification, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } Future> postCertification(updata) async { print("updata is $updata"); final response = await NetworkApiServices().postApi( updata, ApiUrls.postcertification, ); print("response is ${response.data}"); print("response message is ${response.message}"); return response; } // Future guestFollowuser(int userId) async { // print("followRecipe"); // final apiUrl = ApiUrls.postunfollow; // // final body = {"following_iam_principal_xid": userId}; // Map updata = { // "following_iam_principal_xid": userId, // }; // SharedPreferences prefs = await SharedPreferences.getInstance(); // String? token = prefs.getString('access-token'); // Response response; // try { // response = await dio.post( // apiUrl, // data: updata, // options: // Options( // headers: {'authorization': basicAuth, 'access-token': token}, // ), // ); // log(response.toString()); // if (response.statusCode == 200) { // final jsonResponse = json.decode(response.data); // print("resp from api ${jsonResponse["message"]}"); // return jsonResponse["success"]; // } else { // // API call failed // throw Exception('Failed to follow user'); // } // } catch (e) { // // Error occurred while making the API call // throw Exception('Error: $e'); // } // } }