|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
import 'package:doctor_app_flutter/interceptor/http_interceptor.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
import 'package:http_interceptor/http_client_with_interceptor.dart';
|
|
|
|
|
|
|
|
|
|
import '../models/user_model.dart';
|
|
|
|
|
|
|
|
|
@ -9,18 +11,18 @@ 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 SELECT_DEVICE_IMEI =
|
|
|
|
|
'https://hmgwebservices.com/Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI';
|
|
|
|
|
|
|
|
|
|
class AuthProvider with ChangeNotifier {
|
|
|
|
|
Client client =
|
|
|
|
|
HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]);
|
|
|
|
|
Future<Map> login(UserModel userInfo) async {
|
|
|
|
|
Map<String, String> requestHeaders = {
|
|
|
|
|
'Content-type': 'application/json',
|
|
|
|
|
'Accept': 'application/json',
|
|
|
|
|
};
|
|
|
|
|
const url = LOGIN_URL;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
final response = await http.post(url,
|
|
|
|
|
headers: requestHeaders,
|
|
|
|
|
final response = await client.post(url,
|
|
|
|
|
// headers: requestHeaders,
|
|
|
|
|
body: json.encode({
|
|
|
|
|
"UserID": userInfo.UserID,
|
|
|
|
|
"Password": userInfo.Password,
|
|
|
|
@ -39,15 +41,10 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<Map> insertDeviceImei(imei) async {
|
|
|
|
|
Map<String, String> requestHeaders = {
|
|
|
|
|
'Content-type': 'application/json',
|
|
|
|
|
'Accept': 'application/json',
|
|
|
|
|
};
|
|
|
|
|
const url = INSERT_DEVICE_IMEI;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
final response = await http.post(url,
|
|
|
|
|
headers: requestHeaders, body: json.encode(imei));
|
|
|
|
|
final response = await client.post(url, body: json.encode(imei));
|
|
|
|
|
return Future.value(json.decode(response.body));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
print(error);
|
|
|
|
@ -56,15 +53,10 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<Map> selectDeviceImei(imei) async {
|
|
|
|
|
Map<String, String> requestHeaders = {
|
|
|
|
|
'Content-type': 'application/json',
|
|
|
|
|
'Accept': 'application/json',
|
|
|
|
|
};
|
|
|
|
|
const url = SELECT_DEVICE_IMEI;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
final response = await http.post(url,
|
|
|
|
|
headers: requestHeaders, body: json.encode(imei));
|
|
|
|
|
final response = await client.post(url, body: json.encode(imei));
|
|
|
|
|
return Future.value(json.decode(response.body));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
print(error);
|
|
|
|
|