128 lines
4.8 KiB
Dart
128 lines
4.8 KiB
Dart
import 'dart:async';
|
|
|
|
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/Global.dart';
|
|
import 'package:regroup/Utils/dialogs.dart';
|
|
import 'package:regroup/onboarding/Signup/Model/Onboarding/Individual/tellusIndividual.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class Onboard {
|
|
Onboard();
|
|
|
|
Future<ResponseData<dynamic>> Postregisteration(updata) async {
|
|
print("updata is $updata");
|
|
final response = await NetworkApiServices()
|
|
.postApi(updata, ApiUrls.registeration, optionalpar: true);
|
|
print("response is ${response.data}");
|
|
print("response message is ${response.message}");
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
//Map<String, dynamic> responseData = jsonDecode(response.data);
|
|
|
|
return ResponseData<dynamic>(
|
|
response.data['message'], ResponseStatus.SUCCESS);
|
|
}
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> Postverifyregisteration(updata) async {
|
|
print("updata is $updata");
|
|
final response = await NetworkApiServices()
|
|
.postApi(updata, ApiUrls.verifyregisteration, optionalpar: true);
|
|
print("response is ${response.data}");
|
|
print("response message is ${response.message}");
|
|
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
// Map<String, dynamic> res = response.data;
|
|
// print("res is $res");
|
|
// await prefs.setString('access-token', res['data']['token']);
|
|
// await prefs.setInt('isprofileupdate', res['data']['is_profile_updated']);
|
|
|
|
// token = res['data']['token'];
|
|
|
|
print("token is $token");
|
|
print("email is $emailid");
|
|
print("profile update value is $isprofileupdated");
|
|
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
//Map<String, dynamic> responseData = jsonDecode(response.data);
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
Map<String, dynamic> res = response.data;
|
|
print("res is $res");
|
|
await prefs.setString('access-token', res['data']['token']);
|
|
token = res['data']['token'];
|
|
|
|
// if (response.data['status'] == "error") {
|
|
// // return ResponseData<dynamic>(
|
|
// // response.data['message'], ResponseStatus.SUCCESS);
|
|
// return utils.showToast(response.data['message']);
|
|
// }
|
|
return ResponseData<dynamic>(
|
|
response.data['message'], ResponseStatus.SUCCESS);
|
|
}
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData> PosttellusIndividual(updata) async {
|
|
print("updata is $updata");
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
final response =
|
|
await NetworkApiServices().postApi(updata, ApiUrls.tellusIndividual);
|
|
print("response is ${response.data}");
|
|
print("response message is ${response.message}");
|
|
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
if (response.data['status'] == 'success') {
|
|
TellusIndividualModel tellusindiObj =
|
|
TellusIndividualModel.fromJson(response.data);
|
|
// await prefs.setString('fullname', tellusindiObj.data?.profile?.fullName ?? "");
|
|
// await prefs.setString('username', tellusindiObj.data?.profile?.userName ?? "");
|
|
// await prefs.setString('email', tellusindiObj.data?.profile?.emailAddress ?? "");
|
|
// await prefs.setString('phone', tellusindiObj.data?.profile?.phoneNumber ?? "");
|
|
|
|
// emailid = tellusindiObj.data?.profile?.emailAddress;
|
|
// myusername = tellusindiObj.data?.profile?.userName;
|
|
// fullname = tellusindiObj.data?.profile?.fullName;
|
|
// phonenumber = tellusindiObj.data?.profile?.phoneNumber;
|
|
} else {
|
|
return ResponseData<dynamic>(
|
|
response.data['message'], ResponseStatus.FAILED);
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> PostIndividualActivity(updata) async {
|
|
print("updata is $updata");
|
|
final response = await NetworkApiServices().postApi(
|
|
updata,
|
|
ApiUrls.postindividualactivity,
|
|
);
|
|
print("response is ${response.data}");
|
|
print("response message is ${response.message}");
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> postGroups(updata) async {
|
|
print("updata is $updata");
|
|
final response = await NetworkApiServices().postApi(
|
|
updata,
|
|
ApiUrls.postgroups,
|
|
);
|
|
print("response is ${response.data}");
|
|
print("response message is ${response.message}");
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> postCommunities(updata) async {
|
|
print("updata is $updata");
|
|
final response = await NetworkApiServices().postApi(
|
|
updata,
|
|
ApiUrls.postcommunities,
|
|
);
|
|
print("response is ${response.data}");
|
|
print("response message is ${response.message}");
|
|
return response;
|
|
}
|
|
}
|