62 lines
2.0 KiB
Dart
62 lines
2.0 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:dio/dio.dart';
|
|
import 'package:discover_module/hive_fun.dart';
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
|
|
|
class Callapi {
|
|
getallhcpdata() async {
|
|
// const url = 'http://127.0.0.1:8000/api/users';
|
|
//const url = 'http://192.168.2.143:8080/api/users';
|
|
const url = 'http://192.168.172.50:8080/api/users';
|
|
|
|
final response = await Dio().get(url);
|
|
|
|
final jsonresponse = response.data;
|
|
final apihcpdata = Hive.box("hcpdata");
|
|
// if (apihcpdata.isNotEmpty) {
|
|
// apihcpdata.clear();
|
|
// }
|
|
if (apihcpdata.isEmpty) {
|
|
print("alldata_is: , ${jsonresponse} ${jsonresponse.length}");
|
|
for (int i = 0; i < jsonresponse.length; i++) {
|
|
print("hcp:data_is: , ${jsonresponse[i]['email']}");
|
|
|
|
HiveFunctions.storehcpdata({
|
|
"id": jsonresponse[i]['id'],
|
|
"name": jsonresponse[i]['name'],
|
|
"email": jsonresponse[i]['email'],
|
|
"sumry": jsonresponse[i]['summarry'],
|
|
"addr": jsonresponse[i]['addr'],
|
|
"licno": jsonresponse[i]['license_no'],
|
|
"suffix": jsonresponse[i]['p_suffix'],
|
|
"spl": jsonresponse[i]['speciality'],
|
|
"sub_sp": jsonresponse[i]['sub_speciality'],
|
|
"phone_no": jsonresponse[i]['phone_no'],
|
|
"rank": jsonresponse[i]['rank'],
|
|
"score": jsonresponse[i]['score'],
|
|
"events_count": jsonresponse[i]['events_count'],
|
|
"affiliations_count": jsonresponse[i]['affiliations_count'],
|
|
"publications_count": jsonresponse[i]['publications_count'],
|
|
});
|
|
}
|
|
}
|
|
|
|
return jsonresponse;
|
|
}
|
|
|
|
getsinglehcpdata() async {
|
|
// const url = 'http://127.0.0.1:8000/api/users/1';
|
|
// const url = 'http://192.168.2.143:8080/api/users/1';
|
|
const url = 'http://192.168.172.50:8080/api/users/1';
|
|
|
|
final responsehcp = await Dio().post(url);
|
|
final jsonresponse1 = responsehcp.data;
|
|
|
|
// final List<dynamic> Json = json.decode(responsehcp.data);
|
|
|
|
print("Singlejsondata : ${jsonresponse1}");
|
|
return jsonresponse1;
|
|
}
|
|
}
|