89 lines
2.7 KiB
Dart
89 lines
2.7 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import '../../Utils/api_urls.dart';
|
|
import '../../Utils/base_manager.dart';
|
|
import '../../data/network/network_api_services.dart';
|
|
|
|
class ContentBytesApi {
|
|
Future<ResponseData<dynamic>> getContentBytesCategoriesData() async {
|
|
final response = await NetworkApiServices()
|
|
.getApi(ApiUrls.getContentBytesCategoriesApi, isAuth: true);
|
|
log(response.data.toString());
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
Map<String, dynamic> responseData =
|
|
Map<String, dynamic>.from(response.data);
|
|
if (responseData['status'] == "success") {
|
|
return response;
|
|
} else {
|
|
return ResponseData<dynamic>(
|
|
responseData['message'], ResponseStatus.FAILED);
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> getContentBytesData(
|
|
String query, String type, String category) async {
|
|
final response = await NetworkApiServices().postApi(
|
|
{
|
|
'search_data': query,
|
|
'content_type': type,
|
|
'category_id': category,
|
|
},
|
|
ApiUrls.getContentBytesApi,
|
|
);
|
|
log(response.data.toString());
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
Map<String, dynamic> responseData =
|
|
Map<String, dynamic>.from(response.data);
|
|
if (responseData['status'] == "success") {
|
|
return response;
|
|
} else {
|
|
return ResponseData<dynamic>(
|
|
responseData['message'], ResponseStatus.FAILED);
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> getPreviousReadData() async {
|
|
final response = await NetworkApiServices()
|
|
.getApi(ApiUrls.getPreviousReadApi, isAuth: true);
|
|
log(response.data.toString());
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
Map<String, dynamic> responseData =
|
|
Map<String, dynamic>.from(response.data);
|
|
if (responseData['status'] == "success") {
|
|
return response;
|
|
} else {
|
|
return ResponseData<dynamic>(
|
|
responseData['message'], ResponseStatus.FAILED);
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
|
|
Future<ResponseData<dynamic>> updateReadCounts(int xid) async {
|
|
final response = await NetworkApiServices().postApi(
|
|
{
|
|
'content_byte_read_xid': xid,
|
|
},
|
|
ApiUrls.storeReadCountApi,
|
|
);
|
|
log(response.data.toString());
|
|
if (response.status == ResponseStatus.SUCCESS) {
|
|
Map<String, dynamic> responseData =
|
|
Map<String, dynamic>.from(response.data);
|
|
if (responseData['status'] == "success") {
|
|
return response;
|
|
} else {
|
|
return ResponseData<dynamic>(
|
|
responseData['message'], ResponseStatus.FAILED);
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
}
|