497 lines
14 KiB
Dart
497 lines
14 KiB
Dart
|
import 'dart:convert';
|
||
|
|
||
|
import 'package:dio/dio.dart';
|
||
|
import 'package:konectar_events/contacts_module/constants.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_Certificate_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_aff_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_awards_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_education_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_email_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_event_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_location_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_pno_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_training_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/k2_api_model/kolcontact_list_k2.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/nih_model.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/patent_model.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/procedure_model.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/publication_model.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/speaker.dart';
|
||
|
import 'package:konectar_events/contacts_module/model_class/trials.dart';
|
||
|
|
||
|
const String curl = Constants.k2url;
|
||
|
|
||
|
class CallK2api {
|
||
|
getallhcpdata() async {
|
||
|
const url = '$curl/contacts/v2/en/fetch_kols';
|
||
|
|
||
|
print("K2_Urll: $url");
|
||
|
|
||
|
// final response = await Dio().get(url);
|
||
|
|
||
|
final response = await Dio().post(url,
|
||
|
data: {"page": 1, "limit": 100},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
print("ResponseeeeK2: ${response.statusCode}");
|
||
|
|
||
|
if (response.statusCode == 200) {
|
||
|
List<Datum> users = (response.data['data'] as List)
|
||
|
.map((userJson) => Datum.fromJson(userJson))
|
||
|
.toList();
|
||
|
return users;
|
||
|
}
|
||
|
|
||
|
// final jsonresponse = response.data;
|
||
|
|
||
|
// final jsonresponse211 = response.data["data"];
|
||
|
|
||
|
// print("jsonresponse211: ${jsonresponse211}");
|
||
|
|
||
|
// final kolresponse =
|
||
|
// jsonresponse211.map((kollist) => Datum.fromJson(kollist)).toList();
|
||
|
|
||
|
// print("kolresponse_isss: ${kolresponse}");
|
||
|
|
||
|
// return kolresponse;
|
||
|
}
|
||
|
|
||
|
getsinglehcpdata() async {
|
||
|
const url = '$curl/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;
|
||
|
}
|
||
|
|
||
|
Future<List<AffList>?> getaffiliationsdata(id) async {
|
||
|
print("Affiliation_iddd: ${id}");
|
||
|
var url = '$curl/affiliations/v1/en/fetch';
|
||
|
|
||
|
final affiliationres = await Dio().post(url,
|
||
|
data: {"page": 1, "limit": 100},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
if (affiliationres.statusCode == 200) {
|
||
|
DataAffiliations dataaff = DataAffiliations.fromJson(affiliationres.data);
|
||
|
|
||
|
List<AffList> afflist = dataaff.data!;
|
||
|
|
||
|
return afflist;
|
||
|
}
|
||
|
|
||
|
// print("Gettingdata_isss: ${'''[$affiliationres]'''}");
|
||
|
|
||
|
// String arrayText = '''[$affiliationres]''';
|
||
|
|
||
|
// final jsonresponse2 = json.decode(arrayText);
|
||
|
|
||
|
// return jsonresponse2
|
||
|
// .map((doctor) => Affiliations.fromJson(doctor))
|
||
|
// .toList();
|
||
|
}
|
||
|
|
||
|
getpublicationsdata(id) async {
|
||
|
print("getpublicationsdata_iddd: ${id}");
|
||
|
|
||
|
var url = '$curl/publications/$id';
|
||
|
final publicationres = await Dio().get(url);
|
||
|
String arrayText = '''[$publicationres]''';
|
||
|
|
||
|
final jsonresponse2 = json.decode(arrayText);
|
||
|
|
||
|
return jsonresponse2
|
||
|
.map((doctor) => Publications.fromJson(doctor))
|
||
|
.toList();
|
||
|
}
|
||
|
|
||
|
Future<List<EventList>?> geteventsdata(id) async {
|
||
|
var url = '$curl/events/v1/en/fetch';
|
||
|
|
||
|
final events = await Dio().post(url,
|
||
|
data: {"page": 1, "limit": 100},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
if (events.statusCode == 200) {
|
||
|
DataEvent dataeve = DataEvent.fromJson(events.data);
|
||
|
List<EventList> evelist = dataeve.data!;
|
||
|
return evelist;
|
||
|
}
|
||
|
|
||
|
// String evn = '''[$events]''';
|
||
|
// final jsonEvent = json.decode(evn);
|
||
|
// print("All_event: $jsonEvent");
|
||
|
// return jsonEvent.map((doctor) => Events.fromJson(doctor)).toList();
|
||
|
}
|
||
|
|
||
|
getallaffiliationsdata() async {
|
||
|
const url = '$curl/affiliations/';
|
||
|
|
||
|
final events = await Dio().get(url);
|
||
|
// final jsonEvent = events.data;
|
||
|
final jsonEvent = events.data;
|
||
|
print("All_event: $jsonEvent");
|
||
|
|
||
|
return jsonEvent;
|
||
|
}
|
||
|
|
||
|
getallpublicationsdata() async {
|
||
|
const url = '$curl/publications';
|
||
|
|
||
|
final events = await Dio().get(url);
|
||
|
// final jsonEvent = events.data;
|
||
|
final jsonEvent = events.data;
|
||
|
print("All_event: $jsonEvent");
|
||
|
|
||
|
return jsonEvent;
|
||
|
}
|
||
|
|
||
|
allgeteventsdata() async {
|
||
|
const url = '$curl/events';
|
||
|
|
||
|
final events = await Dio().get(url);
|
||
|
// final jsonEvent = events.data;
|
||
|
final jsonEvent = events.data;
|
||
|
print("All_event: $jsonEvent");
|
||
|
|
||
|
return jsonEvent;
|
||
|
}
|
||
|
|
||
|
getalltrials(id) async {
|
||
|
print("TrialsssssAPIIIIIIIIII: $id");
|
||
|
// var url = '$curl/trails/$id';
|
||
|
var url = '$curl/trails/1';
|
||
|
|
||
|
final trials = await Dio().get(url);
|
||
|
String dataa = "[${trials}]";
|
||
|
final jsontrials = jsonDecode(dataa);
|
||
|
print("All_trialsss: $jsontrials");
|
||
|
// return jsontrials;
|
||
|
if (jsontrials.isEmpty) {
|
||
|
print("notnulllllll: $jsontrials");
|
||
|
//return jsontrials.map((doctor) => Trials.fromJson(doctor)).toList();
|
||
|
} else {
|
||
|
return jsontrials.map((doctor) => Trials.fromJson(doctor)).toList();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
getallMedicalInsightdata() async {
|
||
|
const url = '$curl/medicalinsight';
|
||
|
|
||
|
final response = await Dio().get(url);
|
||
|
|
||
|
final jsonresponse = response.data;
|
||
|
return jsonresponse;
|
||
|
}
|
||
|
|
||
|
getSpeakerdata() async {
|
||
|
// print("TrialsssssAPIIIIIIIIII: $id");
|
||
|
// var url = '$curl/trails/$id';
|
||
|
var url = '$curl/speaker/1';
|
||
|
|
||
|
final speaker = await Dio().get(url);
|
||
|
|
||
|
print("Checkkkkk: Speakerrr: $speaker");
|
||
|
|
||
|
final List jsonspe = speaker.data; // Directly use the data
|
||
|
|
||
|
return jsonspe.map((location) => Speaker.fromJson(location)).toList();
|
||
|
}
|
||
|
|
||
|
getEngdata() async {
|
||
|
final String response = await Constants.response;
|
||
|
|
||
|
final Engagement = await json.decode(response);
|
||
|
final List<dynamic> eng = Engagement['Engagement'];
|
||
|
|
||
|
print("engData_isss: $eng");
|
||
|
return eng;
|
||
|
}
|
||
|
|
||
|
getlocationsdata($id) async {
|
||
|
const url = '$curl/contacts/v2/en/kol_location_fetch';
|
||
|
|
||
|
// var url = '$curl/location/1';
|
||
|
|
||
|
// final location = await Dio().get(url);
|
||
|
|
||
|
final location = await Dio().post(url,
|
||
|
data: {
|
||
|
"page": 1,
|
||
|
"limit": 100,
|
||
|
"kol_id": "b470ae0ac9ff5cf81e2d44b8fbfe32b1"
|
||
|
},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
// print("All_locDataaK22: ${location.data}");
|
||
|
|
||
|
final List jsonEvent = location.data["data"]; // Directly use the data
|
||
|
|
||
|
// print("All_locDataa123: ${jsonEvent}");
|
||
|
|
||
|
// return jsonEvent.map((location) => Loc.fromJson(location)).toList();
|
||
|
|
||
|
if (location.statusCode == 200) {
|
||
|
List<Data> kolLocation = jsonEvent.map((e) => Data.fromJson(e)).toList();
|
||
|
|
||
|
print("All_locDataaK22: ${kolLocation}");
|
||
|
|
||
|
return kolLocation;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Future<List<DataPhno>?> getphonedata($id) async {
|
||
|
var url = '$curl/contacts/v2/en/kol_phoneno_fetch';
|
||
|
|
||
|
// final phoneno = await Dio().get(url);
|
||
|
final phoneno = await Dio().post(url,
|
||
|
data: {
|
||
|
"page": 1,
|
||
|
"limit": 100,
|
||
|
"kol_id": "b470ae0ac9ff5cf81e2d44b8fbfe32b1"
|
||
|
},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
if (phoneno.statusCode == 200) {
|
||
|
final List jsonpno = phoneno.data["data"]; // Directly use the data
|
||
|
print("All_locDataaphone_pnos: ${jsonpno}");
|
||
|
DataaPnoresponse dataPno = DataaPnoresponse.fromJson(phoneno.data);
|
||
|
List<DataPhno>? datalist = dataPno.data;
|
||
|
|
||
|
// List kol_pno = jsonpno.map((e) => pno.PhnoData.fromJson(e)).toList();
|
||
|
|
||
|
print("All_kol_pnoDataa123: ${datalist}");
|
||
|
|
||
|
// List<Datum> users = (response.data['data'] as List)
|
||
|
// .map((userJson) => Datum.fromJson(userJson))
|
||
|
// .toList();
|
||
|
// return users;
|
||
|
|
||
|
return datalist;
|
||
|
}
|
||
|
// return datalist;
|
||
|
|
||
|
// return jsonEvent.map((pno) => Phoneno.fromJson(pno)).toList();
|
||
|
}
|
||
|
|
||
|
Future<List<EmailData>?> getemaildata($id) async {
|
||
|
var url = '$curl/contacts/v2/en/kol_email_fetch';
|
||
|
|
||
|
final email = await Dio().post(url,
|
||
|
data: {
|
||
|
"page": 1,
|
||
|
"limit": 100,
|
||
|
"kol_id": "b470ae0ac9ff5cf81e2d44b8fbfe32b1"
|
||
|
},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
print("All_locDataaEmaillK22: ${email.data}");
|
||
|
|
||
|
if (email.statusCode == 200) {
|
||
|
DataEmail email1 = DataEmail.fromJson(email.data);
|
||
|
|
||
|
List<EmailData>? emailinfo = email1.data;
|
||
|
|
||
|
return emailinfo;
|
||
|
}
|
||
|
|
||
|
// final List jsonEvent = email.data; // Directly use the data
|
||
|
|
||
|
// print("All_locDataa123: ${jsonEvent}");
|
||
|
|
||
|
//return jsonEvent.map((email) => Email.fromJson(email)).toList();
|
||
|
}
|
||
|
|
||
|
getpatentdata(id) async {
|
||
|
var url = '$curl/patent/1';
|
||
|
|
||
|
final patent = await Dio().get(url);
|
||
|
|
||
|
print("All_locDataa: ${patent.data}");
|
||
|
|
||
|
final List jsonEvent = patent.data; // Directly use the data
|
||
|
|
||
|
print("All_locDataa123: ${jsonEvent}");
|
||
|
|
||
|
return jsonEvent.map((email) => Patent.fromJson(email)).toList();
|
||
|
}
|
||
|
|
||
|
Future<List<CertificateList>?> getcerlistdata(id) async {
|
||
|
var url = '$curl/contacts/v2/en/kol_certification_fetch';
|
||
|
|
||
|
final cer = await Dio().post(url,
|
||
|
data: {
|
||
|
"page": 1,
|
||
|
"limit": 100,
|
||
|
"kol_id": "b470ae0ac9ff5cf81e2d44b8fbfe32b1"
|
||
|
},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
print("All_locDataa: ${cer.data}");
|
||
|
|
||
|
if (cer.statusCode == 200) {
|
||
|
DataCertificate datacer = DataCertificate.fromJson(cer.data);
|
||
|
List<CertificateList>? cerlist = datacer.data;
|
||
|
|
||
|
return cerlist;
|
||
|
}
|
||
|
|
||
|
// final List jsonEvent = cer.data; // Directly use the data
|
||
|
|
||
|
// print("All_locDataa123: ${jsonEvent}");
|
||
|
|
||
|
// return jsonEvent.map((certificate) => Cer.fromJson(certificate)).toList();
|
||
|
}
|
||
|
|
||
|
Future<List<EducationList>?> getedulistdata($id) async {
|
||
|
var url = '$curl/contacts/v2/en/kol_education_fetch';
|
||
|
|
||
|
final edu = await Dio().post(url,
|
||
|
data: {
|
||
|
"page": 1,
|
||
|
"limit": 100,
|
||
|
"kol_id": "b470ae0ac9ff5cf81e2d44b8fbfe32b1"
|
||
|
},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
print("All_locDataa: ${edu.data}");
|
||
|
|
||
|
if (edu.statusCode == 200) {
|
||
|
DataEducation dataedu = DataEducation.fromJson(edu.data);
|
||
|
|
||
|
List<EducationList>? edulist = dataedu.data;
|
||
|
|
||
|
return edulist;
|
||
|
}
|
||
|
|
||
|
// final List jsonEvent = edu.data; // Directly use the data
|
||
|
|
||
|
// print("All_locDataa123: ${jsonEvent}");
|
||
|
|
||
|
// return jsonEvent.map((edu) => Edu.fromJson(edu)).toList();
|
||
|
}
|
||
|
|
||
|
Future<List<AwardsList>?> getawarddata(id) async {
|
||
|
var url = '$curl/contacts/v2/en/kol_awards_fetch';
|
||
|
|
||
|
final awa = await Dio().post(url,
|
||
|
data: {
|
||
|
"page": 1,
|
||
|
"limit": 100,
|
||
|
"kol_id": "b470ae0ac9ff5cf81e2d44b8fbfe32b1"
|
||
|
},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
print("All_locDataa: ${awa.data}");
|
||
|
|
||
|
if (awa.statusCode == 200) {
|
||
|
DataAwards awardss = DataAwards.fromJson(awa.data);
|
||
|
List<AwardsList> awalist = awardss.data!;
|
||
|
return awalist;
|
||
|
}
|
||
|
|
||
|
// // String loc = "{$location}";
|
||
|
// // final jsonEvent = json.decode(loc);
|
||
|
// // print("All_loc: $jsonEvent");
|
||
|
|
||
|
// final List jsonEvent = awa.data; // Directly use the data
|
||
|
|
||
|
// print("All_locDataa123: ${jsonEvent}");
|
||
|
|
||
|
// return jsonEvent.map((awards) => Awa.fromJson(awards)).toList();
|
||
|
}
|
||
|
|
||
|
Future<List<TrainingList>?> gettrainingdata(id) async {
|
||
|
var url = '$curl/contacts/v2/en/kol_training_fetch';
|
||
|
|
||
|
final training = await Dio().post(url,
|
||
|
data: {
|
||
|
"page": 1,
|
||
|
"limit": 100,
|
||
|
"kol_id": "b470ae0ac9ff5cf81e2d44b8fbfe32b1"
|
||
|
},
|
||
|
options: Options(headers: {
|
||
|
"Authorization":
|
||
|
"Bearer 245|J1GeqJKw33m4YhCOfiMNyQm2U8jbx8rf1JkC567ffcb2f9bd"
|
||
|
}));
|
||
|
|
||
|
print("All_locDataa:Training: ${training.data}");
|
||
|
|
||
|
if (training.statusCode == 200) {
|
||
|
DataTraining trainingdata = DataTraining.fromJson(training.data);
|
||
|
List<TrainingList>? traininglist = trainingdata.data;
|
||
|
|
||
|
return traininglist;
|
||
|
}
|
||
|
|
||
|
// // String loc = "{$location}";
|
||
|
// // final jsonEvent = json.decode(loc);
|
||
|
// // print("All_loc: $jsonEvent");
|
||
|
|
||
|
// final List jsonEvent = training.data; // Directly use the data
|
||
|
|
||
|
// print("All_locDataa123: ${jsonEvent}");
|
||
|
|
||
|
// return jsonEvent.map((awards) => Traning.fromJson(awards)).toList();
|
||
|
}
|
||
|
|
||
|
getnihdata(id) async {
|
||
|
var url = '$curl/nih/1';
|
||
|
|
||
|
final nih = await Dio().get(url);
|
||
|
|
||
|
print("All_locDataa: ${nih.data}");
|
||
|
|
||
|
final List jsonEvent = nih.data; // Directly use the data
|
||
|
|
||
|
print("All_locDataa123: ${jsonEvent}");
|
||
|
|
||
|
return jsonEvent.map((awards) => Nih.fromJson(awards)).toList();
|
||
|
}
|
||
|
|
||
|
getprodata(id) async {
|
||
|
var url = '$curl/pro/1';
|
||
|
|
||
|
final pro = await Dio().get(url);
|
||
|
|
||
|
print("All_locDataa: ${pro.data}");
|
||
|
|
||
|
final List jsonEvent = pro.data; // Directly use the data
|
||
|
|
||
|
print("All_locDataa123: ${jsonEvent}");
|
||
|
|
||
|
return jsonEvent.map((awards) => Pro.fromJson(awards)).toList();
|
||
|
}
|
||
|
}
|