399 lines
14 KiB
Dart
399 lines
14 KiB
Dart
|
import 'dart:convert';
|
||
|
import 'dart:io';
|
||
|
|
||
|
import 'package:dio/dio.dart';
|
||
|
import 'package:dio/io.dart';
|
||
|
import 'package:flutter/services.dart';
|
||
|
import 'package:konectar_events/model/eventsdetailmodel.dart';
|
||
|
import 'package:konectar_events/model/eventsmodel.dart';
|
||
|
import 'package:konectar_events/model/keywords_model.dart';
|
||
|
import 'package:konectar_events/model/neweventsmodel.dart';
|
||
|
import 'package:konectar_events/model/scope_model.dart';
|
||
|
import 'package:konectar_events/model/sessionnotesmodel.dart';
|
||
|
import 'package:konectar_events/model/topics_cloud_model.dart';
|
||
|
import 'package:konectar_events/utils/constants.dart';
|
||
|
|
||
|
class ApiCall {
|
||
|
final dio = Dio();
|
||
|
|
||
|
Future<dynamic> parseInfo() async {
|
||
|
Dio dio = Dio();
|
||
|
(dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
(HttpClient client) {
|
||
|
client.badCertificateCallback =
|
||
|
(X509Certificate cert, String host, int port) => true;
|
||
|
return client;
|
||
|
};
|
||
|
Response response;
|
||
|
response = await dio.putUri(
|
||
|
Uri.parse(
|
||
|
'https://cardio-staging.konectar.io/nested_logins/verify_key'),
|
||
|
data: {
|
||
|
"key":
|
||
|
"\$2a\$08\$u5DKCL4ir88CPKUhGFqbnuoXcibLZnxs/qi/48miKAuNJM/5.WGWy",
|
||
|
"email": "scheepu@tikamobile.com",
|
||
|
"name": "Scheepu",
|
||
|
});
|
||
|
print("response here ");
|
||
|
print(response.data.toString());
|
||
|
return response.data;
|
||
|
}
|
||
|
|
||
|
//https://cardio-staging.konectar.io/notifications/list_all_notifications
|
||
|
Future<dynamic> listnotifications() async {
|
||
|
Dio dio = Dio();
|
||
|
(dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
(HttpClient client) {
|
||
|
client.badCertificateCallback =
|
||
|
(X509Certificate cert, String host, int port) => true;
|
||
|
return client;
|
||
|
};
|
||
|
Response response;
|
||
|
response = await dio.post(
|
||
|
'https://cardio-staging.konectar.io/requested_kols/list_my_pending_approvals/',
|
||
|
options: Options(
|
||
|
followRedirects: false,
|
||
|
validateStatus: (status) {
|
||
|
return status! < 500;
|
||
|
},
|
||
|
headers: {'Content-type': 'application/json; charset=UTF-8'}),
|
||
|
data: {"rows": "10", "page": "1", "sidx": "name", "sord": "desc"});
|
||
|
print("response user settings here ");
|
||
|
print(response.data.toString());
|
||
|
return response.data;
|
||
|
}
|
||
|
|
||
|
Future<List<Therapeutic>> getscopes() async {
|
||
|
Dio dio = Dio();
|
||
|
(dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
(HttpClient client) {
|
||
|
client.badCertificateCallback =
|
||
|
(X509Certificate cert, String host, int port) => true;
|
||
|
return client;
|
||
|
};
|
||
|
Response response;
|
||
|
var formData = FormData.fromMap({
|
||
|
"user_email": "vinodh@aissel.com",
|
||
|
});
|
||
|
response = await dio.post(
|
||
|
'https://cardio-staging.konectar.io/reports/get_therepeutic_name',
|
||
|
options: Options(),
|
||
|
queryParameters: {
|
||
|
"user_email": "vinodh@aissel.com",
|
||
|
},
|
||
|
data: formData);
|
||
|
print("response user settings here############### ");
|
||
|
print(response.data.toString());
|
||
|
Map<String, dynamic> jsondata = json.decode(response.data);
|
||
|
ScopeModel scopeModel = ScopeModel.fromJson(jsondata);
|
||
|
List<Therapeutic> therapeuticList = scopeModel.therapeutics;
|
||
|
print(therapeuticList);
|
||
|
return therapeuticList;
|
||
|
}
|
||
|
|
||
|
Future<List<Keyword>> getkeywords(String keyword) async {
|
||
|
Dio dio = Dio();
|
||
|
(dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
(HttpClient client) {
|
||
|
client.badCertificateCallback =
|
||
|
(X509Certificate cert, String host, int port) => true;
|
||
|
return client;
|
||
|
};
|
||
|
Response response;
|
||
|
var formData = FormData.fromMap(
|
||
|
{"user_email": "vinodh@aissel.com", "keyword": keyword});
|
||
|
response = await dio.post(
|
||
|
'https://cardio-staging.konectar.io/identifications/search_term',
|
||
|
options: Options(),
|
||
|
queryParameters: {
|
||
|
"user_email": "vinodh@aissel.com",
|
||
|
},
|
||
|
data: formData);
|
||
|
print("response user keywords here!!!!!!!!!!!!!!!!!!!!! ");
|
||
|
print(response.data.toString());
|
||
|
Map<String, dynamic> jsondata = json.decode(response.data);
|
||
|
KeywordsModel keywordsModel = KeywordsModel.fromJson(jsondata);
|
||
|
print(keywordsModel);
|
||
|
List<Keyword> keywordList = keywordsModel.keyword;
|
||
|
print(keywordList[0].name);
|
||
|
return keywordList;
|
||
|
}
|
||
|
|
||
|
Future<List<EventsList>?> getEvents() async {
|
||
|
// Dio dio = Dio();
|
||
|
// (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
// (HttpClient client) {
|
||
|
// client.badCertificateCallback =
|
||
|
// (X509Certificate cert, String host, int port) => true;
|
||
|
// return client;
|
||
|
// };
|
||
|
// Response response;
|
||
|
|
||
|
// response = await dio.post(
|
||
|
// //'http://192.168.2.109:8007/api/method/events_list_api',
|
||
|
// '${Constants.domainUrl}eventsapi.api.getEventsList',
|
||
|
// options: Options(),
|
||
|
// );
|
||
|
// print("response user keywords here########## ");
|
||
|
// print(response.data.toString());
|
||
|
dynamic jsonResult =
|
||
|
jsonDecode(await rootBundle.loadString("assets/eventsnew.json"));
|
||
|
// Map<String, dynamic> jsondata = json.decode(jsonResult.toString());
|
||
|
Map<String, dynamic> jsondata = jsonResult;
|
||
|
EventsResp eventresponse = EventsResp.fromJson(jsondata);
|
||
|
EventsData? eventdata = eventresponse.data;
|
||
|
List<EventsList>? eventList = eventdata!.events;
|
||
|
|
||
|
return eventList;
|
||
|
}
|
||
|
|
||
|
Future<List<Eventsdetail>?> getEventsDetail(String eventid) async {
|
||
|
Dio dio = Dio();
|
||
|
(dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
(HttpClient client) {
|
||
|
client.badCertificateCallback =
|
||
|
(X509Certificate cert, String host, int port) => true;
|
||
|
return client;
|
||
|
};
|
||
|
Response response;
|
||
|
|
||
|
response = await dio.post(
|
||
|
'${Constants.domainUrl}eventsdetail?eventid=$eventid',
|
||
|
options: Options(),
|
||
|
);
|
||
|
print("response user keywords here########## ");
|
||
|
print(response.data.toString());
|
||
|
|
||
|
Map<String, dynamic> jsondata = json.decode(response.toString());
|
||
|
EventsDetailResp eventresponse = EventsDetailResp.fromJson(jsondata);
|
||
|
EventsDetailData? eventdata = eventresponse.data;
|
||
|
List<Eventsdetail>? eventsdetailList = eventdata!.eventsdetail;
|
||
|
|
||
|
return eventsdetailList;
|
||
|
}
|
||
|
|
||
|
Future<String> addEventsToFav(String eventid) async {
|
||
|
Dio dio = Dio();
|
||
|
(dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
(HttpClient client) {
|
||
|
client.badCertificateCallback =
|
||
|
(X509Certificate cert, String host, int port) => true;
|
||
|
return client;
|
||
|
};
|
||
|
Response response;
|
||
|
|
||
|
response = await dio.post(
|
||
|
'${Constants.domainUrl}eventsapi.api.addEventsToFav?eventid=$eventid',
|
||
|
options: Options(),
|
||
|
);
|
||
|
print("response user keywords here########## ");
|
||
|
print(response.data.toString());
|
||
|
Map<String, dynamic> jsondata = json.decode(response.toString());
|
||
|
String message = jsondata["message"];
|
||
|
print("***$message");
|
||
|
|
||
|
return message;
|
||
|
}
|
||
|
|
||
|
Future<String> attendEvents(String eventid) async {
|
||
|
Dio dio = Dio();
|
||
|
(dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
(HttpClient client) {
|
||
|
client.badCertificateCallback =
|
||
|
(X509Certificate cert, String host, int port) => true;
|
||
|
return client;
|
||
|
};
|
||
|
Response response;
|
||
|
|
||
|
response = await dio.post(
|
||
|
'${Constants.domainUrl}eventsapi.api.attendingEvents?eventid=$eventid',
|
||
|
options: Options(),
|
||
|
);
|
||
|
print("response user keywords here########## ");
|
||
|
print(response.data.toString());
|
||
|
Map<String, dynamic> jsondata = json.decode(response.toString());
|
||
|
String message = jsondata["message"];
|
||
|
print("***$message");
|
||
|
|
||
|
return message;
|
||
|
}
|
||
|
|
||
|
Future<List<EventsList>?> getLocalEvents() async {
|
||
|
// Dio dio = Dio();
|
||
|
// (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
// (HttpClient client) {
|
||
|
// client.badCertificateCallback =
|
||
|
// (X509Certificate cert, String host, int port) => true;
|
||
|
// return client;
|
||
|
// };
|
||
|
// Response response;
|
||
|
|
||
|
// response = await dio.post(
|
||
|
// //'http://192.168.2.109:8007/api/method/events_list_api',
|
||
|
// '${Constants.domainUrl}eventsapi.api.getEventsList',
|
||
|
// options: Options(),
|
||
|
// );
|
||
|
// print("response user keywords here########## ");
|
||
|
// print(response.data.toString());
|
||
|
dynamic jsonResult =
|
||
|
jsonDecode(await rootBundle.loadString("assets/eventsnew.json"));
|
||
|
// Map<String, dynamic> jsondata = json.decode(jsonResult.toString());
|
||
|
Map<String, dynamic> jsondata = jsonResult;
|
||
|
EventsResp eventresponse = EventsResp.fromJson(jsondata);
|
||
|
EventsData? eventdata = eventresponse.data;
|
||
|
List<EventsList>? eventList = eventdata!.events;
|
||
|
|
||
|
return eventList;
|
||
|
}
|
||
|
|
||
|
Future<List<Eventsdetail>?> getLocalEventsDetail(String eventid) async {
|
||
|
// Dio dio = Dio();
|
||
|
// (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
// (HttpClient client) {
|
||
|
// client.badCertificateCallback =
|
||
|
// (X509Certificate cert, String host, int port) => true;
|
||
|
// return client;
|
||
|
// };
|
||
|
// Response response;
|
||
|
|
||
|
// response = await dio.post(
|
||
|
// '${Constants.domainUrl}eventsdetail?eventid=$eventid',
|
||
|
// options: Options(),
|
||
|
// );
|
||
|
// print("response user keywords here########## ");
|
||
|
// print(response.data.toString());
|
||
|
dynamic jsonResult;
|
||
|
print("eventid:${eventid}");
|
||
|
// if (eventid == "140846") {
|
||
|
try {
|
||
|
jsonResult =
|
||
|
jsonDecode(await rootBundle.loadString("assets/ed${eventid}.json"));
|
||
|
} catch (e) {
|
||
|
jsonResult =
|
||
|
jsonDecode(await rootBundle.loadString("assets/eventsdetail2.json"));
|
||
|
}
|
||
|
|
||
|
// }
|
||
|
// else {
|
||
|
// jsonResult =
|
||
|
// jsonDecode(await rootBundle.loadString("assets/eventsdetail2.json"));
|
||
|
// }
|
||
|
//Map<String, dynamic> jsondata = json.decode(response.toString());
|
||
|
Map<String, dynamic> jsondata = jsonResult;
|
||
|
EventsDetailResp eventresponse = EventsDetailResp.fromJson(jsondata);
|
||
|
EventsDetailData? eventdata = eventresponse.data;
|
||
|
List<Eventsdetail>? eventsdetailList = eventdata!.eventsdetail;
|
||
|
|
||
|
return eventsdetailList;
|
||
|
}
|
||
|
|
||
|
Future<String> addLocalEventsToFav(String eventid) async {
|
||
|
Dio dio = Dio();
|
||
|
(dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
(HttpClient client) {
|
||
|
client.badCertificateCallback =
|
||
|
(X509Certificate cert, String host, int port) => true;
|
||
|
return client;
|
||
|
};
|
||
|
Response response;
|
||
|
|
||
|
response = await dio.post(
|
||
|
'${Constants.domainUrl}eventsapi.api.addEventsToFav?eventid=$eventid',
|
||
|
options: Options(),
|
||
|
);
|
||
|
print("response user keywords here########## ");
|
||
|
print(response.data.toString());
|
||
|
Map<String, dynamic> jsondata = json.decode(response.toString());
|
||
|
String message = jsondata["message"];
|
||
|
print("***$message");
|
||
|
|
||
|
return message;
|
||
|
}
|
||
|
|
||
|
Future<String> attendLocalEvents(String eventid) async {
|
||
|
Dio dio = Dio();
|
||
|
(dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
(HttpClient client) {
|
||
|
client.badCertificateCallback =
|
||
|
(X509Certificate cert, String host, int port) => true;
|
||
|
return client;
|
||
|
};
|
||
|
Response response;
|
||
|
|
||
|
response = await dio.post(
|
||
|
'${Constants.domainUrl}eventsapi.api.attendingEvents?eventid=$eventid',
|
||
|
options: Options(),
|
||
|
);
|
||
|
print("response user keywords here########## ");
|
||
|
print(response.data.toString());
|
||
|
Map<String, dynamic> jsondata = json.decode(response.toString());
|
||
|
String message = jsondata["message"];
|
||
|
print("***$message");
|
||
|
|
||
|
return message;
|
||
|
}
|
||
|
|
||
|
//GET SESSION NOTES ADDED
|
||
|
Future<List<SessionNotesModel>?> getSessionNotes() async {
|
||
|
// Dio dio = Dio();
|
||
|
// (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
// (HttpClient client) {
|
||
|
// client.badCertificateCallback =
|
||
|
// (X509Certificate cert, String host, int port) => true;
|
||
|
// return client;
|
||
|
// };
|
||
|
// Response response;
|
||
|
|
||
|
// response = await dio.post(
|
||
|
// //'http://192.168.2.109:8007/api/method/events_list_api',
|
||
|
// '${Constants.domainUrl}eventsapi.api.getEventsList',
|
||
|
// options: Options(),
|
||
|
// );
|
||
|
// print("response user keywords here########## ");
|
||
|
// print(response.data.toString());
|
||
|
dynamic jsonResult =
|
||
|
jsonDecode(await rootBundle.loadString("assets/topicnotes.json"));
|
||
|
// Map<String, dynamic> jsondata = json.decode(jsonResult.toString());
|
||
|
Map<String, dynamic> jsondata = jsonResult;
|
||
|
NotesResp response = NotesResp.fromJson(jsondata);
|
||
|
NotesData? data = response.data;
|
||
|
List<SessionNotesModel>? eventList = data!.events;
|
||
|
|
||
|
return eventList;
|
||
|
}
|
||
|
|
||
|
//TOPICS CLOUD
|
||
|
|
||
|
Future<List<TopicsCloudData>?> getTopicsCloudData(String eventid) async {
|
||
|
// Dio dio = Dio();
|
||
|
// (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
|
||
|
// (HttpClient client) {
|
||
|
// client.badCertificateCallback =
|
||
|
// (X509Certificate cert, String host, int port) => true;
|
||
|
// return client;
|
||
|
// };
|
||
|
// Response response;
|
||
|
|
||
|
// response = await dio.post(
|
||
|
// //'http://192.168.2.109:8007/api/method/events_list_api',
|
||
|
// '${Constants.domainUrl}eventsapi.api.getEventsList',
|
||
|
// options: Options(),
|
||
|
// );
|
||
|
// print("response user keywords here########## ");
|
||
|
// print(response.data.toString());
|
||
|
dynamic jsonResult =
|
||
|
jsonDecode(await rootBundle.loadString("assets/tagclouds.json"));
|
||
|
// Map<String, dynamic> jsondata = json.decode(jsonResult.toString());
|
||
|
Map<String, dynamic> jsondata = jsonResult;
|
||
|
TopicsCloudResp response = TopicsCloudResp.fromJson(jsondata);
|
||
|
List<TopicsCloudData> data = [];
|
||
|
for (var obj in response.data!) {
|
||
|
if (obj.keys.contains(eventid)) {
|
||
|
data = obj[eventid]!;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return data;
|
||
|
}
|
||
|
}
|