change calling serivce to base app client

merge-requests/104/head
Elham Rababah 6 years ago
parent 02216b497c
commit e6b99adc80

@ -1,86 +1,108 @@
import 'dart:convert';
import 'package:doctor_app_flutter/client/app_client.dart';
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:flutter/cupertino.dart';
import '../models/user_model.dart';
const LOGIN_URL =
'Sentry.svc/REST/MemberLogIN_New';
const INSERT_DEVICE_IMEI =
'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI';
const LOGIN_URL = 'Sentry.svc/REST/MemberLogIN_New';
const INSERT_DEVICE_IMEI = 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI';
const SELECT_DEVICE_IMEI =
'Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI';
const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE =
'Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType';
const MEMBER_CHECK_ACTIVATION_CODE_NEW ='Sentry.svc/REST/MemberCheckActivationCode_New';
const MEMBER_CHECK_ACTIVATION_CODE_NEW =
'Sentry.svc/REST/MemberCheckActivationCode_New';
const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles';
class AuthProvider with ChangeNotifier {
Future<Map> login(UserModel userInfo) async {
const url = LOGIN_URL;
class AuthProvider with ChangeNotifier {
Future<dynamic> login(UserModel userInfo) async {
try {
final response = await AppClient.post(url,
body: json.encode({
"UserID": userInfo.UserID,
"Password": userInfo.Password,
"ProjectID": userInfo.ProjectID,
"LanguageID": userInfo.LanguageID,
"IPAdress": userInfo.IPAdress,
"VersionID": userInfo.VersionID,
"Channel": userInfo.Channel,
"SessionID": userInfo.SessionID
}));
return Future.value(json.decode(response.body));
dynamic localRes;
await BaseAppClient.post(LOGIN_URL,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: {
"UserID": userInfo.UserID,
"Password": userInfo.Password,
"ProjectID": userInfo.ProjectID,
"LanguageID": userInfo.LanguageID,
"IPAdress": userInfo.IPAdress,
"VersionID": userInfo.VersionID,
"Channel": userInfo.Channel,
"SessionID": userInfo.SessionID
});
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future<Map> insertDeviceImei(imei) async {
const url = INSERT_DEVICE_IMEI;
Future<dynamic> insertDeviceImei(imei) async {
try {
final response = await AppClient.post(url, body: json.encode(imei));
return Future.value(json.decode(response.body));
dynamic localRes;
await BaseAppClient.post(INSERT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: imei);
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future<Map> selectDeviceImei(imei) async {
const url = SELECT_DEVICE_IMEI;
Future<dynamic> selectDeviceImei(imei) async {
try {
final response = await AppClient.post(url, body: json.encode(imei));
return Future.value(json.decode(response.body));
dynamic localRes;
await BaseAppClient.post(SELECT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: imei);
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future<Map> sendActivationCodeByOtpNotificationType(
Future sendActivationCodeByOtpNotificationType(
activationCodeModel) async {
const url = SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE;
try {
final response = await AppClient.post(url, body: json.encode(activationCodeModel));
return Future.value(json.decode(response.body));
var localRes;
await BaseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: activationCodeModel);
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future<Map> memberCheckActivationCodeNew(activationCodeModel) async {
const url = MEMBER_CHECK_ACTIVATION_CODE_NEW;
Future<dynamic> memberCheckActivationCodeNew(activationCodeModel) async {
try {
final response = await AppClient.post(url, body: json.encode(activationCodeModel));
return Future.value(json.decode(response.body));
dynamic localRes;
await BaseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: activationCodeModel);
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
@ -94,12 +116,16 @@ class AuthProvider with ChangeNotifier {
*@return:Future<Map>
*@desc: getDocProfiles
*/
Future<Map> getDocProfiles(docInfo) async {
const url = GET_DOC_PROFILES;
Future<dynamic> getDocProfiles(docInfo) async {
try {
final response = await AppClient.post(url, body: json.encode(docInfo));
return Future.value(json.decode(response.body));
dynamic localRes;
await BaseAppClient.post(GET_DOC_PROFILES,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: docInfo);
return Future.value(localRes);
} catch (error) {
print(error);
throw error;

@ -1,6 +1,3 @@
import 'dart:convert';
import 'package:doctor_app_flutter/client/app_client.dart';
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:flutter/cupertino.dart';
@ -18,21 +15,16 @@ class HospitalProvider with ChangeNotifier {
"SessionID": "i1UJwCTSqt",
"IsLoginForDoctorApp": true
};
// try {
// final response = await AppClient.post(url, body: json.encode(info));
// return Future.value(json.decode(response.body));
// } catch (error) {
// throw error;
// // print('error');
// }
dynamic localRes ;
await BaseAppClient.post(url,
onSuccess: ( response, statusCode) {
return Future.value(response);
onSuccess: ( response, statusCode) async {
localRes= response;
},
onFailure: (String error, int statusCode) {
throw error;
},
body: info);
return Future.value(localRes);
}
}

@ -322,7 +322,7 @@ class _VerifyAccountState extends State<VerifyAccount> {
verifyAccountFormValue['digit4'];
print(activationCode);
int projectID = await sharedPref.getInt(PROJECT_ID);
Map model = {
Map<String,dynamic> model = {
"activationCode": activationCode,
"DoctorID": _loggedUser['DoctorID'],
"LogInTokenID": _loggedUser['LogInTokenID'],
@ -421,7 +421,7 @@ class _VerifyAccountState extends State<VerifyAccount> {
projectID: clinicInfo.projectID,
tokenID: '',
languageID: 2);
authProv.getDocProfiles(docInfo).then((res) {
authProv.getDocProfiles(docInfo.toJson()).then((res) {
if (res['MessageStatus'] == 1) {
print("DoctorProfileList ${res['DoctorProfileList'][0]}");
loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata);

@ -255,7 +255,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
if (oTPSendType == 1 || oTPSendType == 2) {
widget.changeLoadingStata(true);
Map model = {
Map<String,dynamic> model = {
"LogInTokenID": _loggedUser['LogInTokenID'],
"Channel": 9,
"MobileNumber": _loggedUser['MobileNumber'],

Loading…
Cancel
Save