|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
class AuthProvider with ChangeNotifier {
|
|
|
|
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,
|
|
|
|
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 {
|
|
|
|
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));
|
|
|
|
return Future.value(json.decode(response.body));
|
|
|
|
} catch (error) {
|
|
|
|
print(error);
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|