You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.0 KiB
Dart
95 lines
3.0 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:doctor_app_flutter/interceptor/http_interceptor.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:http/http.dart';
|
|
import 'package:http_interceptor/http_client_with_interceptor.dart';
|
|
|
|
import '../models/user_model.dart';
|
|
|
|
const LOGIN_URL =
|
|
'https://hmgwebservices.com/Services/Sentry.svc/REST/MemberLogIN_New';
|
|
const INSERT_DEVICE_IMEI =
|
|
'https://hmgwebservices.com/Services/Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI';
|
|
const SELECT_DEVICE_IMEI =
|
|
'https://hmgwebservices.com/Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI';
|
|
|
|
const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE =
|
|
'https://hmgwebservices.com/Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType';
|
|
|
|
const MEMBER_CHECK_ACTIVATION_CODE_NEW ='https://hmgwebservices.com/Services/Sentry.svc/REST/MemberCheckActivationCode_New';
|
|
class AuthProvider with ChangeNotifier {
|
|
Client client =
|
|
HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]);
|
|
Future<Map> login(UserModel userInfo) async {
|
|
const url = LOGIN_URL;
|
|
|
|
try {
|
|
final response = await client.post(url,
|
|
// headers: requestHeaders,
|
|
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));
|
|
} catch (error) {
|
|
print(error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
Future<Map> insertDeviceImei(imei) async {
|
|
const url = INSERT_DEVICE_IMEI;
|
|
|
|
try {
|
|
final response = await client.post(url, body: json.encode(imei));
|
|
return Future.value(json.decode(response.body));
|
|
} catch (error) {
|
|
print(error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
Future<Map> selectDeviceImei(imei) async {
|
|
const url = SELECT_DEVICE_IMEI;
|
|
|
|
try {
|
|
final response = await client.post(url, body: json.encode(imei));
|
|
return Future.value(json.decode(response.body));
|
|
} catch (error) {
|
|
print(error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
Future<Map> sendActivationCodeByOtpNotificationType(activationCodeModel) async{
|
|
const url = SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE;
|
|
|
|
try {
|
|
final response = await client.post(url, body: json.encode(activationCodeModel));
|
|
return Future.value(json.decode(response.body));
|
|
} catch (error) {
|
|
print(error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
Future<Map> memberCheckActivationCodeNew(activationCodeModel) async{
|
|
const url = MEMBER_CHECK_ACTIVATION_CODE_NEW;
|
|
|
|
try {
|
|
final response = await client.post(url, body: json.encode(activationCodeModel));
|
|
return Future.value(json.decode(response.body));
|
|
} catch (error) {
|
|
print(error);
|
|
throw error;
|
|
}
|
|
}
|
|
}
|